summaryrefslogtreecommitdiffstats
path: root/Doc/library/timeit.rst
blob: 4065808854ecffa18641f16830428aa6459ef0bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
:mod:`timeit` --- Measure execution time of small code snippets
===============================================================

.. module:: timeit
   :synopsis: Measure the execution time of small code snippets.

**Source code:** :source:`Lib/timeit.py`

.. index::
   single: Benchmarking
   single: Performance

--------------

This module provides a simple way to time small bits of Python code. It has both
a :ref:`timeit-command-line-interface` as well as a :ref:`callable <python-interface>`
one.  It avoids a number of common traps for measuring execution times.
See also Tim Peters' introduction to the "Algorithms" chapter in the *Python
Cookbook*, published by O'Reilly.


Basic Examples
--------------

The following example shows how the :ref:`timeit-command-line-interface`
can be used to compare three different expressions:

.. code-block:: sh

   $ python3 -m timeit '"-".join(str(n) for n in range(100))'
   10000 loops, best of 5: 30.2 usec per loop
   $ python3 -m timeit '"-".join([str(n) for n in range(100)])'
   10000 loops, best of 5: 27.5 usec per loop
   $ python3 -m timeit '"-".join(map(str, range(100)))'
   10000 loops, best of 5: 23.2 usec per loop

This can be achieved from the :ref:`python-interface` with::

   >>> import timeit
   >>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
   0.3018611848820001
   >>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000)
   0.2727368790656328
   >>> timeit.timeit('"-".join(map(str, range(100)))', number=10000)
   0.23702679807320237


Note however that :mod:`timeit` will automatically determine the number of
repetitions only when the command-line interface is used.  In the
:ref:`timeit-examples` section you can find more advanced examples.


.. _python-interface:

Python Interface
----------------

The module defines three convenience functions and a public class:


.. function:: timeit(stmt='pass', setup='pass', timer=<default timer>, number=1000000, globals=None)

   Create a :class:`Timer` instance with the given statement, *setup* code and
   *timer* function and run its :meth:`.timeit` method with *number* executions.
   The optional *globals* argument specifies a namespace in which to execute the
   code.

   .. versionchanged:: 3.5
      The optional *globals* parameter was added.


.. function:: repeat(stmt='pass', setup='pass', timer=<default timer>, repeat=3, number=1000000, globals=None)

   Create a :class:`Timer` instance with the given statement, *setup* code and
   *timer* function and run its :meth:`.repeat` method with the given *repeat*
   count and *number* executions.  The optional *globals* argument specifies a
   namespace in which to execute the code.

   .. versionchanged:: 3.5
      The optional *globals* parameter was added.

.. function:: default_timer()

   The default timer, which is always :func:`time.perf_counter`.

   .. versionchanged:: 3.3
      :func:`time.perf_counter` is now the default timer.


.. class:: Timer(stmt='pass', setup='pass', timer=<timer function>, globals=None)

   Class for timing execution speed of small code snippets.

   The constructor takes a statement to be timed, an additional statement used
   for setup, and a timer function.  Both statements default to ``'pass'``;
   the timer function is platform-dependent (see the module doc string).
   *stmt* and *setup* may also contain multiple statements separated by ``;``
   or newlines, as long as they don't contain multi-line string literals.  The
   statement will by default be executed within timeit's namespace; this behavior
   can be controlled by passing a namespace to *globals*.

   To measure the execution time of the first statement, use the :meth:`.timeit`
   method.  The :meth:`.repeat` and :meth:`.autorange` methods are convenience
   methods to call :meth:`.timeit` multiple times.

   The execution time of *setup* is excluded from the overall timed execution run.

   The *stmt* and *setup* parameters can also take objects that are callable
   without arguments.  This will embed calls to them in a timer function that
   will then be executed by :meth:`.timeit`.  Note that the timing overhead is a
   little larger in this case because of the extra function calls.

   .. versionchanged:: 3.5
      The optional *globals* parameter was added.

   .. method:: Timer.timeit(number=1000000)

      Time *number* executions of the main statement.  This executes the setup
      statement once, and then returns the time it takes to execute the main
      statement a number of times, measured in seconds as a float.
      The argument is the number of times through the loop, defaulting to one
      million.  The main statement, the setup statement and the timer function
      to be used are passed to the constructor.

      .. note::

         By default, :meth:`.timeit` temporarily turns off :term:`garbage
         collection` during the timing.  The advantage of this approach is that
         it makes independent timings more comparable.  This disadvantage is
         that GC may be an important component of the performance of the
         function being measured.  If so, GC can be re-enabled as the first
         statement in the *setup* string.  For example::

            timeit.Timer('for i in range(10): oct(i)', 'gc.enable()').timeit()


    .. method:: Timer.autorange(callback=None)

       Automatically determine how many times to call :meth:`.timeit`.

       This is a convenience function that calls :meth:`.timeit` repeatedly
       so that the total time >= 0.2 second, returning the eventual
       (number of loops, time taken for that number of loops). It calls
       :meth:`.timeit` with increasing numbers from the sequence 1, 2, 5,
       10, 20, 50, ... until the time taken is at least 0.2 second.

        If *callback* is given and is not ``None``, it will be called after
        each trial with two arguments: ``callback(number, time_taken)``.

        .. versionadded:: 3.6


   .. method:: Timer.repeat(repeat=3, number=1000000)

      Call :meth:`.timeit` a few times.

      This is a convenience function that calls the :meth:`.timeit` repeatedly,
      returning a list of results.  The first argument specifies how many times
      to call :meth:`.timeit`.  The second argument specifies the *number*
      argument for :meth:`.timeit`.

      .. note::

         It's tempting to calculate mean and standard deviation from the result
         vector and report these.  However, this is not very useful.
         In a typical case, the lowest value gives a lower bound for how fast
         your machine can run the given code snippet; higher values in the
         result vector are typically not caused by variability in Python's
         speed, but by other processes interfering with your timing accuracy.
         So the :func:`min` of the result is probably the only number you
         should be interested in.  After that, you should look at the entire
         vector and apply common sense rather than statistics.


   .. method:: Timer.print_exc(file=None)

      Helper to print a traceback from the timed code.

      Typical use::

         t = Timer(...)       # outside the try/except
         try:
             t.timeit(...)    # or t.repeat(...)
         except Exception:
             t.print_exc()

      The advantage over the standard traceback is that source lines in the
      compiled template will be displayed.  The optional *file* argument directs
      where the traceback is sent; it defaults to :data:`sys.stderr`.


.. _timeit-command-line-interface:

Command-Line Interface
----------------------

When called as a program from the command line, the following form is used::

   python -m timeit [-n N] [-r N] [-u U] [-s S] [-h] [statement ...]

Where the following options are understood:

.. program:: timeit

.. cmdoption:: -n N, --number=N

   how many times to execute 'statement'

.. cmdoption:: -r N, --repeat=N

   how many times to repeat the timer (default 3)

.. cmdoption:: -s S, --setup=S

   statement to be executed once initially (default ``pass``)

.. cmdoption:: -p, --process

   measure process time, not wallclock time, using :func:`time.process_time`
   instead of :func:`time.perf_counter`, which is the default

   .. versionadded:: 3.3

.. cmdoption:: -u, --unit=U

    specify a time unit for timer output; can select nsec, usec, msec, or sec

   .. versionadded:: 3.5

.. cmdoption:: -v, --verbose

   print raw timing results; repeat for more digits precision

.. cmdoption:: -h, --help

   print a short usage message and exit

A multi-line statement may be given by specifying each line as a separate
statement argument; indented lines are possible by enclosing an argument in
quotes and using leading spaces.  Multiple :option:`-s` options are treated
similarly.

If :option:`-n` is not given, a suitable number of loops is calculated by trying
successive powers of 10 until the total time is at least 0.2 seconds.

:func:`default_timer` measurements can be affected by other programs running on
the same machine, so the best thing to do when accurate timing is necessary is
to repeat the timing a few times and use the best time.  The :option:`-r`
option is good for this; the default of 3 repetitions is probably enough in
most cases.  You can use :func:`time.process_time` to measure CPU time.

.. note::

   There is a certain baseline overhead associated with executing a pass statement.
   The code here doesn't try to hide it, but you should be aware of it.  The
   baseline overhead can be measured by invoking the program without arguments,
   and it might differ between Python versions.


.. _timeit-examples:

Examples
--------

It is possible to provide a setup statement that is executed only once at the beginning:

.. code-block:: sh

   $ python -m timeit -s 'text = "sample string"; char = "g"'  'char in text'
   5000000 loops, best of 5: 0.0877 usec per loop
   $ python -m timeit -s 'text = "sample string"; char = "g"'  'text.find(char)'
   1000000 loops, best of 5: 0.342 usec per loop

::

   >>> import timeit
   >>> timeit.timeit('char in text', setup='text = "sample string"; char = "g"')
   0.41440500499993504
   >>> timeit.timeit('text.find(char)', setup='text = "sample string"; char = "g"')
   1.7246671520006203

The same can be done using the :class:`Timer` class and its methods::

   >>> import timeit
   >>> t = timeit.Timer('char in text', setup='text = "sample string"; char = "g"')
   >>> t.timeit()
   0.3955516149999312
   >>> t.repeat()
   [0.40193588800002544, 0.3960157959998014, 0.39594301399984033]


The following examples show how to time expressions that contain multiple lines.
Here we compare the cost of using :func:`hasattr` vs. :keyword:`try`/:keyword:`except`
to test for missing and present object attributes:

.. code-block:: sh

   $ python -m timeit 'try:' '  str.__bool__' 'except AttributeError:' '  pass'
   20000 loops, best of 5: 15.7 usec per loop
   $ python -m timeit 'if hasattr(str, "__bool__"): pass'
   50000 loops, best of 5: 4.26 usec per loop

   $ python -m timeit 'try:' '  int.__bool__' 'except AttributeError:' '  pass'
   200000 loops, best of 5: 1.43 usec per loop
   $ python -m timeit 'if hasattr(int, "__bool__"): pass'
   100000 loops, best of 5: 2.23 usec per loop

::

   >>> import timeit
   >>> # attribute is missing
   >>> s = """\
   ... try:
   ...     str.__bool__
   ... except AttributeError:
   ...     pass
   ... """
   >>> timeit.timeit(stmt=s, number=100000)
   0.9138244460009446
   >>> s = "if hasattr(str, '__bool__'): pass"
   >>> timeit.timeit(stmt=s, number=100000)
   0.5829014980008651
   >>>
   >>> # attribute is present
   >>> s = """\
   ... try:
   ...     int.__bool__
   ... except AttributeError:
   ...     pass
   ... """
   >>> timeit.timeit(stmt=s, number=100000)
   0.04215312199994514
   >>> s = "if hasattr(int, '__bool__'): pass"
   >>> timeit.timeit(stmt=s, number=100000)
   0.08588060699912603


To give the :mod:`timeit` module access to functions you define, you can pass a
*setup* parameter which contains an import statement::

   def test():
       """Stupid test function"""
       L = [i for i in range(100)]

   if __name__ == '__main__':
       import timeit
       print(timeit.timeit("test()", setup="from __main__ import test"))

Another option is to pass :func:`globals` to the  *globals* parameter, which will cause the code
to be executed within your current global namespace.  This can be more convenient
than individually specifying imports::

   def f(x):
       return x**2
   def g(x):
       return x**4
   def h(x):
       return x**8

   import timeit
   print(timeit.timeit('[func(42) for func in (f,g,h)]', globals=globals()))
href='/oss-git/Qt.git/diff/examples/declarative/extending/coercion/birthdayparty.cpp?h=v4.7.1&id=7c76abb0dc4204043bec9b6fa315f9753a7986ae'>examples/declarative/extending/coercion/birthdayparty.cpp4
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.h6
-rw-r--r--examples/declarative/extending/coercion/main.cpp8
-rw-r--r--examples/declarative/extending/coercion/person.h2
-rw-r--r--examples/declarative/extending/default/birthdayparty.cpp4
-rw-r--r--examples/declarative/extending/default/birthdayparty.h6
-rw-r--r--examples/declarative/extending/default/main.cpp8
-rw-r--r--examples/declarative/extending/default/person.h2
-rw-r--r--examples/declarative/extending/extended/lineedit.cpp2
-rw-r--r--examples/declarative/extending/extended/main.cpp8
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.cpp4
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.h6
-rw-r--r--examples/declarative/extending/grouped/main.cpp8
-rw-r--r--examples/declarative/extending/grouped/person.h2
-rw-r--r--examples/declarative/extending/properties/birthdayparty.cpp4
-rw-r--r--examples/declarative/extending/properties/birthdayparty.h6
-rw-r--r--examples/declarative/extending/properties/main.cpp8
-rw-r--r--examples/declarative/extending/properties/person.h2
-rw-r--r--examples/declarative/extending/signal/birthdayparty.cpp4
-rw-r--r--examples/declarative/extending/signal/birthdayparty.h6
-rw-r--r--examples/declarative/extending/signal/main.cpp8
-rw-r--r--examples/declarative/extending/signal/person.h2
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.cpp4
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.h6
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.cpp2
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.h10
-rw-r--r--examples/declarative/extending/valuesource/main.cpp8
-rw-r--r--examples/declarative/extending/valuesource/person.h2
-rw-r--r--examples/declarative/imageprovider/main.cpp20
-rw-r--r--examples/declarative/objectlistmodel/main.cpp14
-rw-r--r--examples/declarative/plugins/plugin.cpp8
-rw-r--r--examples/declarative/plugins/plugins.pro8
-rw-r--r--examples/declarative/sql/hello.qml2
-rw-r--r--examples/declarative/webview/qdeclarative-in-html.qml (renamed from examples/declarative/webview/qml-in-html.qml)0
-rw-r--r--src/declarative/3rdparty/qlistmodelinterface.cpp4
-rw-r--r--src/declarative/debugger/debugger.pri16
-rw-r--r--src/declarative/debugger/qdeclarativedebug.cpp937
-rw-r--r--src/declarative/debugger/qdeclarativedebug_p.h371
-rw-r--r--src/declarative/debugger/qdeclarativedebugclient.cpp207
-rw-r--r--src/declarative/debugger/qdeclarativedebugclient_p.h99
-rw-r--r--src/declarative/debugger/qdeclarativedebuggerstatus.cpp54
-rw-r--r--src/declarative/debugger/qdeclarativedebuggerstatus_p.h66
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice.cpp426
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice_p.h92
-rw-r--r--src/declarative/debugger/qmldebug.cpp937
-rw-r--r--src/declarative/debugger/qmldebug_p.h371
-rw-r--r--src/declarative/debugger/qmldebugclient.cpp207
-rw-r--r--src/declarative/debugger/qmldebugclient_p.h99
-rw-r--r--src/declarative/debugger/qmldebuggerstatus.cpp54
-rw-r--r--src/declarative/debugger/qmldebuggerstatus_p.h66
-rw-r--r--src/declarative/debugger/qmldebugservice.cpp426
-rw-r--r--src/declarative/debugger/qmldebugservice_p.h92
-rw-r--r--src/declarative/declarative.pro2
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri168
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors.cpp1059
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p.h196
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p_p.h174
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp306
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h106
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h82
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage.cpp408
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage_p.h103
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h97
-rw-r--r--src/declarative/graphicsitems/qdeclarativeeffects.cpp170
-rw-r--r--src/declarative/graphicsitems/qdeclarativeeffects_p.h65
-rw-r--r--src/declarative/graphicsitems/qdeclarativeevents.cpp193
-rw-r--r--src/declarative/graphicsitems/qdeclarativeevents_p_p.h137
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp1324
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p.h214
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h189
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable.cpp238
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable_p.h95
-rw-r--r--src/declarative/graphicsitems/qdeclarativefocuspanel.cpp89
-rw-r--r--src/declarative/graphicsitems/qdeclarativefocuspanel_p.h77
-rw-r--r--src/declarative/graphicsitems/qdeclarativefocusscope.cpp71
-rw-r--r--src/declarative/graphicsitems/qdeclarativefocusscope_p.h68
-rw-r--r--src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp269
-rw-r--r--src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h90
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp1723
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h222
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp368
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage_p.h102
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage_p_p.h79
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp191
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p.h92
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h84
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp2838
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h243
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h471
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemchangelistener_p.h76
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp161
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule_p.h63
-rw-r--r--src/declarative/graphicsitems/qdeclarativelayoutitem.cpp114
-rw-r--r--src/declarative/graphicsitems/qdeclarativelayoutitem_p.h94
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp2716
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h305
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp488
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader_p.h111
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader_p_p.h88
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp685
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p.h185
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p_p.h117
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem.cpp466
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem_p.h114
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem_p_p.h90
-rw-r--r--src/declarative/graphicsitems/qdeclarativeparticles.cpp1295
-rw-r--r--src/declarative/graphicsitems/qdeclarativeparticles_p.h258
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath.cpp849
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath_p.h262
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath_p_p.h81
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp979
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p.h134
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p_p.h143
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp891
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p.h199
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p_p.h136
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp466
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle_p.h186
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle_p_p.h109
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp328
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater_p.h103
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater_p_p.h82
-rw-r--r--src/declarative/graphicsitems/qdeclarativescalegrid.cpp212
-rw-r--r--src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h133
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp936
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p.h160
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p_p.h127
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp1035
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h240
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p_p.h113
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp913
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h232
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p_p.h114
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp1256
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h253
-rw-r--r--src/declarative/graphicsitems/qdeclarativewebview.cpp1335
-rw-r--r--src/declarative/graphicsitems/qdeclarativewebview_p.h286
-rw-r--r--src/declarative/graphicsitems/qdeclarativewebview_p_p.h151
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors.cpp1059
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors_p.h196
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h174
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp306
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanimatedimage_p.h106
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanimatedimage_p_p.h82
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage.cpp408
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage_p.h103
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage_p_p.h97
-rw-r--r--src/declarative/graphicsitems/qmlgraphicseffects.cpp170
-rw-r--r--src/declarative/graphicsitems/qmlgraphicseffects_p.h65
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsevents.cpp193
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsevents_p_p.h137
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp1324
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable_p.h214
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h189
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflipable.cpp238
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflipable_p.h95
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp89
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsfocuspanel_p.h77
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp71
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsfocusscope_p.h68
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp269
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer_p.h90
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp1723
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview_p.h222
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage.cpp368
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage_p.h102
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage_p_p.h79
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimagebase.cpp191
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimagebase_p.h92
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimagebase_p_p.h84
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp2838
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.h243
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem_p.h471
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitemchangelistener_p.h76
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp161
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h63
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp114
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslayoutitem_p.h94
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp2716
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview_p.h305
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader.cpp488
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader_p.h111
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader_p_p.h88
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmousearea.cpp685
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmousearea_p.h185
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmousearea_p_p.h117
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspainteditem.cpp466
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspainteditem_p.h114
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h90
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles.cpp1295
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles_p.h258
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspath.cpp849
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspath_p.h262
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspath_p_p.h81
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview.cpp979
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview_p.h134
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview_p_p.h143
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners.cpp891
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners_p.h199
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h136
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrectangle.cpp466
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrectangle_p.h186
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrectangle_p_p.h109
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrepeater.cpp328
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrepeater_p.h103
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrepeater_p_p.h82
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp212
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h133
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext.cpp936
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext_p.h160
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext_p_p.h127
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit.cpp1035
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit_p.h240
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit_p_p.h113
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput.cpp913
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput_p.h232
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput_p_p.h114
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp1256
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h253
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp1335
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview_p.h286
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview_p_p.h151
-rw-r--r--src/declarative/qml/parser/parser.pri32
-rw-r--r--src/declarative/qml/parser/qdeclarativejs.g3075
-rw-r--r--src/declarative/qml/parser/qdeclarativejsast.cpp955
-rw-r--r--src/declarative/qml/parser/qdeclarativejsast_p.h2678
-rw-r--r--src/declarative/qml/parser/qdeclarativejsastfwd_p.h189
-rw-r--r--src/declarative/qml/parser/qdeclarativejsastvisitor.cpp58
-rw-r--r--src/declarative/qml/parser/qdeclarativejsastvisitor_p.h335
-rw-r--r--src/declarative/qml/parser/qdeclarativejsengine_p.cpp212
-rw-r--r--src/declarative/qml/parser/qdeclarativejsengine_p.h173
-rw-r--r--src/declarative/qml/parser/qdeclarativejsglobal_p.h64
-rw-r--r--src/declarative/qml/parser/qdeclarativejsgrammar.cpp939
-rw-r--r--src/declarative/qml/parser/qdeclarativejsgrammar_p.h209
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer.cpp1161
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer_p.h249
-rw-r--r--src/declarative/qml/parser/qdeclarativejsmemorypool_p.h133
-rw-r--r--src/declarative/qml/parser/qdeclarativejsnodepool_p.h139
-rw-r--r--src/declarative/qml/parser/qdeclarativejsparser.cpp1843
-rw-r--r--src/declarative/qml/parser/qdeclarativejsparser_p.h246
-rw-r--r--src/declarative/qml/parser/qmljs.g3075
-rw-r--r--src/declarative/qml/parser/qmljsast.cpp955
-rw-r--r--src/declarative/qml/parser/qmljsast_p.h2678
-rw-r--r--src/declarative/qml/parser/qmljsastfwd_p.h189
-rw-r--r--src/declarative/qml/parser/qmljsastvisitor.cpp58
-rw-r--r--src/declarative/qml/parser/qmljsastvisitor_p.h335
-rw-r--r--src/declarative/qml/parser/qmljsengine_p.cpp212
-rw-r--r--src/declarative/qml/parser/qmljsengine_p.h173
-rw-r--r--src/declarative/qml/parser/qmljsglobal_p.h64
-rw-r--r--src/declarative/qml/parser/qmljsgrammar.cpp939
-rw-r--r--src/declarative/qml/parser/qmljsgrammar_p.h209
-rw-r--r--src/declarative/qml/parser/qmljslexer.cpp1161
-rw-r--r--src/declarative/qml/parser/qmljslexer_p.h249
-rw-r--r--src/declarative/qml/parser/qmljsmemorypool_p.h133
-rw-r--r--src/declarative/qml/parser/qmljsnodepool_p.h139
-rw-r--r--src/declarative/qml/parser/qmljsparser.cpp1843
-rw-r--r--src/declarative/qml/parser/qmljsparser_p.h246
-rw-r--r--src/declarative/qml/qdeclarative.h132
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp308
-rw-r--r--src/declarative/qml/qdeclarativebinding_p.h135
-rw-r--r--src/declarative/qml/qdeclarativebinding_p_p.h91
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp263
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal_p.h100
-rw-r--r--src/declarative/qml/qdeclarativeclassfactory.cpp50
-rw-r--r--src/declarative/qml/qdeclarativeclassfactory_p.h74
-rw-r--r--src/declarative/qml/qdeclarativecleanup.cpp87
-rw-r--r--src/declarative/qml/qdeclarativecleanup_p.h79
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings.cpp2738
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings_p.h116
-rw-r--r--src/declarative/qml/qdeclarativecompileddata.cpp239
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp2779
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h337
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp798
-rw-r--r--src/declarative/qml/qdeclarativecomponent.h134
-rw-r--r--src/declarative/qml/qdeclarativecomponent_p.h147
-rw-r--r--src/declarative/qml/qdeclarativecompositetypedata_p.h152
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp670
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager_p.h117
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp574
-rw-r--r--src/declarative/qml/qdeclarativecontext.h107
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h195
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass.cpp275
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass_p.h101
-rw-r--r--src/declarative/qml/qdeclarativecustomparser.cpp263
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h142
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p_p.h89
-rw-r--r--src/declarative/qml/qdeclarativedeclarativedata_p.h138
-rw-r--r--src/declarative/qml/qdeclarativedirparser.cpp220
-rw-r--r--src/declarative/qml/qdeclarativedirparser_p.h125
-rw-r--r--src/declarative/qml/qdeclarativedom.cpp1836
-rw-r--r--src/declarative/qml/qdeclarativedom_p.h360
-rw-r--r--src/declarative/qml/qdeclarativedom_p_p.h157
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp1901
-rw-r--r--src/declarative/qml/qdeclarativeengine.h112
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h340
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp456
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug_p.h121
-rw-r--r--src/declarative/qml/qdeclarativeerror.cpp258
-rw-r--r--src/declarative/qml/qdeclarativeerror.h86
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp810
-rw-r--r--src/declarative/qml/qdeclarativeexpression.h113
-rw-r--r--src/declarative/qml/qdeclarativeexpression_p.h189
-rw-r--r--src/declarative/qml/qdeclarativeextensioninterface.h67
-rw-r--r--src/declarative/qml/qdeclarativeextensionplugin.cpp87
-rw-r--r--src/declarative/qml/qdeclarativeextensionplugin.h72
-rw-r--r--src/declarative/qml/qdeclarativeglobal_p.h91
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass.cpp121
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass_p.h83
-rw-r--r--src/declarative/qml/qdeclarativeguard_p.h156
-rw-r--r--src/declarative/qml/qdeclarativeimageprovider.cpp68
-rw-r--r--src/declarative/qml/qdeclarativeimageprovider.h64
-rw-r--r--src/declarative/qml/qdeclarativeinfo.cpp127
-rw-r--r--src/declarative/qml/qdeclarativeinfo.h92
-rw-r--r--src/declarative/qml/qdeclarativeinstruction.cpp210
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h319
-rw-r--r--src/declarative/qml/qdeclarativeintegercache.cpp86
-rw-r--r--src/declarative/qml/qdeclarativeintegercache_p.h111
-rw-r--r--src/declarative/qml/qdeclarativelist.cpp312
-rw-r--r--src/declarative/qml/qdeclarativelist.h143
-rw-r--r--src/declarative/qml/qdeclarativelist_p.h85
-rw-r--r--src/declarative/qml/qdeclarativelistscriptclass.cpp149
-rw-r--r--src/declarative/qml/qdeclarativelistscriptclass_p.h87
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty.cpp1238
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty.h147
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty_p.h125
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp1153
-rw-r--r--src/declarative/qml/qdeclarativemetatype.h281
-rw-r--r--src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp84
-rw-r--r--src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.h66
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp673
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass_p.h144
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp387
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h357
-rw-r--r--src/declarative/qml/qdeclarativeparserstatus.cpp81
-rw-r--r--src/declarative/qml/qdeclarativeparserstatus.h75
-rw-r--r--src/declarative/qml/qdeclarativeprivate.cpp48
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h211
-rw-r--r--src/declarative/qml/qdeclarativepropertycache.cpp423
-rw-r--r--src/declarative/qml/qdeclarativepropertycache_p.h196
-rw-r--r--src/declarative/qml/qdeclarativepropertyvalueinterceptor.cpp79
-rw-r--r--src/declarative/qml/qdeclarativepropertyvalueinterceptor.h68
-rw-r--r--src/declarative/qml/qdeclarativepropertyvaluesource.cpp71
-rw-r--r--src/declarative/qml/qdeclarativepropertyvaluesource.h67
-rw-r--r--src/declarative/qml/qdeclarativeproxymetaobject.cpp138
-rw-r--r--src/declarative/qml/qdeclarativeproxymetaobject_p.h100
-rw-r--r--src/declarative/qml/qdeclarativerefcount.cpp70
-rw-r--r--src/declarative/qml/qdeclarativerefcount_p.h80
-rw-r--r--src/declarative/qml/qdeclarativerewrite.cpp215
-rw-r--r--src/declarative/qml/qdeclarativerewrite_p.h121
-rw-r--r--src/declarative/qml/qdeclarativescript.cpp87
-rw-r--r--src/declarative/qml/qdeclarativescriptclass_p.h89
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp952
-rw-r--r--src/declarative/qml/qdeclarativescriptparser_p.h137
-rw-r--r--src/declarative/qml/qdeclarativescriptstring.cpp155
-rw-r--r--src/declarative/qml/qdeclarativescriptstring.h87
-rw-r--r--src/declarative/qml/qdeclarativesqldatabase.cpp428
-rw-r--r--src/declarative/qml/qdeclarativesqldatabase_p.h67
-rw-r--r--src/declarative/qml/qdeclarativestringconverters.cpp276
-rw-r--r--src/declarative/qml/qdeclarativestringconverters_p.h87
-rw-r--r--src/declarative/qml/qdeclarativetypenamecache.cpp103
-rw-r--r--src/declarative/qml/qdeclarativetypenamecache_p.h117
-rw-r--r--src/declarative/qml/qdeclarativetypenamescriptclass.cpp166
-rw-r--r--src/declarative/qml/qdeclarativetypenamescriptclass_p.h93
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp706
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h397
-rw-r--r--src/declarative/qml/qdeclarativevaluetypescriptclass.cpp148
-rw-r--r--src/declarative/qml/qdeclarativevaluetypescriptclass_p.h86
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp851
-rw-r--r--src/declarative/qml/qdeclarativevme_p.h119
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject.cpp366
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject_p.h157
-rw-r--r--src/declarative/qml/qdeclarativewatcher.cpp186
-rw-r--r--src/declarative/qml/qdeclarativewatcher_p.h94
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp1041
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript_p.h160
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp1631
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest_p.h67
-rw-r--r--src/declarative/qml/qml.h132
-rw-r--r--src/declarative/qml/qml.pri240
-rw-r--r--src/declarative/qml/qmlbinding.cpp308
-rw-r--r--src/declarative/qml/qmlbinding_p.h135
-rw-r--r--src/declarative/qml/qmlbinding_p_p.h91
-rw-r--r--src/declarative/qml/qmlboundsignal.cpp263
-rw-r--r--src/declarative/qml/qmlboundsignal_p.h100
-rw-r--r--src/declarative/qml/qmlclassfactory.cpp50
-rw-r--r--src/declarative/qml/qmlclassfactory_p.h74
-rw-r--r--src/declarative/qml/qmlcleanup.cpp87
-rw-r--r--src/declarative/qml/qmlcleanup_p.h79
-rw-r--r--src/declarative/qml/qmlcompiledbindings.cpp2738
-rw-r--r--src/declarative/qml/qmlcompiledbindings_p.h116
-rw-r--r--src/declarative/qml/qmlcompileddata.cpp239
-rw-r--r--src/declarative/qml/qmlcompiler.cpp2779
-rw-r--r--src/declarative/qml/qmlcompiler_p.h337
-rw-r--r--src/declarative/qml/qmlcomponent.cpp798
-rw-r--r--src/declarative/qml/qmlcomponent.h134
-rw-r--r--src/declarative/qml/qmlcomponent_p.h147
-rw-r--r--src/declarative/qml/qmlcompositetypedata_p.h152
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp670
-rw-r--r--src/declarative/qml/qmlcompositetypemanager_p.h117
-rw-r--r--src/declarative/qml/qmlcontext.cpp574
-rw-r--r--src/declarative/qml/qmlcontext.h107
-rw-r--r--src/declarative/qml/qmlcontext_p.h195
-rw-r--r--src/declarative/qml/qmlcontextscriptclass.cpp275
-rw-r--r--src/declarative/qml/qmlcontextscriptclass_p.h101
-rw-r--r--src/declarative/qml/qmlcustomparser.cpp263
-rw-r--r--src/declarative/qml/qmlcustomparser_p.h142
-rw-r--r--src/declarative/qml/qmlcustomparser_p_p.h89
-rw-r--r--src/declarative/qml/qmldeclarativedata_p.h138
-rw-r--r--src/declarative/qml/qmldirparser.cpp220
-rw-r--r--src/declarative/qml/qmldirparser_p.h125
-rw-r--r--src/declarative/qml/qmldom.cpp1836
-rw-r--r--src/declarative/qml/qmldom_p.h360
-rw-r--r--src/declarative/qml/qmldom_p_p.h157
-rw-r--r--src/declarative/qml/qmlengine.cpp1901
-rw-r--r--src/declarative/qml/qmlengine.h112
-rw-r--r--src/declarative/qml/qmlengine_p.h340
-rw-r--r--src/declarative/qml/qmlenginedebug.cpp456
-rw-r--r--src/declarative/qml/qmlenginedebug_p.h121
-rw-r--r--src/declarative/qml/qmlerror.cpp258
-rw-r--r--src/declarative/qml/qmlerror.h86
-rw-r--r--src/declarative/qml/qmlexpression.cpp810
-rw-r--r--src/declarative/qml/qmlexpression.h113
-rw-r--r--src/declarative/qml/qmlexpression_p.h189
-rw-r--r--src/declarative/qml/qmlextensioninterface.h67
-rw-r--r--src/declarative/qml/qmlextensionplugin.cpp87
-rw-r--r--src/declarative/qml/qmlextensionplugin.h72
-rw-r--r--src/declarative/qml/qmlglobal_p.h91
-rw-r--r--src/declarative/qml/qmlglobalscriptclass.cpp121
-rw-r--r--src/declarative/qml/qmlglobalscriptclass_p.h83
-rw-r--r--src/declarative/qml/qmlguard_p.h156
-rw-r--r--src/declarative/qml/qmlimageprovider.cpp68
-rw-r--r--src/declarative/qml/qmlimageprovider.h64
-rw-r--r--src/declarative/qml/qmlinfo.cpp127
-rw-r--r--src/declarative/qml/qmlinfo.h92
-rw-r--r--src/declarative/qml/qmlinstruction.cpp210
-rw-r--r--src/declarative/qml/qmlinstruction_p.h319
-rw-r--r--src/declarative/qml/qmlintegercache.cpp86
-rw-r--r--src/declarative/qml/qmlintegercache_p.h111
-rw-r--r--src/declarative/qml/qmllist.cpp312
-rw-r--r--src/declarative/qml/qmllist.h143
-rw-r--r--src/declarative/qml/qmllist_p.h85
-rw-r--r--src/declarative/qml/qmllistscriptclass.cpp149
-rw-r--r--src/declarative/qml/qmllistscriptclass_p.h87
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp1238
-rw-r--r--src/declarative/qml/qmlmetaproperty.h147
-rw-r--r--src/declarative/qml/qmlmetaproperty_p.h125
-rw-r--r--src/declarative/qml/qmlmetatype.cpp1153
-rw-r--r--src/declarative/qml/qmlmetatype.h281
-rw-r--r--src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp84
-rw-r--r--src/declarative/qml/qmlnetworkaccessmanagerfactory.h66
-rw-r--r--src/declarative/qml/qmlobjectscriptclass.cpp673
-rw-r--r--src/declarative/qml/qmlobjectscriptclass_p.h144
-rw-r--r--src/declarative/qml/qmlparser.cpp387
-rw-r--r--src/declarative/qml/qmlparser_p.h357
-rw-r--r--src/declarative/qml/qmlparserstatus.cpp81
-rw-r--r--src/declarative/qml/qmlparserstatus.h75
-rw-r--r--src/declarative/qml/qmlprivate.cpp48
-rw-r--r--src/declarative/qml/qmlprivate.h211
-rw-r--r--src/declarative/qml/qmlpropertycache.cpp423
-rw-r--r--src/declarative/qml/qmlpropertycache_p.h196
-rw-r--r--src/declarative/qml/qmlpropertyvalueinterceptor.cpp79
-rw-r--r--src/declarative/qml/qmlpropertyvalueinterceptor.h68
-rw-r--r--src/declarative/qml/qmlpropertyvaluesource.cpp71
-rw-r--r--src/declarative/qml/qmlpropertyvaluesource.h67
-rw-r--r--src/declarative/qml/qmlproxymetaobject.cpp138
-rw-r--r--src/declarative/qml/qmlproxymetaobject_p.h100
-rw-r--r--src/declarative/qml/qmlrefcount.cpp70
-rw-r--r--src/declarative/qml/qmlrefcount_p.h80
-rw-r--r--src/declarative/qml/qmlrewrite.cpp215
-rw-r--r--src/declarative/qml/qmlrewrite_p.h121
-rw-r--r--src/declarative/qml/qmlscript.cpp87
-rw-r--r--src/declarative/qml/qmlscriptclass_p.h89
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp952
-rw-r--r--src/declarative/qml/qmlscriptparser_p.h137
-rw-r--r--src/declarative/qml/qmlscriptstring.cpp155
-rw-r--r--src/declarative/qml/qmlscriptstring.h87
-rw-r--r--src/declarative/qml/qmlsqldatabase.cpp428
-rw-r--r--src/declarative/qml/qmlsqldatabase_p.h67
-rw-r--r--src/declarative/qml/qmlstringconverters.cpp276
-rw-r--r--src/declarative/qml/qmlstringconverters_p.h87
-rw-r--r--src/declarative/qml/qmltypenamecache.cpp103
-rw-r--r--src/declarative/qml/qmltypenamecache_p.h117
-rw-r--r--src/declarative/qml/qmltypenamescriptclass.cpp166
-rw-r--r--src/declarative/qml/qmltypenamescriptclass_p.h93
-rw-r--r--src/declarative/qml/qmlvaluetype.cpp706
-rw-r--r--src/declarative/qml/qmlvaluetype_p.h397
-rw-r--r--src/declarative/qml/qmlvaluetypescriptclass.cpp148
-rw-r--r--src/declarative/qml/qmlvaluetypescriptclass_p.h86
-rw-r--r--src/declarative/qml/qmlvme.cpp851
-rw-r--r--src/declarative/qml/qmlvme_p.h119
-rw-r--r--src/declarative/qml/qmlvmemetaobject.cpp366
-rw-r--r--src/declarative/qml/qmlvmemetaobject_p.h157
-rw-r--r--src/declarative/qml/qmlwatcher.cpp186
-rw-r--r--src/declarative/qml/qmlwatcher_p.h94
-rw-r--r--src/declarative/qml/qmlworkerscript.cpp1041
-rw-r--r--src/declarative/qml/qmlworkerscript_p.h160
-rw-r--r--src/declarative/qml/qmlxmlhttprequest.cpp1631
-rw-r--r--src/declarative/qml/qmlxmlhttprequest_p.h67
-rw-r--r--src/declarative/qml/rewriter/rewriter.cpp8
-rw-r--r--src/declarative/qml/rewriter/rewriter_p.h6
-rw-r--r--src/declarative/qml/rewriter/textwriter.cpp2
-rw-r--r--src/declarative/qml/rewriter/textwriter_p.h6
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp2369
-rw-r--r--src/declarative/util/qdeclarativeanimation_p.h467
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h364
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp191
-rw-r--r--src/declarative/util/qdeclarativebehavior_p.h92
-rw-r--r--src/declarative/util/qdeclarativebind.cpp202
-rw-r--r--src/declarative/util/qdeclarativebind_p.h95
-rw-r--r--src/declarative/util/qdeclarativeconnection.cpp288
-rw-r--r--src/declarative/util/qdeclarativeconnection_p.h93
-rw-r--r--src/declarative/util/qdeclarativedatetimeformatter.cpp373
-rw-r--r--src/declarative/util/qdeclarativedatetimeformatter_p.h117
-rw-r--r--src/declarative/util/qdeclarativeeasefollow.cpp536
-rw-r--r--src/declarative/util/qdeclarativeeasefollow_p.h114
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp229
-rw-r--r--src/declarative/util/qdeclarativefontloader_p.h95
-rw-r--r--src/declarative/util/qdeclarativelistaccessor.cpp138
-rw-r--r--src/declarative/util/qdeclarativelistaccessor_p.h80
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp983
-rw-r--r--src/declarative/util/qdeclarativelistmodel_p.h139
-rw-r--r--src/declarative/util/qdeclarativenullablevalue_p_p.h81
-rw-r--r--src/declarative/util/qdeclarativenumberformatter.cpp261
-rw-r--r--src/declarative/util/qdeclarativenumberformatter_p.h93
-rw-r--r--src/declarative/util/qdeclarativeopenmetaobject.cpp355
-rw-r--r--src/declarative/util/qdeclarativeopenmetaobject_p.h125
-rw-r--r--src/declarative/util/qdeclarativepackage.cpp167
-rw-r--r--src/declarative/util/qdeclarativepackage_p.h104
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp611
-rw-r--r--src/declarative/util/qdeclarativepixmapcache_p.h107
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp456
-rw-r--r--src/declarative/util/qdeclarativepropertychanges_p.h95
-rw-r--r--src/declarative/util/qdeclarativepropertymap.cpp279
-rw-r--r--src/declarative/util/qdeclarativepropertymap.h90
-rw-r--r--src/declarative/util/qdeclarativespringfollow.cpp464
-rw-r--r--src/declarative/util/qdeclarativespringfollow_p.h112
-rw-r--r--src/declarative/util/qdeclarativestate.cpp482
-rw-r--r--src/declarative/util/qdeclarativestate_p.h181
-rw-r--r--src/declarative/util/qdeclarativestate_p_p.h152
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp440
-rw-r--r--src/declarative/util/qdeclarativestategroup_p.h95
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp833
-rw-r--r--src/declarative/util/qdeclarativestateoperations_p.h184
-rw-r--r--src/declarative/util/qdeclarativestyledtext.cpp347
-rw-r--r--src/declarative/util/qdeclarativestyledtext_p.h69
-rw-r--r--src/declarative/util/qdeclarativesystempalette.cpp303
-rw-r--r--src/declarative/util/qdeclarativesystempalette_p.h122
-rw-r--r--src/declarative/util/qdeclarativetimeline.cpp942
-rw-r--r--src/declarative/util/qdeclarativetimeline_p_p.h200
-rw-r--r--src/declarative/util/qdeclarativetimer.cpp313
-rw-r--r--src/declarative/util/qdeclarativetimer_p.h109
-rw-r--r--src/declarative/util/qdeclarativetransition.cpp249
-rw-r--r--src/declarative/util/qdeclarativetransition_p.h101
-rw-r--r--src/declarative/util/qdeclarativetransitionmanager.cpp282
-rw-r--r--src/declarative/util/qdeclarativetransitionmanager_p_p.h85
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp118
-rw-r--r--src/declarative/util/qdeclarativeutilmodule_p.h63
-rw-r--r--src/declarative/util/qdeclarativeview.cpp570
-rw-r--r--src/declarative/util/qdeclarativeview.h114
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp796
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel_p.h174
-rw-r--r--src/declarative/util/qfxperf.cpp22
-rw-r--r--src/declarative/util/qfxperf_p_p.h8
-rw-r--r--src/declarative/util/qmlanimation.cpp2369
-rw-r--r--src/declarative/util/qmlanimation_p.h467
-rw-r--r--src/declarative/util/qmlanimation_p_p.h364
-rw-r--r--src/declarative/util/qmlbehavior.cpp191
-rw-r--r--src/declarative/util/qmlbehavior_p.h92
-rw-r--r--src/declarative/util/qmlbind.cpp202
-rw-r--r--src/declarative/util/qmlbind_p.h95
-rw-r--r--src/declarative/util/qmlconnection.cpp288
-rw-r--r--src/declarative/util/qmlconnection_p.h93
-rw-r--r--src/declarative/util/qmldatetimeformatter.cpp373
-rw-r--r--src/declarative/util/qmldatetimeformatter_p.h117
-rw-r--r--src/declarative/util/qmleasefollow.cpp536
-rw-r--r--src/declarative/util/qmleasefollow_p.h114
-rw-r--r--src/declarative/util/qmlfontloader.cpp229
-rw-r--r--src/declarative/util/qmlfontloader_p.h95
-rw-r--r--src/declarative/util/qmlgraphicsutilmodule.cpp118
-rw-r--r--src/declarative/util/qmlgraphicsutilmodule_p.h63
-rw-r--r--src/declarative/util/qmllistaccessor.cpp138
-rw-r--r--src/declarative/util/qmllistaccessor_p.h80
-rw-r--r--src/declarative/util/qmllistmodel.cpp983
-rw-r--r--src/declarative/util/qmllistmodel_p.h139
-rw-r--r--src/declarative/util/qmlnullablevalue_p_p.h81
-rw-r--r--src/declarative/util/qmlnumberformatter.cpp261
-rw-r--r--src/declarative/util/qmlnumberformatter_p.h93
-rw-r--r--src/declarative/util/qmlopenmetaobject.cpp355
-rw-r--r--src/declarative/util/qmlopenmetaobject_p.h125
-rw-r--r--src/declarative/util/qmlpackage.cpp167
-rw-r--r--src/declarative/util/qmlpackage_p.h104
-rw-r--r--src/declarative/util/qmlpixmapcache.cpp611
-rw-r--r--src/declarative/util/qmlpixmapcache_p.h107
-rw-r--r--src/declarative/util/qmlpropertychanges.cpp456
-rw-r--r--src/declarative/util/qmlpropertychanges_p.h95
-rw-r--r--src/declarative/util/qmlpropertymap.cpp279
-rw-r--r--src/declarative/util/qmlpropertymap.h90
-rw-r--r--src/declarative/util/qmlspringfollow.cpp464
-rw-r--r--src/declarative/util/qmlspringfollow_p.h112
-rw-r--r--src/declarative/util/qmlstate.cpp482
-rw-r--r--src/declarative/util/qmlstate_p.h181
-rw-r--r--src/declarative/util/qmlstate_p_p.h152
-rw-r--r--src/declarative/util/qmlstategroup.cpp440
-rw-r--r--src/declarative/util/qmlstategroup_p.h95
-rw-r--r--src/declarative/util/qmlstateoperations.cpp833
-rw-r--r--src/declarative/util/qmlstateoperations_p.h184
-rw-r--r--src/declarative/util/qmlstyledtext.cpp347
-rw-r--r--src/declarative/util/qmlstyledtext_p.h69
-rw-r--r--src/declarative/util/qmlsystempalette.cpp303
-rw-r--r--src/declarative/util/qmlsystempalette_p.h122
-rw-r--r--src/declarative/util/qmltimeline.cpp942
-rw-r--r--src/declarative/util/qmltimeline_p_p.h200
-rw-r--r--src/declarative/util/qmltimer.cpp313
-rw-r--r--src/declarative/util/qmltimer_p.h109
-rw-r--r--src/declarative/util/qmltransition.cpp249
-rw-r--r--src/declarative/util/qmltransition_p.h101
-rw-r--r--src/declarative/util/qmltransitionmanager.cpp282
-rw-r--r--src/declarative/util/qmltransitionmanager_p_p.h85
-rw-r--r--src/declarative/util/qmlview.cpp570
-rw-r--r--src/declarative/util/qmlview.h114
-rw-r--r--src/declarative/util/qmlxmllistmodel.cpp796
-rw-r--r--src/declarative/util/qmlxmllistmodel_p.h174
-rw-r--r--src/declarative/util/qnumberformat_p.h2
-rw-r--r--src/declarative/util/util.pri118
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h2
-rw-r--r--src/multimedia/qml/qdeclarative.cpp70
-rw-r--r--src/multimedia/qml/qdeclarative.h62
-rw-r--r--src/multimedia/qml/qdeclarativeaudio.cpp326
-rw-r--r--src/multimedia/qml/qdeclarativeaudio_p.h162
-rw-r--r--src/multimedia/qml/qdeclarativemediabase.cpp413
-rw-r--r--src/multimedia/qml/qdeclarativemediabase_p.h158
-rw-r--r--src/multimedia/qml/qdeclarativevideo.cpp944
-rw-r--r--src/multimedia/qml/qdeclarativevideo_p.h193
-rw-r--r--src/multimedia/qml/qml.cpp70
-rw-r--r--src/multimedia/qml/qml.h62
-rw-r--r--src/multimedia/qml/qml.pri16
-rw-r--r--src/multimedia/qml/qmlaudio.cpp326
-rw-r--r--src/multimedia/qml/qmlaudio_p.h162
-rw-r--r--src/multimedia/qml/qmlgraphicsvideo.cpp944
-rw-r--r--src/multimedia/qml/qmlgraphicsvideo_p.h193
-rw-r--r--src/multimedia/qml/qmlmediabase.cpp413
-rw-r--r--src/multimedia/qml/qmlmediabase_p.h158
-rw-r--r--src/multimedia/qml/qsoundeffect_p.h2
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/multimedia.cpp63
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/multimedia.pro11
-rw-r--r--src/plugins/qdeclarativemodules/qdeclarativemodules.pro (renamed from src/plugins/qmlmodules/qmlmodules.pro)0
-rw-r--r--src/plugins/qdeclarativemodules/widgets/graphicslayouts.cpp (renamed from src/plugins/qmlmodules/widgets/graphicslayouts.cpp)0
-rw-r--r--src/plugins/qdeclarativemodules/widgets/graphicslayouts_p.h226
-rw-r--r--src/plugins/qdeclarativemodules/widgets/graphicswidgets.cpp (renamed from src/plugins/qmlmodules/widgets/graphicswidgets.cpp)0
-rw-r--r--src/plugins/qdeclarativemodules/widgets/graphicswidgets_p.h68
-rw-r--r--src/plugins/qdeclarativemodules/widgets/widgets.cpp146
-rw-r--r--src/plugins/qdeclarativemodules/widgets/widgets.pro15
-rw-r--r--src/plugins/qmlmodules/multimedia/multimedia.cpp63
-rw-r--r--src/plugins/qmlmodules/multimedia/multimedia.pro11
-rw-r--r--src/plugins/qmlmodules/widgets/graphicslayouts_p.h226
-rw-r--r--src/plugins/qmlmodules/widgets/graphicswidgets_p.h68
-rw-r--r--src/plugins/qmlmodules/widgets/widgets.cpp146
-rw-r--r--src/plugins/qmlmodules/widgets/widgets.pro15
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/declarative/declarative.pro110
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp11
-rw-r--r--tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp10
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp20
-rw-r--r--tests/auto/declarative/parserstress/tst_parserstress.cpp8
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/anchors.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/anchors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/centerin.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/centerin.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/crash1.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/crash1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/fill.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/fill.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/loop1.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/loop1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/loop2.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/loop2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/margins.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/margins.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro6
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp448
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/colors.gif (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.gif)bin505 -> 505 bytes-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/colors.qml (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.gif (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.gif)bin164923 -> 164923 bytes-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.qml (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanpause.qml (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanpause.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanstopped.qml (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanstopped.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro7
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp191
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/attached.qml (renamed from tests/auto/declarative/qmlanimations/data/attached.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badproperty1.qml (renamed from tests/auto/declarative/qmlanimations/data/badproperty1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badproperty2.qml (renamed from tests/auto/declarative/qmlanimations/data/badproperty2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml (renamed from tests/auto/declarative/qmlanimations/data/badtype1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml (renamed from tests/auto/declarative/qmlanimations/data/badtype2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml (renamed from tests/auto/declarative/qmlanimations/data/badtype3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badtype4.qml (renamed from tests/auto/declarative/qmlanimations/data/badtype4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml (renamed from tests/auto/declarative/qmlanimations/data/dontAutoStart.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml (renamed from tests/auto/declarative/qmlanimations/data/dontStart.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/dontStart2.qml (renamed from tests/auto/declarative/qmlanimations/data/dontStart2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/dotproperty.qml (renamed from tests/auto/declarative/qmlanimations/data/dotproperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/mixedtype1.qml (renamed from tests/auto/declarative/qmlanimations/data/mixedtype1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/mixedtype2.qml (renamed from tests/auto/declarative/qmlanimations/data/mixedtype2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/properties.qml (renamed from tests/auto/declarative/qmlanimations/data/properties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/properties2.qml (renamed from tests/auto/declarative/qmlanimations/data/properties2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/properties3.qml (renamed from tests/auto/declarative/qmlanimations/data/properties3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/properties4.qml (renamed from tests/auto/declarative/qmlanimations/data/properties4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/properties5.qml (renamed from tests/auto/declarative/qmlanimations/data/properties5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition2.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition3.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition4.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition5.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition6.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml (renamed from tests/auto/declarative/qmlanimations/data/valuesource.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml (renamed from tests/auto/declarative/qmlanimations/data/valuesource2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro6
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp672
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/binding.qml (renamed from tests/auto/declarative/qmlbehaviors/data/binding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/color.qml (renamed from tests/auto/declarative/qmlbehaviors/data/color.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml (renamed from tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml (renamed from tests/auto/declarative/qmlbehaviors/data/disabled.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml (renamed from tests/auto/declarative/qmlbehaviors/data/dontStart.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/empty.qml (renamed from tests/auto/declarative/qmlbehaviors/data/empty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml (renamed from tests/auto/declarative/qmlbehaviors/data/explicit.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml (renamed from tests/auto/declarative/qmlbehaviors/data/groupProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml (renamed from tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/loop.qml (renamed from tests/auto/declarative/qmlbehaviors/data/loop.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml (renamed from tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/parent.qml (renamed from tests/auto/declarative/qmlbehaviors/data/parent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml (renamed from tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml (renamed from tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/simple.qml (renamed from tests/auto/declarative/qmlbehaviors/data/simple.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro6
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp301
-rw-r--r--tests/auto/declarative/qdeclarativebinding/data/test-binding.qml (renamed from tests/auto/declarative/qmlbinding/data/test-binding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml (renamed from tests/auto/declarative/qmlbinding/data/test-binding2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro8
-rw-r--r--tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp107
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/data/colors-round.sci (renamed from tests/auto/declarative/qmlgraphicsborderimage/data/colors-round.sci)0
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/data/colors.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors.png)bin1655 -> 1655 bytes-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/data/invalid.sci (renamed from tests/auto/declarative/qmlgraphicsborderimage/data/invalid.sci)0
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp351
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml (renamed from tests/auto/declarative/qmlconnection/data/test-connection.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml (renamed from tests/auto/declarative/qmlconnection/data/test-connection2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml (renamed from tests/auto/declarative/qmlconnection/data/test-connection3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/trimming.qml (renamed from tests/auto/declarative/qmlconnection/data/trimming.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp139
-rw-r--r--tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro6
-rw-r--r--tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp434
-rw-r--r--tests/auto/declarative/qdeclarativedatetimeformatter/qdeclarativedatetimeformatter.pro5
-rw-r--r--tests/auto/declarative/qdeclarativedatetimeformatter/tst_qdeclarativedatetimeformatter.cpp150
-rw-r--r--tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro7
-rw-r--r--tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp841
-rw-r--r--tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro7
-rw-r--r--tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp157
-rw-r--r--tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro7
-rw-r--r--tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp190
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/MyComponent.qml (renamed from tests/auto/declarative/qmldom/data/MyComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/MyItem.qml (renamed from tests/auto/declarative/qmldom/data/MyItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/importdir/Bar.qml (renamed from tests/auto/declarative/qmldom/data/importdir/Bar.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir/Foo.qml (renamed from tests/auto/declarative/qmldom/data/importlib/sublib/qmldir/Foo.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/top.qml (renamed from tests/auto/declarative/qmldom/data/top.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro7
-rw-r--r--tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp1313
-rw-r--r--tests/auto/declarative/qdeclarativeeasefollow/data/easefollow1.qml (renamed from tests/auto/declarative/qmleasefollow/data/easefollow1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeeasefollow/data/easefollow2.qml (renamed from tests/auto/declarative/qmleasefollow/data/easefollow2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeeasefollow/data/easefollow3.qml (renamed from tests/auto/declarative/qmleasefollow/data/easefollow3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeeasefollow/qdeclarativeeasefollow.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeeasefollow/tst_qdeclarativeeasefollow.cpp122
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml (renamed from tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/CustomObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/MethodsObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml (renamed from tests/auto/declarative/qmlecmascript/data/NestedTypeTransientErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/ScopeObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml (renamed from tests/auto/declarative/qmlecmascript/data/TypeForDynamicCreation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml (renamed from tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml (renamed from tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml (renamed from tests/auto/declarative/qmlecmascript/data/attachedProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml (renamed from tests/auto/declarative/qmlecmascript/data/bindingLoop.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/bug.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml (renamed from tests/auto/declarative/qmlecmascript/data/compositePropertyType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml (renamed from tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml (renamed from tests/auto/declarative/qmlecmascript/data/deferredProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/deletedObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml (renamed from tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml (renamed from tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml (renamed from tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/enums.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/enums.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml (renamed from tests/auto/declarative/qmlecmascript/data/exceptionClearsOnReeval.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml (renamed from tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml (renamed from tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml (renamed from tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml (renamed from tests/auto/declarative/qmlecmascript/data/extensionObjects.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.js (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.2.js)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.3.qml (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.4.qml (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.js (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.js)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml (renamed from tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/jsObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml (renamed from tests/auto/declarative/qmlecmascript/data/listProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml (renamed from tests/auto/declarative/qmlecmascript/data/listToVariant.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/methods.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/methods.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml (renamed from tests/auto/declarative/qmlecmascript/data/methods.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml (renamed from tests/auto/declarative/qmlecmascript/data/methods.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml (renamed from tests/auto/declarative/qmlecmascript/data/methods.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/multiEngineObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/nonExistantAttachedObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml (renamed from tests/auto/declarative/qmlecmascript/data/objectsCompareAsEqual.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml (renamed from tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qdeclarativeToString.qml (renamed from tests/auto/declarative/qmlecmascript/data/qmlToString.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/scope.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scope.qml (renamed from tests/auto/declarative/qmlecmascript/data/scope.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.js (renamed from tests/auto/declarative/qmlecmascript/data/scriptAccess.js)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.qml (renamed from tests/auto/declarative/qmlecmascript/data/scriptAccess.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js (renamed from tests/auto/declarative/qmlecmascript/data/scriptErrors.js)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml (renamed from tests/auto/declarative/qmlecmascript/data/scriptErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml (renamed from tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml (renamed from tests/auto/declarative/qmlecmascript/data/shutdownErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/signalAssignment.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/signalAssignment.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml (renamed from tests/auto/declarative/qmlecmascript/data/signalParameterTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml (renamed from tests/auto/declarative/qmlecmascript/data/signalTriggeredBindings.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml (renamed from tests/auto/declarative/qmlecmascript/data/transientErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml (renamed from tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml (renamed from tests/auto/declarative/qmlecmascript/data/valueTypeFunctions.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro10
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp (renamed from tests/auto/declarative/qmlecmascript/testtypes.cpp)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h598
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp1662
-rw-r--r--tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp240
-rw-r--r--tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro6
-rw-r--r--tests/auto/declarative/qdeclarativeerror/test.txt (renamed from tests/auto/declarative/qmlerror/test.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp242
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml (renamed from tests/auto/declarative/qmlgraphicsflickable/data/flickable01.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml (renamed from tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml (renamed from tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml (renamed from tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp224
-rw-r--r--tests/auto/declarative/qdeclarativeflipable/data/test-flipable.qml (renamed from tests/auto/declarative/qmlgraphicsflipable/data/test-flipable.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp113
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf (renamed from tests/auto/declarative/qmlfontloader/data/dummy.ttf)0
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf (renamed from tests/auto/declarative/qmlfontloader/data/tarzeau_ocr_a.ttf)bin24544 -> 24544 bytes-rw-r--r--tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro8
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp156
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml (renamed from tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview.qml (renamed from tests/auto/declarative/qmlgraphicsgridview/data/gridview.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview2.qml (renamed from tests/auto/declarative/qmlgraphicsgridview/data/gridview2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview3.qml (renamed from tests/auto/declarative/qmlgraphicsgridview/data/gridview3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro8
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp964
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/colors.png (renamed from tests/auto/declarative/qmlgraphicsimage/data/colors.png)bin1655 -> 1655 bytes-rw-r--r--tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp247
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/data/exists.png (renamed from tests/auto/declarative/qmlpixmapcache/data/exists.png)bin2738 -> 2738 bytes-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/data/exists1.png (renamed from tests/auto/declarative/qmlpixmapcache/data/exists1.png)bin2738 -> 2738 bytes-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/data/exists2.png (renamed from tests/auto/declarative/qmlpixmapcache/data/exists2.png)bin2738 -> 2738 bytes-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro12
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp166
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml (renamed from tests/auto/declarative/qmlinfo/data/NestedObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml (renamed from tests/auto/declarative/qmlinfo/data/nestedQmlObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/data/qdeclarativeObject.qml (renamed from tests/auto/declarative/qmlinfo/data/qmlObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro7
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp139
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro6
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp585
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml (renamed from tests/auto/declarative/qmlgraphicsitem/data/keynavigation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/keys.qml (renamed from tests/auto/declarative/qmlgraphicsitem/data/keys.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro7
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp318
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/Alias.qml (renamed from tests/auto/declarative/qmllanguage/data/Alias.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml (renamed from tests/auto/declarative/qmllanguage/data/Alias2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml (renamed from tests/auto/declarative/qmllanguage/data/Alias3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml (renamed from tests/auto/declarative/qmllanguage/data/Alias4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml (renamed from tests/auto/declarative/qmllanguage/data/ComponentComposite.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml (renamed from tests/auto/declarative/qmllanguage/data/CompositeType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml (renamed from tests/auto/declarative/qmllanguage/data/CompositeType2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml (renamed from tests/auto/declarative/qmllanguage/data/CompositeType3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml (renamed from tests/auto/declarative/qmllanguage/data/CompositeType4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml (renamed from tests/auto/declarative/qmllanguage/data/DynamicPropertiesNestedType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml (renamed from tests/auto/declarative/qmllanguage/data/HelperAlias.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/I18n.qml (renamed from tests/auto/declarative/qmllanguage/data/I18n.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml (renamed from tests/auto/declarative/qmllanguage/data/I18nType30.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml (renamed from tests/auto/declarative/qmllanguage/data/MyComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml (renamed from tests/auto/declarative/qmllanguage/data/MyCompositeValueSource.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml (renamed from tests/auto/declarative/qmllanguage/data/MyContainerComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml (renamed from tests/auto/declarative/qmllanguage/data/NestedAlias.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml (renamed from tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml (renamed from tests/auto/declarative/qmllanguage/data/OnCompletedType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.8.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.9.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml (renamed from tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml (renamed from tests/auto/declarative/qmllanguage/data/assignCompositeToType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/assignLiteralSignalProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml (renamed from tests/auto/declarative/qmllanguage/data/assignObjectToSignal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml (renamed from tests/auto/declarative/qmllanguage/data/assignObjectToVariant.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml (renamed from tests/auto/declarative/qmllanguage/data/assignQmlComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml (renamed from tests/auto/declarative/qmllanguage/data/assignSignal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml (renamed from tests/auto/declarative/qmllanguage/data/assignTypeExtremes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml (renamed from tests/auto/declarative/qmllanguage/data/attachedProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml (renamed from tests/auto/declarative/qmllanguage/data/autoComponentCreation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.1.qml (renamed from tests/auto/declarative/qmllanguage/data/component.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.2.qml (renamed from tests/auto/declarative/qmllanguage/data/component.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.3.qml (renamed from tests/auto/declarative/qmllanguage/data/component.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.4.qml (renamed from tests/auto/declarative/qmllanguage/data/component.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.5.qml (renamed from tests/auto/declarative/qmllanguage/data/component.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.6.qml (renamed from tests/auto/declarative/qmllanguage/data/component.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml (renamed from tests/auto/declarative/qmllanguage/data/componentCompositeType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml (renamed from tests/auto/declarative/qmllanguage/data/cppnamespace.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml (renamed from tests/auto/declarative/qmllanguage/data/cppnamespace.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/crash2.qml (renamed from tests/auto/declarative/qmllanguage/data/crash2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml (renamed from tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml (renamed from tests/auto/declarative/qmllanguage/data/customParserTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml (renamed from tests/auto/declarative/qmllanguage/data/customVariantTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml (renamed from tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml (renamed from tests/auto/declarative/qmllanguage/data/defaultGrouped.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml (renamed from tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml (renamed from tests/auto/declarative/qmllanguage/data/doubleSignal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/duplicateIDs.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml (renamed from tests/auto/declarative/qmllanguage/data/duplicateIDs.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml (renamed from tests/auto/declarative/qmllanguage/data/dynamicObject.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml (renamed from tests/auto/declarative/qmllanguage/data/dynamicObjectProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml (renamed from tests/auto/declarative/qmllanguage/data/dynamicProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml (renamed from tests/auto/declarative/qmllanguage/data/dynamicPropertiesNested.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml (renamed from tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/empty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/empty.qml (renamed from tests/auto/declarative/qmllanguage/data/empty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml (renamed from tests/auto/declarative/qmllanguage/data/emptySignal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/failingComponent.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml (renamed from tests/auto/declarative/qmllanguage/data/failingComponentTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/fakeDotProperty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/fakeDotProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/finalOverride.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml (renamed from tests/auto/declarative/qmllanguage/data/finalOverride.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nNameSpace.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nScript.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nStrings.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/idProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/importNamespaceConflict.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml (renamed from tests/auto/declarative/qmllanguage/data/importNamespaceConflict.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml (renamed from tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml (renamed from tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml (renamed from tests/auto/declarative/qmllanguage/data/inlineQmlComponents.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/interfaceProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml (renamed from tests/auto/declarative/qmllanguage/data/interfaceQList.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidImportID.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidImportID.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidRoot.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidRoot.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml (renamed from tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml (renamed from tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml (renamed from tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir (renamed from tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/qmldir)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/listAssignment.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml (renamed from tests/auto/declarative/qmllanguage/data/listAssignment.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/listAssignment.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml (renamed from tests/auto/declarative/qmllanguage/data/listAssignment.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml (renamed from tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml (renamed from tests/auto/declarative/qmllanguage/data/listProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/missingObject.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml (renamed from tests/auto/declarative/qmllanguage/data/missingObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml (renamed from tests/auto/declarative/qmllanguage/data/missingSignal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml (renamed from tests/auto/declarative/qmllanguage/data/nestedErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nullDotProperty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/nullDotProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml (renamed from tests/auto/declarative/qmllanguage/data/onCompleted.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/property.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.1.qml (renamed from tests/auto/declarative/qmllanguage/data/property.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/property.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.2.qml (renamed from tests/auto/declarative/qmllanguage/data/property.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/property.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.3.qml (renamed from tests/auto/declarative/qmllanguage/data/property.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/property.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.4.qml (renamed from tests/auto/declarative/qmllanguage/data/property.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/property.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.5.qml (renamed from tests/auto/declarative/qmllanguage/data/property.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml (renamed from tests/auto/declarative/qmllanguage/data/propertyValueSource.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml (renamed from tests/auto/declarative/qmllanguage/data/propertyValueSource.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/qdeclarativeAttachedPropertiesObjectMethod.1.qml (renamed from tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/qdeclarativeAttachedPropertiesObjectMethod.2.qml (renamed from tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/readOnly.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml (renamed from tests/auto/declarative/qmllanguage/data/readOnly.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/readOnly.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml (renamed from tests/auto/declarative/qmllanguage/data/readOnly.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/readOnly.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml (renamed from tests/auto/declarative/qmllanguage/data/readOnly.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml (renamed from tests/auto/declarative/qmllanguage/data/rootAsQmlComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.1.qml (renamed from tests/auto/declarative/qmllanguage/data/script.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.10.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.10.qml (renamed from tests/auto/declarative/qmllanguage/data/script.10.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.11.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.11.qml (renamed from tests/auto/declarative/qmllanguage/data/script.11.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.12.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.12.qml (renamed from tests/auto/declarative/qmllanguage/data/script.12.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.2.qml (renamed from tests/auto/declarative/qmllanguage/data/script.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.3.qml (renamed from tests/auto/declarative/qmllanguage/data/script.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.4.qml (renamed from tests/auto/declarative/qmllanguage/data/script.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.5.qml (renamed from tests/auto/declarative/qmllanguage/data/script.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.6.qml (renamed from tests/auto/declarative/qmllanguage/data/script.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.7.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.7.qml (renamed from tests/auto/declarative/qmllanguage/data/script.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.8.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.8.qml (renamed from tests/auto/declarative/qmllanguage/data/script.8.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.9.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.9.qml (renamed from tests/auto/declarative/qmllanguage/data/script.9.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml (renamed from tests/auto/declarative/qmllanguage/data/scriptString.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/signal.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml (renamed from tests/auto/declarative/qmllanguage/data/signal.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/signal.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml (renamed from tests/auto/declarative/qmllanguage/data/signal.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/signal.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml (renamed from tests/auto/declarative/qmllanguage/data/signal.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml (renamed from tests/auto/declarative/qmllanguage/data/simpleBindings.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml (renamed from tests/auto/declarative/qmllanguage/data/simpleContainer.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml (renamed from tests/auto/declarative/qmllanguage/data/simpleObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/Test.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml (renamed from tests/auto/declarative/qmllanguage/data/subdir/subsubdir/SubTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/test.js (renamed from tests/auto/declarative/qmllanguage/data/test.js)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/test2.js (renamed from tests/auto/declarative/qmllanguage/data/test2.js)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/unregisteredObject.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml (renamed from tests/auto/declarative/qmllanguage/data/unregisteredObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/unsupportedProperty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/unsupportedProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml (renamed from tests/auto/declarative/qmllanguage/data/valueTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.10.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.10.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.11.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.11.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.12.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.12.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.13.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.13.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.14.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.14.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.15.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.15.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.7.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.8.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.8.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.9.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.9.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro14
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/LocalInternal.qml (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/LocalInternal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/Test.qml (renamed from tests/auto/declarative/qmllanguage/data/subdir/Test.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestLocal.qml (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestLocal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestSubDir.qml (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestSubDir.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/pics/blue.png (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/pics/blue.png)bin84 -> 84 bytes-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/qmldir)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/qmldir (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/qmldir)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.cpp (renamed from tests/auto/declarative/qmllanguage/testtypes.cpp)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h547
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1386
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro6
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp346
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/data/MyType.qml (renamed from tests/auto/declarative/qmllistreference/data/MyType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml (renamed from tests/auto/declarative/qmllistreference/data/engineTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml (renamed from tests/auto/declarative/qmllistreference/data/variantToList.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro5
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp579
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/itemlist.qml (renamed from tests/auto/declarative/qmlgraphicslistview/data/itemlist.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview-enforcerange.qml (renamed from tests/auto/declarative/qmlgraphicslistview/data/listview-enforcerange.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml (renamed from tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml (renamed from tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview.qml (renamed from tests/auto/declarative/qmlgraphicslistview/data/listview.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro8
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp1370
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/GraphicsWidget250x250.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/NoResize.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/NoResize.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/Rect120x60.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/Rect120x60.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/SetSourceComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/SizeToItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/SizeToLoader.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro11
-rw-r--r--tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp464
-rw-r--r--tests/auto/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro5
-rw-r--r--tests/auto/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp1185
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro6
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp377
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin.qml (renamed from tests/auto/declarative/qmlmoduleplugin/plugin.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp89
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro5
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp117
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro4
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/data/dragproperties.qml (renamed from tests/auto/declarative/qmlgraphicsmousearea/data/dragproperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro9
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp138
-rw-r--r--tests/auto/declarative/qdeclarativenumberformatter/qdeclarativenumberformatter.pro5
-rw-r--r--tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp222
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/data/particle.png (renamed from tests/auto/declarative/qmlgraphicsparticles/data/particle.png)bin262 -> 262 bytes-rw-r--r--tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml (renamed from tests/auto/declarative/qmlgraphicsparticles/data/particlemotion.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/data/particles.qml (renamed from tests/auto/declarative/qmlgraphicsparticles/data/particles.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp209
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/datamodel.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/path.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/path.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/pathview.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview1.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/pathview1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview2.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/pathview2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview3.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/pathview3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro8
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp488
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/exists.png (renamed from tests/auto/declarative/qmlimageprovider/data/exists.png)bin2738 -> 2738 bytes-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/exists1.png (renamed from tests/auto/declarative/qmlimageprovider/data/exists1.png)bin2738 -> 2738 bytes-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/exists2.png (renamed from tests/auto/declarative/qmlimageprovider/data/exists2.png)bin2738 -> 2738 bytes-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro9
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp282
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/grid-spacing.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/grid.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/grid.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/horizontal-spacing.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/horizontal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/propertychanges.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/repeater.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/repeater.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/vertical-spacing.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/vertical.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/vertical.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro7
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp455
-rw-r--r--tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro5
-rw-r--r--tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp171
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/closestangle.qml (renamed from tests/auto/declarative/qmlqt/data/closestangle.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml (renamed from tests/auto/declarative/qmlqt/data/consoleLog.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/createComponent.qml (renamed from tests/auto/declarative/qmlqt/data/createComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml (renamed from tests/auto/declarative/qmlqt/data/createComponentData.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml (renamed from tests/auto/declarative/qmlqt/data/createQmlObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/darker.qml (renamed from tests/auto/declarative/qmlqt/data/darker.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/enums.qml (renamed from tests/auto/declarative/qmlqt/data/enums.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/hsla.qml (renamed from tests/auto/declarative/qmlqt/data/hsla.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/lighter.qml (renamed from tests/auto/declarative/qmlqt/data/lighter.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/md5.qml (renamed from tests/auto/declarative/qmlqt/data/md5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/point.qml (renamed from tests/auto/declarative/qmlqt/data/point.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/rect.qml (renamed from tests/auto/declarative/qmlqt/data/rect.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/rgba.qml (renamed from tests/auto/declarative/qmlqt/data/rgba.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/size.qml (renamed from tests/auto/declarative/qmlqt/data/size.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/tint.qml (renamed from tests/auto/declarative/qmlqt/data/tint.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/vector.qml (renamed from tests/auto/declarative/qmlqt/data/vector.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp369
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/intmodel.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/objlist.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/objlist.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/properties.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/repeater.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/repeater.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/repeater2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro8
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp385
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml (renamed from tests/auto/declarative/qmlspringfollow/data/springfollow1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml (renamed from tests/auto/declarative/qmlspringfollow/data/springfollow2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml (renamed from tests/auto/declarative/qmlspringfollow/data/springfollow3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro8
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp137
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/ExtendedRectangle.qml (renamed from tests/auto/declarative/qmlstates/data/ExtendedRectangle.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges.qml (renamed from tests/auto/declarative/qmlstates/data/anchorChanges.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml (renamed from tests/auto/declarative/qmlstates/data/anchorChanges2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml (renamed from tests/auto/declarative/qmlstates/data/anchorChanges3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml (renamed from tests/auto/declarative/qmlstates/data/anchorChanges4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml (renamed from tests/auto/declarative/qmlstates/data/anchorChanges5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml (renamed from tests/auto/declarative/qmlstates/data/autoStateAtStartupRestoreBug.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicBinding.qml (renamed from tests/auto/declarative/qmlstates/data/basicBinding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicBinding2.qml (renamed from tests/auto/declarative/qmlstates/data/basicBinding2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicBinding3.qml (renamed from tests/auto/declarative/qmlstates/data/basicBinding3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicBinding4.qml (renamed from tests/auto/declarative/qmlstates/data/basicBinding4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicChanges.qml (renamed from tests/auto/declarative/qmlstates/data/basicChanges.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicChanges2.qml (renamed from tests/auto/declarative/qmlstates/data/basicChanges2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicChanges3.qml (renamed from tests/auto/declarative/qmlstates/data/basicChanges3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicExtension.qml (renamed from tests/auto/declarative/qmlstates/data/basicExtension.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/deleting.qml (renamed from tests/auto/declarative/qmlstates/data/deleting.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/deletingState.qml (renamed from tests/auto/declarative/qmlstates/data/deletingState.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/explicit.qml (renamed from tests/auto/declarative/qmlstates/data/explicit.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/fakeExtension.qml (renamed from tests/auto/declarative/qmlstates/data/fakeExtension.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/illegalTempState.qml (renamed from tests/auto/declarative/qmlstates/data/illegalTempState.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/legalTempState.qml (renamed from tests/auto/declarative/qmlstates/data/legalTempState.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/nonExistantProp.qml (renamed from tests/auto/declarative/qmlstates/data/nonExistantProp.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange.qml (renamed from tests/auto/declarative/qmlstates/data/parentChange.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange2.qml (renamed from tests/auto/declarative/qmlstates/data/parentChange2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange3.qml (renamed from tests/auto/declarative/qmlstates/data/parentChange3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange4.qml (renamed from tests/auto/declarative/qmlstates/data/parentChange4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange5.qml (renamed from tests/auto/declarative/qmlstates/data/parentChange5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml (renamed from tests/auto/declarative/qmlstates/data/propertyErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/restoreEntryValues.qml (renamed from tests/auto/declarative/qmlstates/data/restoreEntryValues.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/script.qml (renamed from tests/auto/declarative/qmlstates/data/script.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/signalOverride.qml (renamed from tests/auto/declarative/qmlstates/data/signalOverride.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/signalOverride2.qml (renamed from tests/auto/declarative/qmlstates/data/signalOverride2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash.qml (renamed from tests/auto/declarative/qmlstates/data/signalOverrideCrash.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro8
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp917
-rw-r--r--tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro9
-rw-r--r--tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp96
-rw-r--r--tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro5
-rw-r--r--tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp187
-rw-r--r--tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro5
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp844
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/cursorTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/ErrItem.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/ErrItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/NormItem.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/NormItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTest.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestPass.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/httpfail/FailItem.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/httpfail/FailItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/httpslow/WaitItem.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/httpslow/WaitItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/inputmethodhints.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/inputmethodhints.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/navigation.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/navigation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/readOnly.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro9
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp791
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/cursorTest.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/cursorTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/inputmethodhints.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/masks.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/masks.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/maxLength.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/maxLength.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/navigation.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/readOnly.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/validators.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/validators.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro8
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp656
-rw-r--r--tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro7
-rw-r--r--tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp285
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/bindingAssignment.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/bindingConflict.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/bindingRead.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/bindingVariantCopy.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js (renamed from tests/auto/declarative/qmlvaluetypes/data/deletedObject.js)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/deletedObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/enums.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/enums.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/font_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/font_write.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/font_write.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/font_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/point_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/point_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/pointf_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/pointf_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/rect_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/rect_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/rectf_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/rectf_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/scriptAccess.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/scriptVariantCopy.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/size_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/size_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/sizef_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/sizef_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/staticAssignment.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/valueInterceptors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/valueSources.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/vector3d_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/vector3d_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro10
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp (renamed from tests/auto/declarative/qmlvaluetypes/testtypes.cpp)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.h154
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp616
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/basic.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.ico (renamed from tests/auto/declarative/qmlgraphicswebview/data/basic.ico)bin318 -> 318 bytes-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.png (renamed from tests/auto/declarative/qmlgraphicswebview/data/basic.png)bin3961 -> 3961 bytes-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/basic.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/elements.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/elements.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/elements.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/elements.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/forward.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/forward.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/javaScript.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/javaScript.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/javaScript.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/javaScript.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/loadError.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/loadError.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/newwindows.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/newwindows.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/newwindows.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/pixelCache.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/pixelCache.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/pixelCache.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/pixelCache.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/propertychanges.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/sethtml.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/sethtml.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro10
-rw-r--r--tests/auto/declarative/qdeclarativewebview/testtypes.cpp52
-rw-r--r--tests/auto/declarative/qdeclarativewebview/testtypes.h66
-rw-r--r--tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp511
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/abort.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/abort.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/abort.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/attr.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/attr.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/document.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/document.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/element.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/element.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html (renamed from tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html (renamed from tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_PUT.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/status.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/status.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html (renamed from tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/text.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/text.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro13
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp1315
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/model.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/model.xml (renamed from tests/auto/declarative/qmlxmllistmodel/data/model.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/model2.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/model2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/recipes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.xml (renamed from tests/auto/declarative/qmlxmllistmodel/data/recipes.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/roleErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/roleKeys.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/unique.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro11
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp457
-rw-r--r--tests/auto/declarative/qmlanimations/qmlanimations.pro6
-rw-r--r--tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp672
-rw-r--r--tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro6
-rw-r--r--tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp301
-rw-r--r--tests/auto/declarative/qmlbinding/qmlbinding.pro8
-rw-r--r--tests/auto/declarative/qmlbinding/tst_qmlbinding.cpp107
-rw-r--r--tests/auto/declarative/qmlconnection/qmlconnection.pro8
-rw-r--r--tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp139
-rw-r--r--tests/auto/declarative/qmlcontext/qmlcontext.pro6
-rw-r--r--tests/auto/declarative/qmlcontext/tst_qmlcontext.cpp434
-rw-r--r--tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro5
-rw-r--r--tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp150
-rw-r--r--tests/auto/declarative/qmldebug/qmldebug.pro7
-rw-r--r--tests/auto/declarative/qmldebug/tst_qmldebug.cpp841
-rw-r--r--tests/auto/declarative/qmldebugclient/qmldebugclient.pro7
-rw-r--r--tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp157
-rw-r--r--tests/auto/declarative/qmldebugservice/qmldebugservice.pro7
-rw-r--r--tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp190
-rw-r--r--tests/auto/declarative/qmldom/qmldom.pro7
-rw-r--r--tests/auto/declarative/qmldom/tst_qmldom.cpp1313
-rw-r--r--tests/auto/declarative/qmleasefollow/qmleasefollow.pro8
-rw-r--r--tests/auto/declarative/qmleasefollow/tst_qmleasefollow.cpp122
-rw-r--r--tests/auto/declarative/qmlecmascript/qmlecmascript.pro10
-rw-r--r--tests/auto/declarative/qmlecmascript/testtypes.h598
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp1662
-rw-r--r--tests/auto/declarative/qmlengine/qmlengine.pro8
-rw-r--r--tests/auto/declarative/qmlengine/tst_qmlengine.cpp240
-rw-r--r--tests/auto/declarative/qmlerror/qmlerror.pro6
-rw-r--r--tests/auto/declarative/qmlerror/tst_qmlerror.cpp242
-rw-r--r--tests/auto/declarative/qmlfontloader/qmlfontloader.pro8
-rw-r--r--tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp156
-rw-r--r--tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro6
-rw-r--r--tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp448
-rw-r--r--tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro7
-rw-r--r--tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp191
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro9
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp351
-rw-r--r--tests/auto/declarative/qmlgraphicsflickable/qmlgraphicsflickable.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp224
-rw-r--r--tests/auto/declarative/qmlgraphicsflipable/qmlgraphicsflipable.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsflipable/tst_qmlgraphicsflipable.cpp113
-rw-r--r--tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp964
-rw-r--r--tests/auto/declarative/qmlgraphicsimage/qmlgraphicsimage.pro9
-rw-r--r--tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp247
-rw-r--r--tests/auto/declarative/qmlgraphicsitem/qmlgraphicsitem.pro7
-rw-r--r--tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp318
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/qmlgraphicslistview.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp1370
-rw-r--r--tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro11
-rw-r--r--tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp464
-rw-r--r--tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro9
-rw-r--r--tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp138
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp209
-rw-r--r--tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp488
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/qmlgraphicspositioners.pro7
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp455
-rw-r--r--tests/auto/declarative/qmlgraphicsrepeater/qmlgraphicsrepeater.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp385
-rw-r--r--tests/auto/declarative/qmlgraphicstext/qmlgraphicstext.pro5
-rw-r--r--tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp844
-rw-r--r--tests/auto/declarative/qmlgraphicstextedit/qmlgraphicstextedit.pro9
-rw-r--r--tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp791
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/qmlgraphicstextinput.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp656
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/qmlgraphicswebview.pro10
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/testtypes.cpp52
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/testtypes.h66
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp511
-rw-r--r--tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro12
-rw-r--r--tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp166
-rw-r--r--tests/auto/declarative/qmlinfo/qmlinfo.pro7
-rw-r--r--tests/auto/declarative/qmlinfo/tst_qmlinfo.cpp139
-rw-r--r--tests/auto/declarative/qmlinstruction/qmlinstruction.pro6
-rw-r--r--tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp585
-rw-r--r--tests/auto/declarative/qmllanguage/qmllanguage.pro14
-rw-r--r--tests/auto/declarative/qmllanguage/testtypes.h547
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp1385
-rw-r--r--tests/auto/declarative/qmllistmodel/qmllistmodel.pro6
-rw-r--r--tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp346
-rw-r--r--tests/auto/declarative/qmllistreference/qmllistreference.pro5
-rw-r--r--tests/auto/declarative/qmllistreference/tst_qmllistreference.cpp579
-rw-r--r--tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro5
-rw-r--r--tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp1184
-rw-r--r--tests/auto/declarative/qmlmetatype/qmlmetatype.pro6
-rw-r--r--tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp377
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp89
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/plugin/plugin.pro5
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/qmlmoduleplugin.pro7
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.cpp117
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.pro4
-rw-r--r--tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro5
-rw-r--r--tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp222
-rw-r--r--tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro9
-rw-r--r--tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp282
-rw-r--r--tests/auto/declarative/qmlpropertymap/qmlpropertymap.pro5
-rw-r--r--tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp171
-rw-r--r--tests/auto/declarative/qmlqt/qmlqt.pro9
-rw-r--r--tests/auto/declarative/qmlqt/tst_qmlqt.cpp369
-rw-r--r--tests/auto/declarative/qmlspringfollow/qmlspringfollow.pro8
-rw-r--r--tests/auto/declarative/qmlspringfollow/tst_qmlspringfollow.cpp137
-rw-r--r--tests/auto/declarative/qmlstates/qmlstates.pro8
-rw-r--r--tests/auto/declarative/qmlstates/tst_qmlstates.cpp917
-rw-r--r--tests/auto/declarative/qmlstyledtext/qmlstyledtext.pro9
-rw-r--r--tests/auto/declarative/qmlstyledtext/tst_qmlstyledtext.cpp96
-rw-r--r--tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro5
-rw-r--r--tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp187
-rw-r--r--tests/auto/declarative/qmltimer/qmltimer.pro7
-rw-r--r--tests/auto/declarative/qmltimer/tst_qmltimer.cpp285
-rw-r--r--tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro10
-rw-r--r--tests/auto/declarative/qmlvaluetypes/testtypes.h154
-rw-r--r--tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp616
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro13
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp1315
-rw-r--r--tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro11
-rw-r--r--tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp457
-rw-r--r--tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp12
-rw-r--r--tests/auto/declarative/shared/debugutil.cpp46
-rw-r--r--tests/auto/declarative/shared/debugutil_p.h50
-rw-r--r--tests/auto/declarative/sql/tst_sql.cpp18
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/animated-smooth.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/animated-smooth.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/animated.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/animated.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/borders.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/borders.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/content/bw.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/content/bw.png)bin1357 -> 1357 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-round.sci (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-round.sci)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-stretch.sci (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-stretch.sci)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/content/colors.png (renamed from tests/auto/declarative/qmlgraphicsborderimage/data/colors.png)bin1655 -> 1655 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.0.png)bin61731 -> 61731 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.1.png)bin98912 -> 98912 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.2.png)bin48780 -> 48780 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.3.png)bin32431 -> 32431 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.4.png)bin35835 -> 35835 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.5.png)bin79428 -> 79428 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.6.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.6.png)bin45928 -> 45928 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.0.png)bin23684 -> 23684 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.1.png)bin29115 -> 29115 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.2.png)bin27580 -> 27580 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.3.png)bin14822 -> 14822 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.4.png)bin21356 -> 21356 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.5.png)bin31143 -> 31143 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.6.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.6.png)bin26468 -> 26468 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.7.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.7.png)bin16225 -> 16225 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.0.png)bin23029 -> 23029 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.1.png)bin23029 -> 23029 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.2.png)bin23029 -> 23029 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.3.png)bin23029 -> 23029 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.4.png)bin23029 -> 23029 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.0.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.0.png)bin1305 -> 1305 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.1.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.1.png)bin1306 -> 1306 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.2.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.2.png)bin1305 -> 1305 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.3.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.3.png)bin1303 -> 1303 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.4.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.4.png)bin1303 -> 1303 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.5.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.5.png)bin1305 -> 1305 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.6.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.6.png)bin1306 -> 1306 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.qml (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/easefollow.qml (renamed from tests/auto/declarative/visual/qmleasefollow/easefollow.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.0.png)bin1427 -> 1427 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.1.png)bin1357 -> 1357 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.2.png)bin1405 -> 1405 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.3.png)bin1427 -> 1427 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.qml (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.0.png)bin1951 -> 1951 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.1.png)bin1951 -> 1951 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.10.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.10.png)bin1952 -> 1952 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.11.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.11.png)bin1930 -> 1930 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.12.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.12.png)bin1974 -> 1974 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.13.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.13.png)bin1961 -> 1961 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.14.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.14.png)bin1959 -> 1959 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.15.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.15.png)bin1937 -> 1937 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.16.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.16.png)bin1618 -> 1618 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.17.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.17.png)bin1952 -> 1952 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.18.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.18.png)bin1952 -> 1952 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.19.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.19.png)bin1930 -> 1930 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.2.png)bin1976 -> 1976 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.20.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.20.png)bin1930 -> 1930 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.21.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.21.png)bin1947 -> 1947 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.22.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.22.png)bin1941 -> 1941 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.23.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.23.png)bin1951 -> 1951 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.24.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.24.png)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.3.png)bin1987 -> 1987 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.4.png)bin1947 -> 1947 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.5.png)bin1975 -> 1975 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.6.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.6.png)bin1928 -> 1928 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.7.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.7.png)bin1928 -> 1928 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.8.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.8.png)bin1928 -> 1928 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.9.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.9.png)bin1928 -> 1928 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.qml (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/flickable-horizontal.qml (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/flickable-horizontal.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/flickable-vertical.qml (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.0.png)bin1090 -> 1090 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.1.png)bin1134 -> 1134 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.2.png)bin961 -> 961 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.3.png)bin1076 -> 1076 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.4.png)bin1134 -> 1134 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.5.png)bin969 -> 969 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.qml (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/test-flipable.qml (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.0.png)bin1303 -> 1303 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.1.png)bin1317 -> 1317 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.2.png)bin1318 -> 1318 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.3.png)bin1306 -> 1306 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.4.png)bin1308 -> 1308 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.5.png)bin1303 -> 1303 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.6.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.6.png)bin1323 -> 1323 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.7.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.7.png)bin1325 -> 1325 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.8.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.8.png)bin1346 -> 1346 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.9.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.9.png)bin1303 -> 1303 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.qml (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.0.png)bin1310 -> 1310 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.1.png)bin1322 -> 1322 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.10.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.10.png)bin1313 -> 1313 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.2.png)bin1341 -> 1341 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.3.png)bin1368 -> 1368 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.4.png)bin1319 -> 1319 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.5.png)bin1352 -> 1352 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.6.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.6.png)bin1309 -> 1309 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.7.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.7.png)bin1347 -> 1347 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.8.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.8.png)bin1310 -> 1310 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.9.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.9.png)bin1354 -> 1354 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.qml (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/gridview.qml (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/gridview.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/gridview2.qml (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/gridview2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.0.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.0.png)bin1563 -> 1563 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.1.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.1.png)bin1570 -> 1570 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.2.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.2.png)bin1553 -> 1553 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.3.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.3.png)bin1563 -> 1563 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.4.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.4.png)bin1569 -> 1569 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.5.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.5.png)bin1569 -> 1569 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.6.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.6.png)bin1566 -> 1566 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.7.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.7.png)bin1566 -> 1566 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.8.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.8.png)bin1567 -> 1567 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.qml (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.0.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.0.png)bin471 -> 471 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.1.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.1.png)bin474 -> 474 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.10.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.10.png)bin479 -> 479 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.11.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.11.png)bin479 -> 479 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.12.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.12.png)bin479 -> 479 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.13.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.13.png)bin479 -> 479 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.14.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.14.png)bin479 -> 479 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.15.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.15.png)bin479 -> 479 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.16.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.16.png)bin1454 -> 1454 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.17.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.17.png)bin1454 -> 1454 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.18.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.18.png)bin1454 -> 1454 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.19.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.19.png)bin1454 -> 1454 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.2.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.2.png)bin474 -> 474 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.20.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.20.png)bin1454 -> 1454 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.21.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.21.png)bin1454 -> 1454 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.22.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.22.png)bin1454 -> 1454 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.3.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.3.png)bin474 -> 474 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.4.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.4.png)bin481 -> 481 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.5.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.5.png)bin481 -> 481 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.6.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.6.png)bin481 -> 481 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.7.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.7.png)bin481 -> 481 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.8.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.8.png)bin479 -> 479 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.9.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.9.png)bin479 -> 479 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.qml (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/drag.qml (renamed from tests/auto/declarative/visual/qmlmouseregion/drag.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/mouseregion.qml (renamed from tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/data/particles.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.0.png)bin10219 -> 10219 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/data/particles.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.1.png)bin13469 -> 13469 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/data/particles.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.2.png)bin14051 -> 14051 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/data/particles.qml (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/particles.qml (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/star.png (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/star.png)bin262 -> 262 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.0.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.0.png)bin2263 -> 2263 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.1.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.1.png)bin2329 -> 2329 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.2.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.2.png)bin2279 -> 2279 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.3.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.3.png)bin2263 -> 2263 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.4.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.4.png)bin2263 -> 2263 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.5.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.5.png)bin2308 -> 2308 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.6.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.6.png)bin2280 -> 2280 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.qml (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.0.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.0.png)bin2321 -> 2321 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.1.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.1.png)bin2380 -> 2380 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.2.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.2.png)bin2315 -> 2315 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.3.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.3.png)bin2372 -> 2372 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.4.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.4.png)bin2327 -> 2327 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.qml (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/test-pathview-2.qml (renamed from tests/auto/declarative/visual/qmlgraphicspathview/test-pathview-2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/test-pathview.qml (renamed from tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.0.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.0.png)bin1429 -> 1429 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.1.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.1.png)bin1433 -> 1433 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.2.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.2.png)bin1431 -> 1431 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.3.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.3.png)bin1428 -> 1428 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.4.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.4.png)bin1432 -> 1432 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.5.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.5.png)bin1434 -> 1434 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.qml (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.0.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.0.png)bin2790 -> 2790 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.qml (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/dynamic.qml (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/repeater.qml (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/repeater.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/clock.qml (renamed from tests/auto/declarative/visual/qmlspringfollow/clock.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/content/background.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/background.png)bin46895 -> 46895 bytes-rwxr-xr-xtests/auto/declarative/visual/qdeclarativespringfollow/content/center.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/center.png)bin765 -> 765 bytes-rwxr-xr-xtests/auto/declarative/visual/qdeclarativespringfollow/content/clock.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/clock.png)bin20653 -> 20653 bytes-rwxr-xr-xtests/auto/declarative/visual/qdeclarativespringfollow/content/hour.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/hour.png)bin625 -> 625 bytes-rwxr-xr-xtests/auto/declarative/visual/qdeclarativespringfollow/content/minute.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/minute.png)bin625 -> 625 bytes-rwxr-xr-xtests/auto/declarative/visual/qdeclarativespringfollow/content/second.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/second.png)bin303 -> 303 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.0.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/clock.0.png)bin17294 -> 17294 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.1.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/clock.1.png)bin17394 -> 17394 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.2.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/clock.2.png)bin17524 -> 17524 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.3.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/clock.3.png)bin17572 -> 17572 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.qml (renamed from tests/auto/declarative/visual/qmlspringfollow/data/clock.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.0.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.0.png)bin959 -> 959 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.1.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.1.png)bin1244 -> 1244 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.10.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.10.png)bin1299 -> 1299 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.2.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.2.png)bin1224 -> 1224 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.3.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.3.png)bin1243 -> 1243 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.4.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.4.png)bin1230 -> 1230 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.5.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.5.png)bin1231 -> 1231 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.6.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.6.png)bin1239 -> 1239 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.7.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.7.png)bin1241 -> 1241 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.8.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.8.png)bin1237 -> 1237 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.9.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.9.png)bin1229 -> 1229 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.qml (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml (renamed from tests/auto/declarative/visual/qmlspringfollow/follow.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/baseline/data-X11/parentanchor.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/baseline/data/parentanchor.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/baseline/data/parentanchor.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/baseline/parentanchor.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/baseline/parentanchor.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.0.png)bin2276 -> 2276 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.0.png)bin4818 -> 4818 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.1.png)bin4089 -> 4089 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.2.png)bin3128 -> 3128 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.3.png)bin1963 -> 1963 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.0.png)bin736 -> 736 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.0.png)bin1002 -> 1002 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.0.png)bin596 -> 596 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.0.png)bin1604 -> 1604 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.0.png)bin4818 -> 4818 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.1.png)bin4089 -> 4089 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.2.png)bin3128 -> 3128 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.3.png)bin1963 -> 1963 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/elide.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/elide.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/elide2.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/elide2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/multilength.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/multilength.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.0.png)bin103018 -> 103018 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.0.png)bin136492 -> 136492 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.0.png)bin94120 -> 94120 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.0.png)bin121122 -> 121122 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/plaintext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/plaintext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/richtext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/richtext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/cursorDelegate.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.0.png)bin793 -> 793 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.1.png)bin795 -> 795 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.2.png)bin803 -> 803 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.3.png)bin805 -> 805 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.4.png)bin805 -> 805 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.5.png)bin805 -> 805 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.6.png)bin799 -> 799 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.7.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.7.png)bin799 -> 799 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.8.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.8.png)bin803 -> 803 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.0.png)bin365 -> 365 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.1.png)bin365 -> 365 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.2.png)bin366 -> 366 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.3.png)bin362 -> 362 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.0.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.1.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.2.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.3.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.4.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.5.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.6.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.0.png)bin3322 -> 3322 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.1.png)bin3323 -> 3323 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.2.png)bin3325 -> 3325 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.3.png)bin3332 -> 3332 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.4.png)bin3329 -> 3329 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.5.png)bin3818 -> 3818 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.6.png)bin3333 -> 3333 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.7.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.7.png)bin3332 -> 3332 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.8.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.8.png)bin3347 -> 3347 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.0.png)bin4802 -> 4802 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.1.png)bin4804 -> 4804 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.2.png)bin4801 -> 4801 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.3.png)bin4791 -> 4791 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.0.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.1.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.2.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.3.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.4.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.5.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.6.png)bin1110 -> 1110 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/qt-669.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/qt-669.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/wrap.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/wrap.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.0.png)bin793 -> 793 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.1.png)bin796 -> 796 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.2.png)bin804 -> 804 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.3.png)bin805 -> 805 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.4.png)bin805 -> 805 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.5.png)bin805 -> 805 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.6.png)bin801 -> 801 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.7.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.7.png)bin802 -> 802 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.8.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.8.png)bin802 -> 802 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.0.png)bin999 -> 999 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.1.png)bin1880 -> 1880 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.2.png)bin2962 -> 2962 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.3.png)bin2827 -> 2827 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.4.png)bin2827 -> 2827 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.0.png)bin1245 -> 1245 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.0.png)bin3314 -> 3314 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.1.png)bin3377 -> 3377 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.2.png)bin3323 -> 3323 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.3.png)bin3325 -> 3325 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.4.png)bin3322 -> 3322 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.5.png)bin3322 -> 3322 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.6.png)bin3326 -> 3326 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.7.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.7.png)bin3814 -> 3814 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.8.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.8.png)bin3324 -> 3324 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.0.png)bin999 -> 999 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.1.png)bin1880 -> 1880 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.2.png)bin2962 -> 2962 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.3.png)bin2827 -> 2827 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.4.png)bin2827 -> 2827 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.0.png)bin1245 -> 1245 bytes-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/echoMode.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/echoMode.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/hAlign.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/hAlign.qml)0
-rw-r--r--tests/auto/declarative/visual/tst_visual.cpp20
-rw-r--r--tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro6
-rw-r--r--tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp1200
-rw-r--r--tests/auto/qdeclarativevideo/qdeclarativevideo.pro6
-rw-r--r--tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp911
-rw-r--r--tests/auto/qmlaudio/qmlaudio.pro6
-rw-r--r--tests/auto/qmlaudio/tst_qmlaudio.cpp1200
-rw-r--r--tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro6
-rw-r--r--tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp911
-rw-r--r--tests/benchmarks/declarative/binding/testtypes.h8
-rw-r--r--tests/benchmarks/declarative/binding/tst_binding.cpp8
-rw-r--r--tests/benchmarks/declarative/creation/tst_creation.cpp56
-rw-r--r--tests/benchmarks/declarative/declarative.pro8
-rw-r--r--tests/benchmarks/declarative/pointers/tst_pointers.cpp4
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml (renamed from tests/benchmarks/declarative/qmlcomponent/data/myqmlobject.qml)0
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml (renamed from tests/benchmarks/declarative/qmlcomponent/data/myqmlobject_binding.qml)0
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml (renamed from tests/benchmarks/declarative/qmlcomponent/data/object.qml)0
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml (renamed from tests/benchmarks/declarative/qmlcomponent/data/object_id.qml)0
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml (renamed from tests/benchmarks/declarative/qmlcomponent/data/samegame/BoomBlock.qml)0
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStar.png (renamed from tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/blueStar.png)bin278 -> 278 bytes-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png (renamed from tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/blueStone.png)bin2691 -> 2691 bytes-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStar.png (renamed from tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/greenStar.png)bin273 -> 273 bytes-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png (renamed from tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/greenStone.png)bin2662 -> 2662 bytes-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStar.png (renamed from tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/redStar.png)bin274 -> 274 bytes-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png (renamed from tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/redStone.png)bin2604 -> 2604 bytes-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png (renamed from tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/yellowStone.png)bin2667 -> 2667 bytes-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml (renamed from tests/benchmarks/declarative/qmlcomponent/data/synthesized_properties.2.qml)0
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml (renamed from tests/benchmarks/declarative/qmlcomponent/data/synthesized_properties.qml)0
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro19
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp (renamed from tests/benchmarks/declarative/qmlcomponent/testtypes.cpp)0
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h83
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp119
-rw-r--r--tests/benchmarks/declarative/qdeclarativeimage/image.png (renamed from tests/benchmarks/declarative/qmlgraphicsimage/image.png)bin611 -> 611 bytes-rw-r--r--tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro16
-rw-r--r--tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp108
-rw-r--r--tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml (renamed from tests/benchmarks/declarative/qmlmetaproperty/data/object.qml)0
-rw-r--r--tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml (renamed from tests/benchmarks/declarative/qmlmetaproperty/data/synthesized_object.qml)0
-rw-r--r--tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro8
-rw-r--r--tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp113
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/example.qml14
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp231
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro23
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml34
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml41
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml27
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml34
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml34
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml12
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml34
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml37
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml34
-rw-r--r--tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml37
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro19
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/testtypes.h83
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp119
-rw-r--r--tests/benchmarks/declarative/qmlgraphicsimage/qmlgraphicsimage.pro16
-rw-r--r--tests/benchmarks/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp108
-rw-r--r--tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro8
-rw-r--r--tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp113
-rw-r--r--tests/benchmarks/declarative/qmltime/example.qml14
-rw-r--r--tests/benchmarks/declarative/qmltime/qmltime.cpp231
-rw-r--r--tests/benchmarks/declarative/qmltime/qmltime.pro23
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml34
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml41
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/anchors/null.qml27
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml34
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml34
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml12
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml34
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml37
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml34
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml37
-rw-r--r--tests/benchmarks/declarative/script/tst_script.cpp66
-rw-r--r--tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp6
-rw-r--r--tools/configure/configureapp.cpp2
-rw-r--r--tools/linguist/lupdate/lupdate.pro2
-rw-r--r--tools/linguist/lupdate/qdeclarative.cpp240
-rw-r--r--tools/linguist/lupdate/qml.cpp240
-rw-r--r--tools/qdoc3/atom.cpp4
-rw-r--r--tools/qdoc3/atom.h2
-rw-r--r--tools/qdoc3/codemarker.cpp12
-rw-r--r--tools/qdoc3/codemarker.h2
-rw-r--r--tools/qdoc3/cppcodemarker.cpp34
-rw-r--r--tools/qdoc3/cppcodemarker.h2
-rw-r--r--tools/qdoc3/cppcodeparser.cpp40
-rw-r--r--tools/qdoc3/doc.cpp4
-rw-r--r--tools/qdoc3/generator.cpp4
-rw-r--r--tools/qdoc3/generator.h2
-rw-r--r--tools/qdoc3/helpprojectwriter.cpp6
-rw-r--r--tools/qdoc3/htmlgenerator.cpp80
-rw-r--r--tools/qdoc3/htmlgenerator.h14
-rw-r--r--tools/qdoc3/node.cpp42
-rw-r--r--tools/qdoc3/node.h38
-rw-r--r--tools/qdoc3/pagegenerator.cpp8
-rw-r--r--tools/qdoc3/tree.cpp4
-rw-r--r--tools/qml/content/Browser.qml (renamed from tools/qmlviewer/content/Browser.qml)0
-rw-r--r--tools/qml/content/images/folder.png (renamed from tools/qmlviewer/content/images/folder.png)bin1841 -> 1841 bytes-rw-r--r--tools/qml/content/images/titlebar.png (renamed from tools/qmlviewer/content/images/titlebar.png)bin1436 -> 1436 bytes-rw-r--r--tools/qml/content/images/titlebar.sci (renamed from tools/qmlviewer/content/images/titlebar.sci)0
-rw-r--r--tools/qml/content/images/up.png (renamed from tools/qmlviewer/content/images/up.png)bin662 -> 662 bytes-rw-r--r--tools/qml/deviceorientation.cpp (renamed from tools/qmlviewer/deviceorientation.cpp)0
-rw-r--r--tools/qml/deviceorientation.h (renamed from tools/qmlviewer/deviceorientation.h)0
-rw-r--r--tools/qml/deviceorientation_maemo.cpp (renamed from tools/qmlviewer/deviceorientation_maemo.cpp)0
-rw-r--r--tools/qml/main.cpp356
-rw-r--r--tools/qml/proxysettings.cpp (renamed from tools/qmlviewer/proxysettings.cpp)0
-rw-r--r--tools/qml/proxysettings.h (renamed from tools/qmlviewer/proxysettings.h)0
-rw-r--r--tools/qml/proxysettings.ui (renamed from tools/qmlviewer/proxysettings.ui)0
-rw-r--r--tools/qml/qdeclarativefolderlistmodel.cpp420
-rw-r--r--tools/qml/qdeclarativefolderlistmodel.h125
-rw-r--r--tools/qml/qfxtester.cpp382
-rw-r--r--tools/qml/qfxtester.h284
-rw-r--r--tools/qml/qml.pro58
-rw-r--r--tools/qml/qmlruntime.cpp1468
-rw-r--r--tools/qml/qmlruntime.h195
-rw-r--r--tools/qml/qmlruntime.qrc (renamed from tools/qmlviewer/qmlviewer.qrc)0
-rw-r--r--tools/qml/recopts.ui (renamed from tools/qmlviewer/recopts.ui)0
-rw-r--r--tools/qmlviewer/main.cpp356
-rw-r--r--tools/qmlviewer/qfxtester.cpp382
-rw-r--r--tools/qmlviewer/qfxtester.h284
-rw-r--r--tools/qmlviewer/qmlfolderlistmodel.cpp420
-rw-r--r--tools/qmlviewer/qmlfolderlistmodel.h125
-rw-r--r--tools/qmlviewer/qmlviewer.cpp1468
-rw-r--r--tools/qmlviewer/qmlviewer.h195
-rw-r--r--tools/qmlviewer/qmlviewer.pro58
-rw-r--r--tools/tools.pro2
2108 files changed, 141004 insertions, 141001 deletions
diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp
index 0b2d818..0e99731 100644
--- a/demos/declarative/minehunt/main.cpp
+++ b/demos/declarative/minehunt/main.cpp
@@ -38,11 +38,11 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "qmlengine.h"
-#include "qmlcontext.h"
-#include "qml.h"
-#include <qmlgraphicsitem.h>
-#include <qmlview.h>
+#include "qdeclarativeengine.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarative.h"
+#include <qdeclarativeitem.h>
+#include <qdeclarativeview.h>
#include <QWidget>
#include <QApplication>
@@ -133,7 +133,7 @@ private:
int getHint(int row, int col);
void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();}
- QmlView *canvas;
+ QDeclarativeView *canvas;
QList<Tile *> _tiles;
int numCols;
@@ -162,11 +162,11 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags
vbox->setMargin(0);
setLayout(vbox);
- canvas = new QmlView(this);
+ canvas = new QDeclarativeView(this);
canvas->setFixedSize(width, height);
vbox->addWidget(canvas);
- QmlContext *ctxt = canvas->rootContext();
+ QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->addDefaultObject(this);
ctxt->setContextProperty("tiles", QVariant::fromValue<QList<Tile*>*>(&_tiles));//QTBUG-5675
diff --git a/doc/doc.pri b/doc/doc.pri
index 0fc4d72..aea5b08 100644
--- a/doc/doc.pri
+++ b/doc/doc.pri
@@ -21,7 +21,7 @@ $$unixstyle {
}
ADP_DOCS_QDOCCONF_FILE = qt-build-docs.qdocconf
QT_DOCUMENTATION = ($$QDOC qt-api-only.qdocconf assistant.qdocconf designer.qdocconf \
- linguist.qdocconf qmake.qdocconf qml.qdocconf) && \
+ linguist.qdocconf qmake.qdocconf qdeclarative.qdocconf) && \
(cd $$QT_BUILD_TREE && \
$$GENERATOR doc-build/html-qt/qt.qhp -o doc/qch/qt.qch && \
$$GENERATOR doc-build/html-assistant/assistant.qhp -o doc/qch/assistant.qch && \
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index 892535e..2b75211 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\page qmlanimation.html
+\page qdeclarativeanimation.html
\title QML Animation
Animation in QML is done by animating properties of objects. Properties of type
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index a260812..c60847e 100644
--- a/doc/src/declarative/basictypes.qdoc
+++ b/doc/src/declarative/basictypes.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
- \page qmlbasictypes.html
+ \page qdeclarativebasictypes.html
\title QML Basic Types
QML uses a set of property types, which are primitive within QML.
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index 1129f00..4b61bd9 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -88,10 +88,10 @@ completely new applications. QML is fully \l {Extending QML}{extensible from C+
\o \l {Network Transparency}
\o \l {Data Models}
\o \l {anchor-layout.html}{Anchor-based Layout}
-\o \l {qmlstates.html}{States}
-\o \l {qmlanimation.html}{Animation}
-\o \l {qmlmodules.html}{Modules}
-\o \l {qmlfocus.html}{Keyboard Focus}
+\o \l {qdeclarativestates.html}{States}
+\o \l {qdeclarativeanimation.html}{Animation}
+\o \l {qdeclarativemodules.html}{Modules}
+\o \l {qdeclarativefocus.html}{Keyboard Focus}
\o \l {Extending types from QML}
\o \l {Dynamic Object Creation}
\endlist
diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc
index 7a489c0..033c0d1 100644
--- a/doc/src/declarative/dynamicobjects.qdoc
+++ b/doc/src/declarative/dynamicobjects.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\page qmldynamicobjects.html
+\page qdeclarativedynamicobjects.html
\title Dynamic Object Management
QML has some support for dynamically loading and managing QML objects from
@@ -139,7 +139,7 @@ will not have an id in QML.
A restriction which you need to manage with dynamically created items,
is that the creation context must outlive the
-created item. The creation context is the QmlContext in which createComponent
+created item. The creation context is the QDeclarativeContext in which createComponent
was called, or the context in which the Component element, or the item used as the
second argument to createQmlObject, was specified. If the creation
context is destroyed before the dynamic item is, then bindings in the dynamic item will
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index b218b64..470a78c 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\page qmlelements.html
+\page qdeclarativeelements.html
\target elements
\title QML Elements
diff --git a/doc/src/declarative/example-slideswitch.qdoc b/doc/src/declarative/example-slideswitch.qdoc
index d1b1066..42351c5 100644
--- a/doc/src/declarative/example-slideswitch.qdoc
+++ b/doc/src/declarative/example-slideswitch.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\page qmlexampletoggleswitch.html
+\page qdeclarativeexampletoggleswitch.html
\title QML Example - Toggle Switch
This example shows how to create a reusable switch component in QML.
@@ -121,7 +121,7 @@ states (\e on and \e off).
This second function is called when the knob is released and we want to make sure that the knob does not end up between states
(neither \e on nor \e off). If it is the case call the \c toggle() function otherwise we do nothing.
-For more information on scripts see \l{qmljavascript.html}{JavaScript Blocks}.
+For more information on scripts see \l{qdeclarativejavascript.html}{JavaScript Blocks}.
\section2 Transition
\snippet examples/declarative/slideswitch/content/Switch.qml 7
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index 0478731..b7da508 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\page qmlexamples.html
+\page qdeclarativeexamples.html
\title QML Examples and Walkthroughs
\section1 Running Examples and Demos
@@ -77,7 +77,7 @@ These will be documented, and demonstrate how to achieve various things in QML.
\o Elastic Dial
\o \image dial-example.gif
\row
- \o \l{qmlexampletoggleswitch.html}{Toggle Switch}
+ \o \l{qdeclarativeexampletoggleswitch.html}{Toggle Switch}
\o \image switch-example.gif
\row
\o \l{QML Advanced Tutorial}{SameGame}
diff --git a/doc/src/declarative/extending-examples.qdoc b/doc/src/declarative/extending-examples.qdoc
index b912a1d..cc66838 100644
--- a/doc/src/declarative/extending-examples.qdoc
+++ b/doc/src/declarative/extending-examples.qdoc
@@ -108,11 +108,11 @@ The class contains a member to store the celebrant object, and also a
QList<Person *> member.
In QML, the type of a list properties - and the guests property is a list of
-people - are all of type QmlListProperty<T>. QmlListProperty is simple value
+people - are all of type QDeclarativeListProperty<T>. QDeclarativeListProperty is simple value
type that contains a set of function pointers. QML calls these function
pointers whenever it needs to read from, write to or otherwise interact with
the list. In addition to concrete lists like the people list used in this
-example, the use of QmlListProperty allows for "virtual lists" and other advanced
+example, the use of QDeclarativeListProperty allows for "virtual lists" and other advanced
scenarios.
\section2 Define the BirthdayParty
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index e7ed310..d823bf6 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -72,12 +72,12 @@ Custom C++ types are made available to QML using these two macros:
\quotation
\code
#define QML_DECLARE_TYPE(T)
-#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,QmlName,T)
+#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,QDeclarativeName,T)
\endcode
Register the C++ type \a T with the QML system, and make it available in QML
-under the name \a QmlName in library URI version VMAJ.VMIN.
-\a T and \a QmlName may be the same.
+under the name \a QDeclarativeName in library URI version VMAJ.VMIN.
+\a T and \a QDeclarativeName may be the same.
Generally the QML_DECLARE_TYPE() macro should be included immediately following
the type declaration (usually in its header file), and the QML_REGISTER_TYPE()
@@ -88,7 +88,7 @@ constructor.
\endquotation
Types can be registered by libraries (such as Qt does), application code,
-or by plugins (see QmlExtensionPlugin).
+or by plugins (see QDeclarativeExtensionPlugin).
Once registered, all of the \l {Qt's Property System}{properties} of a supported
type are available for use within QML. QML has intrinsic support for properties
@@ -167,7 +167,7 @@ for assignment to appropriately typed properties.
The guests property is a list of \c Person objects. Properties that are lists
of objects or Qt interfaces are also declared with the Q_PROPERTY() macro, just
-like other properties. List properties must have the type \c {QmlListProperty<T>}.
+like other properties. List properties must have the type \c {QDeclarativeListProperty<T>}.
As with object properties, the type \a T must be registered with QML.
The guest property declaration looks like this:
@@ -461,8 +461,8 @@ itself, the QML engine sets up an association between the value source and
the property.
Property value sources are special types that derive from the
-QmlPropertyValueSource base class. This base class contains a single method,
-QmlPropertyValueSource::setTarget(), that the QML engine invokes when
+QDeclarativePropertyValueSource base class. This base class contains a single method,
+QDeclarativePropertyValueSource::setTarget(), that the QML engine invokes when
associating the property value source with a property. The relevant part of
the HappyBirthday type declaration looks like this:
@@ -582,7 +582,7 @@ the appropriate property on the extension object is used instead.
When an extended type is installed, one of the
\code
- #define QML_REGISTER_EXTENDED_TYPE(URI, VMAJ, VFROM, VTO, QmlName,T, ExtendedT)
+ #define QML_REGISTER_EXTENDED_TYPE(URI, VMAJ, VFROM, VTO, QDeclarativeName,T, ExtendedT)
#define QML_REGISTER_EXTENDED_NOCREATE_TYPE(T, ExtendedT)
\endcode
macros should be used instead of the regular \c QML_REGISTER_TYPE or
@@ -597,18 +597,18 @@ status of the QML engine. For example, it might be beneficial to delay
initializing some costly data structures until after all the properties have been
set.
-The QML engine defines an interface class called QmlParserStatus, which contains a
+The QML engine defines an interface class called QDeclarativeParserStatus, which contains a
number of virtual methods that are invoked at various stages during component
instantiation. To receive these notifications, an element implementation inherits
-QmlParserStatus and notifies the Qt meta system using the Q_INTERFACES() macro.
+QDeclarativeParserStatus and notifies the Qt meta system using the Q_INTERFACES() macro.
For example,
\code
-class Example : public QObject, public QmlParserStatus
+class Example : public QObject, public QDeclarativeParserStatus
{
Q_OBJECT
- Q_INTERFACES(QmlParserStatus)
+ Q_INTERFACES(QDeclarativeParserStatus)
public:
virtual void componentComplete()
{
diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc
index 6459a2e..d7e890c 100644
--- a/doc/src/declarative/focus.qdoc
+++ b/doc/src/declarative/focus.qdoc
@@ -41,7 +41,7 @@
/*!
\target qmlfocus
-\page qmlfocus.html
+\page qdeclarativefocus.html
\title Keyboard Focus in QML
When a key is pressed or released, a key event is generated and delivered to the
@@ -56,7 +56,7 @@ and to address some of the cases unique to fluid user interfaces, the QML items
When the user presses or releases a key, the following occurs:
\list 1
\o Qt receives the key action and generates a key event.
-\o If the Qt widget containing the \l QmlView has focus, the key event is delivered to it. Otherwise, regular Qt key handling continues.
+\o If the Qt widget containing the \l QDeclarativeView has focus, the key event is delivered to it. Otherwise, regular Qt key handling continues.
\o The key event is delivered by the scene to the QML \l Item with \e {active focus}. If no \l Item has \e {active focus}, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues.
\o If the QML \l Item with \e {active focus} accepts the key event, propagation stops. Otherwise the event is "bubbled up", by recursively passing it to each \l Item's parent until either the event is accepted, or the root \l Item is reached.
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index fb33664..c718a6d 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\page qmlglobalobject.html
+\page qdeclarativeglobalobject.html
\title QML Global Object
Contains all the properties of the JavaScript global object, plus:
@@ -71,7 +71,7 @@ when the property has one of the following types:
\o Vector3D
\endlist
-There are also string based constructors for these types, see \l{qmlbasictypes.html}{Qml Types}.
+There are also string based constructors for these types, see \l{qdeclarativebasictypes.html}{Qml Types}.
\section3 Qt.rgba(qreal red, qreal green, qreal blue, qreal alpha)
This function returns a Color with the specified \c red, \c green, \c blue and \c alpha components. All components should be in the range 0-1 inclusive.
@@ -218,7 +218,7 @@ The \c openDatabase() and related functions
provide the ability to access local offline storage in an SQL database.
These databases are user-specific and QML-specific. They are stored in the \c Databases subdirectory
-of QmlEngine::offlineStoragePath(), currently as SQLite databases.
+of QDeclarativeEngine::offlineStoragePath(), currently as SQLite databases.
The API conforms to the Synchronous API of the HTML5 Web Database API,
\link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink.
diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc
index b3d6306..c685d3d 100644
--- a/doc/src/declarative/integrating.qdoc
+++ b/doc/src/declarative/integrating.qdoc
@@ -49,16 +49,16 @@ add QML to your UI, without having to rewrite it.
\section1 Adding QML to a \l{QWidget} based UI
If you have an existing QWidget based UI you can simply write new custom
widgets in QML. To integrate them into your application you can create a
-QmlView widget, and load the QML file into that. You'll then have a new widget
+QDeclarativeView widget, and load the QML file into that. You'll then have a new widget
containing your declarative UI, and you can interact with it through the
-QmlView interface. The one drawback of this approach is that QmlView is a lot
+QDeclarativeView interface. The one drawback of this approach is that QDeclarativeView is a lot
heavier than a QWidget in terms of memory consumption and initialization speed,
and so having large numbers of them may lead to performance degredation.
For a smooth transition from a QWidget based UI to a QML based UI, simply
rewrite your widgets in QML one at a time, using the above method. When
all of your widgets are written in QML you can rewrite your main widget in
-QML, so as to load the other widgets in QML instead of using QmlViews. Then
+QML, so as to load the other widgets in QML instead of using QDeclarativeViews. Then
you just load the main QML file on startup.
Keep in mind that QWidgets were designed for different sorts of UIs than QML
@@ -70,7 +70,7 @@ of simple and dynamic elements.
\section1 Adding QML to a QGraphicsView based UI
If you have an existing Graphics View based UI you can create new
-items in QML, and use \l{QmlComponent} to create \l{QGraphicsObject}s
+items in QML, and use \l{QDeclarativeComponent} to create \l{QGraphicsObject}s
from the QML files. These \l{QGraphicsObject}s can then be placed into
your \l{QGraphicsScene} using \l{QGraphicsScene::addItem()} or by
reparenting them to an item already in the \l{QGraphicsScene}.
@@ -79,8 +79,8 @@ Example, for local QML files:
\code
QGraphicsScene* scene = new QGraphicsScene;
-QmlEngine *engine = new QmlEngine;
-QmlComponent component(engine, QUrl::fromLocalFile(filename));
+QDeclarativeEngine *engine = new QDeclarativeEngine;
+QDeclarativeComponent component(engine, QUrl::fromLocalFile(filename));
QGraphicsObject *object =
qobject_cast<QGraphicsObject *>(component.create());
scene->addItem(object);
diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc
index cde8eb8..98183bb 100644
--- a/doc/src/declarative/javascriptblocks.qdoc
+++ b/doc/src/declarative/javascriptblocks.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\page qmljavascript.html
+\page qdeclarativejavascript.html
\title JavaScript Blocks
QML encourages building UIs declaratively, using \l {Property Binding} and the
@@ -124,7 +124,7 @@ The \c source property may reference a relative file, or an absolute path. In t
case of a relative file, the location is resolved relative to the location of the
\l {QML Document} that contains the \l Script element. If the script file is not
accessible, an error will occur. If the source is on a network resource, the
-enclosing QML document will remain in the \l {QmlComponent::status()}{waiting state}
+enclosing QML document will remain in the \l {QDeclarativeComponent::status()}{waiting state}
until the script has been retrieved.
\section1 Running Script at Startup
diff --git a/doc/src/declarative/measuring-performance.qdoc b/doc/src/declarative/measuring-performance.qdoc
index 8f6fe7d..cb608bf 100644
--- a/doc/src/declarative/measuring-performance.qdoc
+++ b/doc/src/declarative/measuring-performance.qdoc
@@ -71,14 +71,14 @@ Q_DEFINE_PERFORMANCE_METRIC(TextSize, "Text Size Calculation");
You could then use this category in the code:
\code
-void QmlGraphicsText::updateSize()
+void QDeclarativeText::updateSize()
{
- QmlPerfTimer<QmlPerf::TextSize> perf;
+ QDeclarativePerfTimer<QDeclarativePerf::TextSize> perf;
...
}
\endcode
-Because there is no cost for a QmlPerfTimer when Q_ENABLE_PERFORMANCE_LOG is not defined, this line can persist in the code and be used to help detect performance bottlenecks and regressions. See the QPerformanceLog documentation for more information on this performance framework.
+Because there is no cost for a QDeclarativePerfTimer when Q_ENABLE_PERFORMANCE_LOG is not defined, this line can persist in the code and be used to help detect performance bottlenecks and regressions. See the QPerformanceLog documentation for more information on this performance framework.
\section1 FPS Measurements
diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc
index dfb9081..ab75f8d 100644
--- a/doc/src/declarative/modules.qdoc
+++ b/doc/src/declarative/modules.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\page qmlmodules.html
+\page qdeclarativemodules.html
\title Modules
A \bold module is a collection of QML types.
@@ -63,7 +63,7 @@ This makes available all types in Qt that were available in Qt 4.6, regardless o
actual version of Qt executing the QML. So even if Qt 4.7 adds a type that would conflict
with a type you defined while using 4.6, that type is not imported, so there is no conflict.
-Types defined by plugins are made using QmlExtensionPlugin. Installed plugins and QML files
+Types defined by plugins are made using QDeclarativeExtensionPlugin. Installed plugins and QML files
can both contribute types to the same module.
@@ -82,7 +82,7 @@ QML, a URI import is used:
import com.nokia.Example 1.0
\endcode
-Files imported in this way are found on the paths added by QmlEngine::addImportPath(),
+Files imported in this way are found on the paths added by QDeclarativeEngine::addImportPath(),
which by default only inludes \c $QTDIR/qml, so the above would make available those types
defined in \c $QTDIR/qml/com/nokia/Example which are specified as being in version 1.0.
Installed plugins and QML files can both contribute types to the same module.
diff --git a/doc/src/declarative/network.qdoc b/doc/src/declarative/network.qdoc
index fc4761e..e642257 100644
--- a/doc/src/declarative/network.qdoc
+++ b/doc/src/declarative/network.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\page qmlnetwork.html
+\page qdeclarativenetwork.html
\title Network Transparency
QML supports network transparency by using URLs (rather than file names) for all
@@ -128,9 +128,9 @@ See the \tt demos/declarative/flickr for a real demonstration of this.
\section1 Configuring the Network Access Manager
-All network access from QML is managed by a QNetworkAccessManager set on the QmlEngine which executes the QML.
+All network access from QML is managed by a QNetworkAccessManager set on the QDeclarativeEngine which executes the QML.
By default, this is an unmodified Qt QNetworkAccessManager. You may set a different manager using
-QmlEngine::setNetworkAccessManager() as appropriate for the policies of your application.
+QDeclarativeEngine::setNetworkAccessManager() as appropriate for the policies of your application.
For example, the \l qmlviewer tool sets a new QNetworkAccessManager which
trusts HTTP Expiry headers to avoid network cache checks, allows HTTP Pipelining, adds a persistent HTTP CookieJar,
a simple disk cache, and supports proxy settings.
@@ -143,7 +143,7 @@ the executable using \l{The Qt Resource System}. Using this, an executable can r
that is compiled into the executable:
\code
- QmlView *canvas = new QmlView;
+ QDeclarativeView *canvas = new QDeclarativeView;
canvas->setUrl(QUrl("qrc:/dial.qml"));
\endcode
diff --git a/doc/src/declarative/qdeclarativedebugging.qdoc b/doc/src/declarative/qdeclarativedebugging.qdoc
new file mode 100644
index 0000000..3ef9ce7
--- /dev/null
+++ b/doc/src/declarative/qdeclarativedebugging.qdoc
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qdeclarativedebugging.html
+\title Debugging QML
+
+\section1 Logging
+
+\c console.log can be used to print debugging information to the console. For example:
+
+\qml
+Rectangle {
+ width: 200; height: 200
+ MouseArea {
+ anchors.fill: parent
+ onClicked: console.log("clicked")
+ }
+}
+\endqml
+
+\section1 Debugging Transitions
+
+When a transition doesn't look quite right, it can be helpful to view it in slow
+motion to see what is happening more clearly. \l {qmlviewer} provides a
+"Slow Down Animations" menu option to facilitate this.
+
+
+\section1 The QML Inspector
+
+The \c qmldebugger tool provides an experimental inspector to aid with debugging.
+It can be run as a Qt Creator plugin or as a standalone application.
+
+\section2 Qt Creator plugin
+
+The Qt Creator plugin currently builds against Qt Creator 1.3.
+
+To build the Qt Creator plugin:
+
+\list
+\o Set an environment variable \c CREATOR_SRC_DIR that points to the Qt Creator
+ source directory
+\o Set an environment variable \c CREATOR_BUILD_DIR that points to the Qt Creator
+ build directory
+\o Run \c qmake on \c $QTDIR/tools/qmldebugger/qmldebugger.pro
+\endlist
+
+This builds the plugin into your Qt Creator installation.
+
+The plugin adds a "QML Inspect" mode into Qt Creator that provides:
+
+\list
+\o An object tree showing all objects and their children
+\o The current property values for the object selected in the object tree
+ (this table is dynamically updated for all properties that have property changed
+ notifications)
+\o An expression evaluator for querying and setting values dynamically
+\o A table of watched properties (double-click on a property in the property
+ table to add it to the watch table)
+\o A graph that shows the frame rate of your application
+\endlist
+
+
+To start the debugger, open a QML project and click the "QML Inspect" mode, then click the green
+"play" button in the toolbar of the bottom-right debugger window.
+
+\image qmldebugger-creator.png
+
+
+\section2 Standalone qmldebugger tool
+
+To run the standalone \c qmldebugger tool, set an environment variable \c QML_DEBUG_SERVER_PORT
+to an available port number and run the \c qmlviewer. For example:
+
+\code
+ QML_DEBUG_SERVER_PORT=3768 qmlviewer myqmlfile.qml
+\endcode
+
+Then in another process, start the \c qmldebugger tool, enter the port number into the corresponding spinbox
+in the top right hand corner, and press the "Connect" button.
+
+*/
diff --git a/doc/src/declarative/qdeclarativedocument.qdoc b/doc/src/declarative/qdeclarativedocument.qdoc
new file mode 100644
index 0000000..a210c98
--- /dev/null
+++ b/doc/src/declarative/qdeclarativedocument.qdoc
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qdeclarativedocuments.html
+\title QML Documents
+
+A QML document is a block of QML source code. QML documents generally correspond to files
+stored on a disk or network resource, but can also be constructed directly from text data.
+
+Here is a simple QML document:
+
+\code
+import Qt 4.6
+
+Rectangle {
+ width: 240; height: 320;
+
+ resources: [
+ Component {
+ id: contactDelegate
+ Text {
+ text: modelData.firstName + " " + modelData.lastName
+ }
+ }
+ ]
+
+ ListView {
+ anchors.fill: parent
+ model: contactModel
+ delegate: contactDelegate
+ }
+}
+\endcode
+
+QML documents are always encoded in UTF-8 format.
+
+A QML document always begins with one or more import statements. To prevent elements
+introduced in later versions from affecting existing QML programs, the element types
+available within a document are controlled by the imported QML \l {Modules}. That is,
+QML is a \e versioned language.
+
+Syntactically a QML document is self contained; QML does \e not have a preprocessor that
+modifies the document prior to presentation to the QML runtime. \c import statements
+do not "include" code in the document, but instead instruct the QML runtime on how to
+resolve type references found in the document. Any type reference present in a QML
+document - such as \c Rectangle and \c ListView - including those made within an
+\l {JavaScript Block} or \l {Property Binding}s, are \e resolved based exclusively on the
+import statements. QML does not import any modules by default, so at least one \c import
+statement must be present or no elements will be available!
+
+A QML document defines a single, top-level \l {QDeclarativeComponent}{QML component}. A QML component
+is a template that is interpreted by the QML runtime to create an object with some predefined
+behaviour. As it is a template, a single QML component can be "run" multiple times to
+produce several objects, each of which are said to be \e instances of the component.
+
+Once created, instances are not dependent on the component that created them, so they can
+operate on independent data. Here is an example of a simple "button" component that is
+instantiated four times, each with a different value for its \c text property.
+
+\table
+\row
+\o
+\raw HTML
+<table><tr><td>
+\endraw
+\code
+import Qt 4.6
+
+BorderImage {
+ property alias text: textElement.text
+ width: 100; height: 30; source: "images/toolbutton.sci"
+
+ Text {
+ id: textElement
+ anchors.centerIn: parent
+ font.pointSize: 20
+ style: Text.Raised
+ color: "white"
+ }
+}
+\endcode
+\raw HTML
+</td> <td>
+\endraw
+\image anatomy-component.png
+\raw HTML
+</td> </tr> </table>
+\endraw
+\endtable
+
+In addition to the top-level component that all QML documents define, documents may also
+include additional \e inline components. Inline components are declared using the
+\l Component element, as can be seen in the first example above. Inline components share
+all the characteristics of regular top-level components and use the same \c import list as their
+containing QML document. Components are one of the most basic building blocks in QML, and are
+frequently used as "factories" by other elements. For example, the \l ListView element uses the
+\c delegate component as the template for instantiating list items - each list item is just a
+new instance of the component with the item specific data set appropriately.
+
+Like other \l {QML Elements}, the \l Component element is an object and must be assigned to a
+property. \l Component objects may also have an object id. In the first example on this page,
+the inline component is added to the \l Rectangle's \c resources list, and then
+\l {Property Binding} is used to assign the \l Component to the \l ListView's \c delegate
+property. While using property binding allows the \l Component object to be shared (for example,
+if the QML document contained multiple \l ListView's with the same delegate), in this case the
+\l Component could have been assigned directly to the \l ListView's \c delegate. The QML
+language even contains a syntactic optimization when assigning directly to a component property
+for this case where it will automatically insert the \l Component tag.
+
+These final two examples are behaviorally identical to the original document.
+
+\table
+\row
+\o
+\code
+import Qt 4.6
+
+Rectangle {
+ width: 240; height: 320;
+
+ ListView {
+ anchors.fill: parent
+ model: contactModel
+ delegate: Component {
+ Text {
+ text: modelData.firstName + " " + modelData.lastName
+ }
+ }
+ }
+}
+\endcode
+\o
+\code
+import Qt 4.6
+
+Rectangle {
+ width: 240; height: 320;
+
+ ListView {
+ anchors.fill: parent
+ model: contactModel
+ delegate: Text {
+ text: modelData.firstName + " " + modelData.lastName
+ }
+ }
+}
+\endcode
+\endtable
+
+\sa QDeclarativeComponent
+*/
diff --git a/doc/src/declarative/qdeclarativei18n.qdoc b/doc/src/declarative/qdeclarativei18n.qdoc
new file mode 100644
index 0000000..9c10a46
--- /dev/null
+++ b/doc/src/declarative/qdeclarativei18n.qdoc
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qdeclarativei18n.html
+\title QML Internationalization
+
+\section1 Overview
+
+Strings in QML can be marked for translation using the qsTr(), qsTranslate(),
+QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions.
+
+For example:
+\qml
+Text { text: qsTr("Pictures") }
+\endqml
+
+These functions are standard QtScript functions; for more details see
+QScriptEngine::installTranslatorFunctions().
+
+QML relies on the core internationalization capabilities provided by Qt. These
+capabilities are described more fully in:
+\list
+\o \l {Internationalization with Qt}
+\o \l {Qt Linguist Manual}
+\endlist
+
+You can test a translation in \l {qmlviewer} using the -translation option.
+
+\section1 Example
+
+First we create a simple QML file with text to be translated. The string
+that needs to be translated is enclosed in a call to \c qsTr().
+
+hello.qml:
+\qml
+import Qt 4.6
+
+Rectangle {
+ width: 200; height: 200
+ Text { text: qsTr("Hello"); anchors.centerIn: parent }
+}
+\endqml
+
+Next we create a translation source file using lupdate:
+\code
+lupdate hello.qml -ts hello.ts
+\endcode
+
+Then we open \c hello.ts in \l{Qt Linguist Manual} {Linguist}, provide
+a translation and create the release file \c hello.qm.
+
+Finally, we can test the translation in qmlviewer:
+\code
+qmlviewer -translation hello.qm hello.qml
+\endcode
+*/
diff --git a/doc/src/declarative/qdeclarativeintro.qdoc b/doc/src/declarative/qdeclarativeintro.qdoc
new file mode 100644
index 0000000..4d05a8c
--- /dev/null
+++ b/doc/src/declarative/qdeclarativeintro.qdoc
@@ -0,0 +1,351 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qdeclarativeintroduction.html
+\title Introduction to the QML language
+
+\tableofcontents
+
+QML is a declarative language designed to describe the user interface of a
+program: both what it looks like, and how it behaves. In QML, a user
+interface is specified as a tree of objects with properties.
+
+This introduction is meant for those with little or no programming
+experience. JavaScript is used as a scripting language in QML, so you may want
+to learn a bit more about it (\l{JavaScript: The Definitive Guide}) before diving
+deeper into QML. It's also helpful to have a basic understanding of other web
+technologies like HTML and CSS, but it's not required.
+
+\section1 Basic QML Syntax
+
+QML looks like this:
+
+\code
+Rectangle {
+ width: 200
+ height: 200
+ color: "white"
+ Image {
+ source: "pics/logo.png"
+ anchors.centerIn: parent
+ }
+}
+\endcode
+
+Objects are specified by their type, followed by a pair of braces. Object
+types always begin with a capital letter. In the above example, there are
+two objects, a \l Rectangle, and an \l Image. Between the braces, we can specify
+information about the object, such as its properties.
+
+Properties are specified as \c {property: value}. In the above example, we
+can see the Image has a property named \c source, which has been assigned the
+value \c "pics/logo.png". The property and its value are separated by a colon.
+
+Properties can be specified one-per-line:
+
+\code
+Rectangle {
+ width: 100
+ height: 100
+}
+\endcode
+
+or you can put multiple properties on a single line:
+
+\code
+Rectangle { width: 100; height: 100 }
+\endcode
+
+When multiple property/value pairs are specified on a single line, they
+must be separated by a semicolon.
+
+\section1 Expressions
+
+In addition to assigning values to properties, you can also assign
+expressions written in JavaScript.
+
+\code
+Rotation {
+ angle: 360 * 3
+}
+\endcode
+
+These expressions can include references to other objects and properties, in which case
+a \e binding is established: when the value of the expression changes, the property the
+expression has been assigned to is automatically updated to that value.
+
+\code
+Item {
+ Text {
+ id: text1
+ text: "Hello World"
+ }
+ Text {
+ id: text2
+ text: text1.text
+ }
+}
+\endcode
+
+In the example above, the \c text2 object will display the same text as \c text1. If \c text1 is changed,
+\c text2 is automatically changed to the same value.
+
+Note that to refer to other objects, we use their \e id values. (See below for more
+information on the \e id property.)
+
+\section1 QML Comments
+
+Commenting in QML is similar to JavaScript.
+\list
+\o Single line comments start with // and finish at the end of the line.
+\o Multiline comments start with /* and finish with *\/
+\endlist
+
+\quotefile doc/src/snippets/declarative/comments.qml
+
+Comments are ignored by the engine. The are useful for explaining what you
+are doing: for referring back to at a later date, or for others reading
+your QML files.
+
+Comments can also be used to prevent the execution of code, which is
+sometimes useful for tracking down problems.
+
+\code
+Text {
+ text: "Hello world!"
+ //opacity: 0.5
+}
+\endcode
+
+In the above example, the Text object will have normal opacity, since the
+line opacity: 0.5 has been turned into a comment.
+
+\section1 Properties
+\target intro-properties
+
+\section2 Property naming
+
+Properties begin with a lowercase letter (with the exception of \l{Attached Properties}).
+
+\section2 Property types
+
+QML supports properties of many types (see \l{QML Basic Types}). The basic types include int,
+real, bool, string, color, and lists.
+
+\code
+Item {
+ x: 10.5 // a 'real' property
+ ...
+ state: "details" // a 'string' property
+ focus: true // a 'bool' property
+}
+\endcode
+
+QML properties are what is known as \e typesafe. That is, they only allow you to assign a value that
+matches the property type. For example, the \c x property of item is a real, and if you try to assign
+a string to it you will get an error.
+
+\badcode
+Item {
+ x: "hello" // illegal!
+}
+\endcode
+
+\section3 The \c id property
+
+Each object can be given a special unique property called an \e id. Assigning an id enables the object
+to be referred to by other objects and scripts.
+
+The first Rectangle element below has an \e id, "myRect". The second Rectange element defines its
+own width by referring to \tt myRect.width, which means it will have the same \tt width
+value as the first Rectangle element.
+
+\code
+Item {
+ Rectangle {
+ id: myRect
+ width: 100
+ height: 100
+ }
+ Rectangle {
+ width: myRect.width
+ height: 200
+ }
+}
+\endcode
+
+Note that an \e id must begin with a lower-case letter or an underscore, and cannot contain characters other than letters, numbers and underscores.
+
+
+\section2 List properties
+
+List properties look like this:
+
+\code
+Item {
+ children: [
+ Image {},
+ Text {}
+ ]
+}
+\endcode
+
+The list is enclosed in square brackets, with a comma separating the
+list elements. In cases where you are only assigning a single item to a
+list, you can omit the square brackets:
+
+\code
+Image {
+ children: Rectangle {}
+}
+\endcode
+
+\section2 Default properties
+
+Each object type can specify one of its list or object properties as its default property.
+If a property has been declared as the default property, the property tag can be omitted.
+
+For example this code:
+\code
+State {
+ changes: [
+ PropertyChanges {},
+ PropertyChanges {}
+ ]
+}
+\endcode
+
+can be simplified to:
+
+\code
+State {
+ PropertyChanges {}
+ PropertyChanges {}
+}
+\endcode
+
+because \c changes is the default property of the \c State type.
+
+\section2 Grouped Properties
+\target dot properties
+
+In some cases properties form a logical group and use a 'dot' or grouped notation
+to show this.
+
+Grouped properties can be written like this:
+\qml
+Text {
+ font.pixelSize: 12
+ font.bold: true
+}
+\endqml
+
+or like this:
+\qml
+Text {
+ font { pixelSize: 12; bold: true }
+}
+\endqml
+
+In the element documentation grouped properties are shown using the 'dot' notation.
+
+\section2 Attached Properties
+\target attached-properties
+
+Some objects attach properties to another object. Attached Properties
+are of the form \e {Type.property} where \e Type is the type of the
+element that attaches \e property.
+
+For example:
+\code
+Component {
+ id: myDelegate
+ Text {
+ text: "Hello"
+ color: ListView.isCurrentItem ? "red" : "blue"
+ }
+}
+ListView {
+ delegate: myDelegate
+}
+\endcode
+
+The \l ListView element attaches the \e ListView.isCurrentItem property
+to each delegate it creates.
+
+Another example of attached properties is the \l Keys element which
+attaches properties for handling key presses to
+any visual Item, for example:
+
+\code
+Item {
+ focus: true
+ Keys.onSelectPressed: console.log("Selected")
+}
+\endcode
+
+\section2 Signal Handlers
+
+Signal handlers allow actions to be taken in reponse to an event. For instance,
+the \l MouseArea element has signal handlers to handle mouse press, release
+and click:
+
+\code
+MouseArea {
+ onPressed: console.log("mouse button pressed")
+}
+\endcode
+
+All signal handlers begin with \e "on".
+
+Some signal handlers include an optional parameter, for example
+the MouseArea onPressed signal handler has a \e mouse parameter:
+
+\code
+MouseArea {
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onPressed: if (mouse.button == Qt.RightButton) console.log("Right mouse button pressed")
+}
+\endcode
+
+
+*/
diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc
new file mode 100644
index 0000000..c0e028e
--- /dev/null
+++ b/doc/src/declarative/qdeclarativemodels.qdoc
@@ -0,0 +1,341 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qdeclarativemodels.html
+\target qmlmodels
+\title Data Models
+
+Some QML Items use Data Models to provide the data to be displayed.
+These items typically require a \e delegate component that
+creates an instance for each item in the model. Models may be static, or
+have items modified, inserted, removed or moved dynamically.
+
+Data is provided to the delegate via named data roles which the
+delegate may bind to. The roles are exposed as properties of the
+\e model context property, though this property is set as a default property
+of the delegate so, unless there is a naming clash with a
+property in the delegate, the roles are usually accessed unqualified. The
+example below would have a clash between he \e color role of the model and
+the \e color property of the Rectangle. The clash is avoided by referencing
+the \e color property of the model by its full name: \e model.color.
+
+\code
+ListModel {
+ id: myModel
+ ListElement { color: "red" }
+ ListElement { color: "green" }
+}
+
+Component {
+ id: myDelegate
+ Rectangle {
+ width: 20; height: 20
+ color: model.color
+ }
+}
+\endcode
+
+A special \e index role containing the index of the item in the model
+is also available.
+
+\e Note: the index role will be set to -1 if the item is removed from
+the model. If you bind to the index role, be sure that the logic
+accounts for the possibility of index being -1, i.e. that the item
+is no longer valid. Usually the item will shortly be destroyed, but
+it is possible to delay delegate destruction in some views via a delayRemove
+attached property.
+
+Models that do not have named roles will have the data provided via
+the \e modelData role. The \e modelData role is also provided for
+Models that have only one role. In this case the \e modelData role
+contains the same data as the named role.
+
+There are a number of QML elements that operate using data models:
+
+\list
+\o ListView
+\o GridView
+\o PathView
+\o \l Repeater
+\endlist
+
+QML supports several types of data model, which may be provided by QML
+or C++ (via QDeclarativeContext::setContextProperty(), for example).
+
+\section1 QML Data Models
+
+\section2 ListModel
+
+ListModel is a simple hierarchy of elements specified in QML. The
+available roles are specified by the \l ListElement properties.
+
+\code
+ListModel {
+ id: fruitModel
+ ListElement {
+ name: "Apple"
+ cost: 2.45
+ }
+ ListElement {
+ name: "Orange"
+ cost: 3.25
+ }
+ ListElement {
+ name: "Banana"
+ cost: 1.95
+ }
+}
+\endcode
+
+The above model has two roles, \e name and \e cost. These can be bound
+to by a ListView delegate, for example:
+
+\code
+Component {
+ id: fruitDelegate
+ Row {
+ Text { text: "Fruit: " + name }
+ Text { text: "Cost: $" + cost }
+ }
+}
+ListView {
+ model: fruitModel
+ delegate: fruitDelegate
+}
+\endcode
+
+
+\section2 XmlListModel
+
+XmlListModel allows construction of a model from an XML data source. The roles
+are specified via the \l XmlRole element.
+
+The following model has three roles, \e title, \e link and \e description:
+\code
+XmlListModel {
+ id: feedModel
+ source: "http://rss.news.yahoo.com/rss/oceania"
+ query: "/rss/channel/item"
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "link"; query: "link/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+}
+\endcode
+
+
+\section2 VisualItemModel
+
+VisualItemModel allows QML items to be provided as a model. This model contains
+both the data and delegate (its child items). This model does not provide any roles.
+
+\code
+ VisualItemModel {
+ id: itemModel
+ Rectangle { height: 30; width: 80; color: "red" }
+ Rectangle { height: 30; width: 80; color: "green" }
+ Rectangle { height: 30; width: 80; color: "blue" }
+ }
+
+ ListView {
+ anchors.fill: parent
+ model: itemModel
+ }
+\endcode
+
+Note that in the above example there is no delegate required.
+The items of the model itself provide the visual elements that
+will be positioned by the view.
+
+
+\section1 C++ Data Models
+
+\section2 QAbstractItemModel
+
+QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNames() method.
+
+
+\section2 QStringList
+
+QStringList provides the contents of the list via the \e modelData role:
+
+\table
+\header
+\o
+\o
+\row
+\o
+\code
+// main.cpp
+QStringList dataList;
+dataList.append("Fred");
+dataList.append("Ginger");
+dataList.appenf("Skipper");
+
+QDeclarativeContext *ctxt = view.rootContext();
+ctxt->setContextProperty("myModel", QVariant::fromValue(&dataList));
+\endcode
+
+\o
+\code
+// main.qml
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ Text { text: modelData }
+ }
+ }
+}
+\endcode
+\endtable
+
+\note There is no way for the view to know that the contents of a QStringList
+have changed. If the QStringList is changed, it will be necessary to reset
+the model by calling QDeclarativeContext::setContextProperty() again.
+
+
+\section2 QList<QObject*>
+
+QList<QObject*> provides the properties of the objects in the list as roles.
+
+\code
+class DataObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString color READ color WRITE setColor)
+...
+};
+
+QList<QObject*> dataList;
+dataList.append(new DataObject("Item 1", "red"));
+dataList.append(new DataObject("Item 2", "green"));
+dataList.append(new DataObject("Item 3", "blue"));
+dataList.append(new DataObject("Item 4", "yellow"));
+
+QDeclarativeContext *ctxt = view.rootContext();
+ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+\endcode
+
+The properties of the object may then be accessed in the delegate:
+
+\code
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ color: model.color
+ Text { text: name }
+ }
+ }
+}
+\endcode
+
+Note: There is no way for the view to know that the contents of a QList
+have changed. If the QList is changed, it will be necessary to reset
+the model by calling QDeclarativeContext::setContextProperty() again.
+
+
+\section1 Other Data Models
+
+
+\section2 An Integer
+
+An Integer specifies a model containing the integer number of elements.
+There are no data roles.
+
+The following example creates a ListView with five elements:
+\code
+Component {
+ id: itemDelegate
+ Text { text: "I am item number: " + index }
+}
+ListView {
+ model: 5
+ delegate: itemDelegate
+}
+\endcode
+
+
+\section2 An Object Instance
+
+An Object Instance specifies a model with a single Object element. The
+properties of the object are provided as roles.
+
+The example below creates a list with one item, showing the color of the
+\e myText text. Note the use of the fully qualified \e model.color property
+to avoid clashing with \e color property of the Text element in the delegate.
+
+\code
+Rectangle {
+ Text {
+ id: myText
+ text: "Hello"
+ color: "#dd44ee"
+ }
+
+ Component {
+ id: myDelegate
+ Text {
+ text: model.color
+ }
+ }
+ ListView {
+ anchors.fill: parent
+ anchors.topMargin: 30
+ model: myText
+ delegate: myDelegate
+ }
+}
+\endcode
+
+*/
diff --git a/doc/src/declarative/qdeclarativereference.qdoc b/doc/src/declarative/qdeclarativereference.qdoc
new file mode 100644
index 0000000..01af7f5
--- /dev/null
+++ b/doc/src/declarative/qdeclarativereference.qdoc
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page qdeclarativereference.html
+ \title QML Reference
+
+ \target qtdeclarativemainpage
+
+ QML is a language for building the animation rich,
+ highly fluid user interfaces that are becoming common in portable consumer
+ electronics devices such as mobile phones, media players, set-top boxes and
+ netbooks. It is also appropriate for highly custom desktop
+ user interfaces, or special elements in more traditional desktop user interfaces.
+
+ Building fluid applications is done declaratively, rather than procedurally.
+ That is, you specify \e what the UI should look like and how it should behave
+ rather than specifying step-by-step \e how to build it. Specifying a UI declaratively
+ does not just include the layout of the interface items, but also the way each
+ individual item looks and behaves and the overall flow of the application.
+
+ The QML elements provide a sophisticated set of graphical and behavioral building
+ blocks. These different elements are combined together in \l {QML Documents}{QML documents} to build components
+ ranging in complexity from simple buttons and sliders, to complete
+ internet-enabled applications like a \l {http://www.flickr.com}{Flickr} photo browser.
+
+ Getting Started:
+ \list
+ \o \l {Introduction to the QML language}
+ \o \l {QML Tutorial}{Tutorial: 'Hello World'}
+ \o \l {QML Advanced Tutorial}{Advanced Tutorial: 'Same Game'}
+ \o \l {QML Examples and Walkthroughs}
+ \endlist
+
+ \section1 Core QML Features:
+ \list
+ \o \l {QML Documents}
+ \o \l {Property Binding}
+ \o \l {JavaScript Blocks}
+ \o \l {QML Scope}
+ \o \l {Network Transparency}
+ \o \l {qmlmodels}{Data Models}
+ \o \l {anchor-layout}{Anchor-based Layout}
+ \o \l {qmlstates}{States}
+ \o \l {qdeclarativeanimation.html}{Animation}
+ \o \l {qdeclarativemodules.html}{Modules}
+ \o \l {qmlfocus}{Keyboard Focus}
+ \o \l {Extending types from QML}
+ \endlist
+
+ QML Reference:
+ \list
+ \o \l {elements}{QML Elements}
+ \o \l {QML Global Object}
+ \o \l {QML Internationalization}
+ \endlist
+*/
diff --git a/doc/src/declarative/qdeclarativestates.qdoc b/doc/src/declarative/qdeclarativestates.qdoc
new file mode 100644
index 0000000..0fea6f8
--- /dev/null
+++ b/doc/src/declarative/qdeclarativestates.qdoc
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qdeclarativestates.html
+\target qmlstates
+\title QML States
+
+\section1 Overview
+
+QML states typically describe user interface configurations, including:
+\list
+\o What UI elements are present
+\o The properties of those elements (including how they behave)
+\o What actions are available
+\endlist
+
+A state can also be thought of as a set of batched changes from a default configuration.
+
+Examples of states in modern UI:
+\list
+\o An Address Book application with a 'View Contact' state and an 'Edit Contact' State. In the first state the contact information presented is read-only (using labels), and in the second it is editable (using editors).
+\o A button with a pressed and unpressed state. When pressed the text moves slightly down and to the right, and the button has a slightly darker appearance.
+\endlist
+
+\section1 States in QML
+
+In QML:
+\list
+\o Any object can use states.
+\o There is a default state. The default state can be explicitly set.
+\o A state can affect the properties of other objects, not just the object owning the state (and not just that object's children).
+\endlist
+
+Here is an example of using states. In the default state \c myRect is positioned at 0,0. In the 'moved' state it is positioned at 50,50. Clicking within the mouse region changes the state from the default state to the 'moved' state, thus moving the rectangle.
+
+\qml
+Item {
+ id: myItem
+
+ Rectangle {
+ id: myRect
+ width: 100
+ height: 100
+ color: "red"
+ }
+
+ states: [
+ State {
+ name: "moved"
+ PropertyChanges {
+ target: myRect
+ x: 50
+ y: 50
+ }
+ }
+ ]
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myItem.state = 'moved'
+ }
+}
+\endqml
+
+State changes can be animated using \l{state-transitions}{Transitions}.
+
+For example, adding this code to the above \c {Item {}} element animates the transition to the "moved" state:
+
+\qml
+ transitions: [
+ Transition {
+ NumberAnimation { properties: "x,y"; duration: 500 }
+ }
+ ]
+\endqml
+
+See \l{state-transitions}{Transitions} for more information.
+
+
+Other things you can do in a state change:
+\list
+\o override signal handlers with PropertyChanges
+\o change an item's visual parent with ParentChange
+\o change an item's anchors with AnchorChanges
+\o run some script with StateChangeScript
+\endlist
+
+*/
diff --git a/doc/src/declarative/qmldebugging.qdoc b/doc/src/declarative/qmldebugging.qdoc
deleted file mode 100644
index 56bd7d2..0000000
--- a/doc/src/declarative/qmldebugging.qdoc
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qmldebugging.html
-\title Debugging QML
-
-\section1 Logging
-
-\c console.log can be used to print debugging information to the console. For example:
-
-\qml
-Rectangle {
- width: 200; height: 200
- MouseArea {
- anchors.fill: parent
- onClicked: console.log("clicked")
- }
-}
-\endqml
-
-\section1 Debugging Transitions
-
-When a transition doesn't look quite right, it can be helpful to view it in slow
-motion to see what is happening more clearly. \l {qmlviewer} provides a
-"Slow Down Animations" menu option to facilitate this.
-
-
-\section1 The QML Inspector
-
-The \c qmldebugger tool provides an experimental inspector to aid with debugging.
-It can be run as a Qt Creator plugin or as a standalone application.
-
-\section2 Qt Creator plugin
-
-The Qt Creator plugin currently builds against Qt Creator 1.3.
-
-To build the Qt Creator plugin:
-
-\list
-\o Set an environment variable \c CREATOR_SRC_DIR that points to the Qt Creator
- source directory
-\o Set an environment variable \c CREATOR_BUILD_DIR that points to the Qt Creator
- build directory
-\o Run \c qmake on \c $QTDIR/tools/qmldebugger/qmldebugger.pro
-\endlist
-
-This builds the plugin into your Qt Creator installation.
-
-The plugin adds a "QML Inspect" mode into Qt Creator that provides:
-
-\list
-\o An object tree showing all objects and their children
-\o The current property values for the object selected in the object tree
- (this table is dynamically updated for all properties that have property changed
- notifications)
-\o An expression evaluator for querying and setting values dynamically
-\o A table of watched properties (double-click on a property in the property
- table to add it to the watch table)
-\o A graph that shows the frame rate of your application
-\endlist
-
-
-To start the debugger, open a QML project and click the "QML Inspect" mode, then click the green
-"play" button in the toolbar of the bottom-right debugger window.
-
-\image qmldebugger-creator.png
-
-
-\section2 Standalone qmldebugger tool
-
-To run the standalone \c qmldebugger tool, set an environment variable \c QML_DEBUG_SERVER_PORT
-to an available port number and run the \c qmlviewer. For example:
-
-\code
- QML_DEBUG_SERVER_PORT=3768 qmlviewer myqmlfile.qml
-\endcode
-
-Then in another process, start the \c qmldebugger tool, enter the port number into the corresponding spinbox
-in the top right hand corner, and press the "Connect" button.
-
-*/
diff --git a/doc/src/declarative/qmldocument.qdoc b/doc/src/declarative/qmldocument.qdoc
deleted file mode 100644
index 977b4ac..0000000
--- a/doc/src/declarative/qmldocument.qdoc
+++ /dev/null
@@ -1,190 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qmldocuments.html
-\title QML Documents
-
-A QML document is a block of QML source code. QML documents generally correspond to files
-stored on a disk or network resource, but can also be constructed directly from text data.
-
-Here is a simple QML document:
-
-\code
-import Qt 4.6
-
-Rectangle {
- width: 240; height: 320;
-
- resources: [
- Component {
- id: contactDelegate
- Text {
- text: modelData.firstName + " " + modelData.lastName
- }
- }
- ]
-
- ListView {
- anchors.fill: parent
- model: contactModel
- delegate: contactDelegate
- }
-}
-\endcode
-
-QML documents are always encoded in UTF-8 format.
-
-A QML document always begins with one or more import statements. To prevent elements
-introduced in later versions from affecting existing QML programs, the element types
-available within a document are controlled by the imported QML \l {Modules}. That is,
-QML is a \e versioned language.
-
-Syntactically a QML document is self contained; QML does \e not have a preprocessor that
-modifies the document prior to presentation to the QML runtime. \c import statements
-do not "include" code in the document, but instead instruct the QML runtime on how to
-resolve type references found in the document. Any type reference present in a QML
-document - such as \c Rectangle and \c ListView - including those made within an
-\l {JavaScript Block} or \l {Property Binding}s, are \e resolved based exclusively on the
-import statements. QML does not import any modules by default, so at least one \c import
-statement must be present or no elements will be available!
-
-A QML document defines a single, top-level \l {QmlComponent}{QML component}. A QML component
-is a template that is interpreted by the QML runtime to create an object with some predefined
-behaviour. As it is a template, a single QML component can be "run" multiple times to
-produce several objects, each of which are said to be \e instances of the component.
-
-Once created, instances are not dependent on the component that created them, so they can
-operate on independent data. Here is an example of a simple "button" component that is
-instantiated four times, each with a different value for its \c text property.
-
-\table
-\row
-\o
-\raw HTML
-<table><tr><td>
-\endraw
-\code
-import Qt 4.6
-
-BorderImage {
- property alias text: textElement.text
- width: 100; height: 30; source: "images/toolbutton.sci"
-
- Text {
- id: textElement
- anchors.centerIn: parent
- font.pointSize: 20
- style: Text.Raised
- color: "white"
- }
-}
-\endcode
-\raw HTML
-</td> <td>
-\endraw
-\image anatomy-component.png
-\raw HTML
-</td> </tr> </table>
-\endraw
-\endtable
-
-In addition to the top-level component that all QML documents define, documents may also
-include additional \e inline components. Inline components are declared using the
-\l Component element, as can be seen in the first example above. Inline components share
-all the characteristics of regular top-level components and use the same \c import list as their
-containing QML document. Components are one of the most basic building blocks in QML, and are
-frequently used as "factories" by other elements. For example, the \l ListView element uses the
-\c delegate component as the template for instantiating list items - each list item is just a
-new instance of the component with the item specific data set appropriately.
-
-Like other \l {QML Elements}, the \l Component element is an object and must be assigned to a
-property. \l Component objects may also have an object id. In the first example on this page,
-the inline component is added to the \l Rectangle's \c resources list, and then
-\l {Property Binding} is used to assign the \l Component to the \l ListView's \c delegate
-property. While using property binding allows the \l Component object to be shared (for example,
-if the QML document contained multiple \l ListView's with the same delegate), in this case the
-\l Component could have been assigned directly to the \l ListView's \c delegate. The QML
-language even contains a syntactic optimization when assigning directly to a component property
-for this case where it will automatically insert the \l Component tag.
-
-These final two examples are behaviorally identical to the original document.
-
-\table
-\row
-\o
-\code
-import Qt 4.6
-
-Rectangle {
- width: 240; height: 320;
-
- ListView {
- anchors.fill: parent
- model: contactModel
- delegate: Component {
- Text {
- text: modelData.firstName + " " + modelData.lastName
- }
- }
- }
-}
-\endcode
-\o
-\code
-import Qt 4.6
-
-Rectangle {
- width: 240; height: 320;
-
- ListView {
- anchors.fill: parent
- model: contactModel
- delegate: Text {
- text: modelData.firstName + " " + modelData.lastName
- }
- }
-}
-\endcode
-\endtable
-
-\sa QmlComponent
-*/
diff --git a/doc/src/declarative/qmli18n.qdoc b/doc/src/declarative/qmli18n.qdoc
deleted file mode 100644
index 0803d6c..0000000
--- a/doc/src/declarative/qmli18n.qdoc
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qmli18n.html
-\title QML Internationalization
-
-\section1 Overview
-
-Strings in QML can be marked for translation using the qsTr(), qsTranslate(),
-QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions.
-
-For example:
-\qml
-Text { text: qsTr("Pictures") }
-\endqml
-
-These functions are standard QtScript functions; for more details see
-QScriptEngine::installTranslatorFunctions().
-
-QML relies on the core internationalization capabilities provided by Qt. These
-capabilities are described more fully in:
-\list
-\o \l {Internationalization with Qt}
-\o \l {Qt Linguist Manual}
-\endlist
-
-You can test a translation in \l {qmlviewer} using the -translation option.
-
-\section1 Example
-
-First we create a simple QML file with text to be translated. The string
-that needs to be translated is enclosed in a call to \c qsTr().
-
-hello.qml:
-\qml
-import Qt 4.6
-
-Rectangle {
- width: 200; height: 200
- Text { text: qsTr("Hello"); anchors.centerIn: parent }
-}
-\endqml
-
-Next we create a translation source file using lupdate:
-\code
-lupdate hello.qml -ts hello.ts
-\endcode
-
-Then we open \c hello.ts in \l{Qt Linguist Manual} {Linguist}, provide
-a translation and create the release file \c hello.qm.
-
-Finally, we can test the translation in qmlviewer:
-\code
-qmlviewer -translation hello.qm hello.qml
-\endcode
-*/
diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc
deleted file mode 100644
index b353e44..0000000
--- a/doc/src/declarative/qmlintro.qdoc
+++ /dev/null
@@ -1,351 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qmlintroduction.html
-\title Introduction to the QML language
-
-\tableofcontents
-
-QML is a declarative language designed to describe the user interface of a
-program: both what it looks like, and how it behaves. In QML, a user
-interface is specified as a tree of objects with properties.
-
-This introduction is meant for those with little or no programming
-experience. JavaScript is used as a scripting language in QML, so you may want
-to learn a bit more about it (\l{JavaScript: The Definitive Guide}) before diving
-deeper into QML. It's also helpful to have a basic understanding of other web
-technologies like HTML and CSS, but it's not required.
-
-\section1 Basic QML Syntax
-
-QML looks like this:
-
-\code
-Rectangle {
- width: 200
- height: 200
- color: "white"
- Image {
- source: "pics/logo.png"
- anchors.centerIn: parent
- }
-}
-\endcode
-
-Objects are specified by their type, followed by a pair of braces. Object
-types always begin with a capital letter. In the above example, there are
-two objects, a \l Rectangle, and an \l Image. Between the braces, we can specify
-information about the object, such as its properties.
-
-Properties are specified as \c {property: value}. In the above example, we
-can see the Image has a property named \c source, which has been assigned the
-value \c "pics/logo.png". The property and its value are separated by a colon.
-
-Properties can be specified one-per-line:
-
-\code
-Rectangle {
- width: 100
- height: 100
-}
-\endcode
-
-or you can put multiple properties on a single line:
-
-\code
-Rectangle { width: 100; height: 100 }
-\endcode
-
-When multiple property/value pairs are specified on a single line, they
-must be separated by a semicolon.
-
-\section1 Expressions
-
-In addition to assigning values to properties, you can also assign
-expressions written in JavaScript.
-
-\code
-Rotation {
- angle: 360 * 3
-}
-\endcode
-
-These expressions can include references to other objects and properties, in which case
-a \e binding is established: when the value of the expression changes, the property the
-expression has been assigned to is automatically updated to that value.
-
-\code
-Item {
- Text {
- id: text1
- text: "Hello World"
- }
- Text {
- id: text2
- text: text1.text
- }
-}
-\endcode
-
-In the example above, the \c text2 object will display the same text as \c text1. If \c text1 is changed,
-\c text2 is automatically changed to the same value.
-
-Note that to refer to other objects, we use their \e id values. (See below for more
-information on the \e id property.)
-
-\section1 QML Comments
-
-Commenting in QML is similar to JavaScript.
-\list
-\o Single line comments start with // and finish at the end of the line.
-\o Multiline comments start with /* and finish with *\/
-\endlist
-
-\quotefile doc/src/snippets/declarative/comments.qml
-
-Comments are ignored by the engine. The are useful for explaining what you
-are doing: for referring back to at a later date, or for others reading
-your QML files.
-
-Comments can also be used to prevent the execution of code, which is
-sometimes useful for tracking down problems.
-
-\code
-Text {
- text: "Hello world!"
- //opacity: 0.5
-}
-\endcode
-
-In the above example, the Text object will have normal opacity, since the
-line opacity: 0.5 has been turned into a comment.
-
-\section1 Properties
-\target intro-properties
-
-\section2 Property naming
-
-Properties begin with a lowercase letter (with the exception of \l{Attached Properties}).
-
-\section2 Property types
-
-QML supports properties of many types (see \l{QML Basic Types}). The basic types include int,
-real, bool, string, color, and lists.
-
-\code
-Item {
- x: 10.5 // a 'real' property
- ...
- state: "details" // a 'string' property
- focus: true // a 'bool' property
-}
-\endcode
-
-QML properties are what is known as \e typesafe. That is, they only allow you to assign a value that
-matches the property type. For example, the \c x property of item is a real, and if you try to assign
-a string to it you will get an error.
-
-\badcode
-Item {
- x: "hello" // illegal!
-}
-\endcode
-
-\section3 The \c id property
-
-Each object can be given a special unique property called an \e id. Assigning an id enables the object
-to be referred to by other objects and scripts.
-
-The first Rectangle element below has an \e id, "myRect". The second Rectange element defines its
-own width by referring to \tt myRect.width, which means it will have the same \tt width
-value as the first Rectangle element.
-
-\code
-Item {
- Rectangle {
- id: myRect
- width: 100
- height: 100
- }
- Rectangle {
- width: myRect.width
- height: 200
- }
-}
-\endcode
-
-Note that an \e id must begin with a lower-case letter or an underscore, and cannot contain characters other than letters, numbers and underscores.
-
-
-\section2 List properties
-
-List properties look like this:
-
-\code
-Item {
- children: [
- Image {},
- Text {}
- ]
-}
-\endcode
-
-The list is enclosed in square brackets, with a comma separating the
-list elements. In cases where you are only assigning a single item to a
-list, you can omit the square brackets:
-
-\code
-Image {
- children: Rectangle {}
-}
-\endcode
-
-\section2 Default properties
-
-Each object type can specify one of its list or object properties as its default property.
-If a property has been declared as the default property, the property tag can be omitted.
-
-For example this code:
-\code
-State {
- changes: [
- PropertyChanges {},
- PropertyChanges {}
- ]
-}
-\endcode
-
-can be simplified to:
-
-\code
-State {
- PropertyChanges {}
- PropertyChanges {}
-}
-\endcode
-
-because \c changes is the default property of the \c State type.
-
-\section2 Grouped Properties
-\target dot properties
-
-In some cases properties form a logical group and use a 'dot' or grouped notation
-to show this.
-
-Grouped properties can be written like this:
-\qml
-Text {
- font.pixelSize: 12
- font.bold: true
-}
-\endqml
-
-or like this:
-\qml
-Text {
- font { pixelSize: 12; bold: true }
-}
-\endqml
-
-In the element documentation grouped properties are shown using the 'dot' notation.
-
-\section2 Attached Properties
-\target attached-properties
-
-Some objects attach properties to another object. Attached Properties
-are of the form \e {Type.property} where \e Type is the type of the
-element that attaches \e property.
-
-For example:
-\code
-Component {
- id: myDelegate
- Text {
- text: "Hello"
- color: ListView.isCurrentItem ? "red" : "blue"
- }
-}
-ListView {
- delegate: myDelegate
-}
-\endcode
-
-The \l ListView element attaches the \e ListView.isCurrentItem property
-to each delegate it creates.
-
-Another example of attached properties is the \l Keys element which
-attaches properties for handling key presses to
-any visual Item, for example:
-
-\code
-Item {
- focus: true
- Keys.onSelectPressed: console.log("Selected")
-}
-\endcode
-
-\section2 Signal Handlers
-
-Signal handlers allow actions to be taken in reponse to an event. For instance,
-the \l MouseArea element has signal handlers to handle mouse press, release
-and click:
-
-\code
-MouseArea {
- onPressed: console.log("mouse button pressed")
-}
-\endcode
-
-All signal handlers begin with \e "on".
-
-Some signal handlers include an optional parameter, for example
-the MouseArea onPressed signal handler has a \e mouse parameter:
-
-\code
-MouseArea {
- acceptedButtons: Qt.LeftButton | Qt.RightButton
- onPressed: if (mouse.button == Qt.RightButton) console.log("Right mouse button pressed")
-}
-\endcode
-
-
-*/
diff --git a/doc/src/declarative/qmlmodels.qdoc b/doc/src/declarative/qmlmodels.qdoc
deleted file mode 100644
index 4843a7b..0000000
--- a/doc/src/declarative/qmlmodels.qdoc
+++ /dev/null
@@ -1,341 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qmlmodels.html
-\target qmlmodels
-\title Data Models
-
-Some QML Items use Data Models to provide the data to be displayed.
-These items typically require a \e delegate component that
-creates an instance for each item in the model. Models may be static, or
-have items modified, inserted, removed or moved dynamically.
-
-Data is provided to the delegate via named data roles which the
-delegate may bind to. The roles are exposed as properties of the
-\e model context property, though this property is set as a default property
-of the delegate so, unless there is a naming clash with a
-property in the delegate, the roles are usually accessed unqualified. The
-example below would have a clash between he \e color role of the model and
-the \e color property of the Rectangle. The clash is avoided by referencing
-the \e color property of the model by its full name: \e model.color.
-
-\code
-ListModel {
- id: myModel
- ListElement { color: "red" }
- ListElement { color: "green" }
-}
-
-Component {
- id: myDelegate
- Rectangle {
- width: 20; height: 20
- color: model.color
- }
-}
-\endcode
-
-A special \e index role containing the index of the item in the model
-is also available.
-
-\e Note: the index role will be set to -1 if the item is removed from
-the model. If you bind to the index role, be sure that the logic
-accounts for the possibility of index being -1, i.e. that the item
-is no longer valid. Usually the item will shortly be destroyed, but
-it is possible to delay delegate destruction in some views via a delayRemove
-attached property.
-
-Models that do not have named roles will have the data provided via
-the \e modelData role. The \e modelData role is also provided for
-Models that have only one role. In this case the \e modelData role
-contains the same data as the named role.
-
-There are a number of QML elements that operate using data models:
-
-\list
-\o ListView
-\o GridView
-\o PathView
-\o \l Repeater
-\endlist
-
-QML supports several types of data model, which may be provided by QML
-or C++ (via QmlContext::setContextProperty(), for example).
-
-\section1 QML Data Models
-
-\section2 ListModel
-
-ListModel is a simple hierarchy of elements specified in QML. The
-available roles are specified by the \l ListElement properties.
-
-\code
-ListModel {
- id: fruitModel
- ListElement {
- name: "Apple"
- cost: 2.45
- }
- ListElement {
- name: "Orange"
- cost: 3.25
- }
- ListElement {
- name: "Banana"
- cost: 1.95
- }
-}
-\endcode
-
-The above model has two roles, \e name and \e cost. These can be bound
-to by a ListView delegate, for example:
-
-\code
-Component {
- id: fruitDelegate
- Row {
- Text { text: "Fruit: " + name }
- Text { text: "Cost: $" + cost }
- }
-}
-ListView {
- model: fruitModel
- delegate: fruitDelegate
-}
-\endcode
-
-
-\section2 XmlListModel
-
-XmlListModel allows construction of a model from an XML data source. The roles
-are specified via the \l XmlRole element.
-
-The following model has three roles, \e title, \e link and \e description:
-\code
-XmlListModel {
- id: feedModel
- source: "http://rss.news.yahoo.com/rss/oceania"
- query: "/rss/channel/item"
- XmlRole { name: "title"; query: "title/string()" }
- XmlRole { name: "link"; query: "link/string()" }
- XmlRole { name: "description"; query: "description/string()" }
-}
-\endcode
-
-
-\section2 VisualItemModel
-
-VisualItemModel allows QML items to be provided as a model. This model contains
-both the data and delegate (its child items). This model does not provide any roles.
-
-\code
- VisualItemModel {
- id: itemModel
- Rectangle { height: 30; width: 80; color: "red" }
- Rectangle { height: 30; width: 80; color: "green" }
- Rectangle { height: 30; width: 80; color: "blue" }
- }
-
- ListView {
- anchors.fill: parent
- model: itemModel
- }
-\endcode
-
-Note that in the above example there is no delegate required.
-The items of the model itself provide the visual elements that
-will be positioned by the view.
-
-
-\section1 C++ Data Models
-
-\section2 QAbstractItemModel
-
-QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNames() method.
-
-
-\section2 QStringList
-
-QStringList provides the contents of the list via the \e modelData role:
-
-\table
-\header
-\o
-\o
-\row
-\o
-\code
-// main.cpp
-QStringList dataList;
-dataList.append("Fred");
-dataList.append("Ginger");
-dataList.appenf("Skipper");
-
-QmlContext *ctxt = view.rootContext();
-ctxt->setContextProperty("myModel", QVariant::fromValue(&dataList));
-\endcode
-
-\o
-\code
-// main.qml
-ListView {
- width: 100
- height: 100
- anchors.fill: parent
- model: myModel
- delegate: Component {
- Rectangle {
- height: 25
- Text { text: modelData }
- }
- }
-}
-\endcode
-\endtable
-
-\note There is no way for the view to know that the contents of a QStringList
-have changed. If the QStringList is changed, it will be necessary to reset
-the model by calling QmlContext::setContextProperty() again.
-
-
-\section2 QList<QObject*>
-
-QList<QObject*> provides the properties of the objects in the list as roles.
-
-\code
-class DataObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QString color READ color WRITE setColor)
-...
-};
-
-QList<QObject*> dataList;
-dataList.append(new DataObject("Item 1", "red"));
-dataList.append(new DataObject("Item 2", "green"));
-dataList.append(new DataObject("Item 3", "blue"));
-dataList.append(new DataObject("Item 4", "yellow"));
-
-QmlContext *ctxt = view.rootContext();
-ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
-\endcode
-
-The properties of the object may then be accessed in the delegate:
-
-\code
-ListView {
- width: 100
- height: 100
- anchors.fill: parent
- model: myModel
- delegate: Component {
- Rectangle {
- height: 25
- width: 100
- color: model.color
- Text { text: name }
- }
- }
-}
-\endcode
-
-Note: There is no way for the view to know that the contents of a QList
-have changed. If the QList is changed, it will be necessary to reset
-the model by calling QmlContext::setContextProperty() again.
-
-
-\section1 Other Data Models
-
-
-\section2 An Integer
-
-An Integer specifies a model containing the integer number of elements.
-There are no data roles.
-
-The following example creates a ListView with five elements:
-\code
-Component {
- id: itemDelegate
- Text { text: "I am item number: " + index }
-}
-ListView {
- model: 5
- delegate: itemDelegate
-}
-\endcode
-
-
-\section2 An Object Instance
-
-An Object Instance specifies a model with a single Object element. The
-properties of the object are provided as roles.
-
-The example below creates a list with one item, showing the color of the
-\e myText text. Note the use of the fully qualified \e model.color property
-to avoid clashing with \e color property of the Text element in the delegate.
-
-\code
-Rectangle {
- Text {
- id: myText
- text: "Hello"
- color: "#dd44ee"
- }
-
- Component {
- id: myDelegate
- Text {
- text: model.color
- }
- }
- ListView {
- anchors.fill: parent
- anchors.topMargin: 30
- model: myText
- delegate: myDelegate
- }
-}
-\endcode
-
-*/
diff --git a/doc/src/declarative/qmlreference.qdoc b/doc/src/declarative/qmlreference.qdoc
deleted file mode 100644
index 107d579..0000000
--- a/doc/src/declarative/qmlreference.qdoc
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \page qmlreference.html
- \title QML Reference
-
- \target qtdeclarativemainpage
-
- QML is a language for building the animation rich,
- highly fluid user interfaces that are becoming common in portable consumer
- electronics devices such as mobile phones, media players, set-top boxes and
- netbooks. It is also appropriate for highly custom desktop
- user interfaces, or special elements in more traditional desktop user interfaces.
-
- Building fluid applications is done declaratively, rather than procedurally.
- That is, you specify \e what the UI should look like and how it should behave
- rather than specifying step-by-step \e how to build it. Specifying a UI declaratively
- does not just include the layout of the interface items, but also the way each
- individual item looks and behaves and the overall flow of the application.
-
- The QML elements provide a sophisticated set of graphical and behavioral building
- blocks. These different elements are combined together in \l {QML Documents}{QML documents} to build components
- ranging in complexity from simple buttons and sliders, to complete
- internet-enabled applications like a \l {http://www.flickr.com}{Flickr} photo browser.
-
- Getting Started:
- \list
- \o \l {Introduction to the QML language}
- \o \l {QML Tutorial}{Tutorial: 'Hello World'}
- \o \l {QML Advanced Tutorial}{Advanced Tutorial: 'Same Game'}
- \o \l {QML Examples and Walkthroughs}
- \endlist
-
- \section1 Core QML Features:
- \list
- \o \l {QML Documents}
- \o \l {Property Binding}
- \o \l {JavaScript Blocks}
- \o \l {QML Scope}
- \o \l {Network Transparency}
- \o \l {qmlmodels}{Data Models}
- \o \l {anchor-layout}{Anchor-based Layout}
- \o \l {qmlstates}{States}
- \o \l {qmlanimation.html}{Animation}
- \o \l {qmlmodules.html}{Modules}
- \o \l {qmlfocus}{Keyboard Focus}
- \o \l {Extending types from QML}
- \endlist
-
- QML Reference:
- \list
- \o \l {elements}{QML Elements}
- \o \l {QML Global Object}
- \o \l {QML Internationalization}
- \endlist
-*/
diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc
new file mode 100644
index 0000000..6d3e109
--- /dev/null
+++ b/doc/src/declarative/qmlruntime.qdoc
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page qmlruntime.html
+ \title Qt Declarative UI Viewer (qmlviewer)
+ \ingroup qttools
+ \keyword qmlviewer
+
+ This page documents the \e{Declarative UI Viewer} for the Qt GUI
+ toolkit. The \c qmlviewer reads a declarative user interface definition
+ (\c .qml) file and displays the user interface it describes.
+
+ qmlviewer is a development tool. It is not intended to be
+ installed in a production environment.
+
+ \section1 Options
+
+ When run with the \c -help option, qmlviewer shows available options.
+
+ \section1 Dummy Data
+
+ One use of qmlviewer is to allow QML files to be viewed stand-alone,
+ rather than being loaded from within a Qt program. Qt applications will
+ usually bind objects and properties into the execution context before
+ running the QML. To stand-in for such bindings, you can provide dummy
+ data: create a directory called "dummydata" in the same directory as
+ the target QML file and create files there with the "qml" extension.
+ All such files will be loaded as QML objects and bound to the root
+ context as a property with the name of the file (without ".qml").
+
+ For example, if the Qt application has a "clock.time" property
+ that is a qreal from 0 to 86400 representing the number of seconds since
+ midnight, dummy data for this could be provided by \c dummydata/clock.qml:
+ \code
+ QtObject { property real time: 12345 }
+ \endcode
+ Any QML can be used in the dummy data files. You could even animate the
+ fictional data!
+
+ \section1 Screen Orientation
+
+ A special piece of dummy data which is integrated into the viewer is
+ a simple orientation property. The orientation can be set via the
+ settings menu in the application, or by pressing Ctrl+T to toggle it.
+
+ To use this from within your QML file, import QDeclarativeViewer 1.0 and create a
+ Screen object. This object has a property, orientation, which can be either
+ Screen.Landscape or Screen.Portrait and which can be bound to in your
+ application. An example is below:
+
+\code
+ import QDeclarativeViewer 1.0 as QDeclarativeViewer
+
+ Item {
+ QDeclarativeViewer.Screen { id: qmlviewerScreen }
+ state: (qmlviewerScreen.orientation == QDeclarativeViewer.Screen.Landscape) ? 'landscape' : ''
+ }
+\endcode
+
+*/
diff --git a/doc/src/declarative/qmlstates.qdoc b/doc/src/declarative/qmlstates.qdoc
deleted file mode 100644
index 2118c2b..0000000
--- a/doc/src/declarative/qmlstates.qdoc
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qmlstates.html
-\target qmlstates
-\title QML States
-
-\section1 Overview
-
-QML states typically describe user interface configurations, including:
-\list
-\o What UI elements are present
-\o The properties of those elements (including how they behave)
-\o What actions are available
-\endlist
-
-A state can also be thought of as a set of batched changes from a default configuration.
-
-Examples of states in modern UI:
-\list
-\o An Address Book application with a 'View Contact' state and an 'Edit Contact' State. In the first state the contact information presented is read-only (using labels), and in the second it is editable (using editors).
-\o A button with a pressed and unpressed state. When pressed the text moves slightly down and to the right, and the button has a slightly darker appearance.
-\endlist
-
-\section1 States in QML
-
-In QML:
-\list
-\o Any object can use states.
-\o There is a default state. The default state can be explicitly set.
-\o A state can affect the properties of other objects, not just the object owning the state (and not just that object's children).
-\endlist
-
-Here is an example of using states. In the default state \c myRect is positioned at 0,0. In the 'moved' state it is positioned at 50,50. Clicking within the mouse region changes the state from the default state to the 'moved' state, thus moving the rectangle.
-
-\qml
-Item {
- id: myItem
-
- Rectangle {
- id: myRect
- width: 100
- height: 100
- color: "red"
- }
-
- states: [
- State {
- name: "moved"
- PropertyChanges {
- target: myRect
- x: 50
- y: 50
- }
- }
- ]
-
- MouseArea {
- anchors.fill: parent
- onClicked: myItem.state = 'moved'
- }
-}
-\endqml
-
-State changes can be animated using \l{state-transitions}{Transitions}.
-
-For example, adding this code to the above \c {Item {}} element animates the transition to the "moved" state:
-
-\qml
- transitions: [
- Transition {
- NumberAnimation { properties: "x,y"; duration: 500 }
- }
- ]
-\endqml
-
-See \l{state-transitions}{Transitions} for more information.
-
-
-Other things you can do in a state change:
-\list
-\o override signal handlers with PropertyChanges
-\o change an item's visual parent with ParentChange
-\o change an item's anchors with AnchorChanges
-\o run some script with StateChangeScript
-\endlist
-
-*/
diff --git a/doc/src/declarative/qmlviewer.qdoc b/doc/src/declarative/qmlviewer.qdoc
deleted file mode 100644
index c2b29d3..0000000
--- a/doc/src/declarative/qmlviewer.qdoc
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \page qmlviewer.html
- \title Qt Declarative UI Viewer (qmlviewer)
- \ingroup qttools
- \keyword qmlviewer
-
- This page documents the \e{Declarative UI Viewer} for the Qt GUI
- toolkit. The \c qmlviewer reads a declarative user interface definition
- (\c .qml) file and displays the user interface it describes.
-
- qmlviewer is a development tool. It is not intended to be
- installed in a production environment.
-
- \section1 Options
-
- When run with the \c -help option, qmlviewer shows available options.
-
- \section1 Dummy Data
-
- One use of qmlviewer is to allow QML files to be viewed stand-alone,
- rather than being loaded from within a Qt program. Qt applications will
- usually bind objects and properties into the execution context before
- running the QML. To stand-in for such bindings, you can provide dummy
- data: create a directory called "dummydata" in the same directory as
- the target QML file and create files there with the "qml" extension.
- All such files will be loaded as QML objects and bound to the root
- context as a property with the name of the file (without ".qml").
-
- For example, if the Qt application has a "clock.time" property
- that is a qreal from 0 to 86400 representing the number of seconds since
- midnight, dummy data for this could be provided by \c dummydata/clock.qml:
- \code
- QtObject { property real time: 12345 }
- \endcode
- Any QML can be used in the dummy data files. You could even animate the
- fictional data!
-
- \section1 Screen Orientation
-
- A special piece of dummy data which is integrated into the viewer is
- a simple orientation property. The orientation can be set via the
- settings menu in the application, or by pressing Ctrl+T to toggle it.
-
- To use this from within your QML file, import QmlViewer 1.0 and create a
- Screen object. This object has a property, orientation, which can be either
- Screen.Landscape or Screen.Portrait and which can be bound to in your
- application. An example is below:
-
-\code
- import QmlViewer 1.0 as QmlViewer
-
- Item {
- QmlViewer.Screen { id: qmlviewerScreen }
- state: (qmlviewerScreen.orientation == QmlViewer.Screen.Landscape) ? 'landscape' : ''
- }
-\endcode
-
-*/
diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc
index 732ff86..66d537d 100644
--- a/doc/src/declarative/qtbinding.qdoc
+++ b/doc/src/declarative/qtbinding.qdoc
@@ -46,50 +46,50 @@
\tableofcontents
-The QML API is split into three main classes - QmlEngine, QmlComponent and QmlContext.
-QmlEngine provides the environment in which QML is run, QmlComponent encapsulates
-\l {QML Documents}, and QmlContext allows applications to expose data to QML component instances.
+The QML API is split into three main classes - QDeclarativeEngine, QDeclarativeComponent and QDeclarativeContext.
+QDeclarativeEngine provides the environment in which QML is run, QDeclarativeComponent encapsulates
+\l {QML Documents}, and QDeclarativeContext allows applications to expose data to QML component instances.
-QML also includes a convenience API, QmlView, for applications that simply want to embed QML
-components into a new QGraphicsView. QmlView covers up many of the details discussed below.
-While QmlView is mainly intended for rapid prototyping it can have uses in production applications.
+QML also includes a convenience API, QDeclarativeView, for applications that simply want to embed QML
+components into a new QGraphicsView. QDeclarativeView covers up many of the details discussed below.
+While QDeclarativeView is mainly intended for rapid prototyping it can have uses in production applications.
If you are looking at retrofitting an existing Qt application with QML,
read \l{Integrating QML with existing Qt UI code}.
\section1 Basic Usage
-Every application requires at least one QmlEngine. A QmlEngine allows the configuration of
+Every application requires at least one QDeclarativeEngine. A QDeclarativeEngine allows the configuration of
global settings that apply to all the QML component instances - such as the QNetworkAccessManager
that is used for network communications, and the path used for persistent storage.
-Multiple QmlEngine's are only needed if the application requires these settings to differ
+Multiple QDeclarativeEngine's are only needed if the application requires these settings to differ
between QML component instances.
-\l {QML Documents} are loaded using the QmlComponent class. Each QmlComponent instance
-represents a single QML document. A QmlComponent can be passed a document URL, or raw text
+\l {QML Documents} are loaded using the QDeclarativeComponent class. Each QDeclarativeComponent instance
+represents a single QML document. A QDeclarativeComponent can be passed a document URL, or raw text
representing the content of the document. The document URL can be a local filesystem URL, or
any network URL supported by QNetworkAccessManager.
-QML component instances can then be created by calling the QmlComponent::create() method. Here's
+QML component instances can then be created by calling the QDeclarativeComponent::create() method. Here's
an example of loading a QML document, and creating an object from it.
\code
-QmlEngine *engine = new QmlEngine(parent);
-QmlComponent component(engine, QUrl("main.qml"));
+QDeclarativeEngine *engine = new QDeclarativeEngine(parent);
+QDeclarativeComponent component(engine, QUrl("main.qml"));
QObject *myObject = component.create();
\endcode
\section1 Exposing Data
-QML components are instantiated in a QmlContext. A context allows the application to expose data
-to the QML component instance. A single QmlContext can be used to instantiate all the objects
-used by an application, or several QmlContext can be created for more fine grained control over
-the data exposed to each instance. If a context is not passed to the QmlComponent::create()
-method, the QmlEngine's \l {QmlEngine::rootContext()}{root context} is used. Data exposed through
+QML components are instantiated in a QDeclarativeContext. A context allows the application to expose data
+to the QML component instance. A single QDeclarativeContext can be used to instantiate all the objects
+used by an application, or several QDeclarativeContext can be created for more fine grained control over
+the data exposed to each instance. If a context is not passed to the QDeclarativeComponent::create()
+method, the QDeclarativeEngine's \l {QDeclarativeEngine::rootContext()}{root context} is used. Data exposed through
the root context is available to all object instances.
\section1 Simple Data
-To expose data to a QML component instance, applications set \l {QmlContext::setContextProperty()}
+To expose data to a QML component instance, applications set \l {QDeclarativeContext::setContextProperty()}
{context properties} which are then accessible by name from QML \l {Property Binding}s and
\l {JavaScript Blocks}. The following example shows how to expose a background color to a QML
file.
@@ -99,11 +99,11 @@ file.
\o
\code
// main.cpp
-QmlContext *windowContext = new QmlContext(engine->rootContext());
+QDeclarativeContext *windowContext = new QDeclarativeContext(engine->rootContext());
windowContext->setContextProperty("backgroundColor",
QColor(Qt::lightsteelblue));
-QmlComponent component(&engine, "main.qml");
+QDeclarativeComponent component(&engine, "main.qml");
QObject *window = component.create(windowContext);
\endcode
\o
@@ -125,14 +125,14 @@ Rectangle {
Context properties work just like normal properties in QML bindings - if the \c backgroundColor
context property in the previous example was changed to red, the component object instances would
all be automatically updated. Note that it is the responsibility of the creator to delete any
-QmlContext it constructs. If the \c windowContext in the example above is no longer needed when
+QDeclarativeContext it constructs. If the \c windowContext in the example above is no longer needed when
the \c window component instantiation is destroyed, the \c windowContext must be destroyed
explicitly. The simplest way to ensure this is to set \c window as \c windowContext's parent.
-QmlContexts form a tree - each QmlContext except for the root context has a parent. Child
-QmlContexts effectively inherit the context properties present in their parents. This gives
+QDeclarativeContexts form a tree - each QDeclarativeContext except for the root context has a parent. Child
+QDeclarativeContexts effectively inherit the context properties present in their parents. This gives
applications more freedom in partitioning the data exposed to different QML object instances.
-If a QmlContext sets a context property that is also set in one of its parents, the new context
+If a QDeclarativeContext sets a context property that is also set in one of its parents, the new context
property shadows that in the parent. In The following example, the \c background context property
in \c {Context 1} shadows the \c background context property in the root context.
@@ -185,10 +185,10 @@ int main(int argc, char **argv)
{
// ...
- QmlContext *windowContext = new QmlContext(engine->rootContext());
+ QDeclarativeContext *windowContext = new QDeclarativeContext(engine->rootContext());
windowContext->setContextProperty("palette", new CustomPalette);
- QmlComponent component(&engine, "main.qml");
+ QDeclarativeComponent component(&engine, "main.qml");
QObject *window = component.create(windowContext);
}
\endcode
@@ -230,7 +230,7 @@ binding that does not have a NOTIFY signal will cause QML to issue a warning at
\section2 Dynamic Structured Data
If an application is too dynamic to structure data as compile-time QObject types, dynamically
-structured data can be constructed at runtime using the QmlPropertyMap class.
+structured data can be constructed at runtime using the QDeclarativePropertyMap class.
\section1 Calling C++ methods from QML
@@ -279,7 +279,7 @@ int main(int argc, char **argv)
{
// ...
- QmlContext *context = engine->rootContext();
+ QDeclarativeContext *context = engine->rootContext();
context->setContextProperty("ledBlinker", new LEDBlinker);
// ...
@@ -329,15 +329,15 @@ Of course, it is also possible to call \l {Adding new methods}{functions declare
\section1 Network Components
-If the URL passed to QmlComponent is a network resource, or if the QML document references a
-network resource, the QmlComponent has to fetch the network data before it is able to create
-objects. In this case, the QmlComponent will have a \l {QmlComponent::Loading}{Loading}
-\l {QmlComponent::status()}{status}. An application will have to wait until the component
-is \l {QmlComponent::Ready}{Ready} before calling \l {QmlComponent::create()}.
+If the URL passed to QDeclarativeComponent is a network resource, or if the QML document references a
+network resource, the QDeclarativeComponent has to fetch the network data before it is able to create
+objects. In this case, the QDeclarativeComponent will have a \l {QDeclarativeComponent::Loading}{Loading}
+\l {QDeclarativeComponent::status()}{status}. An application will have to wait until the component
+is \l {QDeclarativeComponent::Ready}{Ready} before calling \l {QDeclarativeComponent::create()}.
The following example shows how to load a QML file from a network resource. After creating
-the QmlComponent, it tests whether the component is loading. If it is, it connects to the
-QmlComponent::statusChanged() signal and otherwise calls the \c {continueLoading()} method
+the QDeclarativeComponent, it tests whether the component is loading. If it is, it connects to the
+QDeclarativeComponent::statusChanged() signal and otherwise calls the \c {continueLoading()} method
directly. This test is necessary, even for URLs that are known to be remote, just in case
the component has been cached and is ready immediately.
@@ -345,9 +345,9 @@ the component has been cached and is ready immediately.
MyApplication::MyApplication()
{
// ...
- component = new QmlComponent(engine, QUrl("http://www.example.com/main.qml"));
+ component = new QDeclarativeComponent(engine, QUrl("http://www.example.com/main.qml"));
if (component->isLoading())
- QObject::connect(component, SIGNAL(statusChanged(QmlComponent::Status)),
+ QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
this, SLOT(continueLoading()));
else
continueLoading();
@@ -381,7 +381,7 @@ For example:
MyApplication::MyApplication()
{
// ...
- component = new QmlComponent(engine, QUrl("qrc:/main.qml"));
+ component = new QDeclarativeComponent(engine, QUrl("qrc:/main.qml"));
if (component->isError()) {
qWarning() << component->errors();
} else {
diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc
index 343359c..ca1d596 100644
--- a/doc/src/declarative/qtprogrammers.qdoc
+++ b/doc/src/declarative/qtprogrammers.qdoc
@@ -61,7 +61,7 @@ QML provides direct access to the following concepts from Qt:
\o QAction - the \l {QML Basic Types}{action} type
\o QObject signals and slots - available as functions to call in JavaScript
\o QObject properties - available as variables in JavaScript
- \o QWidget - QmlView is a QML-displaying widget
+ \o QWidget - QDeclarativeView is a QML-displaying widget
\o Qt models - used directly in data binding (QAbstractItemModel and next generation QListModelInterface)
\endlist
@@ -84,14 +84,14 @@ QML Items also serve these purposes. Each is considered separately below.
\section2 Simple Widgets
-The most important rule to remember while implementing a new QmlGraphicsItem in C++
+The most important rule to remember while implementing a new QDeclarativeItem in C++
is that it should not contain any look and feel policies - leave that to the
QML usage of the item.
As an example, imagine you wanted a reusable Button item. If you therefore
-decided to write a QmlGraphicsItem subclass to implement a button,
+decided to write a QDeclarativeItem subclass to implement a button,
just as QToolButton subclasses QWidget for this purpose, following the rule above, your
-\c QmlGraphicsButton would not have any appearance - just the notions of enabled, triggering, etc.
+\c QDeclarativeButton would not have any appearance - just the notions of enabled, triggering, etc.
But there is already an object in Qt that does this: QAction.
@@ -103,13 +103,13 @@ The look and feel of an action - the appearance of the button, the transition be
and exactly how it respond to mouse, key, or touch input, should all be left for definition
in QML.
-It is illustrative to note that QmlGraphicsTextEdit is built upon QTextControl,
-QmlGraphicsWebView is built upon QWebPage, and ListView uses QListModelInterface,
+It is illustrative to note that QDeclarativeTextEdit is built upon QTextControl,
+QDeclarativeWebView is built upon QWebPage, and ListView uses QListModelInterface,
just as QTextEdit, QWebView, and QListView are built upon
those same UI-agnostic components.
The encapsulation of the look and feel that QWidgets gives is important, and for this
-the QML concept of \l {qmldocuments.html}{components} serves the same purpose. If you are building a complete
+the QML concept of \l {qdeclarativedocuments.html}{components} serves the same purpose. If you are building a complete
suite of applications which should have a consistent look and feel, you should build
a set of reusable components with the look and feel you desire.
diff --git a/doc/src/declarative/scope.qdoc b/doc/src/declarative/scope.qdoc
index f709335..218af89 100644
--- a/doc/src/declarative/scope.qdoc
+++ b/doc/src/declarative/scope.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\page qmlscope.html
+\page qdeclarativescope.html
\title QML Scope
\tableofcontents
@@ -348,14 +348,14 @@ Item {
}
\endcode
-\section1 QmlContext chain
+\section1 QDeclarativeContext chain
-The \l QmlContext chain allows C++ applications to pass data into QML applications.
-\l QmlComponent object instances created from C++ are passed a \l QmlContext in which they
-are created. Variables defined in this context appear in the scope chain. Each QmlContext
-also defines a parent context. Variables in child QmlContext's shadow those in its parent.
+The \l QDeclarativeContext chain allows C++ applications to pass data into QML applications.
+\l QDeclarativeComponent object instances created from C++ are passed a \l QDeclarativeContext in which they
+are created. Variables defined in this context appear in the scope chain. Each QDeclarativeContext
+also defines a parent context. Variables in child QDeclarativeContext's shadow those in its parent.
-Consider the following QmlContext tree.
+Consider the following QDeclarativeContext tree.
\image qml-context-tree.png
diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp
index 0aeeecf..76e0736 100644
--- a/examples/declarative/extending/adding/main.cpp
+++ b/examples/declarative/extending/adding/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "person.h"
@@ -50,8 +50,8 @@ int main(int argc, char ** argv)
QML_REGISTER_TYPE(People, 1,0, Person, Person);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
Person *person = qobject_cast<Person *>(component.create());
if (person) {
qWarning() << "The person's name is" << person->name();
diff --git a/examples/declarative/extending/adding/person.h b/examples/declarative/extending/adding/person.h
index 691766b..fbaf2df 100644
--- a/examples/declarative/extending/adding/person.h
+++ b/examples/declarative/extending/adding/person.h
@@ -43,7 +43,7 @@
#include <QObject>
// ![0]
-#include <qml.h>
+#include <qdeclarative.h>
class Person : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/attached/birthdayparty.cpp b/examples/declarative/extending/attached/birthdayparty.cpp
index 293628e..d4f2675 100644
--- a/examples/declarative/extending/attached/birthdayparty.cpp
+++ b/examples/declarative/extending/attached/birthdayparty.cpp
@@ -70,9 +70,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/declarative/extending/attached/birthdayparty.h b/examples/declarative/extending/attached/birthdayparty.h
index 9ba0f8b..d8ca2e1 100644
--- a/examples/declarative/extending/attached/birthdayparty.h
+++ b/examples/declarative/extending/attached/birthdayparty.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QDate>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -65,7 +65,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -73,7 +73,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/attached/main.cpp b/examples/declarative/extending/attached/main.cpp
index f4223a2..684d8d3 100644
--- a/examples/declarative/extending/attached/main.cpp
+++ b/examples/declarative/extending/attached/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -56,8 +56,8 @@ int main(int argc, char ** argv)
QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/attached/person.h b/examples/declarative/extending/attached/person.h
index dd03091..0f86d8b 100644
--- a/examples/declarative/extending/attached/person.h
+++ b/examples/declarative/extending/attached/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/binding/birthdayparty.cpp b/examples/declarative/extending/binding/birthdayparty.cpp
index 392c59a..e5be2b9 100644
--- a/examples/declarative/extending/binding/birthdayparty.cpp
+++ b/examples/declarative/extending/binding/birthdayparty.cpp
@@ -76,9 +76,9 @@ void BirthdayParty::setCelebrant(Person *c)
emit celebrantChanged();
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/declarative/extending/binding/birthdayparty.h b/examples/declarative/extending/binding/birthdayparty.h
index 8bdb76a..8486442 100644
--- a/examples/declarative/extending/binding/birthdayparty.h
+++ b/examples/declarative/extending/binding/birthdayparty.h
@@ -44,7 +44,7 @@
#include <QObject>
#include <QDate>
#include <QDebug>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -71,7 +71,7 @@ Q_OBJECT
// ![0]
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant NOTIFY celebrantChanged)
// ![0]
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker)
Q_CLASSINFO("DefaultProperty", "guests")
public:
@@ -80,7 +80,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/binding/happybirthday.cpp b/examples/declarative/extending/binding/happybirthday.cpp
index 704d384..7d4d021 100644
--- a/examples/declarative/extending/binding/happybirthday.cpp
+++ b/examples/declarative/extending/binding/happybirthday.cpp
@@ -50,7 +50,7 @@ HappyBirthday::HappyBirthday(QObject *parent)
timer->start(1000);
}
-void HappyBirthday::setTarget(const QmlMetaProperty &p)
+void HappyBirthday::setTarget(const QDeclarativeMetaProperty &p)
{
m_target = p;
}
diff --git a/examples/declarative/extending/binding/happybirthday.h b/examples/declarative/extending/binding/happybirthday.h
index 852bec7..ee4d1ec 100644
--- a/examples/declarative/extending/binding/happybirthday.h
+++ b/examples/declarative/extending/binding/happybirthday.h
@@ -41,20 +41,20 @@
#ifndef HAPPYBIRTHDAY_H
#define HAPPYBIRTHDAY_H
-#include <QmlPropertyValueSource>
-#include <QmlMetaProperty>
-#include <qml.h>
+#include <QDeclarativePropertyValueSource>
+#include <QDeclarativeMetaProperty>
+#include <qdeclarative.h>
#include <QStringList>
-class HappyBirthday : public QObject, public QmlPropertyValueSource
+class HappyBirthday : public QObject, public QDeclarativePropertyValueSource
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
public:
HappyBirthday(QObject *parent = 0);
- virtual void setTarget(const QmlMetaProperty &);
+ virtual void setTarget(const QDeclarativeMetaProperty &);
QString name() const;
void setName(const QString &);
@@ -67,7 +67,7 @@ signals:
private:
int m_line;
QStringList m_lyrics;
- QmlMetaProperty m_target;
+ QDeclarativeMetaProperty m_target;
QString m_name;
};
QML_DECLARE_TYPE(HappyBirthday);
diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp
index ea0e33a..873f8c9 100644
--- a/examples/declarative/extending/binding/main.cpp
+++ b/examples/declarative/extending/binding/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "happybirthday.h"
@@ -58,8 +58,8 @@ int main(int argc, char ** argv)
QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/binding/person.h b/examples/declarative/extending/binding/person.h
index e8aa6a8..1bec71c 100644
--- a/examples/declarative/extending/binding/person.h
+++ b/examples/declarative/extending/binding/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/coercion/birthdayparty.cpp b/examples/declarative/extending/coercion/birthdayparty.cpp
index f0eb599..523a42d 100644
--- a/examples/declarative/extending/coercion/birthdayparty.cpp
+++ b/examples/declarative/extending/coercion/birthdayparty.cpp
@@ -55,9 +55,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/declarative/extending/coercion/birthdayparty.h b/examples/declarative/extending/coercion/birthdayparty.h
index 5a9eb08..fffd407 100644
--- a/examples/declarative/extending/coercion/birthdayparty.h
+++ b/examples/declarative/extending/coercion/birthdayparty.h
@@ -42,7 +42,7 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayParty : public QObject
@@ -50,7 +50,7 @@ class BirthdayParty : public QObject
Q_OBJECT
// ![0]
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
// ![0]
public:
BirthdayParty(QObject *parent = 0);
@@ -58,7 +58,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp
index b1a203f..1e2209f 100644
--- a/examples/declarative/extending/coercion/main.cpp
+++ b/examples/declarative/extending/coercion/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -56,8 +56,8 @@ int main(int argc, char ** argv)
QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/coercion/person.h b/examples/declarative/extending/coercion/person.h
index 9bb9a3d..298ffb1 100644
--- a/examples/declarative/extending/coercion/person.h
+++ b/examples/declarative/extending/coercion/person.h
@@ -42,7 +42,7 @@
#define PERSON_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
class Person : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/default/birthdayparty.cpp b/examples/declarative/extending/default/birthdayparty.cpp
index f0eb599..523a42d 100644
--- a/examples/declarative/extending/default/birthdayparty.cpp
+++ b/examples/declarative/extending/default/birthdayparty.cpp
@@ -55,9 +55,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/declarative/extending/default/birthdayparty.h b/examples/declarative/extending/default/birthdayparty.h
index f25f8c2..49c20bd 100644
--- a/examples/declarative/extending/default/birthdayparty.h
+++ b/examples/declarative/extending/default/birthdayparty.h
@@ -42,7 +42,7 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
// ![0]
@@ -50,7 +50,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -58,7 +58,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/default/main.cpp b/examples/declarative/extending/default/main.cpp
index ea51e00..7d7f8a1 100644
--- a/examples/declarative/extending/default/main.cpp
+++ b/examples/declarative/extending/default/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -54,8 +54,8 @@ int main(int argc, char ** argv)
QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/default/person.h b/examples/declarative/extending/default/person.h
index 884dda3..b3eceaa 100644
--- a/examples/declarative/extending/default/person.h
+++ b/examples/declarative/extending/default/person.h
@@ -42,7 +42,7 @@
#define PERSON_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
class Person : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/extended/lineedit.cpp b/examples/declarative/extending/extended/lineedit.cpp
index 0d8eb7f..417fbd9 100644
--- a/examples/declarative/extending/extended/lineedit.cpp
+++ b/examples/declarative/extending/extended/lineedit.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "lineedit.h"
-#include <qml.h>
+#include <qdeclarative.h>
LineEditExtension::LineEditExtension(QObject *object)
: QObject(object), m_lineedit(static_cast<QLineEdit *>(object))
diff --git a/examples/declarative/extending/extended/main.cpp b/examples/declarative/extending/extended/main.cpp
index ad4bf50..5cbeea3 100644
--- a/examples/declarative/extending/extended/main.cpp
+++ b/examples/declarative/extending/extended/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include <QLineEdit>
#include "lineedit.h"
@@ -51,8 +51,8 @@ int main(int argc, char ** argv)
QML_REGISTER_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
QLineEdit *edit = qobject_cast<QLineEdit *>(component.create());
if (edit) {
diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp
index f0eb599..523a42d 100644
--- a/examples/declarative/extending/grouped/birthdayparty.cpp
+++ b/examples/declarative/extending/grouped/birthdayparty.cpp
@@ -55,9 +55,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/declarative/extending/grouped/birthdayparty.h b/examples/declarative/extending/grouped/birthdayparty.h
index fd0d955..42439c4 100644
--- a/examples/declarative/extending/grouped/birthdayparty.h
+++ b/examples/declarative/extending/grouped/birthdayparty.h
@@ -42,14 +42,14 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -57,7 +57,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp
index a8dafd9..15a0bb5 100644
--- a/examples/declarative/extending/grouped/main.cpp
+++ b/examples/declarative/extending/grouped/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -55,8 +55,8 @@ int main(int argc, char ** argv)
QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/grouped/person.h b/examples/declarative/extending/grouped/person.h
index 89ccedc..5dab378 100644
--- a/examples/declarative/extending/grouped/person.h
+++ b/examples/declarative/extending/grouped/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/properties/birthdayparty.cpp b/examples/declarative/extending/properties/birthdayparty.cpp
index 2fbdad9..14fd6a3 100644
--- a/examples/declarative/extending/properties/birthdayparty.cpp
+++ b/examples/declarative/extending/properties/birthdayparty.cpp
@@ -56,9 +56,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/declarative/extending/properties/birthdayparty.h b/examples/declarative/extending/properties/birthdayparty.h
index e5d316c..c4cb536 100644
--- a/examples/declarative/extending/properties/birthdayparty.h
+++ b/examples/declarative/extending/properties/birthdayparty.h
@@ -42,7 +42,7 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
// ![0]
@@ -54,7 +54,7 @@ Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
// ![1]
// ![2]
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
// ![2]
// ![3]
public:
@@ -63,7 +63,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/properties/main.cpp b/examples/declarative/extending/properties/main.cpp
index 2211b89..ce69ad2 100644
--- a/examples/declarative/extending/properties/main.cpp
+++ b/examples/declarative/extending/properties/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -52,8 +52,8 @@ int main(int argc, char ** argv)
QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
QML_REGISTER_TYPE(People, 1,0, Person, Person);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/properties/person.h b/examples/declarative/extending/properties/person.h
index 8d665f0..860a607 100644
--- a/examples/declarative/extending/properties/person.h
+++ b/examples/declarative/extending/properties/person.h
@@ -42,7 +42,7 @@
#define PERSON_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
class Person : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/signal/birthdayparty.cpp b/examples/declarative/extending/signal/birthdayparty.cpp
index d57e075..65ff530 100644
--- a/examples/declarative/extending/signal/birthdayparty.cpp
+++ b/examples/declarative/extending/signal/birthdayparty.cpp
@@ -71,9 +71,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/declarative/extending/signal/birthdayparty.h b/examples/declarative/extending/signal/birthdayparty.h
index 30ed43b..bcdc513 100644
--- a/examples/declarative/extending/signal/birthdayparty.h
+++ b/examples/declarative/extending/signal/birthdayparty.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QDate>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -65,7 +65,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -73,7 +73,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/signal/main.cpp b/examples/declarative/extending/signal/main.cpp
index 9d8e253..afc1a66 100644
--- a/examples/declarative/extending/signal/main.cpp
+++ b/examples/declarative/extending/signal/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -56,8 +56,8 @@ int main(int argc, char ** argv)
QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/signal/person.h b/examples/declarative/extending/signal/person.h
index dd03091..0f86d8b 100644
--- a/examples/declarative/extending/signal/person.h
+++ b/examples/declarative/extending/signal/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/valuesource/birthdayparty.cpp b/examples/declarative/extending/valuesource/birthdayparty.cpp
index 5b3fec1..99d98be 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.cpp
+++ b/examples/declarative/extending/valuesource/birthdayparty.cpp
@@ -71,9 +71,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h
index b5a0522..819a200 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.h
+++ b/examples/declarative/extending/valuesource/birthdayparty.h
@@ -44,7 +44,7 @@
#include <QObject>
#include <QDate>
#include <QDebug>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -66,7 +66,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
// ![0]
Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker)
// ![0]
@@ -77,7 +77,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/valuesource/happybirthday.cpp b/examples/declarative/extending/valuesource/happybirthday.cpp
index 306ec98..7b9d05a 100644
--- a/examples/declarative/extending/valuesource/happybirthday.cpp
+++ b/examples/declarative/extending/valuesource/happybirthday.cpp
@@ -50,7 +50,7 @@ HappyBirthday::HappyBirthday(QObject *parent)
timer->start(1000);
}
-void HappyBirthday::setTarget(const QmlMetaProperty &p)
+void HappyBirthday::setTarget(const QDeclarativeMetaProperty &p)
{
m_target = p;
}
diff --git a/examples/declarative/extending/valuesource/happybirthday.h b/examples/declarative/extending/valuesource/happybirthday.h
index c02a7d7..44f55e4 100644
--- a/examples/declarative/extending/valuesource/happybirthday.h
+++ b/examples/declarative/extending/valuesource/happybirthday.h
@@ -41,13 +41,13 @@
#ifndef HAPPYBIRTHDAY_H
#define HAPPYBIRTHDAY_H
-#include <QmlPropertyValueSource>
-#include <qml.h>
+#include <QDeclarativePropertyValueSource>
+#include <qdeclarative.h>
#include <QStringList>
// ![0]
-class HappyBirthday : public QObject, public QmlPropertyValueSource
+class HappyBirthday : public QObject, public QDeclarativePropertyValueSource
{
Q_OBJECT
// ![0]
@@ -56,7 +56,7 @@ Q_PROPERTY(QString name READ name WRITE setName)
public:
HappyBirthday(QObject *parent = 0);
- virtual void setTarget(const QmlMetaProperty &);
+ virtual void setTarget(const QDeclarativeMetaProperty &);
// ![1]
QString name() const;
@@ -68,7 +68,7 @@ private slots:
private:
int m_line;
QStringList m_lyrics;
- QmlMetaProperty m_target;
+ QDeclarativeMetaProperty m_target;
QString m_name;
// ![2]
};
diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp
index ea0e33a..873f8c9 100644
--- a/examples/declarative/extending/valuesource/main.cpp
+++ b/examples/declarative/extending/valuesource/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "happybirthday.h"
@@ -58,8 +58,8 @@ int main(int argc, char ** argv)
QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/valuesource/person.h b/examples/declarative/extending/valuesource/person.h
index dd03091..0f86d8b 100644
--- a/examples/declarative/extending/valuesource/person.h
+++ b/examples/declarative/extending/valuesource/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT
diff --git a/examples/declarative/imageprovider/main.cpp b/examples/declarative/imageprovider/main.cpp
index eaaded2..d9d4c1a 100644
--- a/examples/declarative/imageprovider/main.cpp
+++ b/examples/declarative/imageprovider/main.cpp
@@ -41,22 +41,22 @@
#include <QApplication>
-#include <qmlengine.h>
-#include <qmlcontext.h>
-#include <qml.h>
-#include <qmlgraphicsitem.h>
-#include <qmlimageprovider.h>
-#include <qmlview.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarative.h>
+#include <qdeclarativeitem.h>
+#include <qdeclarativeimageprovider.h>
+#include <qdeclarativeview.h>
#include <QImage>
#include <QPainter>
/*
- This example illustrates using a QmlImageProvider to serve
+ This example illustrates using a QDeclarativeImageProvider to serve
images asynchronously.
*/
//![0]
-class ColorImageProvider : public QmlImageProvider
+class ColorImageProvider : public QDeclarativeImageProvider
{
public:
// This is run in a low priority thread.
@@ -74,7 +74,7 @@ int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- QmlView view;
+ QDeclarativeView view;
view.engine()->addImageProvider("colors", new ColorImageProvider);
@@ -87,7 +87,7 @@ int main(int argc, char ** argv)
dataList.append("image://colors/purple");
dataList.append("image://colors/yellow");
- QmlContext *ctxt = view.rootContext();
+ QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
view.setSource(QUrl("qrc:view.qml"));
diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp
index 7ea742b..b210570 100644
--- a/examples/declarative/objectlistmodel/main.cpp
+++ b/examples/declarative/objectlistmodel/main.cpp
@@ -41,11 +41,11 @@
#include <QApplication>
-#include <qmlengine.h>
-#include <qmlcontext.h>
-#include <qml.h>
-#include <qmlgraphicsitem.h>
-#include <qmlview.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarative.h>
+#include <qdeclarativeitem.h>
+#include <qdeclarativeview.h>
#include "dataobject.h"
@@ -58,7 +58,7 @@ int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- QmlView view;
+ QDeclarativeView view;
QList<QObject*> dataList;
dataList.append(new DataObject("Item 1", "red"));
@@ -66,7 +66,7 @@ int main(int argc, char ** argv)
dataList.append(new DataObject("Item 3", "blue"));
dataList.append(new DataObject("Item 4", "yellow"));
- QmlContext *ctxt = view.rootContext();
+ QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
view.setSource(QUrl("qrc:view.qml"));
diff --git a/examples/declarative/plugins/plugin.cpp b/examples/declarative/plugins/plugin.cpp
index 8e21263..f6385d0 100644
--- a/examples/declarative/plugins/plugin.cpp
+++ b/examples/declarative/plugins/plugin.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include <QtDeclarative/QmlExtensionPlugin>
-#include <QtDeclarative/qml.h>
+#include <QtDeclarative/QDeclarativeExtensionPlugin>
+#include <QtDeclarative/qdeclarative.h>
#include <qdebug.h>
#include <qdatetime.h>
#include <qbasictimer.h>
@@ -140,11 +140,11 @@ MinuteTimer *Time::timer=0;
QML_DECLARE_TYPE(Time);
-class QExampleQmlPlugin : public QmlExtensionPlugin
+class QExampleQmlPlugin : public QDeclarativeExtensionPlugin
{
Q_OBJECT
public:
- void initialize(QmlEngine *engine, const char *uri)
+ void initialize(QDeclarativeEngine *engine, const char *uri)
{
Q_UNUSED(engine);
Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample"));
diff --git a/examples/declarative/plugins/plugins.pro b/examples/declarative/plugins/plugins.pro
index c9c9f7e..c925cea 100644
--- a/examples/declarative/plugins/plugins.pro
+++ b/examples/declarative/plugins/plugins.pro
@@ -7,21 +7,21 @@ VERSION = 1.0.0
SOURCES += plugin.cpp
-qmlsources.files += \
- com/nokia/TimeExample/qmldir \
+qdeclarativesources.files += \
+ com/nokia/TimeExample/qdeclarativedir \
com/nokia/TimeExample/center.png \
com/nokia/TimeExample/clock.png \
com/nokia/TimeExample/Clock.qml \
com/nokia/TimeExample/hour.png \
com/nokia/TimeExample/minute.png
-qmlsources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample
sources.files += plugins.pro plugin.cpp plugins.qml
sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins
target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample
-INSTALLS += qmlsources sources target
+INSTALLS += qdeclarativesources sources target
symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml
index 96e0675..277dfeb 100644
--- a/examples/declarative/sql/hello.qml
+++ b/examples/declarative/sql/hello.qml
@@ -3,7 +3,7 @@ import Qt 4.6
Text {
Script {
function findGreetings() {
- var db = openDatabaseSync("QmlExampleDB", "1.0", "The Example QML SQL!", 1000000);
+ var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000);
db.transaction(
function(tx) {
diff --git a/examples/declarative/webview/qml-in-html.qml b/examples/declarative/webview/qdeclarative-in-html.qml
index a2f2f2a..a2f2f2a 100644
--- a/examples/declarative/webview/qml-in-html.qml
+++ b/examples/declarative/webview/qdeclarative-in-html.qml
diff --git a/src/declarative/3rdparty/qlistmodelinterface.cpp b/src/declarative/3rdparty/qlistmodelinterface.cpp
index 939e985..50714ce 100644
--- a/src/declarative/3rdparty/qlistmodelinterface.cpp
+++ b/src/declarative/3rdparty/qlistmodelinterface.cpp
@@ -46,11 +46,11 @@ QT_BEGIN_NAMESPACE
/*!
\internal
\class QListModelInterface
- \brief The QListModelInterface class can be subclassed to provide C++ models to QmlGraphics Views
+ \brief The QListModelInterface class can be subclassed to provide C++ models to QDeclarativeGraphics Views
This class is comprised primarily of pure virtual functions which
you must implement in a subclass. You can then use the subclass
- as a model for a QmlGraphics view, such as a QmlGraphicsListView.
+ as a model for a QDeclarativeGraphics view, such as a QDeclarativeListView.
*/
/*! \fn QListModelInterface::QListModelInterface(QObject *parent)
diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri
index 261b2ff..dedea55 100644
--- a/src/declarative/debugger/debugger.pri
+++ b/src/declarative/debugger/debugger.pri
@@ -1,15 +1,15 @@
INCLUDEPATH += $$PWD
SOURCES += \
- $$PWD/qmldebuggerstatus.cpp \
+ $$PWD/qdeclarativedebuggerstatus.cpp \
$$PWD/qpacketprotocol.cpp \
- $$PWD/qmldebugservice.cpp \
- $$PWD/qmldebugclient.cpp \
- $$PWD/qmldebug.cpp
+ $$PWD/qdeclarativedebugservice.cpp \
+ $$PWD/qdeclarativedebugclient.cpp \
+ $$PWD/qdeclarativedebug.cpp
HEADERS += \
- $$PWD/qmldebuggerstatus_p.h \
+ $$PWD/qdeclarativedebuggerstatus_p.h \
$$PWD/qpacketprotocol_p.h \
- $$PWD/qmldebugservice_p.h \
- $$PWD/qmldebugclient_p.h \
- $$PWD/qmldebug_p.h
+ $$PWD/qdeclarativedebugservice_p.h \
+ $$PWD/qdeclarativedebugclient_p.h \
+ $$PWD/qdeclarativedebug_p.h
diff --git a/src/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativedebug.cpp
new file mode 100644
index 0000000..e4b7d4d
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebug.cpp
@@ -0,0 +1,937 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativedebug_p.h"
+
+#include "qdeclarativedebugclient_p.h"
+
+#include <qdeclarativeenginedebug_p.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngineDebugClient : public QDeclarativeDebugClient
+{
+public:
+ QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p);
+
+protected:
+ virtual void messageReceived(const QByteArray &);
+
+private:
+ QDeclarativeEngineDebugPrivate *priv;
+};
+
+class QDeclarativeEngineDebugPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeEngineDebug)
+public:
+ QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *);
+
+ void message(const QByteArray &);
+
+ QDeclarativeEngineDebugClient *client;
+ int nextId;
+ int getId();
+
+ void decode(QDataStream &, QDeclarativeDebugContextReference &);
+ void decode(QDataStream &, QDeclarativeDebugObjectReference &, bool simple);
+
+ static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugEnginesQuery *);
+ static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugRootContextQuery *);
+ static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugObjectQuery *);
+ static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugExpressionQuery *);
+
+ QHash<int, QDeclarativeDebugEnginesQuery *> enginesQuery;
+ QHash<int, QDeclarativeDebugRootContextQuery *> rootContextQuery;
+ QHash<int, QDeclarativeDebugObjectQuery *> objectQuery;
+ QHash<int, QDeclarativeDebugExpressionQuery *> expressionQuery;
+
+ QHash<int, QDeclarativeDebugWatch *> watched;
+};
+
+QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client,
+ QDeclarativeEngineDebugPrivate *p)
+: QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p)
+{
+ setEnabled(true);
+}
+
+void QDeclarativeEngineDebugClient::messageReceived(const QByteArray &data)
+{
+ priv->message(data);
+}
+
+QDeclarativeEngineDebugPrivate::QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *c)
+: client(new QDeclarativeEngineDebugClient(c, this)), nextId(0)
+{
+}
+
+int QDeclarativeEngineDebugPrivate::getId()
+{
+ return nextId++;
+}
+
+void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugEnginesQuery *q)
+{
+ if (c && q) {
+ QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
+ p->enginesQuery.remove(q->m_queryId);
+ }
+}
+
+void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c,
+ QDeclarativeDebugRootContextQuery *q)
+{
+ if (c && q) {
+ QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
+ p->rootContextQuery.remove(q->m_queryId);
+ }
+}
+
+void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugObjectQuery *q)
+{
+ if (c && q) {
+ QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
+ p->objectQuery.remove(q->m_queryId);
+ }
+}
+
+void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugExpressionQuery *q)
+{
+ if (c && q) {
+ QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
+ p->expressionQuery.remove(q->m_queryId);
+ }
+}
+
+void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o,
+ bool simple)
+{
+ QDeclarativeEngineDebugServer::QDeclarativeObjectData data;
+ ds >> data;
+ o.m_debugId = data.objectId;
+ o.m_class = data.objectType;
+ o.m_name = data.objectName;
+ o.m_source.m_url = data.url;
+ o.m_source.m_lineNumber = data.lineNumber;
+ o.m_source.m_columnNumber = data.columnNumber;
+ o.m_contextDebugId = data.contextId;
+
+ if (simple)
+ return;
+
+ int childCount;
+ bool recur;
+ ds >> childCount >> recur;
+
+ for (int ii = 0; ii < childCount; ++ii) {
+ o.m_children.append(QDeclarativeDebugObjectReference());
+ decode(ds, o.m_children.last(), !recur);
+ }
+
+ int propCount;
+ ds >> propCount;
+
+ for (int ii = 0; ii < propCount; ++ii) {
+ QDeclarativeEngineDebugServer::QDeclarativeObjectProperty data;
+ ds >> data;
+ QDeclarativeDebugPropertyReference prop;
+ prop.m_objectDebugId = o.m_debugId;
+ prop.m_name = data.name;
+ prop.m_binding = data.binding;
+ prop.m_hasNotifySignal = data.hasNotifySignal;
+ prop.m_valueTypeName = data.valueTypeName;
+ switch (data.type) {
+ case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Basic:
+ case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::List:
+ case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::SignalProperty:
+ {
+ prop.m_value = data.value;
+ break;
+ }
+ case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Object:
+ {
+ QDeclarativeDebugObjectReference obj;
+ obj.m_debugId = prop.m_value.toInt();
+ prop.m_value = qVariantFromValue(obj);
+ break;
+ }
+ case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Unknown:
+ break;
+ }
+ o.m_properties << prop;
+ }
+}
+
+void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugContextReference &c)
+{
+ ds >> c.m_name >> c.m_debugId;
+
+ int contextCount;
+ ds >> contextCount;
+
+ for (int ii = 0; ii < contextCount; ++ii) {
+ c.m_contexts.append(QDeclarativeDebugContextReference());
+ decode(ds, c.m_contexts.last());
+ }
+
+ int objectCount;
+ ds >> objectCount;
+
+ for (int ii = 0; ii < objectCount; ++ii) {
+ QDeclarativeDebugObjectReference obj;
+ decode(ds, obj, true);
+
+ obj.m_contextDebugId = c.m_debugId;
+ c.m_objects << obj;
+ }
+}
+
+void QDeclarativeEngineDebugPrivate::message(const QByteArray &data)
+{
+ QDataStream ds(data);
+
+ QByteArray type;
+ ds >> type;
+
+ //qDebug() << "QDeclarativeEngineDebugPrivate::message()" << type;
+
+ if (type == "LIST_ENGINES_R") {
+ int queryId;
+ ds >> queryId;
+
+ QDeclarativeDebugEnginesQuery *query = enginesQuery.value(queryId);
+ if (!query)
+ return;
+ enginesQuery.remove(queryId);
+
+ int count;
+ ds >> count;
+
+ for (int ii = 0; ii < count; ++ii) {
+ QDeclarativeDebugEngineReference ref;
+ ds >> ref.m_name;
+ ds >> ref.m_debugId;
+ query->m_engines << ref;
+ }
+
+ query->m_client = 0;
+ query->setState(QDeclarativeDebugQuery::Completed);
+ } else if (type == "LIST_OBJECTS_R") {
+ int queryId;
+ ds >> queryId;
+
+ QDeclarativeDebugRootContextQuery *query = rootContextQuery.value(queryId);
+ if (!query)
+ return;
+ rootContextQuery.remove(queryId);
+
+ if (!ds.atEnd())
+ decode(ds, query->m_context);
+
+ query->m_client = 0;
+ query->setState(QDeclarativeDebugQuery::Completed);
+ } else if (type == "FETCH_OBJECT_R") {
+ int queryId;
+ ds >> queryId;
+
+ QDeclarativeDebugObjectQuery *query = objectQuery.value(queryId);
+ if (!query)
+ return;
+ objectQuery.remove(queryId);
+
+ if (!ds.atEnd())
+ decode(ds, query->m_object, false);
+
+ query->m_client = 0;
+ query->setState(QDeclarativeDebugQuery::Completed);
+ } else if (type == "EVAL_EXPRESSION_R") {
+ int queryId;
+ QVariant result;
+ ds >> queryId >> result;
+
+ QDeclarativeDebugExpressionQuery *query = expressionQuery.value(queryId);
+ if (!query)
+ return;
+ expressionQuery.remove(queryId);
+
+ query->m_result = result;
+ query->m_client = 0;
+ query->setState(QDeclarativeDebugQuery::Completed);
+ } else if (type == "WATCH_PROPERTY_R") {
+ int queryId;
+ bool ok;
+ ds >> queryId >> ok;
+
+ QDeclarativeDebugWatch *watch = watched.value(queryId);
+ if (!watch)
+ return;
+
+ watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive);
+ } else if (type == "WATCH_OBJECT_R") {
+ int queryId;
+ bool ok;
+ ds >> queryId >> ok;
+
+ QDeclarativeDebugWatch *watch = watched.value(queryId);
+ if (!watch)
+ return;
+
+ watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive);
+ } else if (type == "WATCH_EXPR_OBJECT_R") {
+ int queryId;
+ bool ok;
+ ds >> queryId >> ok;
+
+ QDeclarativeDebugWatch *watch = watched.value(queryId);
+ if (!watch)
+ return;
+
+ watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive);
+ } else if (type == "UPDATE_WATCH") {
+ int queryId;
+ int debugId;
+ QByteArray name;
+ QVariant value;
+ ds >> queryId >> debugId >> name >> value;
+
+ QDeclarativeDebugWatch *watch = watched.value(queryId, 0);
+ if (!watch)
+ return;
+ emit watch->valueChanged(name, value);
+ }
+}
+
+QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent)
+: QObject(*(new QDeclarativeEngineDebugPrivate(client)), parent)
+{
+}
+
+QDeclarativeDebugPropertyWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugPropertyReference &property, QObject *parent)
+{
+ Q_D(QDeclarativeEngineDebug);
+
+ QDeclarativeDebugPropertyWatch *watch = new QDeclarativeDebugPropertyWatch(parent);
+ if (d->client->isConnected()) {
+ int queryId = d->getId();
+ watch->m_queryId = queryId;
+ watch->m_client = this;
+ watch->m_objectDebugId = property.objectDebugId();
+ watch->m_name = property.name();
+ d->watched.insert(queryId, watch);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8();
+ d->client->sendMessage(message);
+ } else {
+ watch->m_state = QDeclarativeDebugWatch::Dead;
+ }
+
+ return watch;
+}
+
+QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugContextReference &, const QString &, QObject *)
+{
+ qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented");
+ return 0;
+}
+
+QDeclarativeDebugObjectExpressionWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, const QString &expr, QObject *parent)
+{
+ Q_D(QDeclarativeEngineDebug);
+ QDeclarativeDebugObjectExpressionWatch *watch = new QDeclarativeDebugObjectExpressionWatch(parent);
+ if (d->client->isConnected()) {
+ int queryId = d->getId();
+ watch->m_queryId = queryId;
+ watch->m_client = this;
+ watch->m_objectDebugId = object.debugId();
+ watch->m_expr = expr;
+ d->watched.insert(queryId, watch);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr;
+ d->client->sendMessage(message);
+ } else {
+ watch->m_state = QDeclarativeDebugWatch::Dead;
+ }
+ return watch;
+}
+
+QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, QObject *parent)
+{
+ Q_D(QDeclarativeEngineDebug);
+
+ QDeclarativeDebugWatch *watch = new QDeclarativeDebugWatch(parent);
+ if (d->client->isConnected()) {
+ int queryId = d->getId();
+ watch->m_queryId = queryId;
+ watch->m_client = this;
+ watch->m_objectDebugId = object.debugId();
+ d->watched.insert(queryId, watch);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId();
+ d->client->sendMessage(message);
+ } else {
+ watch->m_state = QDeclarativeDebugWatch::Dead;
+ }
+
+ return watch;
+}
+
+QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugFileReference &, QObject *)
+{
+ qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented");
+ return 0;
+}
+
+void QDeclarativeEngineDebug::removeWatch(QDeclarativeDebugWatch *watch)
+{
+ Q_D(QDeclarativeEngineDebug);
+
+ if (!watch || !watch->m_client)
+ return;
+
+ watch->m_client = 0;
+ watch->setState(QDeclarativeDebugWatch::Inactive);
+
+ d->watched.remove(watch->queryId());
+
+ if (d->client && d->client->isConnected()) {
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("NO_WATCH") << watch->queryId();
+ d->client->sendMessage(message);
+ }
+}
+
+QDeclarativeDebugEnginesQuery *QDeclarativeEngineDebug::queryAvailableEngines(QObject *parent)
+{
+ Q_D(QDeclarativeEngineDebug);
+
+ QDeclarativeDebugEnginesQuery *query = new QDeclarativeDebugEnginesQuery(parent);
+ if (d->client->isConnected()) {
+ query->m_client = this;
+ int queryId = d->getId();
+ query->m_queryId = queryId;
+ d->enginesQuery.insert(queryId, query);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("LIST_ENGINES") << queryId;
+ d->client->sendMessage(message);
+ } else {
+ query->m_state = QDeclarativeDebugQuery::Error;
+ }
+
+ return query;
+}
+
+QDeclarativeDebugRootContextQuery *QDeclarativeEngineDebug::queryRootContexts(const QDeclarativeDebugEngineReference &engine, QObject *parent)
+{
+ Q_D(QDeclarativeEngineDebug);
+
+ QDeclarativeDebugRootContextQuery *query = new QDeclarativeDebugRootContextQuery(parent);
+ if (d->client->isConnected() && engine.debugId() != -1) {
+ query->m_client = this;
+ int queryId = d->getId();
+ query->m_queryId = queryId;
+ d->rootContextQuery.insert(queryId, query);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId();
+ d->client->sendMessage(message);
+ } else {
+ query->m_state = QDeclarativeDebugQuery::Error;
+ }
+
+ return query;
+}
+
+QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObject(const QDeclarativeDebugObjectReference &object, QObject *parent)
+{
+ Q_D(QDeclarativeEngineDebug);
+
+ QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent);
+ if (d->client->isConnected() && object.debugId() != -1) {
+ query->m_client = this;
+ int queryId = d->getId();
+ query->m_queryId = queryId;
+ d->objectQuery.insert(queryId, query);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
+ << false;
+ d->client->sendMessage(message);
+ } else {
+ query->m_state = QDeclarativeDebugQuery::Error;
+ }
+
+ return query;
+}
+
+QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObjectRecursive(const QDeclarativeDebugObjectReference &object, QObject *parent)
+{
+ Q_D(QDeclarativeEngineDebug);
+
+ QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent);
+ if (d->client->isConnected() && object.debugId() != -1) {
+ query->m_client = this;
+ int queryId = d->getId();
+ query->m_queryId = queryId;
+ d->objectQuery.insert(queryId, query);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
+ << true;
+ d->client->sendMessage(message);
+ } else {
+ query->m_state = QDeclarativeDebugQuery::Error;
+ }
+
+ return query;
+}
+
+QDeclarativeDebugExpressionQuery *QDeclarativeEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent)
+{
+ Q_D(QDeclarativeEngineDebug);
+
+ QDeclarativeDebugExpressionQuery *query = new QDeclarativeDebugExpressionQuery(parent);
+ if (d->client->isConnected() && objectDebugId != -1) {
+ query->m_client = this;
+ query->m_expr = expr;
+ int queryId = d->getId();
+ query->m_queryId = queryId;
+ d->expressionQuery.insert(queryId, query);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr;
+ d->client->sendMessage(message);
+ } else {
+ query->m_state = QDeclarativeDebugQuery::Error;
+ }
+
+ return query;
+}
+
+QDeclarativeDebugWatch::QDeclarativeDebugWatch(QObject *parent)
+: QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1)
+{
+}
+
+QDeclarativeDebugWatch::~QDeclarativeDebugWatch()
+{
+}
+
+int QDeclarativeDebugWatch::queryId() const
+{
+ return m_queryId;
+}
+
+int QDeclarativeDebugWatch::objectDebugId() const
+{
+ return m_objectDebugId;
+}
+
+QDeclarativeDebugWatch::State QDeclarativeDebugWatch::state() const
+{
+ return m_state;
+}
+
+void QDeclarativeDebugWatch::setState(State s)
+{
+ if (m_state == s)
+ return;
+ m_state = s;
+ emit stateChanged(m_state);
+}
+
+QDeclarativeDebugPropertyWatch::QDeclarativeDebugPropertyWatch(QObject *parent)
+ : QDeclarativeDebugWatch(parent)
+{
+}
+
+QString QDeclarativeDebugPropertyWatch::name() const
+{
+ return m_name;
+}
+
+
+QDeclarativeDebugObjectExpressionWatch::QDeclarativeDebugObjectExpressionWatch(QObject *parent)
+ : QDeclarativeDebugWatch(parent)
+{
+}
+
+QString QDeclarativeDebugObjectExpressionWatch::expression() const
+{
+ return m_expr;
+}
+
+
+QDeclarativeDebugQuery::QDeclarativeDebugQuery(QObject *parent)
+: QObject(parent), m_state(Waiting)
+{
+}
+
+QDeclarativeDebugQuery::State QDeclarativeDebugQuery::state() const
+{
+ return m_state;
+}
+
+bool QDeclarativeDebugQuery::isWaiting() const
+{
+ return m_state == Waiting;
+}
+
+void QDeclarativeDebugQuery::setState(State s)
+{
+ if (m_state == s)
+ return;
+ m_state = s;
+ emit stateChanged(m_state);
+}
+
+QDeclarativeDebugEnginesQuery::QDeclarativeDebugEnginesQuery(QObject *parent)
+: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
+{
+}
+
+QDeclarativeDebugEnginesQuery::~QDeclarativeDebugEnginesQuery()
+{
+ if (m_client && m_queryId != -1)
+ QDeclarativeEngineDebugPrivate::remove(m_client, this);
+}
+
+QList<QDeclarativeDebugEngineReference> QDeclarativeDebugEnginesQuery::engines() const
+{
+ return m_engines;
+}
+
+QDeclarativeDebugRootContextQuery::QDeclarativeDebugRootContextQuery(QObject *parent)
+: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
+{
+}
+
+QDeclarativeDebugRootContextQuery::~QDeclarativeDebugRootContextQuery()
+{
+ if (m_client && m_queryId != -1)
+ QDeclarativeEngineDebugPrivate::remove(m_client, this);
+}
+
+QDeclarativeDebugContextReference QDeclarativeDebugRootContextQuery::rootContext() const
+{
+ return m_context;
+}
+
+QDeclarativeDebugObjectQuery::QDeclarativeDebugObjectQuery(QObject *parent)
+: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
+{
+}
+
+QDeclarativeDebugObjectQuery::~QDeclarativeDebugObjectQuery()
+{
+ if (m_client && m_queryId != -1)
+ QDeclarativeEngineDebugPrivate::remove(m_client, this);
+}
+
+QDeclarativeDebugObjectReference QDeclarativeDebugObjectQuery::object() const
+{
+ return m_object;
+}
+
+QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(QObject *parent)
+: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
+{
+}
+
+QDeclarativeDebugExpressionQuery::~QDeclarativeDebugExpressionQuery()
+{
+ if (m_client && m_queryId != -1)
+ QDeclarativeEngineDebugPrivate::remove(m_client, this);
+}
+
+QString QDeclarativeDebugExpressionQuery::expression() const
+{
+ return m_expr;
+}
+
+QVariant QDeclarativeDebugExpressionQuery::result() const
+{
+ return m_result;
+}
+
+QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference()
+: m_debugId(-1)
+{
+}
+
+QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(int debugId)
+: m_debugId(debugId)
+{
+}
+
+QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &o)
+: m_debugId(o.m_debugId), m_name(o.m_name)
+{
+}
+
+QDeclarativeDebugEngineReference &
+QDeclarativeDebugEngineReference::operator=(const QDeclarativeDebugEngineReference &o)
+{
+ m_debugId = o.m_debugId; m_name = o.m_name;
+ return *this;
+}
+
+int QDeclarativeDebugEngineReference::debugId() const
+{
+ return m_debugId;
+}
+
+QString QDeclarativeDebugEngineReference::name() const
+{
+ return m_name;
+}
+
+QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference()
+: m_debugId(-1), m_contextDebugId(-1)
+{
+}
+
+QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId)
+: m_debugId(debugId), m_contextDebugId(-1)
+{
+}
+
+QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &o)
+: m_debugId(o.m_debugId), m_class(o.m_class), m_name(o.m_name),
+ m_source(o.m_source), m_contextDebugId(o.m_contextDebugId),
+ m_properties(o.m_properties), m_children(o.m_children)
+{
+}
+
+QDeclarativeDebugObjectReference &
+QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o)
+{
+ m_debugId = o.m_debugId; m_class = o.m_class; m_name = o.m_name;
+ m_source = o.m_source; m_contextDebugId = o.m_contextDebugId;
+ m_properties = o.m_properties; m_children = o.m_children;
+ return *this;
+}
+
+int QDeclarativeDebugObjectReference::debugId() const
+{
+ return m_debugId;
+}
+
+QString QDeclarativeDebugObjectReference::className() const
+{
+ return m_class;
+}
+
+QString QDeclarativeDebugObjectReference::name() const
+{
+ return m_name;
+}
+
+QDeclarativeDebugFileReference QDeclarativeDebugObjectReference::source() const
+{
+ return m_source;
+}
+
+int QDeclarativeDebugObjectReference::contextDebugId() const
+{
+ return m_contextDebugId;
+}
+
+QList<QDeclarativeDebugPropertyReference> QDeclarativeDebugObjectReference::properties() const
+{
+ return m_properties;
+}
+
+QList<QDeclarativeDebugObjectReference> QDeclarativeDebugObjectReference::children() const
+{
+ return m_children;
+}
+
+QDeclarativeDebugContextReference::QDeclarativeDebugContextReference()
+: m_debugId(-1)
+{
+}
+
+QDeclarativeDebugContextReference::QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &o)
+: m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts)
+{
+}
+
+QDeclarativeDebugContextReference &QDeclarativeDebugContextReference::operator=(const QDeclarativeDebugContextReference &o)
+{
+ m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects;
+ m_contexts = o.m_contexts;
+ return *this;
+}
+
+int QDeclarativeDebugContextReference::debugId() const
+{
+ return m_debugId;
+}
+
+QString QDeclarativeDebugContextReference::name() const
+{
+ return m_name;
+}
+
+QList<QDeclarativeDebugObjectReference> QDeclarativeDebugContextReference::objects() const
+{
+ return m_objects;
+}
+
+QList<QDeclarativeDebugContextReference> QDeclarativeDebugContextReference::contexts() const
+{
+ return m_contexts;
+}
+
+QDeclarativeDebugFileReference::QDeclarativeDebugFileReference()
+: m_lineNumber(-1), m_columnNumber(-1)
+{
+}
+
+QDeclarativeDebugFileReference::QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &o)
+: m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber)
+{
+}
+
+QDeclarativeDebugFileReference &QDeclarativeDebugFileReference::operator=(const QDeclarativeDebugFileReference &o)
+{
+ m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber;
+ return *this;
+}
+
+QUrl QDeclarativeDebugFileReference::url() const
+{
+ return m_url;
+}
+
+void QDeclarativeDebugFileReference::setUrl(const QUrl &u)
+{
+ m_url = u;
+}
+
+int QDeclarativeDebugFileReference::lineNumber() const
+{
+ return m_lineNumber;
+}
+
+void QDeclarativeDebugFileReference::setLineNumber(int l)
+{
+ m_lineNumber = l;
+}
+
+int QDeclarativeDebugFileReference::columnNumber() const
+{
+ return m_columnNumber;
+}
+
+void QDeclarativeDebugFileReference::setColumnNumber(int c)
+{
+ m_columnNumber = c;
+}
+
+QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference()
+: m_objectDebugId(-1), m_hasNotifySignal(false)
+{
+}
+
+QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &o)
+: m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value),
+ m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding),
+ m_hasNotifySignal(o.m_hasNotifySignal)
+{
+}
+
+QDeclarativeDebugPropertyReference &QDeclarativeDebugPropertyReference::operator=(const QDeclarativeDebugPropertyReference &o)
+{
+ m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value;
+ m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding;
+ m_hasNotifySignal = o.m_hasNotifySignal;
+ return *this;
+}
+
+int QDeclarativeDebugPropertyReference::objectDebugId() const
+{
+ return m_objectDebugId;
+}
+
+QString QDeclarativeDebugPropertyReference::name() const
+{
+ return m_name;
+}
+
+QString QDeclarativeDebugPropertyReference::valueTypeName() const
+{
+ return m_valueTypeName;
+}
+
+QVariant QDeclarativeDebugPropertyReference::value() const
+{
+ return m_value;
+}
+
+QString QDeclarativeDebugPropertyReference::binding() const
+{
+ return m_binding;
+}
+
+bool QDeclarativeDebugPropertyReference::hasNotifySignal() const
+{
+ return m_hasNotifySignal;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/debugger/qdeclarativedebug_p.h b/src/declarative/debugger/qdeclarativedebug_p.h
new file mode 100644
index 0000000..f0c7a77
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebug_p.h
@@ -0,0 +1,371 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QDECLARATIVEDEBUG_H
+#define QDECLARATIVEDEBUG_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeDebugConnection;
+class QDeclarativeDebugWatch;
+class QDeclarativeDebugPropertyWatch;
+class QDeclarativeDebugObjectExpressionWatch;
+class QDeclarativeDebugEnginesQuery;
+class QDeclarativeDebugRootContextQuery;
+class QDeclarativeDebugObjectQuery;
+class QDeclarativeDebugExpressionQuery;
+class QDeclarativeDebugPropertyReference;
+class QDeclarativeDebugContextReference;
+class QDeclarativeDebugObjectReference;
+class QDeclarativeDebugFileReference;
+class QDeclarativeDebugEngineReference;
+class QDeclarativeEngineDebugPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeEngineDebug : public QObject
+{
+Q_OBJECT
+public:
+ QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0);
+
+ QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &,
+ QObject *parent = 0);
+ QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &,
+ QObject *parent = 0);
+ QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &,
+ QObject *parent = 0);
+ QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &,
+ QObject *parent = 0);
+ QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &,
+ QObject *parent = 0);
+
+ void removeWatch(QDeclarativeDebugWatch *watch);
+
+ QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
+ QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &,
+ QObject *parent = 0);
+ QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &,
+ QObject *parent = 0);
+ QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &,
+ QObject *parent = 0);
+ QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId,
+ const QString &expr,
+ QObject *parent = 0);
+
+private:
+ Q_DECLARE_PRIVATE(QDeclarativeEngineDebug)
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugWatch : public QObject
+{
+Q_OBJECT
+public:
+ enum State { Waiting, Active, Inactive, Dead };
+
+ QDeclarativeDebugWatch(QObject *);
+ ~QDeclarativeDebugWatch();
+
+ int queryId() const;
+ int objectDebugId() const;
+ State state() const;
+
+Q_SIGNALS:
+ void stateChanged(QDeclarativeDebugWatch::State);
+ //void objectChanged(int, const QDeclarativeDebugObjectReference &);
+ //void valueChanged(int, const QVariant &);
+
+ // Server sends value as string if it is a user-type variant
+ void valueChanged(const QByteArray &name, const QVariant &value);
+
+private:
+ friend class QDeclarativeEngineDebug;
+ friend class QDeclarativeEngineDebugPrivate;
+ void setState(State);
+ State m_state;
+ int m_queryId;
+ QDeclarativeEngineDebug *m_client;
+ int m_objectDebugId;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch
+{
+ Q_OBJECT
+public:
+ QDeclarativeDebugPropertyWatch(QObject *parent);
+
+ QString name() const;
+
+private:
+ friend class QDeclarativeEngineDebug;
+ QString m_name;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch
+{
+ Q_OBJECT
+public:
+ QDeclarativeDebugObjectExpressionWatch(QObject *parent);
+
+ QString expression() const;
+
+private:
+ friend class QDeclarativeEngineDebug;
+ QString m_expr;
+ int m_debugId;
+};
+
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugQuery : public QObject
+{
+Q_OBJECT
+public:
+ enum State { Waiting, Error, Completed };
+
+ State state() const;
+ bool isWaiting() const;
+
+// bool waitUntilCompleted();
+
+Q_SIGNALS:
+ void stateChanged(QDeclarativeDebugQuery::State);
+
+protected:
+ QDeclarativeDebugQuery(QObject *);
+
+private:
+ friend class QDeclarativeEngineDebug;
+ friend class QDeclarativeEngineDebugPrivate;
+ void setState(State);
+ State m_state;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugFileReference
+{
+public:
+ QDeclarativeDebugFileReference();
+ QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &);
+ QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &);
+
+ QUrl url() const;
+ void setUrl(const QUrl &);
+ int lineNumber() const;
+ void setLineNumber(int);
+ int columnNumber() const;
+ void setColumnNumber(int);
+
+private:
+ friend class QDeclarativeEngineDebugPrivate;
+ QUrl m_url;
+ int m_lineNumber;
+ int m_columnNumber;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugEngineReference
+{
+public:
+ QDeclarativeDebugEngineReference();
+ QDeclarativeDebugEngineReference(int);
+ QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &);
+ QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &);
+
+ int debugId() const;
+ QString name() const;
+
+private:
+ friend class QDeclarativeEngineDebugPrivate;
+ int m_debugId;
+ QString m_name;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugObjectReference
+{
+public:
+ QDeclarativeDebugObjectReference();
+ QDeclarativeDebugObjectReference(int);
+ QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &);
+ QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &);
+
+ int debugId() const;
+ QString className() const;
+ QString name() const;
+
+ QDeclarativeDebugFileReference source() const;
+ int contextDebugId() const;
+
+ QList<QDeclarativeDebugPropertyReference> properties() const;
+ QList<QDeclarativeDebugObjectReference> children() const;
+
+private:
+ friend class QDeclarativeEngineDebugPrivate;
+ int m_debugId;
+ QString m_class;
+ QString m_name;
+ QDeclarativeDebugFileReference m_source;
+ int m_contextDebugId;
+ QList<QDeclarativeDebugPropertyReference> m_properties;
+ QList<QDeclarativeDebugObjectReference> m_children;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugContextReference
+{
+public:
+ QDeclarativeDebugContextReference();
+ QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &);
+ QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &);
+
+ int debugId() const;
+ QString name() const;
+
+ QList<QDeclarativeDebugObjectReference> objects() const;
+ QList<QDeclarativeDebugContextReference> contexts() const;
+
+private:
+ friend class QDeclarativeEngineDebugPrivate;
+ int m_debugId;
+ QString m_name;
+ QList<QDeclarativeDebugObjectReference> m_objects;
+ QList<QDeclarativeDebugContextReference> m_contexts;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugPropertyReference
+{
+public:
+ QDeclarativeDebugPropertyReference();
+ QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &);
+ QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &);
+
+ int objectDebugId() const;
+ QString name() const;
+ QVariant value() const;
+ QString valueTypeName() const;
+ QString binding() const;
+ bool hasNotifySignal() const;
+
+private:
+ friend class QDeclarativeEngineDebugPrivate;
+ int m_objectDebugId;
+ QString m_name;
+ QVariant m_value;
+ QString m_valueTypeName;
+ QString m_binding;
+ bool m_hasNotifySignal;
+};
+
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery
+{
+Q_OBJECT
+public:
+ virtual ~QDeclarativeDebugEnginesQuery();
+ QList<QDeclarativeDebugEngineReference> engines() const;
+private:
+ friend class QDeclarativeEngineDebug;
+ friend class QDeclarativeEngineDebugPrivate;
+ QDeclarativeDebugEnginesQuery(QObject *);
+ QDeclarativeEngineDebug *m_client;
+ int m_queryId;
+ QList<QDeclarativeDebugEngineReference> m_engines;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery
+{
+Q_OBJECT
+public:
+ virtual ~QDeclarativeDebugRootContextQuery();
+ QDeclarativeDebugContextReference rootContext() const;
+private:
+ friend class QDeclarativeEngineDebug;
+ friend class QDeclarativeEngineDebugPrivate;
+ QDeclarativeDebugRootContextQuery(QObject *);
+ QDeclarativeEngineDebug *m_client;
+ int m_queryId;
+ QDeclarativeDebugContextReference m_context;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery
+{
+Q_OBJECT
+public:
+ virtual ~QDeclarativeDebugObjectQuery();
+ QDeclarativeDebugObjectReference object() const;
+private:
+ friend class QDeclarativeEngineDebug;
+ friend class QDeclarativeEngineDebugPrivate;
+ QDeclarativeDebugObjectQuery(QObject *);
+ QDeclarativeEngineDebug *m_client;
+ int m_queryId;
+ QDeclarativeDebugObjectReference m_object;
+
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery
+{
+Q_OBJECT
+public:
+ virtual ~QDeclarativeDebugExpressionQuery();
+ QString expression() const;
+ QVariant result() const;
+private:
+ friend class QDeclarativeEngineDebug;
+ friend class QDeclarativeEngineDebugPrivate;
+ QDeclarativeDebugExpressionQuery(QObject *);
+ QDeclarativeEngineDebug *m_client;
+ int m_queryId;
+ QString m_expr;
+ QVariant m_result;
+
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeclarativeDebugEngineReference)
+Q_DECLARE_METATYPE(QDeclarativeDebugObjectReference)
+Q_DECLARE_METATYPE(QDeclarativeDebugContextReference)
+Q_DECLARE_METATYPE(QDeclarativeDebugPropertyReference)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEDEBUG_H
diff --git a/src/declarative/debugger/qdeclarativedebugclient.cpp b/src/declarative/debugger/qdeclarativedebugclient.cpp
new file mode 100644
index 0000000..c23e32f
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebugclient.cpp
@@ -0,0 +1,207 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativedebugclient_p.h"
+
+#include "qpacketprotocol_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qstringlist.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeDebugConnectionPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c);
+ QDeclarativeDebugConnection *q;
+ QPacketProtocol *protocol;
+
+ QStringList enabled;
+ QHash<QString, QDeclarativeDebugClient *> plugins;
+public Q_SLOTS:
+ void connected();
+ void readyRead();
+};
+
+QDeclarativeDebugConnectionPrivate::QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c)
+: QObject(c), q(c), protocol(0)
+{
+ protocol = new QPacketProtocol(q, this);
+ QObject::connect(c, SIGNAL(connected()), this, SLOT(connected()));
+ QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
+}
+
+void QDeclarativeDebugConnectionPrivate::connected()
+{
+ QPacket pack;
+ pack << QString(QLatin1String("QDeclarativeDebugServer")) << enabled;
+ protocol->send(pack);
+}
+
+void QDeclarativeDebugConnectionPrivate::readyRead()
+{
+ QPacket pack = protocol->read();
+ QString name; QByteArray message;
+ pack >> name >> message;
+
+ QHash<QString, QDeclarativeDebugClient *>::Iterator iter =
+ plugins.find(name);
+ if (iter == plugins.end()) {
+ qWarning() << "QDeclarativeDebugConnection: Message received for missing plugin" << name;
+ } else {
+ (*iter)->messageReceived(message);
+ }
+}
+
+QDeclarativeDebugConnection::QDeclarativeDebugConnection(QObject *parent)
+: QTcpSocket(parent), d(new QDeclarativeDebugConnectionPrivate(this))
+{
+}
+
+bool QDeclarativeDebugConnection::isConnected() const
+{
+ return state() == ConnectedState;
+}
+
+class QDeclarativeDebugClientPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeDebugClient)
+public:
+ QDeclarativeDebugClientPrivate();
+
+ QString name;
+ QDeclarativeDebugConnection *client;
+ bool enabled;
+};
+
+QDeclarativeDebugClientPrivate::QDeclarativeDebugClientPrivate()
+: client(0), enabled(false)
+{
+}
+
+QDeclarativeDebugClient::QDeclarativeDebugClient(const QString &name,
+ QDeclarativeDebugConnection *parent)
+: QObject(*(new QDeclarativeDebugClientPrivate), parent)
+{
+ Q_D(QDeclarativeDebugClient);
+ d->name = name;
+ d->client = parent;
+
+ if (!d->client)
+ return;
+
+ if (d->client->d->plugins.contains(name)) {
+ qWarning() << "QDeclarativeDebugClient: Conflicting plugin name" << name;
+ d->client = 0;
+ } else {
+ d->client->d->plugins.insert(name, this);
+ }
+}
+
+QString QDeclarativeDebugClient::name() const
+{
+ Q_D(const QDeclarativeDebugClient);
+ return d->name;
+}
+
+bool QDeclarativeDebugClient::isEnabled() const
+{
+ Q_D(const QDeclarativeDebugClient);
+ return d->enabled;
+}
+
+void QDeclarativeDebugClient::setEnabled(bool e)
+{
+ Q_D(QDeclarativeDebugClient);
+ if (e == d->enabled)
+ return;
+
+ d->enabled = e;
+
+ if (d->client) {
+ if (e)
+ d->client->d->enabled.append(d->name);
+ else
+ d->client->d->enabled.removeAll(d->name);
+
+ if (d->client->state() == QTcpSocket::ConnectedState) {
+ QPacket pack;
+ pack << QString(QLatin1String("QDeclarativeDebugServer"));
+ if (e) pack << (int)1;
+ else pack << (int)2;
+ pack << d->name;
+ d->client->d->protocol->send(pack);
+ }
+ }
+}
+
+bool QDeclarativeDebugClient::isConnected() const
+{
+ Q_D(const QDeclarativeDebugClient);
+
+ if (!d->client)
+ return false;
+ return d->client->isConnected();
+}
+
+void QDeclarativeDebugClient::sendMessage(const QByteArray &message)
+{
+ Q_D(QDeclarativeDebugClient);
+
+ if (!d->client || !d->client->isConnected())
+ return;
+
+ QPacket pack;
+ pack << d->name << message;
+ d->client->d->protocol->send(pack);
+}
+
+void QDeclarativeDebugClient::messageReceived(const QByteArray &)
+{
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativedebugclient.moc>
diff --git a/src/declarative/debugger/qdeclarativedebugclient_p.h b/src/declarative/debugger/qdeclarativedebugclient_p.h
new file mode 100644
index 0000000..4144a66
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebugclient_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEDEBUGCLIENT_H
+#define QDECLARATIVEDEBUGCLIENT_H
+
+#include <QtNetwork/qtcpsocket.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeDebugConnectionPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugConnection : public QTcpSocket
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(QDeclarativeDebugConnection)
+public:
+ QDeclarativeDebugConnection(QObject * = 0);
+
+ bool isConnected() const;
+private:
+ QDeclarativeDebugConnectionPrivate *d;
+ friend class QDeclarativeDebugClient;
+ friend class QDeclarativeDebugClientPrivate;
+};
+
+class QDeclarativeDebugClientPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugClient : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeDebugClient)
+ Q_DISABLE_COPY(QDeclarativeDebugClient)
+
+public:
+ QDeclarativeDebugClient(const QString &, QDeclarativeDebugConnection *parent);
+
+ QString name() const;
+
+ bool isEnabled() const;
+ void setEnabled(bool);
+
+ bool isConnected() const;
+
+ void sendMessage(const QByteArray &);
+
+protected:
+ virtual void messageReceived(const QByteArray &);
+
+private:
+ friend class QDeclarativeDebugConnection;
+ friend class QDeclarativeDebugConnectionPrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEDEBUGCLIENT_H
diff --git a/src/declarative/debugger/qdeclarativedebuggerstatus.cpp b/src/declarative/debugger/qdeclarativedebuggerstatus.cpp
new file mode 100644
index 0000000..5908628
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebuggerstatus.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativedebuggerstatus_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeDebuggerStatus::~QDeclarativeDebuggerStatus()
+{
+}
+
+void QDeclarativeDebuggerStatus::setSelectedState(bool)
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebuggerstatus_p.h b/src/declarative/debugger/qdeclarativedebuggerstatus_p.h
new file mode 100644
index 0000000..a3ba40a
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebuggerstatus_p.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEDEBUGGERSTATUS_P_H
+#define QDECLARATIVEDEBUGGERSTATUS_P_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDebuggerStatus
+{
+public:
+ virtual ~QDeclarativeDebuggerStatus();
+
+ virtual void setSelectedState(bool);
+};
+Q_DECLARE_INTERFACE(QDeclarativeDebuggerStatus, "com.trolltech.qml.QDeclarativeDebuggerStatus")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QLMDEBUGGERSTATUS_P_H
diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp
new file mode 100644
index 0000000..d9bbdb5
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebugservice.cpp
@@ -0,0 +1,426 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativedebugservice_p.h"
+
+#include "qpacketprotocol_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtNetwork/qtcpserver.h>
+#include <QtNetwork/qtcpsocket.h>
+#include <QtCore/qstringlist.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeDebugServerPrivate;
+class QDeclarativeDebugServer : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeDebugServer)
+ Q_DISABLE_COPY(QDeclarativeDebugServer)
+public:
+ static QDeclarativeDebugServer *instance();
+ void wait();
+ void registerForStartNotification(QObject *object, const char *receiver);
+
+private Q_SLOTS:
+ void readyRead();
+ void registeredObjectDestroyed(QObject *object);
+
+private:
+ friend class QDeclarativeDebugService;
+ friend class QDeclarativeDebugServicePrivate;
+ QDeclarativeDebugServer(int);
+};
+
+class QDeclarativeDebugServerPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeDebugServer)
+public:
+ QDeclarativeDebugServerPrivate();
+ void wait();
+
+ int port;
+ QTcpSocket *connection;
+ QPacketProtocol *protocol;
+ QHash<QString, QDeclarativeDebugService *> plugins;
+ QStringList enabledPlugins;
+ QList<QPair<QObject*, QByteArray> > notifyClients;
+};
+
+class QDeclarativeDebugServicePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeDebugService)
+public:
+ QDeclarativeDebugServicePrivate();
+
+ QString name;
+ QDeclarativeDebugServer *server;
+};
+
+QDeclarativeDebugServerPrivate::QDeclarativeDebugServerPrivate()
+: connection(0), protocol(0)
+{
+}
+
+void QDeclarativeDebugServerPrivate::wait()
+{
+ Q_Q(QDeclarativeDebugServer);
+ QTcpServer server;
+
+ if (!server.listen(QHostAddress::Any, port)) {
+ qWarning("QDeclarativeDebugServer: Unable to listen on port %d", port);
+ return;
+ }
+
+ qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", port);
+
+ for (int i=0; i<notifyClients.count(); i++) {
+ if (!QMetaObject::invokeMethod(notifyClients[i].first, notifyClients[i].second)) {
+ qWarning() << "QDeclarativeDebugServer: unable to call method" << notifyClients[i].second
+ << "on object" << notifyClients[i].first << "to notify of debug server start";
+ }
+ }
+ notifyClients.clear();
+
+ if (!server.waitForNewConnection(-1)) {
+ qWarning("QDeclarativeDebugServer: Connection error");
+ return;
+ }
+
+ connection = server.nextPendingConnection();
+ connection->setParent(q);
+ protocol = new QPacketProtocol(connection, q);
+
+ // ### Wait for hello
+ while (!protocol->packetsAvailable()) {
+ connection->waitForReadyRead();
+ }
+ QPacket hello = protocol->read();
+ QString name;
+ hello >> name >> enabledPlugins;
+ if (name != QLatin1String("QDeclarativeDebugServer")) {
+ qWarning("QDeclarativeDebugServer: Invalid hello message");
+ delete protocol; delete connection; connection = 0; protocol = 0;
+ return;
+ }
+
+ QObject::connect(protocol, SIGNAL(readyRead()), q, SLOT(readyRead()));
+ q->readyRead();
+
+ qWarning("QDeclarativeDebugServer: Connection established");
+}
+
+QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
+{
+ static bool envTested = false;
+ static QDeclarativeDebugServer *server = 0;
+
+ if (!envTested) {
+ envTested = true;
+ QByteArray env = qgetenv("QML_DEBUG_SERVER_PORT");
+
+ bool ok = false;
+ int port = env.toInt(&ok);
+
+ if (ok && port > 1024)
+ server = new QDeclarativeDebugServer(port);
+ }
+
+ return server;
+}
+
+void QDeclarativeDebugServer::wait()
+{
+ Q_D(QDeclarativeDebugServer);
+ d->wait();
+}
+
+void QDeclarativeDebugServer::registerForStartNotification(QObject *object, const char *methodName)
+{
+ Q_D(QDeclarativeDebugServer);
+ connect(object, SIGNAL(destroyed(QObject*)), SLOT(registeredObjectDestroyed(QObject*)));
+ d->notifyClients.append(qMakePair(object, QByteArray(methodName)));
+}
+
+void QDeclarativeDebugServer::registeredObjectDestroyed(QObject *object)
+{
+ Q_D(QDeclarativeDebugServer);
+ QMutableListIterator<QPair<QObject*, QByteArray> > i(d->notifyClients);
+ while (i.hasNext()) {
+ if (i.next().first == object)
+ i.remove();
+ }
+}
+
+QDeclarativeDebugServer::QDeclarativeDebugServer(int port)
+: QObject(*(new QDeclarativeDebugServerPrivate))
+{
+ Q_D(QDeclarativeDebugServer);
+ d->port = port;
+}
+
+void QDeclarativeDebugServer::readyRead()
+{
+ Q_D(QDeclarativeDebugServer);
+
+ QString debugServer(QLatin1String("QDeclarativeDebugServer"));
+
+ while (d->protocol->packetsAvailable()) {
+ QPacket pack = d->protocol->read();
+
+ QString name;
+ pack >> name;
+
+ if (name == debugServer) {
+ int op = -1; QString plugin;
+ pack >> op >> plugin;
+
+ if (op == 1) {
+ // Enable
+ if (!d->enabledPlugins.contains(plugin)) {
+ d->enabledPlugins.append(plugin);
+ QHash<QString, QDeclarativeDebugService *>::Iterator iter =
+ d->plugins.find(plugin);
+ if (iter != d->plugins.end())
+ (*iter)->enabledChanged(true);
+ }
+
+ } else if (op == 2) {
+ // Disable
+ if (d->enabledPlugins.contains(plugin)) {
+ d->enabledPlugins.removeAll(plugin);
+ QHash<QString, QDeclarativeDebugService *>::Iterator iter =
+ d->plugins.find(plugin);
+ if (iter != d->plugins.end())
+ (*iter)->enabledChanged(false);
+ }
+ } else {
+ qWarning("QDeclarativeDebugServer: Invalid control message %d", op);
+ }
+
+ } else {
+ QByteArray message;
+ pack >> message;
+
+ QHash<QString, QDeclarativeDebugService *>::Iterator iter =
+ d->plugins.find(name);
+ if (iter == d->plugins.end()) {
+ qWarning() << "QDeclarativeDebugServer: Message received for missing plugin" << name;
+ } else {
+ (*iter)->messageReceived(message);
+ }
+ }
+ }
+}
+
+QDeclarativeDebugServicePrivate::QDeclarativeDebugServicePrivate()
+: server(0)
+{
+}
+
+QDeclarativeDebugService::QDeclarativeDebugService(const QString &name, QObject *parent)
+: QObject(*(new QDeclarativeDebugServicePrivate), parent)
+{
+ Q_D(QDeclarativeDebugService);
+ d->name = name;
+ d->server = QDeclarativeDebugServer::instance();
+
+ if (!d->server)
+ return;
+
+ if (d->server->d_func()->plugins.contains(name)) {
+ qWarning() << "QDeclarativeDebugService: Conflicting plugin name" << name;
+ d->server = 0;
+ } else {
+ d->server->d_func()->plugins.insert(name, this);
+ }
+}
+
+QString QDeclarativeDebugService::name() const
+{
+ Q_D(const QDeclarativeDebugService);
+ return d->name;
+}
+
+bool QDeclarativeDebugService::isEnabled() const
+{
+ Q_D(const QDeclarativeDebugService);
+ return (d->server && d->server->d_func()->enabledPlugins.contains(d->name));
+}
+
+namespace {
+
+ struct ObjectReference
+ {
+ QPointer<QObject> object;
+ int id;
+ };
+
+ struct ObjectReferenceHash
+ {
+ ObjectReferenceHash() : nextId(0) {}
+
+ QHash<QObject *, ObjectReference> objects;
+ QHash<int, QObject *> ids;
+
+ int nextId;
+ };
+
+}
+Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash);
+
+
+/*!
+ Returns a unique id for \a object. Calling this method multiple times
+ for the same object will return the same id.
+*/
+int QDeclarativeDebugService::idForObject(QObject *object)
+{
+ if (!object)
+ return -1;
+
+ ObjectReferenceHash *hash = objectReferenceHash();
+ QHash<QObject *, ObjectReference>::Iterator iter =
+ hash->objects.find(object);
+
+ if (iter == hash->objects.end()) {
+ int id = hash->nextId++;
+
+ hash->ids.insert(id, object);
+ iter = hash->objects.insert(object, ObjectReference());
+ iter->object = object;
+ iter->id = id;
+ } else if (iter->object != object) {
+ int id = hash->nextId++;
+
+ hash->ids.remove(iter->id);
+
+ hash->ids.insert(id, object);
+ iter->object = object;
+ iter->id = id;
+ }
+ return iter->id;
+}
+
+/*!
+ Returns the object for unique \a id. If the object has not previously been
+ assigned an id, through idForObject(), then 0 is returned. If the object
+ has been destroyed, 0 is returned.
+*/
+QObject *QDeclarativeDebugService::objectForId(int id)
+{
+ ObjectReferenceHash *hash = objectReferenceHash();
+
+ QHash<int, QObject *>::Iterator iter = hash->ids.find(id);
+ if (iter == hash->ids.end())
+ return 0;
+
+
+ QHash<QObject *, ObjectReference>::Iterator objIter =
+ hash->objects.find(*iter);
+ Q_ASSERT(objIter != hash->objects.end());
+
+ if (objIter->object == 0) {
+ hash->ids.erase(iter);
+ hash->objects.erase(objIter);
+ return 0;
+ } else {
+ return *iter;
+ }
+}
+
+bool QDeclarativeDebugService::isDebuggingEnabled()
+{
+ return QDeclarativeDebugServer::instance() != 0;
+}
+
+QString QDeclarativeDebugService::objectToString(QObject *obj)
+{
+ if(!obj)
+ return QLatin1String("NULL");
+
+ QString objectName = obj->objectName();
+ if(objectName.isEmpty())
+ objectName = QLatin1String("<unnamed>");
+
+ QString rv = QString::fromUtf8(obj->metaObject()->className()) +
+ QLatin1String(": ") + objectName;
+
+ return rv;
+}
+
+void QDeclarativeDebugService::waitForClients()
+{
+ QDeclarativeDebugServer::instance()->wait();
+}
+
+void QDeclarativeDebugService::notifyOnServerStart(QObject *object, const char *receiver)
+{
+ QDeclarativeDebugServer::instance()->registerForStartNotification(object, receiver);
+}
+
+void QDeclarativeDebugService::sendMessage(const QByteArray &message)
+{
+ Q_D(QDeclarativeDebugService);
+
+ if (!d->server || !d->server->d_func()->connection)
+ return;
+
+ QPacket pack;
+ pack << d->name << message;
+ d->server->d_func()->protocol->send(pack);
+ d->server->d_func()->connection->flush();
+}
+
+void QDeclarativeDebugService::enabledChanged(bool)
+{
+}
+
+void QDeclarativeDebugService::messageReceived(const QByteArray &)
+{
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativedebugservice.moc>
diff --git a/src/declarative/debugger/qdeclarativedebugservice_p.h b/src/declarative/debugger/qdeclarativedebugservice_p.h
new file mode 100644
index 0000000..498edf3
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebugservice_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEDEBUGSERVICE_H
+#define QDECLARATIVEDEBUGSERVICE_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeDebugServicePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugService : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeDebugService)
+ Q_DISABLE_COPY(QDeclarativeDebugService)
+public:
+ QDeclarativeDebugService(const QString &, QObject *parent = 0);
+
+ QString name() const;
+
+ bool isEnabled() const;
+
+ void sendMessage(const QByteArray &);
+
+ static int idForObject(QObject *);
+ static QObject *objectForId(int);
+
+ static bool isDebuggingEnabled();
+ static QString objectToString(QObject *obj);
+
+ static void waitForClients();
+
+ static void notifyOnServerStart(QObject *object, const char *receiver);
+
+protected:
+ virtual void enabledChanged(bool);
+ virtual void messageReceived(const QByteArray &);
+
+private:
+ void registerForStartNotification(QObject *object, const char *methodName);
+ friend class QDeclarativeDebugServer;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEDEBUGSERVICE_H
+
diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp
deleted file mode 100644
index 32d8bbb..0000000
--- a/src/declarative/debugger/qmldebug.cpp
+++ /dev/null
@@ -1,937 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmldebug_p.h"
-
-#include "qmldebugclient_p.h"
-
-#include <qmlenginedebug_p.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngineDebugClient : public QmlDebugClient
-{
-public:
- QmlEngineDebugClient(QmlDebugConnection *client, QmlEngineDebugPrivate *p);
-
-protected:
- virtual void messageReceived(const QByteArray &);
-
-private:
- QmlEngineDebugPrivate *priv;
-};
-
-class QmlEngineDebugPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlEngineDebug)
-public:
- QmlEngineDebugPrivate(QmlDebugConnection *);
-
- void message(const QByteArray &);
-
- QmlEngineDebugClient *client;
- int nextId;
- int getId();
-
- void decode(QDataStream &, QmlDebugContextReference &);
- void decode(QDataStream &, QmlDebugObjectReference &, bool simple);
-
- static void remove(QmlEngineDebug *, QmlDebugEnginesQuery *);
- static void remove(QmlEngineDebug *, QmlDebugRootContextQuery *);
- static void remove(QmlEngineDebug *, QmlDebugObjectQuery *);
- static void remove(QmlEngineDebug *, QmlDebugExpressionQuery *);
-
- QHash<int, QmlDebugEnginesQuery *> enginesQuery;
- QHash<int, QmlDebugRootContextQuery *> rootContextQuery;
- QHash<int, QmlDebugObjectQuery *> objectQuery;
- QHash<int, QmlDebugExpressionQuery *> expressionQuery;
-
- QHash<int, QmlDebugWatch *> watched;
-};
-
-QmlEngineDebugClient::QmlEngineDebugClient(QmlDebugConnection *client,
- QmlEngineDebugPrivate *p)
-: QmlDebugClient(QLatin1String("QmlEngine"), client), priv(p)
-{
- setEnabled(true);
-}
-
-void QmlEngineDebugClient::messageReceived(const QByteArray &data)
-{
- priv->message(data);
-}
-
-QmlEngineDebugPrivate::QmlEngineDebugPrivate(QmlDebugConnection *c)
-: client(new QmlEngineDebugClient(c, this)), nextId(0)
-{
-}
-
-int QmlEngineDebugPrivate::getId()
-{
- return nextId++;
-}
-
-void QmlEngineDebugPrivate::remove(QmlEngineDebug *c, QmlDebugEnginesQuery *q)
-{
- if (c && q) {
- QmlEngineDebugPrivate *p = (QmlEngineDebugPrivate *)QObjectPrivate::get(c);
- p->enginesQuery.remove(q->m_queryId);
- }
-}
-
-void QmlEngineDebugPrivate::remove(QmlEngineDebug *c,
- QmlDebugRootContextQuery *q)
-{
- if (c && q) {
- QmlEngineDebugPrivate *p = (QmlEngineDebugPrivate *)QObjectPrivate::get(c);
- p->rootContextQuery.remove(q->m_queryId);
- }
-}
-
-void QmlEngineDebugPrivate::remove(QmlEngineDebug *c, QmlDebugObjectQuery *q)
-{
- if (c && q) {
- QmlEngineDebugPrivate *p = (QmlEngineDebugPrivate *)QObjectPrivate::get(c);
- p->objectQuery.remove(q->m_queryId);
- }
-}
-
-void QmlEngineDebugPrivate::remove(QmlEngineDebug *c, QmlDebugExpressionQuery *q)
-{
- if (c && q) {
- QmlEngineDebugPrivate *p = (QmlEngineDebugPrivate *)QObjectPrivate::get(c);
- p->expressionQuery.remove(q->m_queryId);
- }
-}
-
-void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o,
- bool simple)
-{
- QmlEngineDebugServer::QmlObjectData data;
- ds >> data;
- o.m_debugId = data.objectId;
- o.m_class = data.objectType;
- o.m_name = data.objectName;
- o.m_source.m_url = data.url;
- o.m_source.m_lineNumber = data.lineNumber;
- o.m_source.m_columnNumber = data.columnNumber;
- o.m_contextDebugId = data.contextId;
-
- if (simple)
- return;
-
- int childCount;
- bool recur;
- ds >> childCount >> recur;
-
- for (int ii = 0; ii < childCount; ++ii) {
- o.m_children.append(QmlDebugObjectReference());
- decode(ds, o.m_children.last(), !recur);
- }
-
- int propCount;
- ds >> propCount;
-
- for (int ii = 0; ii < propCount; ++ii) {
- QmlEngineDebugServer::QmlObjectProperty data;
- ds >> data;
- QmlDebugPropertyReference prop;
- prop.m_objectDebugId = o.m_debugId;
- prop.m_name = data.name;
- prop.m_binding = data.binding;
- prop.m_hasNotifySignal = data.hasNotifySignal;
- prop.m_valueTypeName = data.valueTypeName;
- switch (data.type) {
- case QmlEngineDebugServer::QmlObjectProperty::Basic:
- case QmlEngineDebugServer::QmlObjectProperty::List:
- case QmlEngineDebugServer::QmlObjectProperty::SignalProperty:
- {
- prop.m_value = data.value;
- break;
- }
- case QmlEngineDebugServer::QmlObjectProperty::Object:
- {
- QmlDebugObjectReference obj;
- obj.m_debugId = prop.m_value.toInt();
- prop.m_value = qVariantFromValue(obj);
- break;
- }
- case QmlEngineDebugServer::QmlObjectProperty::Unknown:
- break;
- }
- o.m_properties << prop;
- }
-}
-
-void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugContextReference &c)
-{
- ds >> c.m_name >> c.m_debugId;
-
- int contextCount;
- ds >> contextCount;
-
- for (int ii = 0; ii < contextCount; ++ii) {
- c.m_contexts.append(QmlDebugContextReference());
- decode(ds, c.m_contexts.last());
- }
-
- int objectCount;
- ds >> objectCount;
-
- for (int ii = 0; ii < objectCount; ++ii) {
- QmlDebugObjectReference obj;
- decode(ds, obj, true);
-
- obj.m_contextDebugId = c.m_debugId;
- c.m_objects << obj;
- }
-}
-
-void QmlEngineDebugPrivate::message(const QByteArray &data)
-{
- QDataStream ds(data);
-
- QByteArray type;
- ds >> type;
-
- //qDebug() << "QmlEngineDebugPrivate::message()" << type;
-
- if (type == "LIST_ENGINES_R") {
- int queryId;
- ds >> queryId;
-
- QmlDebugEnginesQuery *query = enginesQuery.value(queryId);
- if (!query)
- return;
- enginesQuery.remove(queryId);
-
- int count;
- ds >> count;
-
- for (int ii = 0; ii < count; ++ii) {
- QmlDebugEngineReference ref;
- ds >> ref.m_name;
- ds >> ref.m_debugId;
- query->m_engines << ref;
- }
-
- query->m_client = 0;
- query->setState(QmlDebugQuery::Completed);
- } else if (type == "LIST_OBJECTS_R") {
- int queryId;
- ds >> queryId;
-
- QmlDebugRootContextQuery *query = rootContextQuery.value(queryId);
- if (!query)
- return;
- rootContextQuery.remove(queryId);
-
- if (!ds.atEnd())
- decode(ds, query->m_context);
-
- query->m_client = 0;
- query->setState(QmlDebugQuery::Completed);
- } else if (type == "FETCH_OBJECT_R") {
- int queryId;
- ds >> queryId;
-
- QmlDebugObjectQuery *query = objectQuery.value(queryId);
- if (!query)
- return;
- objectQuery.remove(queryId);
-
- if (!ds.atEnd())
- decode(ds, query->m_object, false);
-
- query->m_client = 0;
- query->setState(QmlDebugQuery::Completed);
- } else if (type == "EVAL_EXPRESSION_R") {
- int queryId;
- QVariant result;
- ds >> queryId >> result;
-
- QmlDebugExpressionQuery *query = expressionQuery.value(queryId);
- if (!query)
- return;
- expressionQuery.remove(queryId);
-
- query->m_result = result;
- query->m_client = 0;
- query->setState(QmlDebugQuery::Completed);
- } else if (type == "WATCH_PROPERTY_R") {
- int queryId;
- bool ok;
- ds >> queryId >> ok;
-
- QmlDebugWatch *watch = watched.value(queryId);
- if (!watch)
- return;
-
- watch->setState(ok ? QmlDebugWatch::Active : QmlDebugWatch::Inactive);
- } else if (type == "WATCH_OBJECT_R") {
- int queryId;
- bool ok;
- ds >> queryId >> ok;
-
- QmlDebugWatch *watch = watched.value(queryId);
- if (!watch)
- return;
-
- watch->setState(ok ? QmlDebugWatch::Active : QmlDebugWatch::Inactive);
- } else if (type == "WATCH_EXPR_OBJECT_R") {
- int queryId;
- bool ok;
- ds >> queryId >> ok;
-
- QmlDebugWatch *watch = watched.value(queryId);
- if (!watch)
- return;
-
- watch->setState(ok ? QmlDebugWatch::Active : QmlDebugWatch::Inactive);
- } else if (type == "UPDATE_WATCH") {
- int queryId;
- int debugId;
- QByteArray name;
- QVariant value;
- ds >> queryId >> debugId >> name >> value;
-
- QmlDebugWatch *watch = watched.value(queryId, 0);
- if (!watch)
- return;
- emit watch->valueChanged(name, value);
- }
-}
-
-QmlEngineDebug::QmlEngineDebug(QmlDebugConnection *client, QObject *parent)
-: QObject(*(new QmlEngineDebugPrivate(client)), parent)
-{
-}
-
-QmlDebugPropertyWatch *QmlEngineDebug::addWatch(const QmlDebugPropertyReference &property, QObject *parent)
-{
- Q_D(QmlEngineDebug);
-
- QmlDebugPropertyWatch *watch = new QmlDebugPropertyWatch(parent);
- if (d->client->isConnected()) {
- int queryId = d->getId();
- watch->m_queryId = queryId;
- watch->m_client = this;
- watch->m_objectDebugId = property.objectDebugId();
- watch->m_name = property.name();
- d->watched.insert(queryId, watch);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8();
- d->client->sendMessage(message);
- } else {
- watch->m_state = QmlDebugWatch::Dead;
- }
-
- return watch;
-}
-
-QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugContextReference &, const QString &, QObject *)
-{
- qWarning("QmlEngineDebug::addWatch(): Not implemented");
- return 0;
-}
-
-QmlDebugObjectExpressionWatch *QmlEngineDebug::addWatch(const QmlDebugObjectReference &object, const QString &expr, QObject *parent)
-{
- Q_D(QmlEngineDebug);
- QmlDebugObjectExpressionWatch *watch = new QmlDebugObjectExpressionWatch(parent);
- if (d->client->isConnected()) {
- int queryId = d->getId();
- watch->m_queryId = queryId;
- watch->m_client = this;
- watch->m_objectDebugId = object.debugId();
- watch->m_expr = expr;
- d->watched.insert(queryId, watch);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr;
- d->client->sendMessage(message);
- } else {
- watch->m_state = QmlDebugWatch::Dead;
- }
- return watch;
-}
-
-QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugObjectReference &object, QObject *parent)
-{
- Q_D(QmlEngineDebug);
-
- QmlDebugWatch *watch = new QmlDebugWatch(parent);
- if (d->client->isConnected()) {
- int queryId = d->getId();
- watch->m_queryId = queryId;
- watch->m_client = this;
- watch->m_objectDebugId = object.debugId();
- d->watched.insert(queryId, watch);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId();
- d->client->sendMessage(message);
- } else {
- watch->m_state = QmlDebugWatch::Dead;
- }
-
- return watch;
-}
-
-QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugFileReference &, QObject *)
-{
- qWarning("QmlEngineDebug::addWatch(): Not implemented");
- return 0;
-}
-
-void QmlEngineDebug::removeWatch(QmlDebugWatch *watch)
-{
- Q_D(QmlEngineDebug);
-
- if (!watch || !watch->m_client)
- return;
-
- watch->m_client = 0;
- watch->setState(QmlDebugWatch::Inactive);
-
- d->watched.remove(watch->queryId());
-
- if (d->client && d->client->isConnected()) {
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("NO_WATCH") << watch->queryId();
- d->client->sendMessage(message);
- }
-}
-
-QmlDebugEnginesQuery *QmlEngineDebug::queryAvailableEngines(QObject *parent)
-{
- Q_D(QmlEngineDebug);
-
- QmlDebugEnginesQuery *query = new QmlDebugEnginesQuery(parent);
- if (d->client->isConnected()) {
- query->m_client = this;
- int queryId = d->getId();
- query->m_queryId = queryId;
- d->enginesQuery.insert(queryId, query);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("LIST_ENGINES") << queryId;
- d->client->sendMessage(message);
- } else {
- query->m_state = QmlDebugQuery::Error;
- }
-
- return query;
-}
-
-QmlDebugRootContextQuery *QmlEngineDebug::queryRootContexts(const QmlDebugEngineReference &engine, QObject *parent)
-{
- Q_D(QmlEngineDebug);
-
- QmlDebugRootContextQuery *query = new QmlDebugRootContextQuery(parent);
- if (d->client->isConnected() && engine.debugId() != -1) {
- query->m_client = this;
- int queryId = d->getId();
- query->m_queryId = queryId;
- d->rootContextQuery.insert(queryId, query);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId();
- d->client->sendMessage(message);
- } else {
- query->m_state = QmlDebugQuery::Error;
- }
-
- return query;
-}
-
-QmlDebugObjectQuery *QmlEngineDebug::queryObject(const QmlDebugObjectReference &object, QObject *parent)
-{
- Q_D(QmlEngineDebug);
-
- QmlDebugObjectQuery *query = new QmlDebugObjectQuery(parent);
- if (d->client->isConnected() && object.debugId() != -1) {
- query->m_client = this;
- int queryId = d->getId();
- query->m_queryId = queryId;
- d->objectQuery.insert(queryId, query);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
- << false;
- d->client->sendMessage(message);
- } else {
- query->m_state = QmlDebugQuery::Error;
- }
-
- return query;
-}
-
-QmlDebugObjectQuery *QmlEngineDebug::queryObjectRecursive(const QmlDebugObjectReference &object, QObject *parent)
-{
- Q_D(QmlEngineDebug);
-
- QmlDebugObjectQuery *query = new QmlDebugObjectQuery(parent);
- if (d->client->isConnected() && object.debugId() != -1) {
- query->m_client = this;
- int queryId = d->getId();
- query->m_queryId = queryId;
- d->objectQuery.insert(queryId, query);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
- << true;
- d->client->sendMessage(message);
- } else {
- query->m_state = QmlDebugQuery::Error;
- }
-
- return query;
-}
-
-QmlDebugExpressionQuery *QmlEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent)
-{
- Q_D(QmlEngineDebug);
-
- QmlDebugExpressionQuery *query = new QmlDebugExpressionQuery(parent);
- if (d->client->isConnected() && objectDebugId != -1) {
- query->m_client = this;
- query->m_expr = expr;
- int queryId = d->getId();
- query->m_queryId = queryId;
- d->expressionQuery.insert(queryId, query);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr;
- d->client->sendMessage(message);
- } else {
- query->m_state = QmlDebugQuery::Error;
- }
-
- return query;
-}
-
-QmlDebugWatch::QmlDebugWatch(QObject *parent)
-: QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1)
-{
-}
-
-QmlDebugWatch::~QmlDebugWatch()
-{
-}
-
-int QmlDebugWatch::queryId() const
-{
- return m_queryId;
-}
-
-int QmlDebugWatch::objectDebugId() const
-{
- return m_objectDebugId;
-}
-
-QmlDebugWatch::State QmlDebugWatch::state() const
-{
- return m_state;
-}
-
-void QmlDebugWatch::setState(State s)
-{
- if (m_state == s)
- return;
- m_state = s;
- emit stateChanged(m_state);
-}
-
-QmlDebugPropertyWatch::QmlDebugPropertyWatch(QObject *parent)
- : QmlDebugWatch(parent)
-{
-}
-
-QString QmlDebugPropertyWatch::name() const
-{
- return m_name;
-}
-
-
-QmlDebugObjectExpressionWatch::QmlDebugObjectExpressionWatch(QObject *parent)
- : QmlDebugWatch(parent)
-{
-}
-
-QString QmlDebugObjectExpressionWatch::expression() const
-{
- return m_expr;
-}
-
-
-QmlDebugQuery::QmlDebugQuery(QObject *parent)
-: QObject(parent), m_state(Waiting)
-{
-}
-
-QmlDebugQuery::State QmlDebugQuery::state() const
-{
- return m_state;
-}
-
-bool QmlDebugQuery::isWaiting() const
-{
- return m_state == Waiting;
-}
-
-void QmlDebugQuery::setState(State s)
-{
- if (m_state == s)
- return;
- m_state = s;
- emit stateChanged(m_state);
-}
-
-QmlDebugEnginesQuery::QmlDebugEnginesQuery(QObject *parent)
-: QmlDebugQuery(parent), m_client(0), m_queryId(-1)
-{
-}
-
-QmlDebugEnginesQuery::~QmlDebugEnginesQuery()
-{
- if (m_client && m_queryId != -1)
- QmlEngineDebugPrivate::remove(m_client, this);
-}
-
-QList<QmlDebugEngineReference> QmlDebugEnginesQuery::engines() const
-{
- return m_engines;
-}
-
-QmlDebugRootContextQuery::QmlDebugRootContextQuery(QObject *parent)
-: QmlDebugQuery(parent), m_client(0), m_queryId(-1)
-{
-}
-
-QmlDebugRootContextQuery::~QmlDebugRootContextQuery()
-{
- if (m_client && m_queryId != -1)
- QmlEngineDebugPrivate::remove(m_client, this);
-}
-
-QmlDebugContextReference QmlDebugRootContextQuery::rootContext() const
-{
- return m_context;
-}
-
-QmlDebugObjectQuery::QmlDebugObjectQuery(QObject *parent)
-: QmlDebugQuery(parent), m_client(0), m_queryId(-1)
-{
-}
-
-QmlDebugObjectQuery::~QmlDebugObjectQuery()
-{
- if (m_client && m_queryId != -1)
- QmlEngineDebugPrivate::remove(m_client, this);
-}
-
-QmlDebugObjectReference QmlDebugObjectQuery::object() const
-{
- return m_object;
-}
-
-QmlDebugExpressionQuery::QmlDebugExpressionQuery(QObject *parent)
-: QmlDebugQuery(parent), m_client(0), m_queryId(-1)
-{
-}
-
-QmlDebugExpressionQuery::~QmlDebugExpressionQuery()
-{
- if (m_client && m_queryId != -1)
- QmlEngineDebugPrivate::remove(m_client, this);
-}
-
-QString QmlDebugExpressionQuery::expression() const
-{
- return m_expr;
-}
-
-QVariant QmlDebugExpressionQuery::result() const
-{
- return m_result;
-}
-
-QmlDebugEngineReference::QmlDebugEngineReference()
-: m_debugId(-1)
-{
-}
-
-QmlDebugEngineReference::QmlDebugEngineReference(int debugId)
-: m_debugId(debugId)
-{
-}
-
-QmlDebugEngineReference::QmlDebugEngineReference(const QmlDebugEngineReference &o)
-: m_debugId(o.m_debugId), m_name(o.m_name)
-{
-}
-
-QmlDebugEngineReference &
-QmlDebugEngineReference::operator=(const QmlDebugEngineReference &o)
-{
- m_debugId = o.m_debugId; m_name = o.m_name;
- return *this;
-}
-
-int QmlDebugEngineReference::debugId() const
-{
- return m_debugId;
-}
-
-QString QmlDebugEngineReference::name() const
-{
- return m_name;
-}
-
-QmlDebugObjectReference::QmlDebugObjectReference()
-: m_debugId(-1), m_contextDebugId(-1)
-{
-}
-
-QmlDebugObjectReference::QmlDebugObjectReference(int debugId)
-: m_debugId(debugId), m_contextDebugId(-1)
-{
-}
-
-QmlDebugObjectReference::QmlDebugObjectReference(const QmlDebugObjectReference &o)
-: m_debugId(o.m_debugId), m_class(o.m_class), m_name(o.m_name),
- m_source(o.m_source), m_contextDebugId(o.m_contextDebugId),
- m_properties(o.m_properties), m_children(o.m_children)
-{
-}
-
-QmlDebugObjectReference &
-QmlDebugObjectReference::operator=(const QmlDebugObjectReference &o)
-{
- m_debugId = o.m_debugId; m_class = o.m_class; m_name = o.m_name;
- m_source = o.m_source; m_contextDebugId = o.m_contextDebugId;
- m_properties = o.m_properties; m_children = o.m_children;
- return *this;
-}
-
-int QmlDebugObjectReference::debugId() const
-{
- return m_debugId;
-}
-
-QString QmlDebugObjectReference::className() const
-{
- return m_class;
-}
-
-QString QmlDebugObjectReference::name() const
-{
- return m_name;
-}
-
-QmlDebugFileReference QmlDebugObjectReference::source() const
-{
- return m_source;
-}
-
-int QmlDebugObjectReference::contextDebugId() const
-{
- return m_contextDebugId;
-}
-
-QList<QmlDebugPropertyReference> QmlDebugObjectReference::properties() const
-{
- return m_properties;
-}
-
-QList<QmlDebugObjectReference> QmlDebugObjectReference::children() const
-{
- return m_children;
-}
-
-QmlDebugContextReference::QmlDebugContextReference()
-: m_debugId(-1)
-{
-}
-
-QmlDebugContextReference::QmlDebugContextReference(const QmlDebugContextReference &o)
-: m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts)
-{
-}
-
-QmlDebugContextReference &QmlDebugContextReference::operator=(const QmlDebugContextReference &o)
-{
- m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects;
- m_contexts = o.m_contexts;
- return *this;
-}
-
-int QmlDebugContextReference::debugId() const
-{
- return m_debugId;
-}
-
-QString QmlDebugContextReference::name() const
-{
- return m_name;
-}
-
-QList<QmlDebugObjectReference> QmlDebugContextReference::objects() const
-{
- return m_objects;
-}
-
-QList<QmlDebugContextReference> QmlDebugContextReference::contexts() const
-{
- return m_contexts;
-}
-
-QmlDebugFileReference::QmlDebugFileReference()
-: m_lineNumber(-1), m_columnNumber(-1)
-{
-}
-
-QmlDebugFileReference::QmlDebugFileReference(const QmlDebugFileReference &o)
-: m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber)
-{
-}
-
-QmlDebugFileReference &QmlDebugFileReference::operator=(const QmlDebugFileReference &o)
-{
- m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber;
- return *this;
-}
-
-QUrl QmlDebugFileReference::url() const
-{
- return m_url;
-}
-
-void QmlDebugFileReference::setUrl(const QUrl &u)
-{
- m_url = u;
-}
-
-int QmlDebugFileReference::lineNumber() const
-{
- return m_lineNumber;
-}
-
-void QmlDebugFileReference::setLineNumber(int l)
-{
- m_lineNumber = l;
-}
-
-int QmlDebugFileReference::columnNumber() const
-{
- return m_columnNumber;
-}
-
-void QmlDebugFileReference::setColumnNumber(int c)
-{
- m_columnNumber = c;
-}
-
-QmlDebugPropertyReference::QmlDebugPropertyReference()
-: m_objectDebugId(-1), m_hasNotifySignal(false)
-{
-}
-
-QmlDebugPropertyReference::QmlDebugPropertyReference(const QmlDebugPropertyReference &o)
-: m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value),
- m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding),
- m_hasNotifySignal(o.m_hasNotifySignal)
-{
-}
-
-QmlDebugPropertyReference &QmlDebugPropertyReference::operator=(const QmlDebugPropertyReference &o)
-{
- m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value;
- m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding;
- m_hasNotifySignal = o.m_hasNotifySignal;
- return *this;
-}
-
-int QmlDebugPropertyReference::objectDebugId() const
-{
- return m_objectDebugId;
-}
-
-QString QmlDebugPropertyReference::name() const
-{
- return m_name;
-}
-
-QString QmlDebugPropertyReference::valueTypeName() const
-{
- return m_valueTypeName;
-}
-
-QVariant QmlDebugPropertyReference::value() const
-{
- return m_value;
-}
-
-QString QmlDebugPropertyReference::binding() const
-{
- return m_binding;
-}
-
-bool QmlDebugPropertyReference::hasNotifySignal() const
-{
- return m_hasNotifySignal;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/debugger/qmldebug_p.h b/src/declarative/debugger/qmldebug_p.h
deleted file mode 100644
index a1371d5..0000000
--- a/src/declarative/debugger/qmldebug_p.h
+++ /dev/null
@@ -1,371 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QMLDEBUG_H
-#define QMLDEBUG_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlDebugConnection;
-class QmlDebugWatch;
-class QmlDebugPropertyWatch;
-class QmlDebugObjectExpressionWatch;
-class QmlDebugEnginesQuery;
-class QmlDebugRootContextQuery;
-class QmlDebugObjectQuery;
-class QmlDebugExpressionQuery;
-class QmlDebugPropertyReference;
-class QmlDebugContextReference;
-class QmlDebugObjectReference;
-class QmlDebugFileReference;
-class QmlDebugEngineReference;
-class QmlEngineDebugPrivate;
-class Q_DECLARATIVE_EXPORT QmlEngineDebug : public QObject
-{
-Q_OBJECT
-public:
- QmlEngineDebug(QmlDebugConnection *, QObject * = 0);
-
- QmlDebugPropertyWatch *addWatch(const QmlDebugPropertyReference &,
- QObject *parent = 0);
- QmlDebugWatch *addWatch(const QmlDebugContextReference &, const QString &,
- QObject *parent = 0);
- QmlDebugObjectExpressionWatch *addWatch(const QmlDebugObjectReference &, const QString &,
- QObject *parent = 0);
- QmlDebugWatch *addWatch(const QmlDebugObjectReference &,
- QObject *parent = 0);
- QmlDebugWatch *addWatch(const QmlDebugFileReference &,
- QObject *parent = 0);
-
- void removeWatch(QmlDebugWatch *watch);
-
- QmlDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
- QmlDebugRootContextQuery *queryRootContexts(const QmlDebugEngineReference &,
- QObject *parent = 0);
- QmlDebugObjectQuery *queryObject(const QmlDebugObjectReference &,
- QObject *parent = 0);
- QmlDebugObjectQuery *queryObjectRecursive(const QmlDebugObjectReference &,
- QObject *parent = 0);
- QmlDebugExpressionQuery *queryExpressionResult(int objectDebugId,
- const QString &expr,
- QObject *parent = 0);
-
-private:
- Q_DECLARE_PRIVATE(QmlEngineDebug)
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugWatch : public QObject
-{
-Q_OBJECT
-public:
- enum State { Waiting, Active, Inactive, Dead };
-
- QmlDebugWatch(QObject *);
- ~QmlDebugWatch();
-
- int queryId() const;
- int objectDebugId() const;
- State state() const;
-
-Q_SIGNALS:
- void stateChanged(QmlDebugWatch::State);
- //void objectChanged(int, const QmlDebugObjectReference &);
- //void valueChanged(int, const QVariant &);
-
- // Server sends value as string if it is a user-type variant
- void valueChanged(const QByteArray &name, const QVariant &value);
-
-private:
- friend class QmlEngineDebug;
- friend class QmlEngineDebugPrivate;
- void setState(State);
- State m_state;
- int m_queryId;
- QmlEngineDebug *m_client;
- int m_objectDebugId;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugPropertyWatch : public QmlDebugWatch
-{
- Q_OBJECT
-public:
- QmlDebugPropertyWatch(QObject *parent);
-
- QString name() const;
-
-private:
- friend class QmlEngineDebug;
- QString m_name;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugObjectExpressionWatch : public QmlDebugWatch
-{
- Q_OBJECT
-public:
- QmlDebugObjectExpressionWatch(QObject *parent);
-
- QString expression() const;
-
-private:
- friend class QmlEngineDebug;
- QString m_expr;
- int m_debugId;
-};
-
-
-class Q_DECLARATIVE_EXPORT QmlDebugQuery : public QObject
-{
-Q_OBJECT
-public:
- enum State { Waiting, Error, Completed };
-
- State state() const;
- bool isWaiting() const;
-
-// bool waitUntilCompleted();
-
-Q_SIGNALS:
- void stateChanged(QmlDebugQuery::State);
-
-protected:
- QmlDebugQuery(QObject *);
-
-private:
- friend class QmlEngineDebug;
- friend class QmlEngineDebugPrivate;
- void setState(State);
- State m_state;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugFileReference
-{
-public:
- QmlDebugFileReference();
- QmlDebugFileReference(const QmlDebugFileReference &);
- QmlDebugFileReference &operator=(const QmlDebugFileReference &);
-
- QUrl url() const;
- void setUrl(const QUrl &);
- int lineNumber() const;
- void setLineNumber(int);
- int columnNumber() const;
- void setColumnNumber(int);
-
-private:
- friend class QmlEngineDebugPrivate;
- QUrl m_url;
- int m_lineNumber;
- int m_columnNumber;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugEngineReference
-{
-public:
- QmlDebugEngineReference();
- QmlDebugEngineReference(int);
- QmlDebugEngineReference(const QmlDebugEngineReference &);
- QmlDebugEngineReference &operator=(const QmlDebugEngineReference &);
-
- int debugId() const;
- QString name() const;
-
-private:
- friend class QmlEngineDebugPrivate;
- int m_debugId;
- QString m_name;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugObjectReference
-{
-public:
- QmlDebugObjectReference();
- QmlDebugObjectReference(int);
- QmlDebugObjectReference(const QmlDebugObjectReference &);
- QmlDebugObjectReference &operator=(const QmlDebugObjectReference &);
-
- int debugId() const;
- QString className() const;
- QString name() const;
-
- QmlDebugFileReference source() const;
- int contextDebugId() const;
-
- QList<QmlDebugPropertyReference> properties() const;
- QList<QmlDebugObjectReference> children() const;
-
-private:
- friend class QmlEngineDebugPrivate;
- int m_debugId;
- QString m_class;
- QString m_name;
- QmlDebugFileReference m_source;
- int m_contextDebugId;
- QList<QmlDebugPropertyReference> m_properties;
- QList<QmlDebugObjectReference> m_children;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugContextReference
-{
-public:
- QmlDebugContextReference();
- QmlDebugContextReference(const QmlDebugContextReference &);
- QmlDebugContextReference &operator=(const QmlDebugContextReference &);
-
- int debugId() const;
- QString name() const;
-
- QList<QmlDebugObjectReference> objects() const;
- QList<QmlDebugContextReference> contexts() const;
-
-private:
- friend class QmlEngineDebugPrivate;
- int m_debugId;
- QString m_name;
- QList<QmlDebugObjectReference> m_objects;
- QList<QmlDebugContextReference> m_contexts;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugPropertyReference
-{
-public:
- QmlDebugPropertyReference();
- QmlDebugPropertyReference(const QmlDebugPropertyReference &);
- QmlDebugPropertyReference &operator=(const QmlDebugPropertyReference &);
-
- int objectDebugId() const;
- QString name() const;
- QVariant value() const;
- QString valueTypeName() const;
- QString binding() const;
- bool hasNotifySignal() const;
-
-private:
- friend class QmlEngineDebugPrivate;
- int m_objectDebugId;
- QString m_name;
- QVariant m_value;
- QString m_valueTypeName;
- QString m_binding;
- bool m_hasNotifySignal;
-};
-
-
-class Q_DECLARATIVE_EXPORT QmlDebugEnginesQuery : public QmlDebugQuery
-{
-Q_OBJECT
-public:
- virtual ~QmlDebugEnginesQuery();
- QList<QmlDebugEngineReference> engines() const;
-private:
- friend class QmlEngineDebug;
- friend class QmlEngineDebugPrivate;
- QmlDebugEnginesQuery(QObject *);
- QmlEngineDebug *m_client;
- int m_queryId;
- QList<QmlDebugEngineReference> m_engines;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugRootContextQuery : public QmlDebugQuery
-{
-Q_OBJECT
-public:
- virtual ~QmlDebugRootContextQuery();
- QmlDebugContextReference rootContext() const;
-private:
- friend class QmlEngineDebug;
- friend class QmlEngineDebugPrivate;
- QmlDebugRootContextQuery(QObject *);
- QmlEngineDebug *m_client;
- int m_queryId;
- QmlDebugContextReference m_context;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugObjectQuery : public QmlDebugQuery
-{
-Q_OBJECT
-public:
- virtual ~QmlDebugObjectQuery();
- QmlDebugObjectReference object() const;
-private:
- friend class QmlEngineDebug;
- friend class QmlEngineDebugPrivate;
- QmlDebugObjectQuery(QObject *);
- QmlEngineDebug *m_client;
- int m_queryId;
- QmlDebugObjectReference m_object;
-
-};
-
-class Q_DECLARATIVE_EXPORT QmlDebugExpressionQuery : public QmlDebugQuery
-{
-Q_OBJECT
-public:
- virtual ~QmlDebugExpressionQuery();
- QString expression() const;
- QVariant result() const;
-private:
- friend class QmlEngineDebug;
- friend class QmlEngineDebugPrivate;
- QmlDebugExpressionQuery(QObject *);
- QmlEngineDebug *m_client;
- int m_queryId;
- QString m_expr;
- QVariant m_result;
-
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QmlDebugEngineReference)
-Q_DECLARE_METATYPE(QmlDebugObjectReference)
-Q_DECLARE_METATYPE(QmlDebugContextReference)
-Q_DECLARE_METATYPE(QmlDebugPropertyReference)
-
-QT_END_HEADER
-
-#endif // QMLDEBUG_H
diff --git a/src/declarative/debugger/qmldebugclient.cpp b/src/declarative/debugger/qmldebugclient.cpp
deleted file mode 100644
index ae42b5b..0000000
--- a/src/declarative/debugger/qmldebugclient.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmldebugclient_p.h"
-
-#include "qpacketprotocol_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qstringlist.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlDebugConnectionPrivate : public QObject
-{
- Q_OBJECT
-public:
- QmlDebugConnectionPrivate(QmlDebugConnection *c);
- QmlDebugConnection *q;
- QPacketProtocol *protocol;
-
- QStringList enabled;
- QHash<QString, QmlDebugClient *> plugins;
-public Q_SLOTS:
- void connected();
- void readyRead();
-};
-
-QmlDebugConnectionPrivate::QmlDebugConnectionPrivate(QmlDebugConnection *c)
-: QObject(c), q(c), protocol(0)
-{
- protocol = new QPacketProtocol(q, this);
- QObject::connect(c, SIGNAL(connected()), this, SLOT(connected()));
- QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
-}
-
-void QmlDebugConnectionPrivate::connected()
-{
- QPacket pack;
- pack << QString(QLatin1String("QmlDebugServer")) << enabled;
- protocol->send(pack);
-}
-
-void QmlDebugConnectionPrivate::readyRead()
-{
- QPacket pack = protocol->read();
- QString name; QByteArray message;
- pack >> name >> message;
-
- QHash<QString, QmlDebugClient *>::Iterator iter =
- plugins.find(name);
- if (iter == plugins.end()) {
- qWarning() << "QmlDebugConnection: Message received for missing plugin" << name;
- } else {
- (*iter)->messageReceived(message);
- }
-}
-
-QmlDebugConnection::QmlDebugConnection(QObject *parent)
-: QTcpSocket(parent), d(new QmlDebugConnectionPrivate(this))
-{
-}
-
-bool QmlDebugConnection::isConnected() const
-{
- return state() == ConnectedState;
-}
-
-class QmlDebugClientPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlDebugClient)
-public:
- QmlDebugClientPrivate();
-
- QString name;
- QmlDebugConnection *client;
- bool enabled;
-};
-
-QmlDebugClientPrivate::QmlDebugClientPrivate()
-: client(0), enabled(false)
-{
-}
-
-QmlDebugClient::QmlDebugClient(const QString &name,
- QmlDebugConnection *parent)
-: QObject(*(new QmlDebugClientPrivate), parent)
-{
- Q_D(QmlDebugClient);
- d->name = name;
- d->client = parent;
-
- if (!d->client)
- return;
-
- if (d->client->d->plugins.contains(name)) {
- qWarning() << "QmlDebugClient: Conflicting plugin name" << name;
- d->client = 0;
- } else {
- d->client->d->plugins.insert(name, this);
- }
-}
-
-QString QmlDebugClient::name() const
-{
- Q_D(const QmlDebugClient);
- return d->name;
-}
-
-bool QmlDebugClient::isEnabled() const
-{
- Q_D(const QmlDebugClient);
- return d->enabled;
-}
-
-void QmlDebugClient::setEnabled(bool e)
-{
- Q_D(QmlDebugClient);
- if (e == d->enabled)
- return;
-
- d->enabled = e;
-
- if (d->client) {
- if (e)
- d->client->d->enabled.append(d->name);
- else
- d->client->d->enabled.removeAll(d->name);
-
- if (d->client->state() == QTcpSocket::ConnectedState) {
- QPacket pack;
- pack << QString(QLatin1String("QmlDebugServer"));
- if (e) pack << (int)1;
- else pack << (int)2;
- pack << d->name;
- d->client->d->protocol->send(pack);
- }
- }
-}
-
-bool QmlDebugClient::isConnected() const
-{
- Q_D(const QmlDebugClient);
-
- if (!d->client)
- return false;
- return d->client->isConnected();
-}
-
-void QmlDebugClient::sendMessage(const QByteArray &message)
-{
- Q_D(QmlDebugClient);
-
- if (!d->client || !d->client->isConnected())
- return;
-
- QPacket pack;
- pack << d->name << message;
- d->client->d->protocol->send(pack);
-}
-
-void QmlDebugClient::messageReceived(const QByteArray &)
-{
-}
-
-QT_END_NAMESPACE
-
-#include <qmldebugclient.moc>
diff --git a/src/declarative/debugger/qmldebugclient_p.h b/src/declarative/debugger/qmldebugclient_p.h
deleted file mode 100644
index c3e6eff..0000000
--- a/src/declarative/debugger/qmldebugclient_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLDEBUGCLIENT_H
-#define QMLDEBUGCLIENT_H
-
-#include <QtNetwork/qtcpsocket.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlDebugConnectionPrivate;
-class Q_DECLARATIVE_EXPORT QmlDebugConnection : public QTcpSocket
-{
- Q_OBJECT
- Q_DISABLE_COPY(QmlDebugConnection)
-public:
- QmlDebugConnection(QObject * = 0);
-
- bool isConnected() const;
-private:
- QmlDebugConnectionPrivate *d;
- friend class QmlDebugClient;
- friend class QmlDebugClientPrivate;
-};
-
-class QmlDebugClientPrivate;
-class Q_DECLARATIVE_EXPORT QmlDebugClient : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlDebugClient)
- Q_DISABLE_COPY(QmlDebugClient)
-
-public:
- QmlDebugClient(const QString &, QmlDebugConnection *parent);
-
- QString name() const;
-
- bool isEnabled() const;
- void setEnabled(bool);
-
- bool isConnected() const;
-
- void sendMessage(const QByteArray &);
-
-protected:
- virtual void messageReceived(const QByteArray &);
-
-private:
- friend class QmlDebugConnection;
- friend class QmlDebugConnectionPrivate;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLDEBUGCLIENT_H
diff --git a/src/declarative/debugger/qmldebuggerstatus.cpp b/src/declarative/debugger/qmldebuggerstatus.cpp
deleted file mode 100644
index 0f2a973..0000000
--- a/src/declarative/debugger/qmldebuggerstatus.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmldebuggerstatus_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QmlDebuggerStatus::~QmlDebuggerStatus()
-{
-}
-
-void QmlDebuggerStatus::setSelectedState(bool)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qmldebuggerstatus_p.h b/src/declarative/debugger/qmldebuggerstatus_p.h
deleted file mode 100644
index 42538f3..0000000
--- a/src/declarative/debugger/qmldebuggerstatus_p.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLDEBUGGERSTATUS_P_H
-#define QMLDEBUGGERSTATUS_P_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QmlDebuggerStatus
-{
-public:
- virtual ~QmlDebuggerStatus();
-
- virtual void setSelectedState(bool);
-};
-Q_DECLARE_INTERFACE(QmlDebuggerStatus, "com.trolltech.qml.QmlDebuggerStatus")
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QLMDEBUGGERSTATUS_P_H
diff --git a/src/declarative/debugger/qmldebugservice.cpp b/src/declarative/debugger/qmldebugservice.cpp
deleted file mode 100644
index 7b21869..0000000
--- a/src/declarative/debugger/qmldebugservice.cpp
+++ /dev/null
@@ -1,426 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmldebugservice_p.h"
-
-#include "qpacketprotocol_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtNetwork/qtcpserver.h>
-#include <QtNetwork/qtcpsocket.h>
-#include <QtCore/qstringlist.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlDebugServerPrivate;
-class QmlDebugServer : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlDebugServer)
- Q_DISABLE_COPY(QmlDebugServer)
-public:
- static QmlDebugServer *instance();
- void wait();
- void registerForStartNotification(QObject *object, const char *receiver);
-
-private Q_SLOTS:
- void readyRead();
- void registeredObjectDestroyed(QObject *object);
-
-private:
- friend class QmlDebugService;
- friend class QmlDebugServicePrivate;
- QmlDebugServer(int);
-};
-
-class QmlDebugServerPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlDebugServer)
-public:
- QmlDebugServerPrivate();
- void wait();
-
- int port;
- QTcpSocket *connection;
- QPacketProtocol *protocol;
- QHash<QString, QmlDebugService *> plugins;
- QStringList enabledPlugins;
- QList<QPair<QObject*, QByteArray> > notifyClients;
-};
-
-class QmlDebugServicePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlDebugService)
-public:
- QmlDebugServicePrivate();
-
- QString name;
- QmlDebugServer *server;
-};
-
-QmlDebugServerPrivate::QmlDebugServerPrivate()
-: connection(0), protocol(0)
-{
-}
-
-void QmlDebugServerPrivate::wait()
-{
- Q_Q(QmlDebugServer);
- QTcpServer server;
-
- if (!server.listen(QHostAddress::Any, port)) {
- qWarning("QmlDebugServer: Unable to listen on port %d", port);
- return;
- }
-
- qWarning("QmlDebugServer: Waiting for connection on port %d...", port);
-
- for (int i=0; i<notifyClients.count(); i++) {
- if (!QMetaObject::invokeMethod(notifyClients[i].first, notifyClients[i].second)) {
- qWarning() << "QmlDebugServer: unable to call method" << notifyClients[i].second
- << "on object" << notifyClients[i].first << "to notify of debug server start";
- }
- }
- notifyClients.clear();
-
- if (!server.waitForNewConnection(-1)) {
- qWarning("QmlDebugServer: Connection error");
- return;
- }
-
- connection = server.nextPendingConnection();
- connection->setParent(q);
- protocol = new QPacketProtocol(connection, q);
-
- // ### Wait for hello
- while (!protocol->packetsAvailable()) {
- connection->waitForReadyRead();
- }
- QPacket hello = protocol->read();
- QString name;
- hello >> name >> enabledPlugins;
- if (name != QLatin1String("QmlDebugServer")) {
- qWarning("QmlDebugServer: Invalid hello message");
- delete protocol; delete connection; connection = 0; protocol = 0;
- return;
- }
-
- QObject::connect(protocol, SIGNAL(readyRead()), q, SLOT(readyRead()));
- q->readyRead();
-
- qWarning("QmlDebugServer: Connection established");
-}
-
-QmlDebugServer *QmlDebugServer::instance()
-{
- static bool envTested = false;
- static QmlDebugServer *server = 0;
-
- if (!envTested) {
- envTested = true;
- QByteArray env = qgetenv("QML_DEBUG_SERVER_PORT");
-
- bool ok = false;
- int port = env.toInt(&ok);
-
- if (ok && port > 1024)
- server = new QmlDebugServer(port);
- }
-
- return server;
-}
-
-void QmlDebugServer::wait()
-{
- Q_D(QmlDebugServer);
- d->wait();
-}
-
-void QmlDebugServer::registerForStartNotification(QObject *object, const char *methodName)
-{
- Q_D(QmlDebugServer);
- connect(object, SIGNAL(destroyed(QObject*)), SLOT(registeredObjectDestroyed(QObject*)));
- d->notifyClients.append(qMakePair(object, QByteArray(methodName)));
-}
-
-void QmlDebugServer::registeredObjectDestroyed(QObject *object)
-{
- Q_D(QmlDebugServer);
- QMutableListIterator<QPair<QObject*, QByteArray> > i(d->notifyClients);
- while (i.hasNext()) {
- if (i.next().first == object)
- i.remove();
- }
-}
-
-QmlDebugServer::QmlDebugServer(int port)
-: QObject(*(new QmlDebugServerPrivate))
-{
- Q_D(QmlDebugServer);
- d->port = port;
-}
-
-void QmlDebugServer::readyRead()
-{
- Q_D(QmlDebugServer);
-
- QString debugServer(QLatin1String("QmlDebugServer"));
-
- while (d->protocol->packetsAvailable()) {
- QPacket pack = d->protocol->read();
-
- QString name;
- pack >> name;
-
- if (name == debugServer) {
- int op = -1; QString plugin;
- pack >> op >> plugin;
-
- if (op == 1) {
- // Enable
- if (!d->enabledPlugins.contains(plugin)) {
- d->enabledPlugins.append(plugin);
- QHash<QString, QmlDebugService *>::Iterator iter =
- d->plugins.find(plugin);
- if (iter != d->plugins.end())
- (*iter)->enabledChanged(true);
- }
-
- } else if (op == 2) {
- // Disable
- if (d->enabledPlugins.contains(plugin)) {
- d->enabledPlugins.removeAll(plugin);
- QHash<QString, QmlDebugService *>::Iterator iter =
- d->plugins.find(plugin);
- if (iter != d->plugins.end())
- (*iter)->enabledChanged(false);
- }
- } else {
- qWarning("QmlDebugServer: Invalid control message %d", op);
- }
-
- } else {
- QByteArray message;
- pack >> message;
-
- QHash<QString, QmlDebugService *>::Iterator iter =
- d->plugins.find(name);
- if (iter == d->plugins.end()) {
- qWarning() << "QmlDebugServer: Message received for missing plugin" << name;
- } else {
- (*iter)->messageReceived(message);
- }
- }
- }
-}
-
-QmlDebugServicePrivate::QmlDebugServicePrivate()
-: server(0)
-{
-}
-
-QmlDebugService::QmlDebugService(const QString &name, QObject *parent)
-: QObject(*(new QmlDebugServicePrivate), parent)
-{
- Q_D(QmlDebugService);
- d->name = name;
- d->server = QmlDebugServer::instance();
-
- if (!d->server)
- return;
-
- if (d->server->d_func()->plugins.contains(name)) {
- qWarning() << "QmlDebugService: Conflicting plugin name" << name;
- d->server = 0;
- } else {
- d->server->d_func()->plugins.insert(name, this);
- }
-}
-
-QString QmlDebugService::name() const
-{
- Q_D(const QmlDebugService);
- return d->name;
-}
-
-bool QmlDebugService::isEnabled() const
-{
- Q_D(const QmlDebugService);
- return (d->server && d->server->d_func()->enabledPlugins.contains(d->name));
-}
-
-namespace {
-
- struct ObjectReference
- {
- QPointer<QObject> object;
- int id;
- };
-
- struct ObjectReferenceHash
- {
- ObjectReferenceHash() : nextId(0) {}
-
- QHash<QObject *, ObjectReference> objects;
- QHash<int, QObject *> ids;
-
- int nextId;
- };
-
-}
-Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash);
-
-
-/*!
- Returns a unique id for \a object. Calling this method multiple times
- for the same object will return the same id.
-*/
-int QmlDebugService::idForObject(QObject *object)
-{
- if (!object)
- return -1;
-
- ObjectReferenceHash *hash = objectReferenceHash();
- QHash<QObject *, ObjectReference>::Iterator iter =
- hash->objects.find(object);
-
- if (iter == hash->objects.end()) {
- int id = hash->nextId++;
-
- hash->ids.insert(id, object);
- iter = hash->objects.insert(object, ObjectReference());
- iter->object = object;
- iter->id = id;
- } else if (iter->object != object) {
- int id = hash->nextId++;
-
- hash->ids.remove(iter->id);
-
- hash->ids.insert(id, object);
- iter->object = object;
- iter->id = id;
- }
- return iter->id;
-}
-
-/*!
- Returns the object for unique \a id. If the object has not previously been
- assigned an id, through idForObject(), then 0 is returned. If the object
- has been destroyed, 0 is returned.
-*/
-QObject *QmlDebugService::objectForId(int id)
-{
- ObjectReferenceHash *hash = objectReferenceHash();
-
- QHash<int, QObject *>::Iterator iter = hash->ids.find(id);
- if (iter == hash->ids.end())
- return 0;
-
-
- QHash<QObject *, ObjectReference>::Iterator objIter =
- hash->objects.find(*iter);
- Q_ASSERT(objIter != hash->objects.end());
-
- if (objIter->object == 0) {
- hash->ids.erase(iter);
- hash->objects.erase(objIter);
- return 0;
- } else {
- return *iter;
- }
-}
-
-bool QmlDebugService::isDebuggingEnabled()
-{
- return QmlDebugServer::instance() != 0;
-}
-
-QString QmlDebugService::objectToString(QObject *obj)
-{
- if(!obj)
- return QLatin1String("NULL");
-
- QString objectName = obj->objectName();
- if(objectName.isEmpty())
- objectName = QLatin1String("<unnamed>");
-
- QString rv = QString::fromUtf8(obj->metaObject()->className()) +
- QLatin1String(": ") + objectName;
-
- return rv;
-}
-
-void QmlDebugService::waitForClients()
-{
- QmlDebugServer::instance()->wait();
-}
-
-void QmlDebugService::notifyOnServerStart(QObject *object, const char *receiver)
-{
- QmlDebugServer::instance()->registerForStartNotification(object, receiver);
-}
-
-void QmlDebugService::sendMessage(const QByteArray &message)
-{
- Q_D(QmlDebugService);
-
- if (!d->server || !d->server->d_func()->connection)
- return;
-
- QPacket pack;
- pack << d->name << message;
- d->server->d_func()->protocol->send(pack);
- d->server->d_func()->connection->flush();
-}
-
-void QmlDebugService::enabledChanged(bool)
-{
-}
-
-void QmlDebugService::messageReceived(const QByteArray &)
-{
-}
-
-QT_END_NAMESPACE
-
-#include <qmldebugservice.moc>
diff --git a/src/declarative/debugger/qmldebugservice_p.h b/src/declarative/debugger/qmldebugservice_p.h
deleted file mode 100644
index 33ddda0..0000000
--- a/src/declarative/debugger/qmldebugservice_p.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLDEBUGSERVICE_H
-#define QMLDEBUGSERVICE_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlDebugServicePrivate;
-class Q_DECLARATIVE_EXPORT QmlDebugService : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlDebugService)
- Q_DISABLE_COPY(QmlDebugService)
-public:
- QmlDebugService(const QString &, QObject *parent = 0);
-
- QString name() const;
-
- bool isEnabled() const;
-
- void sendMessage(const QByteArray &);
-
- static int idForObject(QObject *);
- static QObject *objectForId(int);
-
- static bool isDebuggingEnabled();
- static QString objectToString(QObject *obj);
-
- static void waitForClients();
-
- static void notifyOnServerStart(QObject *object, const char *receiver);
-
-protected:
- virtual void enabledChanged(bool);
- virtual void messageReceived(const QByteArray &);
-
-private:
- void registerForStartNotification(QObject *object, const char *methodName);
- friend class QmlDebugServer;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLDEBUGSERVICE_H
-
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
index 05eb566..4287e25 100644
--- a/src/declarative/declarative.pro
+++ b/src/declarative/declarative.pro
@@ -9,7 +9,7 @@ solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtXml
-exists("qml_enable_gcov") {
+exists("qdeclarative_enable_gcov") {
QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors
LIBS += -lgcov
}
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index e5343c6..7a85f00 100644
--- a/src/declarative/graphicsitems/graphicsitems.pri
+++ b/src/declarative/graphicsitems/graphicsitems.pri
@@ -1,93 +1,93 @@
INCLUDEPATH += $$PWD
HEADERS += \
- $$PWD/qmlgraphicsitemsmodule_p.h \
- $$PWD/qmlgraphicsanchors_p.h \
- $$PWD/qmlgraphicsanchors_p_p.h \
- $$PWD/qmlgraphicsevents_p_p.h \
- $$PWD/qmlgraphicseffects_p.h \
- $$PWD/qmlgraphicsflickable_p.h \
- $$PWD/qmlgraphicsflickable_p_p.h \
- $$PWD/qmlgraphicsflipable_p.h \
- $$PWD/qmlgraphicsgridview_p.h \
- $$PWD/qmlgraphicsimage_p.h \
- $$PWD/qmlgraphicsimagebase_p.h \
- $$PWD/qmlgraphicsborderimage_p.h \
- $$PWD/qmlgraphicspainteditem_p.h \
- $$PWD/qmlgraphicspainteditem_p_p.h \
- $$PWD/qmlgraphicsimage_p_p.h \
- $$PWD/qmlgraphicsborderimage_p_p.h \
- $$PWD/qmlgraphicsimagebase_p_p.h \
- $$PWD/qmlgraphicsanimatedimage_p.h \
- $$PWD/qmlgraphicsanimatedimage_p_p.h \
- $$PWD/qmlgraphicsitem.h \
- $$PWD/qmlgraphicsitem_p.h \
- $$PWD/qmlgraphicsfocuspanel_p.h \
- $$PWD/qmlgraphicsfocusscope_p.h \
- $$PWD/qmlgraphicspositioners_p.h \
- $$PWD/qmlgraphicspositioners_p_p.h \
- $$PWD/qmlgraphicsloader_p.h \
- $$PWD/qmlgraphicsloader_p_p.h \
- $$PWD/qmlgraphicsmousearea_p.h \
- $$PWD/qmlgraphicsmousearea_p_p.h \
- $$PWD/qmlgraphicspath_p.h \
- $$PWD/qmlgraphicspath_p_p.h \
- $$PWD/qmlgraphicspathview_p.h \
- $$PWD/qmlgraphicspathview_p_p.h \
- $$PWD/qmlgraphicsrectangle_p.h \
- $$PWD/qmlgraphicsrectangle_p_p.h \
- $$PWD/qmlgraphicsrepeater_p.h \
- $$PWD/qmlgraphicsrepeater_p_p.h \
- $$PWD/qmlgraphicsscalegrid_p_p.h \
- $$PWD/qmlgraphicstextinput_p.h \
- $$PWD/qmlgraphicstextinput_p_p.h \
- $$PWD/qmlgraphicstextedit_p.h \
- $$PWD/qmlgraphicstextedit_p_p.h \
- $$PWD/qmlgraphicstext_p.h \
- $$PWD/qmlgraphicstext_p_p.h \
- $$PWD/qmlgraphicsvisualitemmodel_p.h \
- $$PWD/qmlgraphicslistview_p.h \
- $$PWD/qmlgraphicsgraphicsobjectcontainer_p.h \
- $$PWD/qmlgraphicsparticles_p.h \
- $$PWD/qmlgraphicslayoutitem_p.h \
- $$PWD/qmlgraphicsitemchangelistener_p.h \
- $$PWD/qmlgraphicseffects.cpp
+ $$PWD/qdeclarativeitemsmodule_p.h \
+ $$PWD/qdeclarativeanchors_p.h \
+ $$PWD/qdeclarativeanchors_p_p.h \
+ $$PWD/qdeclarativeevents_p_p.h \
+ $$PWD/qdeclarativeeffects_p.h \
+ $$PWD/qdeclarativeflickable_p.h \
+ $$PWD/qdeclarativeflickable_p_p.h \
+ $$PWD/qdeclarativeflipable_p.h \
+ $$PWD/qdeclarativegridview_p.h \
+ $$PWD/qdeclarativeimage_p.h \
+ $$PWD/qdeclarativeimagebase_p.h \
+ $$PWD/qdeclarativeborderimage_p.h \
+ $$PWD/qdeclarativepainteditem_p.h \
+ $$PWD/qdeclarativepainteditem_p_p.h \
+ $$PWD/qdeclarativeimage_p_p.h \
+ $$PWD/qdeclarativeborderimage_p_p.h \
+ $$PWD/qdeclarativeimagebase_p_p.h \
+ $$PWD/qdeclarativeanimatedimage_p.h \
+ $$PWD/qdeclarativeanimatedimage_p_p.h \
+ $$PWD/qdeclarativeitem.h \
+ $$PWD/qdeclarativeitem_p.h \
+ $$PWD/qdeclarativefocuspanel_p.h \
+ $$PWD/qdeclarativefocusscope_p.h \
+ $$PWD/qdeclarativepositioners_p.h \
+ $$PWD/qdeclarativepositioners_p_p.h \
+ $$PWD/qdeclarativeloader_p.h \
+ $$PWD/qdeclarativeloader_p_p.h \
+ $$PWD/qdeclarativemousearea_p.h \
+ $$PWD/qdeclarativemousearea_p_p.h \
+ $$PWD/qdeclarativepath_p.h \
+ $$PWD/qdeclarativepath_p_p.h \
+ $$PWD/qdeclarativepathview_p.h \
+ $$PWD/qdeclarativepathview_p_p.h \
+ $$PWD/qdeclarativerectangle_p.h \
+ $$PWD/qdeclarativerectangle_p_p.h \
+ $$PWD/qdeclarativerepeater_p.h \
+ $$PWD/qdeclarativerepeater_p_p.h \
+ $$PWD/qdeclarativescalegrid_p_p.h \
+ $$PWD/qdeclarativetextinput_p.h \
+ $$PWD/qdeclarativetextinput_p_p.h \
+ $$PWD/qdeclarativetextedit_p.h \
+ $$PWD/qdeclarativetextedit_p_p.h \
+ $$PWD/qdeclarativetext_p.h \
+ $$PWD/qdeclarativetext_p_p.h \
+ $$PWD/qdeclarativevisualitemmodel_p.h \
+ $$PWD/qdeclarativelistview_p.h \
+ $$PWD/qdeclarativegraphicsobjectcontainer_p.h \
+ $$PWD/qdeclarativeparticles_p.h \
+ $$PWD/qdeclarativelayoutitem_p.h \
+ $$PWD/qdeclarativeitemchangelistener_p.h \
+ $$PWD/qdeclarativeeffects.cpp
SOURCES += \
- $$PWD/qmlgraphicsitemsmodule.cpp \
- $$PWD/qmlgraphicsanchors.cpp \
- $$PWD/qmlgraphicsevents.cpp \
- $$PWD/qmlgraphicsflickable.cpp \
- $$PWD/qmlgraphicsflipable.cpp \
- $$PWD/qmlgraphicsgridview.cpp \
- $$PWD/qmlgraphicsimage.cpp \
- $$PWD/qmlgraphicsborderimage.cpp \
- $$PWD/qmlgraphicsimagebase.cpp \
- $$PWD/qmlgraphicsanimatedimage.cpp \
- $$PWD/qmlgraphicspainteditem.cpp \
- $$PWD/qmlgraphicsitem.cpp \
- $$PWD/qmlgraphicsfocuspanel.cpp \
- $$PWD/qmlgraphicsfocusscope.cpp \
- $$PWD/qmlgraphicspositioners.cpp \
- $$PWD/qmlgraphicsloader.cpp \
- $$PWD/qmlgraphicsmousearea.cpp \
- $$PWD/qmlgraphicspath.cpp \
- $$PWD/qmlgraphicspathview.cpp \
- $$PWD/qmlgraphicsrectangle.cpp \
- $$PWD/qmlgraphicsrepeater.cpp \
- $$PWD/qmlgraphicsscalegrid.cpp \
- $$PWD/qmlgraphicstextinput.cpp \
- $$PWD/qmlgraphicstext.cpp \
- $$PWD/qmlgraphicstextedit.cpp \
- $$PWD/qmlgraphicsvisualitemmodel.cpp \
- $$PWD/qmlgraphicslistview.cpp \
- $$PWD/qmlgraphicsgraphicsobjectcontainer.cpp \
- $$PWD/qmlgraphicsparticles.cpp \
- $$PWD/qmlgraphicslayoutitem.cpp \
+ $$PWD/qdeclarativeitemsmodule.cpp \
+ $$PWD/qdeclarativeanchors.cpp \
+ $$PWD/qdeclarativeevents.cpp \
+ $$PWD/qdeclarativeflickable.cpp \
+ $$PWD/qdeclarativeflipable.cpp \
+ $$PWD/qdeclarativegridview.cpp \
+ $$PWD/qdeclarativeimage.cpp \
+ $$PWD/qdeclarativeborderimage.cpp \
+ $$PWD/qdeclarativeimagebase.cpp \
+ $$PWD/qdeclarativeanimatedimage.cpp \
+ $$PWD/qdeclarativepainteditem.cpp \
+ $$PWD/qdeclarativeitem.cpp \
+ $$PWD/qdeclarativefocuspanel.cpp \
+ $$PWD/qdeclarativefocusscope.cpp \
+ $$PWD/qdeclarativepositioners.cpp \
+ $$PWD/qdeclarativeloader.cpp \
+ $$PWD/qdeclarativemousearea.cpp \
+ $$PWD/qdeclarativepath.cpp \
+ $$PWD/qdeclarativepathview.cpp \
+ $$PWD/qdeclarativerectangle.cpp \
+ $$PWD/qdeclarativerepeater.cpp \
+ $$PWD/qdeclarativescalegrid.cpp \
+ $$PWD/qdeclarativetextinput.cpp \
+ $$PWD/qdeclarativetext.cpp \
+ $$PWD/qdeclarativetextedit.cpp \
+ $$PWD/qdeclarativevisualitemmodel.cpp \
+ $$PWD/qdeclarativelistview.cpp \
+ $$PWD/qdeclarativegraphicsobjectcontainer.cpp \
+ $$PWD/qdeclarativeparticles.cpp \
+ $$PWD/qdeclarativelayoutitem.cpp \
contains(QT_CONFIG, webkit) {
QT+=webkit
- SOURCES += $$PWD/qmlgraphicswebview.cpp
- HEADERS += $$PWD/qmlgraphicswebview_p.h
- HEADERS += $$PWD/qmlgraphicswebview_p_p.h
+ SOURCES += $$PWD/qdeclarativewebview.cpp
+ HEADERS += $$PWD/qdeclarativewebview_p.h
+ HEADERS += $$PWD/qdeclarativewebview_p_p.h
}
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors.cpp b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
new file mode 100644
index 0000000..274d778
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
@@ -0,0 +1,1059 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeanchors_p_p.h"
+
+#include "qdeclarativeitem.h"
+#include "qdeclarativeitem_p.h"
+
+#include <qdeclarativeinfo.h>
+
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+//TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)?
+//TODO: support non-parent, non-sibling (need to find lowest common ancestor)
+
+//### const item?
+//local position
+static qreal position(QDeclarativeItem *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
+{
+ qreal ret = 0.0;
+ switch(anchorLine) {
+ case QDeclarativeAnchorLine::Left:
+ ret = item->x();
+ break;
+ case QDeclarativeAnchorLine::Right:
+ ret = item->x() + item->width();
+ break;
+ case QDeclarativeAnchorLine::Top:
+ ret = item->y();
+ break;
+ case QDeclarativeAnchorLine::Bottom:
+ ret = item->y() + item->height();
+ break;
+ case QDeclarativeAnchorLine::HCenter:
+ ret = item->x() + item->width()/2;
+ break;
+ case QDeclarativeAnchorLine::VCenter:
+ ret = item->y() + item->height()/2;
+ break;
+ case QDeclarativeAnchorLine::Baseline:
+ ret = item->y() + item->baselineOffset();
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+//position when origin is 0,0
+static qreal adjustedPosition(QDeclarativeItem *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
+{
+ int ret = 0;
+ switch(anchorLine) {
+ case QDeclarativeAnchorLine::Left:
+ ret = 0;
+ break;
+ case QDeclarativeAnchorLine::Right:
+ ret = item->width();
+ break;
+ case QDeclarativeAnchorLine::Top:
+ ret = 0;
+ break;
+ case QDeclarativeAnchorLine::Bottom:
+ ret = item->height();
+ break;
+ case QDeclarativeAnchorLine::HCenter:
+ ret = item->width()/2;
+ break;
+ case QDeclarativeAnchorLine::VCenter:
+ ret = item->height()/2;
+ break;
+ case QDeclarativeAnchorLine::Baseline:
+ ret = item->baselineOffset();
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+/*!
+ \internal
+ \class QDeclarativeAnchors
+ \since 4.7
+ \ingroup group_layouts
+ \brief The QDeclarativeAnchors class provides a way to lay out items relative to other items.
+
+ \warning Currently, only anchoring to siblings or parent is supported.
+*/
+
+QDeclarativeAnchors::QDeclarativeAnchors(QObject *parent)
+ : QObject(*new QDeclarativeAnchorsPrivate(0), parent)
+{
+ qFatal("QDeclarativeAnchors::QDeclarativeAnchors(QObject*) called");
+}
+
+QDeclarativeAnchors::QDeclarativeAnchors(QDeclarativeItem *item, QObject *parent)
+ : QObject(*new QDeclarativeAnchorsPrivate(item), parent)
+{
+}
+
+QDeclarativeAnchors::~QDeclarativeAnchors()
+{
+ Q_D(QDeclarativeAnchors);
+ d->remDepend(d->fill);
+ d->remDepend(d->centerIn);
+ d->remDepend(d->left.item);
+ d->remDepend(d->right.item);
+ d->remDepend(d->top.item);
+ d->remDepend(d->bottom.item);
+ d->remDepend(d->vCenter.item);
+ d->remDepend(d->hCenter.item);
+ d->remDepend(d->baseline.item);
+}
+
+void QDeclarativeAnchorsPrivate::fillChanged()
+{
+ if (!fill || !isItemComplete())
+ return;
+
+ if (updatingFill < 2) {
+ ++updatingFill;
+
+ if (fill == item->parentItem()) { //child-parent
+ setItemPos(QPointF(leftMargin, topMargin));
+ } else if (fill->parentItem() == item->parentItem()) { //siblings
+ setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin));
+ }
+ setItemWidth(fill->width()-leftMargin-rightMargin);
+ setItemHeight(fill->height()-topMargin-bottomMargin);
+
+ --updatingFill;
+ } else {
+ // ### Make this certain :)
+ qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on fill.");
+ }
+
+}
+
+void QDeclarativeAnchorsPrivate::centerInChanged()
+{
+ if (!centerIn || fill || !isItemComplete())
+ return;
+
+ if (updatingCenterIn < 2) {
+ ++updatingCenterIn;
+
+ if (centerIn == item->parentItem()) {
+ QPointF p((item->parentItem()->width() - item->width()) / 2. + hCenterOffset,
+ (item->parentItem()->height() - item->height()) / 2. + vCenterOffset);
+ setItemPos(p);
+
+ } else if (centerIn->parentItem() == item->parentItem()) {
+
+ QPointF p(centerIn->x() + (centerIn->width() - item->width()) / 2. + hCenterOffset,
+ centerIn->y() + (centerIn->height() - item->height()) / 2. + vCenterOffset);
+ setItemPos(p);
+ }
+
+ --updatingCenterIn;
+ } else {
+ // ### Make this certain :)
+ qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on centerIn.");
+ }
+}
+
+void QDeclarativeAnchorsPrivate::clearItem(QDeclarativeItem *item)
+{
+ if (!item)
+ return;
+ if (fill == item)
+ fill = 0;
+ if (centerIn == item)
+ centerIn = 0;
+ if (left.item == item) {
+ left.item = 0;
+ usedAnchors &= ~QDeclarativeAnchors::HasLeftAnchor;
+ }
+ if (right.item == item) {
+ right.item = 0;
+ usedAnchors &= ~QDeclarativeAnchors::HasRightAnchor;
+ }
+ if (top.item == item) {
+ top.item = 0;
+ usedAnchors &= ~QDeclarativeAnchors::HasTopAnchor;
+ }
+ if (bottom.item == item) {
+ bottom.item = 0;
+ usedAnchors &= ~QDeclarativeAnchors::HasBottomAnchor;
+ }
+ if (vCenter.item == item) {
+ vCenter.item = 0;
+ usedAnchors &= ~QDeclarativeAnchors::HasVCenterAnchor;
+ }
+ if (hCenter.item == item) {
+ hCenter.item = 0;
+ usedAnchors &= ~QDeclarativeAnchors::HasHCenterAnchor;
+ }
+ if (baseline.item == item) {
+ baseline.item = 0;
+ usedAnchors &= ~QDeclarativeAnchors::HasBaselineAnchor;
+ }
+}
+
+void QDeclarativeAnchorsPrivate::addDepend(QDeclarativeItem *item)
+{
+ if (!item)
+ return;
+ QDeclarativeItemPrivate *p =
+ static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(item));
+ p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+}
+
+void QDeclarativeAnchorsPrivate::remDepend(QDeclarativeItem *item)
+{
+ if (!item)
+ return;
+ QDeclarativeItemPrivate *p =
+ static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(item));
+ p->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+}
+
+bool QDeclarativeAnchorsPrivate::isItemComplete() const
+{
+ return componentComplete;
+}
+
+void QDeclarativeAnchors::classBegin()
+{
+ Q_D(QDeclarativeAnchors);
+ d->componentComplete = false;
+}
+
+void QDeclarativeAnchors::componentComplete()
+{
+ Q_D(QDeclarativeAnchors);
+ d->componentComplete = true;
+}
+
+void QDeclarativeAnchorsPrivate::setItemHeight(qreal v)
+{
+ updatingMe = true;
+ item->setHeight(v);
+ updatingMe = false;
+}
+
+void QDeclarativeAnchorsPrivate::setItemWidth(qreal v)
+{
+ updatingMe = true;
+ item->setWidth(v);
+ updatingMe = false;
+}
+
+void QDeclarativeAnchorsPrivate::setItemX(qreal v)
+{
+ updatingMe = true;
+ item->setX(v);
+ updatingMe = false;
+}
+
+void QDeclarativeAnchorsPrivate::setItemY(qreal v)
+{
+ updatingMe = true;
+ item->setY(v);
+ updatingMe = false;
+}
+
+void QDeclarativeAnchorsPrivate::setItemPos(const QPointF &v)
+{
+ updatingMe = true;
+ item->setPos(v);
+ updatingMe = false;
+}
+
+void QDeclarativeAnchorsPrivate::updateMe()
+{
+ if (updatingMe) {
+ updatingMe = false;
+ return;
+ }
+
+ fillChanged();
+ centerInChanged();
+ updateHorizontalAnchors();
+ updateVerticalAnchors();
+}
+
+void QDeclarativeAnchorsPrivate::updateOnComplete()
+{
+ fillChanged();
+ centerInChanged();
+ updateHorizontalAnchors();
+ updateVerticalAnchors();
+}
+
+void QDeclarativeAnchorsPrivate::itemGeometryChanged(QDeclarativeItem *, const QRectF &newG, const QRectF &oldG)
+{
+ fillChanged();
+ centerInChanged();
+
+ if (newG.x() != oldG.x() || newG.width() != oldG.width())
+ updateHorizontalAnchors();
+ if (newG.y() != oldG.y() || newG.height() != oldG.height())
+ updateVerticalAnchors();
+}
+
+QDeclarativeItem *QDeclarativeAnchors::fill() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->fill;
+}
+
+void QDeclarativeAnchors::setFill(QDeclarativeItem *f)
+{
+ Q_D(QDeclarativeAnchors);
+ if (d->fill == f)
+ return;
+
+ if (!f) {
+ d->remDepend(d->fill);
+ d->fill = f;
+ emit fillChanged();
+ return;
+ }
+ if (f != d->item->parentItem() && f->parentItem() != d->item->parentItem()){
+ qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling.");
+ return;
+ }
+ d->remDepend(d->fill);
+ d->fill = f;
+ d->addDepend(d->fill);
+ emit fillChanged();
+ d->fillChanged();
+}
+
+void QDeclarativeAnchors::resetFill()
+{
+ setFill(0);
+}
+
+QDeclarativeItem *QDeclarativeAnchors::centerIn() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->centerIn;
+}
+
+void QDeclarativeAnchors::setCenterIn(QDeclarativeItem* c)
+{
+ Q_D(QDeclarativeAnchors);
+ if (d->centerIn == c)
+ return;
+
+ if (!c) {
+ d->remDepend(d->centerIn);
+ d->centerIn = c;
+ emit centerInChanged();
+ return;
+ }
+ if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){
+ qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling.");
+ return;
+ }
+
+ d->remDepend(d->centerIn);
+ d->centerIn = c;
+ d->addDepend(d->centerIn);
+ emit centerInChanged();
+ d->centerInChanged();
+}
+
+void QDeclarativeAnchors::resetCenterIn()
+{
+ setCenterIn(0);
+}
+
+bool QDeclarativeAnchorsPrivate::calcStretch(const QDeclarativeAnchorLine &edge1,
+ const QDeclarativeAnchorLine &edge2,
+ int offset1,
+ int offset2,
+ QDeclarativeAnchorLine::AnchorLine line,
+ int &stretch)
+{
+ bool edge1IsParent = (edge1.item == item->parentItem());
+ bool edge2IsParent = (edge2.item == item->parentItem());
+ bool edge1IsSibling = (edge1.item->parentItem() == item->parentItem());
+ bool edge2IsSibling = (edge2.item->parentItem() == item->parentItem());
+
+ bool invalid = false;
+ if ((edge2IsParent && edge1IsParent) || (edge2IsSibling && edge1IsSibling)) {
+ stretch = ((int)position(edge2.item, edge2.anchorLine) + offset2)
+ - ((int)position(edge1.item, edge1.anchorLine) + offset1);
+ } else if (edge2IsParent && edge1IsSibling) {
+ stretch = ((int)position(edge2.item, edge2.anchorLine) + offset2)
+ - ((int)position(item->parentItem(), line)
+ + (int)position(edge1.item, edge1.anchorLine) + offset1);
+ } else if (edge2IsSibling && edge1IsParent) {
+ stretch = ((int)position(item->parentItem(), line) + (int)position(edge2.item, edge2.anchorLine) + offset2)
+ - ((int)position(edge1.item, edge1.anchorLine) + offset1);
+ } else
+ invalid = true;
+
+ return invalid;
+}
+
+void QDeclarativeAnchorsPrivate::updateVerticalAnchors()
+{
+ if (fill || centerIn || !isItemComplete())
+ return;
+
+ if (updatingVerticalAnchor < 2) {
+ ++updatingVerticalAnchor;
+ if (usedAnchors & QDeclarativeAnchors::HasTopAnchor) {
+ //Handle stretching
+ bool invalid = true;
+ int height = 0;
+ if (usedAnchors & QDeclarativeAnchors::HasBottomAnchor) {
+ invalid = calcStretch(top, bottom, topMargin, -bottomMargin, QDeclarativeAnchorLine::Top, height);
+ } else if (usedAnchors & QDeclarativeAnchors::HasVCenterAnchor) {
+ invalid = calcStretch(top, vCenter, topMargin, vCenterOffset, QDeclarativeAnchorLine::Top, height);
+ height *= 2;
+ }
+ if (!invalid)
+ setItemHeight(height);
+
+ //Handle top
+ if (top.item == item->parentItem()) {
+ setItemY(adjustedPosition(top.item, top.anchorLine) + topMargin);
+ } else if (top.item->parentItem() == item->parentItem()) {
+ setItemY(position(top.item, top.anchorLine) + topMargin);
+ }
+ } else if (usedAnchors & QDeclarativeAnchors::HasBottomAnchor) {
+ //Handle stretching (top + bottom case is handled above)
+ if (usedAnchors & QDeclarativeAnchors::HasVCenterAnchor) {
+ int height = 0;
+ bool invalid = calcStretch(vCenter, bottom, vCenterOffset, -bottomMargin,
+ QDeclarativeAnchorLine::Top, height);
+ if (!invalid)
+ setItemHeight(height*2);
+ }
+
+ //Handle bottom
+ if (bottom.item == item->parentItem()) {
+ setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - item->height() - bottomMargin);
+ } else if (bottom.item->parentItem() == item->parentItem()) {
+ setItemY(position(bottom.item, bottom.anchorLine) - item->height() - bottomMargin);
+ }
+ } else if (usedAnchors & QDeclarativeAnchors::HasVCenterAnchor) {
+ //(stetching handled above)
+
+ //Handle vCenter
+ if (vCenter.item == item->parentItem()) {
+ setItemY(adjustedPosition(vCenter.item, vCenter.anchorLine)
+ - item->height()/2 + vCenterOffset);
+ } else if (vCenter.item->parentItem() == item->parentItem()) {
+ setItemY(position(vCenter.item, vCenter.anchorLine) - item->height()/2 + vCenterOffset);
+ }
+ } else if (usedAnchors & QDeclarativeAnchors::HasBaselineAnchor) {
+ //Handle baseline
+ if (baseline.item == item->parentItem()) {
+ setItemY(adjustedPosition(baseline.item, baseline.anchorLine)
+ - item->baselineOffset() + baselineOffset);
+ } else if (baseline.item->parentItem() == item->parentItem()) {
+ setItemY(position(baseline.item, baseline.anchorLine)
+ - item->baselineOffset() + baselineOffset);
+ }
+ }
+ --updatingVerticalAnchor;
+ } else {
+ // ### Make this certain :)
+ qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on vertical anchor.");
+ }
+}
+
+void QDeclarativeAnchorsPrivate::updateHorizontalAnchors()
+{
+ if (fill || centerIn || !isItemComplete())
+ return;
+
+ if (updatingHorizontalAnchor < 2) {
+ ++updatingHorizontalAnchor;
+
+ if (usedAnchors & QDeclarativeAnchors::HasLeftAnchor) {
+ //Handle stretching
+ bool invalid = true;
+ int width = 0;
+ if (usedAnchors & QDeclarativeAnchors::HasRightAnchor) {
+ invalid = calcStretch(left, right, leftMargin, -rightMargin, QDeclarativeAnchorLine::Left, width);
+ } else if (usedAnchors & QDeclarativeAnchors::HasHCenterAnchor) {
+ invalid = calcStretch(left, hCenter, leftMargin, hCenterOffset, QDeclarativeAnchorLine::Left, width);
+ width *= 2;
+ }
+ if (!invalid)
+ setItemWidth(width);
+
+ //Handle left
+ if (left.item == item->parentItem()) {
+ setItemX(adjustedPosition(left.item, left.anchorLine) + leftMargin);
+ } else if (left.item->parentItem() == item->parentItem()) {
+ setItemX(position(left.item, left.anchorLine) + leftMargin);
+ }
+ } else if (usedAnchors & QDeclarativeAnchors::HasRightAnchor) {
+ //Handle stretching (left + right case is handled in updateLeftAnchor)
+ if (usedAnchors & QDeclarativeAnchors::HasHCenterAnchor) {
+ int width = 0;
+ bool invalid = calcStretch(hCenter, right, hCenterOffset, -rightMargin,
+ QDeclarativeAnchorLine::Left, width);
+ if (!invalid)
+ setItemWidth(width*2);
+ }
+
+ //Handle right
+ if (right.item == item->parentItem()) {
+ setItemX(adjustedPosition(right.item, right.anchorLine) - item->width() - rightMargin);
+ } else if (right.item->parentItem() == item->parentItem()) {
+ setItemX(position(right.item, right.anchorLine) - item->width() - rightMargin);
+ }
+ } else if (usedAnchors & QDeclarativeAnchors::HasHCenterAnchor) {
+ //Handle hCenter
+ if (hCenter.item == item->parentItem()) {
+ setItemX(adjustedPosition(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset);
+ } else if (hCenter.item->parentItem() == item->parentItem()) {
+ setItemX(position(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset);
+ }
+ }
+
+ --updatingHorizontalAnchor;
+ } else {
+ // ### Make this certain :)
+ qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on horizontal anchor.");
+ }
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchors::top() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->top;
+}
+
+void QDeclarativeAnchors::setTop(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchors);
+ if (!d->checkVAnchorValid(edge) || d->top == edge)
+ return;
+
+ d->usedAnchors |= HasTopAnchor;
+
+ if (!d->checkVValid()) {
+ d->usedAnchors &= ~HasTopAnchor;
+ return;
+ }
+
+ d->remDepend(d->top.item);
+ d->top = edge;
+ d->addDepend(d->top.item);
+ emit topChanged();
+ d->updateVerticalAnchors();
+}
+
+void QDeclarativeAnchors::resetTop()
+{
+ Q_D(QDeclarativeAnchors);
+ d->usedAnchors &= ~HasTopAnchor;
+ d->remDepend(d->top.item);
+ d->top = QDeclarativeAnchorLine();
+ emit topChanged();
+ d->updateVerticalAnchors();
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchors::bottom() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->bottom;
+}
+
+void QDeclarativeAnchors::setBottom(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchors);
+ if (!d->checkVAnchorValid(edge) || d->bottom == edge)
+ return;
+
+ d->usedAnchors |= HasBottomAnchor;
+
+ if (!d->checkVValid()) {
+ d->usedAnchors &= ~HasBottomAnchor;
+ return;
+ }
+
+ d->remDepend(d->bottom.item);
+ d->bottom = edge;
+ d->addDepend(d->bottom.item);
+ emit bottomChanged();
+ d->updateVerticalAnchors();
+}
+
+void QDeclarativeAnchors::resetBottom()
+{
+ Q_D(QDeclarativeAnchors);
+ d->usedAnchors &= ~HasBottomAnchor;
+ d->remDepend(d->bottom.item);
+ d->bottom = QDeclarativeAnchorLine();
+ emit bottomChanged();
+ d->updateVerticalAnchors();
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchors::verticalCenter() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->vCenter;
+}
+
+void QDeclarativeAnchors::setVerticalCenter(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchors);
+ if (!d->checkVAnchorValid(edge) || d->vCenter == edge)
+ return;
+
+ d->usedAnchors |= HasVCenterAnchor;
+
+ if (!d->checkVValid()) {
+ d->usedAnchors &= ~HasVCenterAnchor;
+ return;
+ }
+
+ d->remDepend(d->vCenter.item);
+ d->vCenter = edge;
+ d->addDepend(d->vCenter.item);
+ emit verticalCenterChanged();
+ d->updateVerticalAnchors();
+}
+
+void QDeclarativeAnchors::resetVerticalCenter()
+{
+ Q_D(QDeclarativeAnchors);
+ d->usedAnchors &= ~HasVCenterAnchor;
+ d->remDepend(d->vCenter.item);
+ d->vCenter = QDeclarativeAnchorLine();
+ emit verticalCenterChanged();
+ d->updateVerticalAnchors();
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchors::baseline() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->baseline;
+}
+
+void QDeclarativeAnchors::setBaseline(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchors);
+ if (!d->checkVAnchorValid(edge) || d->baseline == edge)
+ return;
+
+ d->usedAnchors |= HasBaselineAnchor;
+
+ if (!d->checkVValid()) {
+ d->usedAnchors &= ~HasBaselineAnchor;
+ return;
+ }
+
+ d->remDepend(d->baseline.item);
+ d->baseline = edge;
+ d->addDepend(d->baseline.item);
+ emit baselineChanged();
+ d->updateVerticalAnchors();
+}
+
+void QDeclarativeAnchors::resetBaseline()
+{
+ Q_D(QDeclarativeAnchors);
+ d->usedAnchors &= ~HasBaselineAnchor;
+ d->remDepend(d->baseline.item);
+ d->baseline = QDeclarativeAnchorLine();
+ emit baselineChanged();
+ d->updateVerticalAnchors();
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchors::left() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->left;
+}
+
+void QDeclarativeAnchors::setLeft(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchors);
+ if (!d->checkHAnchorValid(edge) || d->left == edge)
+ return;
+
+ d->usedAnchors |= HasLeftAnchor;
+
+ if (!d->checkHValid()) {
+ d->usedAnchors &= ~HasLeftAnchor;
+ return;
+ }
+
+ d->remDepend(d->left.item);
+ d->left = edge;
+ d->addDepend(d->left.item);
+ emit leftChanged();
+ d->updateHorizontalAnchors();
+}
+
+void QDeclarativeAnchors::resetLeft()
+{
+ Q_D(QDeclarativeAnchors);
+ d->usedAnchors &= ~HasLeftAnchor;
+ d->remDepend(d->left.item);
+ d->left = QDeclarativeAnchorLine();
+ emit leftChanged();
+ d->updateHorizontalAnchors();
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchors::right() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->right;
+}
+
+void QDeclarativeAnchors::setRight(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchors);
+ if (!d->checkHAnchorValid(edge) || d->right == edge)
+ return;
+
+ d->usedAnchors |= HasRightAnchor;
+
+ if (!d->checkHValid()) {
+ d->usedAnchors &= ~HasRightAnchor;
+ return;
+ }
+
+ d->remDepend(d->right.item);
+ d->right = edge;
+ d->addDepend(d->right.item);
+ emit rightChanged();
+ d->updateHorizontalAnchors();
+}
+
+void QDeclarativeAnchors::resetRight()
+{
+ Q_D(QDeclarativeAnchors);
+ d->usedAnchors &= ~HasRightAnchor;
+ d->remDepend(d->right.item);
+ d->right = QDeclarativeAnchorLine();
+ emit rightChanged();
+ d->updateHorizontalAnchors();
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchors::horizontalCenter() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->hCenter;
+}
+
+void QDeclarativeAnchors::setHorizontalCenter(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchors);
+ if (!d->checkHAnchorValid(edge) || d->hCenter == edge)
+ return;
+
+ d->usedAnchors |= HasHCenterAnchor;
+
+ if (!d->checkHValid()) {
+ d->usedAnchors &= ~HasHCenterAnchor;
+ return;
+ }
+
+ d->remDepend(d->hCenter.item);
+ d->hCenter = edge;
+ d->addDepend(d->hCenter.item);
+ emit horizontalCenterChanged();
+ d->updateHorizontalAnchors();
+}
+
+void QDeclarativeAnchors::resetHorizontalCenter()
+{
+ Q_D(QDeclarativeAnchors);
+ d->usedAnchors &= ~HasHCenterAnchor;
+ d->remDepend(d->hCenter.item);
+ d->hCenter = QDeclarativeAnchorLine();
+ emit horizontalCenterChanged();
+ d->updateHorizontalAnchors();
+}
+
+qreal QDeclarativeAnchors::leftMargin() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->leftMargin;
+}
+
+void QDeclarativeAnchors::setLeftMargin(qreal offset)
+{
+ Q_D(QDeclarativeAnchors);
+ if (d->leftMargin == offset)
+ return;
+ d->leftMargin = offset;
+ if(d->fill)
+ d->fillChanged();
+ else
+ d->updateHorizontalAnchors();
+ emit leftMarginChanged();
+}
+
+qreal QDeclarativeAnchors::rightMargin() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->rightMargin;
+}
+
+void QDeclarativeAnchors::setRightMargin(qreal offset)
+{
+ Q_D(QDeclarativeAnchors);
+ if (d->rightMargin == offset)
+ return;
+ d->rightMargin = offset;
+ if(d->fill)
+ d->fillChanged();
+ else
+ d->updateHorizontalAnchors();
+ emit rightMarginChanged();
+}
+
+qreal QDeclarativeAnchors::margins() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->margins;
+}
+
+void QDeclarativeAnchors::setMargins(qreal offset)
+{
+ Q_D(QDeclarativeAnchors);
+ if (d->margins == offset)
+ return;
+ //###Is it significantly faster to set them directly so we can call fillChanged only once?
+ if(!d->rightMargin || d->rightMargin == d->margins)
+ setRightMargin(offset);
+ if(!d->leftMargin || d->leftMargin == d->margins)
+ setLeftMargin(offset);
+ if(!d->topMargin || d->topMargin == d->margins)
+ setTopMargin(offset);
+ if(!d->bottomMargin || d->bottomMargin == d->margins)
+ setBottomMargin(offset);
+ d->margins = offset;
+ emit marginsChanged();
+
+}
+
+qreal QDeclarativeAnchors::horizontalCenterOffset() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->hCenterOffset;
+}
+
+void QDeclarativeAnchors::setHorizontalCenterOffset(qreal offset)
+{
+ Q_D(QDeclarativeAnchors);
+ if (d->hCenterOffset == offset)
+ return;
+ d->hCenterOffset = offset;
+ if(d->centerIn)
+ d->centerInChanged();
+ else
+ d->updateHorizontalAnchors();
+ emit horizontalCenterOffsetChanged();
+}
+
+qreal QDeclarativeAnchors::topMargin() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->topMargin;
+}
+
+void QDeclarativeAnchors::setTopMargin(qreal offset)
+{
+ Q_D(QDeclarativeAnchors);
+ if (d->topMargin == offset)
+ return;
+ d->topMargin = offset;
+ if(d->fill)
+ d->fillChanged();
+ else
+ d->updateVerticalAnchors();
+ emit topMarginChanged();
+}
+
+qreal QDeclarativeAnchors::bottomMargin() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->bottomMargin;
+}
+
+void QDeclarativeAnchors::setBottomMargin(qreal offset)
+{
+ Q_D(QDeclarativeAnchors);
+ if (d->bottomMargin == offset)
+ return;
+ d->bottomMargin = offset;
+ if(d->fill)
+ d->fillChanged();
+ else
+ d->updateVerticalAnchors();
+ emit bottomMarginChanged();
+}
+
+qreal QDeclarativeAnchors::verticalCenterOffset() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->vCenterOffset;
+}
+
+void QDeclarativeAnchors::setVerticalCenterOffset(qreal offset)
+{
+ Q_D(QDeclarativeAnchors);
+ if (d->vCenterOffset == offset)
+ return;
+ d->vCenterOffset = offset;
+ if(d->centerIn)
+ d->centerInChanged();
+ else
+ d->updateVerticalAnchors();
+ emit verticalCenterOffsetChanged();
+}
+
+qreal QDeclarativeAnchors::baselineOffset() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->baselineOffset;
+}
+
+void QDeclarativeAnchors::setBaselineOffset(qreal offset)
+{
+ Q_D(QDeclarativeAnchors);
+ if (d->baselineOffset == offset)
+ return;
+ d->baselineOffset = offset;
+ d->updateVerticalAnchors();
+ emit baselineOffsetChanged();
+}
+
+QDeclarativeAnchors::UsedAnchors QDeclarativeAnchors::usedAnchors() const
+{
+ Q_D(const QDeclarativeAnchors);
+ return d->usedAnchors;
+}
+
+bool QDeclarativeAnchorsPrivate::checkHValid() const
+{
+ if (usedAnchors & QDeclarativeAnchors::HasLeftAnchor &&
+ usedAnchors & QDeclarativeAnchors::HasRightAnchor &&
+ usedAnchors & QDeclarativeAnchors::HasHCenterAnchor) {
+ qmlInfo(item) << QDeclarativeAnchors::tr("Cannot specify left, right, and hcenter anchors.");
+ return false;
+ }
+
+ return true;
+}
+
+bool QDeclarativeAnchorsPrivate::checkHAnchorValid(QDeclarativeAnchorLine anchor) const
+{
+ if (!anchor.item) {
+ qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to a null item.");
+ return false;
+ } else if (anchor.anchorLine & QDeclarativeAnchorLine::Vertical_Mask) {
+ qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor a horizontal edge to a vertical edge.");
+ return false;
+ } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){
+ qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
+ return false;
+ } else if (anchor.item == item) {
+ qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor item to self.");
+ return false;
+ }
+
+ return true;
+}
+
+bool QDeclarativeAnchorsPrivate::checkVValid() const
+{
+ if (usedAnchors & QDeclarativeAnchors::HasTopAnchor &&
+ usedAnchors & QDeclarativeAnchors::HasBottomAnchor &&
+ usedAnchors & QDeclarativeAnchors::HasVCenterAnchor) {
+ qmlInfo(item) << QDeclarativeAnchors::tr("Cannot specify top, bottom, and vcenter anchors.");
+ return false;
+ } else if (usedAnchors & QDeclarativeAnchors::HasBaselineAnchor &&
+ (usedAnchors & QDeclarativeAnchors::HasTopAnchor ||
+ usedAnchors & QDeclarativeAnchors::HasBottomAnchor ||
+ usedAnchors & QDeclarativeAnchors::HasVCenterAnchor)) {
+ qmlInfo(item) << QDeclarativeAnchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.");
+ return false;
+ }
+
+ return true;
+}
+
+bool QDeclarativeAnchorsPrivate::checkVAnchorValid(QDeclarativeAnchorLine anchor) const
+{
+ if (!anchor.item) {
+ qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to a null item.");
+ return false;
+ } else if (anchor.anchorLine & QDeclarativeAnchorLine::Horizontal_Mask) {
+ qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor a vertical edge to a horizontal edge.");
+ return false;
+ } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){
+ qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
+ return false;
+ } else if (anchor.item == item){
+ qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor item to self.");
+ return false;
+ }
+
+ return true;
+}
+
+#include <moc_qdeclarativeanchors_p.cpp>
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p.h
new file mode 100644
index 0000000..0b97e8c
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p.h
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEANCHORS_H
+#define QDECLARATIVEANCHORS_H
+
+#include "qdeclarativeitem.h"
+
+#include <qdeclarative.h>
+
+#include <QtCore/QObject>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeAnchorsPrivate;
+class QDeclarativeAnchorLine;
+class Q_DECLARATIVE_EXPORT QDeclarativeAnchors : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QDeclarativeAnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged)
+ Q_PROPERTY(QDeclarativeAnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged)
+ Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged)
+ Q_PROPERTY(QDeclarativeAnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged)
+ Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged)
+ Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged)
+ Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged)
+ Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged)
+ Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
+ Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
+ Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged())
+ Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
+ Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
+ Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged())
+ Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())
+ Q_PROPERTY(QDeclarativeItem *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged)
+ Q_PROPERTY(QDeclarativeItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
+
+public:
+ QDeclarativeAnchors(QObject *parent=0);
+ QDeclarativeAnchors(QDeclarativeItem *item, QObject *parent=0);
+ virtual ~QDeclarativeAnchors();
+
+ enum UsedAnchor {
+ HasLeftAnchor = 0x01,
+ HasRightAnchor = 0x02,
+ HasTopAnchor = 0x04,
+ HasBottomAnchor = 0x08,
+ HasHCenterAnchor = 0x10,
+ HasVCenterAnchor = 0x20,
+ HasBaselineAnchor = 0x40,
+ Horizontal_Mask = HasLeftAnchor | HasRightAnchor | HasHCenterAnchor,
+ Vertical_Mask = HasTopAnchor | HasBottomAnchor | HasVCenterAnchor | HasBaselineAnchor
+ };
+ Q_DECLARE_FLAGS(UsedAnchors, UsedAnchor)
+
+ QDeclarativeAnchorLine left() const;
+ void setLeft(const QDeclarativeAnchorLine &edge);
+ void resetLeft();
+
+ QDeclarativeAnchorLine right() const;
+ void setRight(const QDeclarativeAnchorLine &edge);
+ void resetRight();
+
+ QDeclarativeAnchorLine horizontalCenter() const;
+ void setHorizontalCenter(const QDeclarativeAnchorLine &edge);
+ void resetHorizontalCenter();
+
+ QDeclarativeAnchorLine top() const;
+ void setTop(const QDeclarativeAnchorLine &edge);
+ void resetTop();
+
+ QDeclarativeAnchorLine bottom() const;
+ void setBottom(const QDeclarativeAnchorLine &edge);
+ void resetBottom();
+
+ QDeclarativeAnchorLine verticalCenter() const;
+ void setVerticalCenter(const QDeclarativeAnchorLine &edge);
+ void resetVerticalCenter();
+
+ QDeclarativeAnchorLine baseline() const;
+ void setBaseline(const QDeclarativeAnchorLine &edge);
+ void resetBaseline();
+
+ qreal leftMargin() const;
+ void setLeftMargin(qreal);
+
+ qreal rightMargin() const;
+ void setRightMargin(qreal);
+
+ qreal horizontalCenterOffset() const;
+ void setHorizontalCenterOffset(qreal);
+
+ qreal topMargin() const;
+ void setTopMargin(qreal);
+
+ qreal bottomMargin() const;
+ void setBottomMargin(qreal);
+
+ qreal margins() const;
+ void setMargins(qreal);
+
+ qreal verticalCenterOffset() const;
+ void setVerticalCenterOffset(qreal);
+
+ qreal baselineOffset() const;
+ void setBaselineOffset(qreal);
+
+ QDeclarativeItem *fill() const;
+ void setFill(QDeclarativeItem *);
+ void resetFill();
+
+ QDeclarativeItem *centerIn() const;
+ void setCenterIn(QDeclarativeItem *);
+ void resetCenterIn();
+
+ UsedAnchors usedAnchors() const;
+
+ void classBegin();
+ void componentComplete();
+
+Q_SIGNALS:
+ void leftChanged();
+ void rightChanged();
+ void topChanged();
+ void bottomChanged();
+ void verticalCenterChanged();
+ void horizontalCenterChanged();
+ void baselineChanged();
+ void fillChanged();
+ void centerInChanged();
+ void leftMarginChanged();
+ void rightMarginChanged();
+ void topMarginChanged();
+ void bottomMarginChanged();
+ void marginsChanged();
+ void verticalCenterOffsetChanged();
+ void horizontalCenterOffsetChanged();
+ void baselineOffsetChanged();
+
+private:
+ friend class QDeclarativeItem;
+ Q_DISABLE_COPY(QDeclarativeAnchors)
+ Q_DECLARE_PRIVATE(QDeclarativeAnchors)
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeAnchors::UsedAnchors)
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeAnchors)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
new file mode 100644
index 0000000..d9d7ffa
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEANCHORS_P_H
+#define QDECLARATIVEANCHORS_P_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 "qdeclarativeanchors_p.h"
+#include "qdeclarativeitemchangelistener_p.h"
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeAnchorLine
+{
+public:
+ QDeclarativeAnchorLine() : item(0), anchorLine(Invalid)
+ {
+ }
+
+ enum AnchorLine {
+ Invalid = 0x0,
+ Left = 0x01,
+ Right = 0x02,
+ Top = 0x04,
+ Bottom = 0x08,
+ HCenter = 0x10,
+ VCenter = 0x20,
+ Baseline = 0x40,
+ Horizontal_Mask = Left | Right | HCenter,
+ Vertical_Mask = Top | Bottom | VCenter | Baseline
+ };
+
+ QDeclarativeItem *item;
+ AnchorLine anchorLine;
+
+ bool operator==(const QDeclarativeAnchorLine& other) const
+ {
+ return item == other.item && anchorLine == other.anchorLine;
+ }
+};
+
+class QDeclarativeAnchorsPrivate : public QObjectPrivate, public QDeclarativeItemChangeListener
+{
+ Q_DECLARE_PUBLIC(QDeclarativeAnchors)
+public:
+ QDeclarativeAnchorsPrivate(QDeclarativeItem *i)
+ : updatingMe(false), updatingHorizontalAnchor(0),
+ updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(i), usedAnchors(0), fill(0),
+ centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
+ margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0),
+ componentComplete(true)
+ {
+ }
+
+ void init()
+ {
+ }
+
+ void clearItem(QDeclarativeItem *);
+
+ void addDepend(QDeclarativeItem *);
+ void remDepend(QDeclarativeItem *);
+ bool isItemComplete() const;
+
+ bool updatingMe;
+ int updatingHorizontalAnchor;
+ int updatingVerticalAnchor;
+ int updatingFill;
+ int updatingCenterIn;
+
+ void setItemHeight(qreal);
+ void setItemWidth(qreal);
+ void setItemX(qreal);
+ void setItemY(qreal);
+ void setItemPos(const QPointF &);
+
+ void updateOnComplete();
+ void updateMe();
+
+ // QDeclarativeItemGeometryListener interface
+ void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &);
+ QDeclarativeAnchorsPrivate *anchorPrivate() { return this; }
+
+ bool checkHValid() const;
+ bool checkVValid() const;
+ bool checkHAnchorValid(QDeclarativeAnchorLine anchor) const;
+ bool checkVAnchorValid(QDeclarativeAnchorLine anchor) const;
+ bool calcStretch(const QDeclarativeAnchorLine &edge1, const QDeclarativeAnchorLine &edge2, int offset1, int offset2, QDeclarativeAnchorLine::AnchorLine line, int &stretch);
+
+ void updateHorizontalAnchors();
+ void updateVerticalAnchors();
+ void fillChanged();
+ void centerInChanged();
+
+ QDeclarativeItem *item;
+ QDeclarativeAnchors::UsedAnchors usedAnchors;
+
+ QDeclarativeItem *fill;
+ QDeclarativeItem *centerIn;
+
+ QDeclarativeAnchorLine left;
+ QDeclarativeAnchorLine right;
+ QDeclarativeAnchorLine top;
+ QDeclarativeAnchorLine bottom;
+ QDeclarativeAnchorLine vCenter;
+ QDeclarativeAnchorLine hCenter;
+ QDeclarativeAnchorLine baseline;
+
+ qreal leftMargin;
+ qreal rightMargin;
+ qreal topMargin;
+ qreal bottomMargin;
+ qreal margins;
+ qreal vCenterOffset;
+ qreal hCenterOffset;
+ qreal baselineOffset;
+
+ bool componentComplete;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeclarativeAnchorLine)
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
new file mode 100644
index 0000000..20b1de3
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
@@ -0,0 +1,306 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeanimatedimage_p.h"
+#include "qdeclarativeanimatedimage_p_p.h"
+
+#include <qdeclarativeengine.h>
+
+#include <QMovie>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QDeclarativeAnimatedImage
+ \internal
+*/
+
+/*!
+ \qmlclass AnimatedImage QDeclarativeAnimatedImage
+ \inherits Image
+ \since 4.7
+
+ This item provides for playing animations stored as images containing a series of frames,
+ such as GIF files. The full list of supported formats can be determined with
+ QMovie::supportedFormats().
+
+ \table
+ \row
+ \o \image animatedimageitem.gif
+ \o
+ \qml
+Item {
+ width: anim.width; height: anim.height+8
+ AnimatedImage { id: anim; source: "pics/games-anim.gif" }
+ Rectangle { color: "red"; width: 4; height: 8; y: anim.height
+ x: (anim.width-width)*anim.currentFrame/(anim.frameCount-1)
+ }
+}
+ \endqml
+ \endtable
+*/
+
+QDeclarativeAnimatedImage::QDeclarativeAnimatedImage(QDeclarativeItem *parent)
+ : QDeclarativeImage(*(new QDeclarativeAnimatedImagePrivate), parent)
+{
+}
+
+QDeclarativeAnimatedImage::~QDeclarativeAnimatedImage()
+{
+ Q_D(QDeclarativeAnimatedImage);
+ delete d->_movie;
+}
+
+/*!
+ \qmlproperty bool AnimatedImage::paused
+ This property holds whether the animated image is paused or not
+
+ Defaults to false, and can be set to true when you want to pause.
+*/
+bool QDeclarativeAnimatedImage::isPaused() const
+{
+ Q_D(const QDeclarativeAnimatedImage);
+ if(!d->_movie)
+ return false;
+ return d->_movie->state()==QMovie::Paused;
+}
+
+void QDeclarativeAnimatedImage::setPaused(bool pause)
+{
+ Q_D(QDeclarativeAnimatedImage);
+ if(pause == d->paused)
+ return;
+ d->paused = pause;
+ if(!d->_movie)
+ return;
+ d->_movie->setPaused(pause);
+}
+/*!
+ \qmlproperty bool AnimatedImage::playing
+ This property holds whether the animated image is playing or not
+
+ Defaults to true, so as to start playing immediately.
+*/
+bool QDeclarativeAnimatedImage::isPlaying() const
+{
+ Q_D(const QDeclarativeAnimatedImage);
+ if (!d->_movie)
+ return false;
+ return d->_movie->state()!=QMovie::NotRunning;
+}
+
+void QDeclarativeAnimatedImage::setPlaying(bool play)
+{
+ Q_D(QDeclarativeAnimatedImage);
+ if(play == d->playing)
+ return;
+ d->playing = play;
+ if (!d->_movie)
+ return;
+ if (play)
+ d->_movie->start();
+ else
+ d->_movie->stop();
+}
+
+/*!
+ \qmlproperty int AnimatedImage::currentFrame
+ \qmlproperty int AnimatedImage::frameCount
+
+ currentFrame is the frame that is currently visible. Watching when this changes can
+ allow other things to animate at the same time as the image. frameCount is the number
+ of frames in the animation. For some animation formats, frameCount is unknown and set to zero.
+*/
+int QDeclarativeAnimatedImage::currentFrame() const
+{
+ Q_D(const QDeclarativeAnimatedImage);
+ if (!d->_movie)
+ return d->preset_currentframe;
+ return d->_movie->currentFrameNumber();
+}
+
+void QDeclarativeAnimatedImage::setCurrentFrame(int frame)
+{
+ Q_D(QDeclarativeAnimatedImage);
+ if (!d->_movie) {
+ d->preset_currentframe = frame;
+ return;
+ }
+ d->_movie->jumpToFrame(frame);
+}
+
+int QDeclarativeAnimatedImage::frameCount() const
+{
+ Q_D(const QDeclarativeAnimatedImage);
+ if (!d->_movie)
+ return 0;
+ return d->_movie->frameCount();
+}
+
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
+void QDeclarativeAnimatedImage::setSource(const QUrl &url)
+{
+ Q_D(QDeclarativeAnimatedImage);
+ if (url == d->url)
+ return;
+
+ delete d->_movie;
+ d->_movie = 0;
+
+ if (d->reply) {
+ d->reply->deleteLater();
+ d->reply = 0;
+ }
+
+ d->url = url;
+
+ if (url.isEmpty()) {
+ delete d->_movie;
+ d->status = Null;
+ } else {
+#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
+ QString lf = toLocalFileOrQrc(url);
+ if (!lf.isEmpty()) {
+ //### should be unified with movieRequestFinished
+ d->_movie = new QMovie(lf);
+ if (!d->_movie->isValid()){
+ qWarning() << "Error Reading Animated Image File" << d->url;
+ delete d->_movie;
+ d->_movie = 0;
+ return;
+ }
+ connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
+ this, SLOT(playingStatusChanged()));
+ connect(d->_movie, SIGNAL(frameChanged(int)),
+ this, SLOT(movieUpdate()));
+ d->_movie->setCacheMode(QMovie::CacheAll);
+ if(d->playing)
+ d->_movie->start();
+ else
+ d->_movie->jumpToFrame(0);
+ if(d->paused)
+ d->_movie->setPaused(true);
+ d->setPixmap(d->_movie->currentPixmap());
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(d->progress);
+ return;
+ }
+#endif
+ d->status = Loading;
+ QNetworkRequest req(d->url);
+ req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ d->reply = qmlEngine(this)->networkAccessManager()->get(req);
+ QObject::connect(d->reply, SIGNAL(finished()),
+ this, SLOT(movieRequestFinished()));
+ }
+
+ emit statusChanged(d->status);
+}
+
+void QDeclarativeAnimatedImage::movieRequestFinished()
+{
+ Q_D(QDeclarativeAnimatedImage);
+ d->_movie = new QMovie(d->reply);
+ if (!d->_movie->isValid()){
+ qWarning() << "Error Reading Animated Image File " << d->url;
+ delete d->_movie;
+ d->_movie = 0;
+ return;
+ }
+ connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
+ this, SLOT(playingStatusChanged()));
+ connect(d->_movie, SIGNAL(frameChanged(int)),
+ this, SLOT(movieUpdate()));
+ d->_movie->setCacheMode(QMovie::CacheAll);
+ if(d->playing)
+ d->_movie->start();
+ if (d->paused || !d->playing) {
+ d->_movie->jumpToFrame(d->preset_currentframe);
+ d->preset_currentframe = 0;
+ }
+ if(d->paused)
+ d->_movie->setPaused(true);
+ d->setPixmap(d->_movie->currentPixmap());
+}
+
+void QDeclarativeAnimatedImage::movieUpdate()
+{
+ Q_D(QDeclarativeAnimatedImage);
+ d->setPixmap(d->_movie->currentPixmap());
+ emit frameChanged();
+}
+
+void QDeclarativeAnimatedImage::playingStatusChanged()
+{
+ Q_D(QDeclarativeAnimatedImage);
+ if((d->_movie->state() != QMovie::NotRunning) != d->playing){
+ d->playing = (d->_movie->state() != QMovie::NotRunning);
+ emit playingChanged();
+ }
+ if((d->_movie->state() == QMovie::Paused) != d->paused){
+ d->playing = (d->_movie->state() == QMovie::Paused);
+ emit pausedChanged();
+ }
+}
+
+void QDeclarativeAnimatedImage::componentComplete()
+{
+ Q_D(QDeclarativeAnimatedImage);
+ QDeclarativeImage::componentComplete();
+ if (!d->reply) {
+ setCurrentFrame(d->preset_currentframe);
+ d->preset_currentframe = 0;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h
new file mode 100644
index 0000000..b2979fe
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEANIMATEDIMAGE_H
+#define QDECLARATIVEANIMATEDIMAGE_H
+
+#include "qdeclarativeimage_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QMovie;
+class QDeclarativeAnimatedImagePrivate;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeAnimatedImage : public QDeclarativeImage
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged)
+ Q_PROPERTY(int frameCount READ frameCount)
+public:
+ QDeclarativeAnimatedImage(QDeclarativeItem *parent=0);
+ ~QDeclarativeAnimatedImage();
+
+ bool isPlaying() const;
+ void setPlaying(bool play);
+
+ bool isPaused() const;
+ void setPaused(bool pause);
+
+ int currentFrame() const;
+ void setCurrentFrame(int frame);
+
+ int frameCount() const;
+
+ // Extends QDeclarativeImage's src property*/
+ virtual void setSource(const QUrl&);
+
+Q_SIGNALS:
+ void playingChanged();
+ void pausedChanged();
+ void frameChanged();
+
+private Q_SLOTS:
+ void movieUpdate();
+ void movieRequestFinished();
+ void playingStatusChanged();
+
+protected:
+ void componentComplete();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeAnimatedImage)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeAnimatedImage)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeAnimatedImage)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h
new file mode 100644
index 0000000..39bb3e5
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEANIMATEDIMAGE_P_H
+#define QDECLARATIVEANIMATEDIMAGE_P_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 "qdeclarativeimage_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QMovie;
+class QNetworkReply;
+
+class QDeclarativeAnimatedImagePrivate : public QDeclarativeImagePrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeAnimatedImage)
+
+public:
+ QDeclarativeAnimatedImagePrivate()
+ : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0)
+ {
+ }
+
+ bool playing;
+ bool paused;
+ int preset_currentframe;
+ QMovie *_movie;
+ QNetworkReply *reply;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEANIMATEDIMAGE_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
new file mode 100644
index 0000000..1f26338
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
@@ -0,0 +1,408 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeborderimage_p.h"
+#include "qdeclarativeborderimage_p_p.h"
+
+#include <qdeclarativeengine.h>
+
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QFile>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass BorderImage QDeclarativeBorderImage
+ \brief The BorderImage element provides an image that can be used as a border.
+ \inherits Item
+ \since 4.7
+
+ \snippet snippets/declarative/border-image.qml 0
+
+ \image BorderImage.png
+ */
+
+/*!
+ \class QDeclarativeBorderImage BorderImage
+ \internal
+ \brief The QDeclarativeBorderImage class provides an image item that you can add to a QDeclarativeView.
+*/
+
+QDeclarativeBorderImage::QDeclarativeBorderImage(QDeclarativeItem *parent)
+ : QDeclarativeImageBase(*(new QDeclarativeBorderImagePrivate), parent)
+{
+}
+
+QDeclarativeBorderImage::~QDeclarativeBorderImage()
+{
+ Q_D(QDeclarativeBorderImage);
+ if (d->sciReply)
+ d->sciReply->deleteLater();
+ if (d->sciPendingPixmapCache)
+ QDeclarativePixmapCache::cancel(d->sciurl, this);
+}
+/*!
+ \qmlproperty enum BorderImage::status
+
+ This property holds the status of image loading. It can be one of:
+ \list
+ \o Null - no image has been set
+ \o Ready - the image has been loaded
+ \o Loading - the image is currently being loaded
+ \o Error - an error occurred while loading the image
+ \endlist
+
+ \sa progress
+*/
+
+/*!
+ \qmlproperty real BorderImage::progress
+
+ This property holds the progress of image loading, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+
+ \sa status
+*/
+
+/*!
+ \qmlproperty bool BorderImage::smooth
+
+ Set this property if you want the image to be smoothly filtered when scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the image is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the image is stationary on
+ the screen. A common pattern when animating an image is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+*/
+
+/*!
+ \qmlproperty url BorderImage::source
+
+ BorderImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.
+
+ It can also handle .sci files, which are a Qml-specific format. A .sci file uses a simple text-based format that specifies
+ the borders, the image file and the tile rules.
+
+ The following .sci file sets the borders to 10 on each side for the image \c picture.png:
+ \qml
+ border.left: 10
+ border.top: 10
+ border.bottom: 10
+ border.right: 10
+ source: picture.png
+ \endqml
+
+ The URL may be absolute, or relative to the URL of the component.
+*/
+
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
+
+void QDeclarativeBorderImage::setSource(const QUrl &url)
+{
+ Q_D(QDeclarativeBorderImage);
+ //equality is fairly expensive, so we bypass for simple, common case
+ if ((d->url.isEmpty() == url.isEmpty()) && url == d->url)
+ return;
+
+ if (d->sciReply) {
+ d->sciReply->deleteLater();
+ d->sciReply = 0;
+ }
+
+ if (d->pendingPixmapCache) {
+ QDeclarativePixmapCache::cancel(d->url, this);
+ d->pendingPixmapCache = false;
+ }
+ if (d->sciPendingPixmapCache) {
+ QDeclarativePixmapCache::cancel(d->sciurl, this);
+ d->sciPendingPixmapCache = false;
+ }
+
+ d->url = url;
+ d->sciurl = QUrl();
+ if (d->progress != 0.0) {
+ d->progress = 0.0;
+ emit progressChanged(d->progress);
+ }
+
+ if (url.isEmpty()) {
+ d->pix = QPixmap();
+ d->status = Null;
+ setImplicitWidth(0);
+ setImplicitHeight(0);
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ update();
+ } else {
+ d->status = Loading;
+ if (d->url.path().endsWith(QLatin1String(".sci"))) {
+#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
+ QString lf = toLocalFileOrQrc(d->url);
+ if (!lf.isEmpty()) {
+ QFile file(lf);
+ file.open(QIODevice::ReadOnly);
+ setGridScaledImage(QDeclarativeGridScaledImage(&file));
+ } else
+#endif
+ {
+ QNetworkRequest req(d->url);
+ d->sciReply = qmlEngine(this)->networkAccessManager()->get(req);
+ QObject::connect(d->sciReply, SIGNAL(finished()),
+ this, SLOT(sciRequestFinished()));
+ }
+ } else {
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix);
+ if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) {
+ QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url);
+ d->pendingPixmapCache = true;
+ connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
+ connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ } else {
+ //### should be unified with requestFinished
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->pix.isNull())
+ d->status = Error;
+ if (d->status == Loading)
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(d->progress);
+ update();
+ }
+ }
+ }
+
+ emit statusChanged(d->status);
+}
+
+/*!
+ \qmlproperty int BorderImage::border.left
+ \qmlproperty int BorderImage::border.right
+ \qmlproperty int BorderImage::border.top
+ \qmlproperty int BorderImage::border.bottom
+
+ \target ImagexmlpropertiesscaleGrid
+
+ The 4 border lines (2 horizontal and 2 vertical) break an image into 9 sections, as shown below:
+
+ \image declarative-scalegrid.png
+
+ When the image is scaled:
+ \list
+ \i the corners (sections 1, 3, 7, and 9) are not scaled at all
+ \i the middle (section 5) is scaled according to BorderImage::horizontalTileMode and BorderImage::verticalTileMode
+ \i sections 2 and 8 are scaled according to BorderImage::horizontalTileMode
+ \i sections 4 and 6 are scaled according to BorderImage::verticalTileMode
+ \endlist
+
+ Each border line (left, right, top, and bottom) specifies an offset from the respective side. For example, \c{border.bottom: 10} sets the bottom line 10 pixels up from the bottom of the image.
+
+ The border lines can also be specified using a
+ \l {BorderImage::source}{.sci file}.
+*/
+
+QDeclarativeScaleGrid *QDeclarativeBorderImage::border()
+{
+ Q_D(QDeclarativeBorderImage);
+ return d->getScaleGrid();
+}
+
+/*!
+ \qmlproperty TileMode BorderImage::horizontalTileMode
+ \qmlproperty TileMode BorderImage::verticalTileMode
+
+ This property describes how to repeat or stretch the middle parts of the border image.
+
+ \list
+ \o Stretch - Scale the image to fit to the available area.
+ \o Repeat - Tile the image until there is no more space. May crop the last image.
+ \o Round - Like Repeat, but scales the images down to ensure that the last image is not cropped.
+ \endlist
+*/
+QDeclarativeBorderImage::TileMode QDeclarativeBorderImage::horizontalTileMode() const
+{
+ Q_D(const QDeclarativeBorderImage);
+ return d->horizontalTileMode;
+}
+
+void QDeclarativeBorderImage::setHorizontalTileMode(TileMode t)
+{
+ Q_D(QDeclarativeBorderImage);
+ if (t != d->horizontalTileMode) {
+ d->horizontalTileMode = t;
+ emit horizontalTileModeChanged();
+ update();
+ }
+}
+
+QDeclarativeBorderImage::TileMode QDeclarativeBorderImage::verticalTileMode() const
+{
+ Q_D(const QDeclarativeBorderImage);
+ return d->verticalTileMode;
+}
+
+void QDeclarativeBorderImage::setVerticalTileMode(TileMode t)
+{
+ Q_D(QDeclarativeBorderImage);
+ if (t != d->verticalTileMode) {
+ d->verticalTileMode = t;
+ emit verticalTileModeChanged();
+ update();
+ }
+}
+
+void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledImage& sci)
+{
+ Q_D(QDeclarativeBorderImage);
+ if (!sci.isValid()) {
+ d->status = Error;
+ emit statusChanged(d->status);
+ } else {
+ QDeclarativeScaleGrid *sg = border();
+ sg->setTop(sci.gridTop());
+ sg->setBottom(sci.gridBottom());
+ sg->setLeft(sci.gridLeft());
+ sg->setRight(sci.gridRight());
+ d->horizontalTileMode = sci.horizontalTileRule();
+ d->verticalTileMode = sci.verticalTileRule();
+
+ d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix);
+ if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) {
+ QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->sciurl);
+ d->sciPendingPixmapCache = true;
+ connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
+ connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ } else {
+ //### should be unified with requestFinished
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->pix.isNull())
+ d->status = Error;
+ if (d->status == Loading)
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(1.0);
+ update();
+ }
+ }
+}
+
+void QDeclarativeBorderImage::requestFinished()
+{
+ Q_D(QDeclarativeBorderImage);
+
+ if (d->url.path().endsWith(QLatin1String(".sci"))) {
+ d->sciPendingPixmapCache = false;
+ QDeclarativePixmapCache::get(d->sciurl, &d->pix);
+ } else {
+ d->pendingPixmapCache = false;
+ if (QDeclarativePixmapCache::get(d->url, &d->pix) != QDeclarativePixmapReply::Ready)
+ d->status = Error;
+ }
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->status == Loading)
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(1.0);
+ update();
+}
+
+void QDeclarativeBorderImage::sciRequestFinished()
+{
+ Q_D(QDeclarativeBorderImage);
+ if (d->sciReply->error() != QNetworkReply::NoError) {
+ d->status = Error;
+ d->sciReply->deleteLater();
+ d->sciReply = 0;
+ emit statusChanged(d->status);
+ } else {
+ QDeclarativeGridScaledImage sci(d->sciReply);
+ d->sciReply->deleteLater();
+ d->sciReply = 0;
+ setGridScaledImage(sci);
+ }
+}
+
+void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ Q_D(QDeclarativeBorderImage);
+ if (d->pix.isNull())
+ return;
+
+ bool oldAA = p->testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
+ if (d->smooth)
+ p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+
+ const QDeclarativeScaleGrid *border = d->getScaleGrid();
+ QMargins margins(border->left(), border->top(), border->right(), border->bottom());
+ QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode);
+ qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, d->pix, d->pix.rect(), margins, rules);
+ if (d->smooth) {
+ p->setRenderHint(QPainter::Antialiasing, oldAA);
+ p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage_p.h b/src/declarative/graphicsitems/qdeclarativeborderimage_p.h
new file mode 100644
index 0000000..db81fd8
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEBORDERIMAGE_H
+#define QDECLARATIVEBORDERIMAGE_H
+
+#include "qdeclarativeimagebase_p.h"
+
+#include <QtNetwork/qnetworkreply.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeScaleGrid;
+class QDeclarativeGridScaledImage;
+class QDeclarativeBorderImagePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeBorderImage : public QDeclarativeImageBase
+{
+ Q_OBJECT
+ Q_ENUMS(TileMode)
+
+ Q_PROPERTY(QDeclarativeScaleGrid *border READ border CONSTANT)
+ Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode NOTIFY horizontalTileModeChanged)
+ Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged)
+
+public:
+ QDeclarativeBorderImage(QDeclarativeItem *parent=0);
+ ~QDeclarativeBorderImage();
+
+ QDeclarativeScaleGrid *border();
+
+ enum TileMode { Stretch = Qt::StretchTile, Repeat = Qt::RepeatTile, Round = Qt::RoundTile };
+
+ TileMode horizontalTileMode() const;
+ void setHorizontalTileMode(TileMode);
+
+ TileMode verticalTileMode() const;
+ void setVerticalTileMode(TileMode);
+
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ void setSource(const QUrl &url);
+
+Q_SIGNALS:
+ void horizontalTileModeChanged();
+ void verticalTileModeChanged();
+
+private:
+ void setGridScaledImage(const QDeclarativeGridScaledImage& sci);
+
+private Q_SLOTS:
+ void requestFinished();
+ void sciRequestFinished();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeBorderImage)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeBorderImage)
+};
+
+QT_END_NAMESPACE
+QML_DECLARE_TYPE(QDeclarativeBorderImage)
+QT_END_HEADER
+
+#endif // QDECLARATIVEBORDERIMAGE_H
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h b/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h
new file mode 100644
index 0000000..b9cf73a
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEBORDERIMAGE_P_H
+#define QDECLARATIVEBORDERIMAGE_P_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 "qdeclarativeimagebase_p_p.h"
+#include "qdeclarativescalegrid_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkReply;
+class QDeclarativeBorderImagePrivate : public QDeclarativeImageBasePrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeBorderImage)
+
+public:
+ QDeclarativeBorderImagePrivate()
+ : border(0), sciReply(0),
+ sciPendingPixmapCache(false),
+ horizontalTileMode(QDeclarativeBorderImage::Stretch),
+ verticalTileMode(QDeclarativeBorderImage::Stretch)
+ {
+ }
+
+ ~QDeclarativeBorderImagePrivate()
+ {
+ }
+
+ QDeclarativeScaleGrid *getScaleGrid()
+ {
+ Q_Q(QDeclarativeBorderImage);
+ if (!border)
+ border = new QDeclarativeScaleGrid(q);
+ return border;
+ }
+
+ QDeclarativeScaleGrid *border;
+ QUrl sciurl;
+ QNetworkReply *sciReply;
+ bool sciPendingPixmapCache;
+ QDeclarativeBorderImage::TileMode horizontalTileMode;
+ QDeclarativeBorderImage::TileMode verticalTileMode;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEBORDERIMAGE_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativeeffects.cpp b/src/declarative/graphicsitems/qdeclarativeeffects.cpp
new file mode 100644
index 0000000..efab24e
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeeffects.cpp
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qdeclarative.h>
+
+#include <QtGui/qgraphicseffect.h>
+
+/*!
+ \qmlclass Blur QGraphicsBlurEffect
+ \brief The Blur object provides a blur effect.
+
+ A blur effect blurs the source item. This effect is useful for reducing details;
+ for example, when the a source loses focus and attention should be drawn to other
+ elements. Use blurRadius to control the level of detail and blurHint to control
+ the quality of the blur.
+
+ By default, the blur radius is 5 pixels.
+
+ \img graphicseffect-blur.png
+*/
+
+/*!
+ \qmlproperty real Blur::blurRadius
+
+ This controls how blurry an item will appear.
+
+ A smaller radius produces a sharper appearance, and a larger radius produces
+ a more blurred appearance.
+
+ The default radius is 5 pixels.
+*/
+/*!
+ \qmlproperty enumeration Blur::blurHint
+
+ Use Qt.PerformanceHint to specify a faster blur or Qt.QualityHint hint
+ to specify a higher quality blur.
+
+ If the blur radius is animated, it is recommended you use Qt.PerformanceHint.
+
+ The default hint is Qt.PerformanceHint.
+*/
+
+/*!
+ \qmlclass Colorize QGraphicsColorizeEffect
+ \brief The Colorize object provides a colorize effect.
+
+ A colorize effect renders the source item with a tint of its color.
+
+ By default, the color is light blue.
+
+ \img graphicseffect-colorize.png
+*/
+
+/*!
+ \qmlproperty color Colorize::color
+ The color of the effect.
+
+ By default, the color is light blue.
+*/
+
+/*!
+ \qmlproperty real Colorize::strength
+
+ To what extent the source item is "colored". A strength of 0.0 is equal to no effect,
+ while 1.0 means full colorization. By default, the strength is 1.0.
+*/
+
+
+/*!
+ \qmlclass DropShadow QGraphicsDropShadowEffect
+ \brief The DropShadow object provides a drop shadow effect.
+
+ A drop shadow effect renders the source item with a drop shadow. The color of
+ the drop shadow can be modified using the color property. The drop
+ shadow offset can be modified using the xOffset and yOffset properties and the blur
+ radius of the drop shadow can be changed with the blurRadius property.
+
+ By default, the drop shadow is a semi-transparent dark gray shadow,
+ blurred with a radius of 1 at an offset of 8 pixels towards the lower right.
+
+ \img graphicseffect-drop-shadow.png
+*/
+
+/*!
+ \qmlproperty real DropShadow::xOffset
+ \qmlproperty real DropShadow::yOffset
+ The shadow offset in pixels.
+
+ By default, xOffset and yOffset are 8 pixels.
+*/
+
+/*!
+ \qmlproperty real DropShadow::blurRadius
+ The blur radius in pixels of the drop shadow.
+
+ Using a smaller radius results in a sharper shadow, whereas using a bigger
+ radius results in a more blurred shadow.
+
+ By default, the blur radius is 1 pixel.
+*/
+
+/*!
+ \qmlproperty color DropShadow::color
+ The color of the drop shadow.
+
+ By default, the drop color is a semi-transparent dark gray.
+*/
+
+
+/*!
+ \qmlclass Opacity QGraphicsOpacityEffect
+ \brief The Opacity object provides an opacity effect.
+
+ An opacity effect renders the source with an opacity. This effect is useful
+ for making the source semi-transparent, similar to a fade-in/fade-out
+ sequence. The opacity can be modified using the opacity property.
+
+ By default, the opacity is 0.7.
+
+ \img graphicseffect-opacity.png
+*/
+
+/*!
+ \qmlproperty real Opacity::opacity
+ This property specifies how opaque an item should appear.
+
+ The value should be in the range of 0.0 to 1.0, where 0.0 is
+ fully transparent and 1.0 is fully opaque.
+
+ By default, the opacity is 0.7.
+*/
+
diff --git a/src/declarative/graphicsitems/qdeclarativeeffects_p.h b/src/declarative/graphicsitems/qdeclarativeeffects_p.h
new file mode 100644
index 0000000..73eec6a
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeeffects_p.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEEFFECTS_P_H
+#define QDECLARATIVEEFFECTS_P_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 <qdeclarative.h>
+#include <QtGui/qgraphicseffect.h>
+
+QML_DECLARE_TYPE(QGraphicsEffect)
+QML_DECLARE_TYPE(QGraphicsBlurEffect)
+QML_DECLARE_TYPE(QGraphicsColorizeEffect)
+QML_DECLARE_TYPE(QGraphicsDropShadowEffect)
+QML_DECLARE_TYPE(QGraphicsOpacityEffect)
+
+#endif // QDECLARATIVEEFFECTS_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativeevents.cpp b/src/declarative/graphicsitems/qdeclarativeevents.cpp
new file mode 100644
index 0000000..d2cbb54
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeevents.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeevents_p_p.h"
+
+QT_BEGIN_NAMESPACE
+/*!
+ \qmlclass KeyEvent QDeclarativeKeyEvent
+ \since 4.7
+ \brief The KeyEvent object provides information about a key event.
+
+ For example, the following changes the Item's state property when the Enter
+ key is pressed:
+ \qml
+Item {
+ focus: true
+ Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
+}
+ \endqml
+*/
+
+/*!
+ \internal
+ \class QDeclarativeKeyEvent
+*/
+
+/*!
+ \qmlproperty int KeyEvent::key
+
+ This property holds the code of the key that was pressed or released.
+
+ See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. These codes are
+ independent of the underlying window system. Note that this
+ function does not distinguish between capital and non-capital
+ letters, use the text() function (returning the Unicode text the
+ key generated) for this purpose.
+
+ A value of either 0 or \l {Qt::Key_unknown}{Qt.Key_Unknown} means that the event is not
+ the result of a known key; for example, it may be the result of
+ a compose sequence, a keyboard macro, or due to key event
+ compression.
+*/
+
+/*!
+ \qmlproperty string KeyEvent::text
+
+ This property holds the Unicode text that the key generated.
+ The text returned can be an empty string in cases where modifier keys,
+ such as Shift, Control, Alt, and Meta, are being pressed or released.
+ In such cases \c key will contain a valid value
+*/
+
+/*!
+ \qmlproperty bool KeyEvent::isAutoRepeat
+
+ This property holds whether this event comes from an auto-repeating key.
+*/
+
+/*!
+ \qmlproperty int KeyEvent::count
+
+ This property holds the number of keys involved in this event. If \l KeyEvent::text
+ is not empty, this is simply the length of the string.
+*/
+
+/*!
+ \qmlproperty bool KeyEvent::accepted
+
+ Setting \a accepted to true prevents the key event from being
+ propagated to the item's parent.
+
+ Generally, if the item acts on the key event then it should be accepted
+ so that ancestor items do not also respond to the same event.
+*/
+
+
+/*!
+ \qmlclass MouseEvent QDeclarativeMouseEvent
+ \brief The MouseEvent object provides information about a mouse event.
+
+ The position of the mouse can be found via the x and y properties.
+ The button that caused the event is available via the button property.
+*/
+
+/*!
+ \internal
+ \class QDeclarativeMouseEvent
+*/
+
+/*!
+ \qmlproperty int MouseEvent::x
+ \qmlproperty int MouseEvent::y
+
+ These properties hold the position of the mouse event.
+*/
+
+/*!
+ \qmlproperty enum MouseEvent::button
+
+ This property holds the button that caused the event. It can be one of:
+ \list
+ \o Qt.LeftButton
+ \o Qt.RightButton
+ \o Qt.MidButton
+ \endlist
+*/
+
+/*!
+ \qmlproperty bool MouseEvent::wasHeld
+
+ This property is true if the mouse button has been held pressed longer the
+ threshold (800ms).
+*/
+
+/*!
+ \qmlproperty int MouseEvent::buttons
+
+ This property holds the mouse buttons pressed when the event was generated.
+ For mouse move events, this is all buttons that are pressed down. For mouse
+ press and double click events this includes the button that caused the event.
+ For mouse release events this excludes the button that caused the event.
+
+ It contains a bitwise combination of:
+ \list
+ \o Qt.LeftButton
+ \o Qt.RightButton
+ \o Qt.MidButton
+ \endlist
+*/
+
+/*!
+ \qmlproperty int MouseEvent::modifiers
+
+ This property holds the keyboard modifier flags that existed immediately
+ before the event occurred.
+
+ It contains a bitwise combination of:
+ \list
+ \o Qt.NoModifier - No modifier key is pressed.
+ \o Qt.ShiftModifier - A Shift key on the keyboard is pressed.
+ \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
+ \o Qt.AltModifier - An Alt key on the keyboard is pressed.
+ \o Qt.MetaModifier - A Meta key on the keyboard is pressed.
+ \o Qt.KeypadModifier - A keypad button is pressed.
+ \endlist
+
+ For example, to react to a Shift key + Left mouse button click:
+ \qml
+MouseArea {
+ onClicked: { if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) doSomething(); }
+}
+ \endqml
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeevents_p_p.h b/src/declarative/graphicsitems/qdeclarativeevents_p_p.h
new file mode 100644
index 0000000..65ac8de
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeevents_p_p.h
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEEVENTS_P_H
+#define QDECLARATIVEEVENTS_P_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 <qdeclarative.h>
+
+#include <QtCore/qobject.h>
+#include <QtGui/qevent.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeKeyEvent : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int key READ key)
+ Q_PROPERTY(QString text READ text)
+ Q_PROPERTY(int modifiers READ modifiers)
+ Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat)
+ Q_PROPERTY(int count READ count)
+ Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
+
+public:
+ QDeclarativeKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
+ : event(type, key, modifiers, text, autorep, count) { event.setAccepted(false); }
+ QDeclarativeKeyEvent(const QKeyEvent &ke)
+ : event(ke) { event.setAccepted(false); }
+
+ int key() const { return event.key(); }
+ QString text() const { return event.text(); }
+ int modifiers() const { return event.modifiers(); }
+ bool isAutoRepeat() const { return event.isAutoRepeat(); }
+ int count() const { return event.count(); }
+
+ bool isAccepted() { return event.isAccepted(); }
+ void setAccepted(bool accepted) { event.setAccepted(accepted); }
+
+private:
+ QKeyEvent event;
+};
+
+class QDeclarativeMouseEvent : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int x READ x)
+ Q_PROPERTY(int y READ y)
+ Q_PROPERTY(int button READ button)
+ Q_PROPERTY(int buttons READ buttons)
+ Q_PROPERTY(int modifiers READ modifiers)
+ Q_PROPERTY(bool wasHeld READ wasHeld)
+ Q_PROPERTY(bool isClick READ isClick)
+ Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
+
+public:
+ QDeclarativeMouseEvent(int x, int y, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers
+ , bool isClick=false, bool wasHeld=false)
+ : _x(x), _y(y), _button(button), _buttons(buttons), _modifiers(modifiers)
+ , _wasHeld(wasHeld), _isClick(isClick), _accepted(true) {}
+
+ int x() const { return _x; }
+ int y() const { return _y; }
+ int button() const { return _button; }
+ int buttons() const { return _buttons; }
+ int modifiers() const { return _modifiers; }
+ bool wasHeld() const { return _wasHeld; }
+ bool isClick() const { return _isClick; }
+
+ bool isAccepted() { return _accepted; }
+ void setAccepted(bool accepted) { _accepted = accepted; }
+
+private:
+ int _x;
+ int _y;
+ Qt::MouseButton _button;
+ Qt::MouseButtons _buttons;
+ Qt::KeyboardModifiers _modifiers;
+ bool _wasHeld;
+ bool _isClick;
+ bool _accepted;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeKeyEvent)
+QML_DECLARE_TYPE(QDeclarativeMouseEvent)
+
+#endif // QDECLARATIVEEVENTS_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
new file mode 100644
index 0000000..9f19f53
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -0,0 +1,1324 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeflickable_p.h"
+#include "qdeclarativeflickable_p_p.h"
+
+#include <QGraphicsSceneMouseEvent>
+#include <QPointer>
+#include <QTimer>
+
+QT_BEGIN_NAMESPACE
+
+
+// FlickThreshold determines how far the "mouse" must have moved
+// before we perform a flick.
+static const int FlickThreshold = 20;
+
+// Really slow flicks can be annoying.
+static const int minimumFlickVelocity = 200;
+
+QDeclarativeFlickableVisibleArea::QDeclarativeFlickableVisibleArea(QDeclarativeFlickable *parent)
+ : QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.)
+ , m_yPosition(0.), m_heightRatio(0.)
+{
+}
+
+qreal QDeclarativeFlickableVisibleArea::widthRatio() const
+{
+ return m_widthRatio;
+}
+
+qreal QDeclarativeFlickableVisibleArea::xPosition() const
+{
+ return m_xPosition;
+}
+
+qreal QDeclarativeFlickableVisibleArea::heightRatio() const
+{
+ return m_heightRatio;
+}
+
+qreal QDeclarativeFlickableVisibleArea::yPosition() const
+{
+ return m_yPosition;
+}
+
+void QDeclarativeFlickableVisibleArea::updateVisible()
+{
+ QDeclarativeFlickablePrivate *p = static_cast<QDeclarativeFlickablePrivate *>(QGraphicsItemPrivate::get(flickable));
+ bool pageChange = false;
+
+ // Vertical
+ const qreal viewheight = flickable->height();
+ const qreal maxyextent = -flickable->maxYExtent() + flickable->minYExtent();
+ qreal pagePos = (-p->_moveY.value() + flickable->minYExtent()) / (maxyextent + viewheight);
+ qreal pageSize = viewheight / (maxyextent + viewheight);
+
+ if (pageSize != m_heightRatio) {
+ m_heightRatio = pageSize;
+ pageChange = true;
+ }
+ if (pagePos != m_yPosition) {
+ m_yPosition = pagePos;
+ pageChange = true;
+ }
+
+ // Horizontal
+ const qreal viewwidth = flickable->width();
+ const qreal maxxextent = -flickable->maxXExtent() + flickable->minXExtent();
+ pagePos = (-p->_moveX.value() + flickable->minXExtent()) / (maxxextent + viewwidth);
+ pageSize = viewwidth / (maxxextent + viewwidth);
+
+ if (pageSize != m_widthRatio) {
+ m_widthRatio = pageSize;
+ pageChange = true;
+ }
+ if (pagePos != m_xPosition) {
+ m_xPosition = pagePos;
+ pageChange = true;
+ }
+ if (pageChange)
+ emit pageChanged();
+}
+
+
+QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate()
+ : viewport(new QDeclarativeItem)
+ , _moveX(this, &QDeclarativeFlickablePrivate::setRoundedViewportX)
+ , _moveY(this, &QDeclarativeFlickablePrivate::setRoundedViewportY)
+ , vWidth(-1), vHeight(-1), overShoot(true), flicked(false), moving(false), stealMouse(false)
+ , pressed(false), atXEnd(false), atXBeginning(true), atYEnd(false), atYBeginning(true)
+ , interactive(true), deceleration(500), maxVelocity(2000), reportedVelocitySmoothing(100)
+ , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(200)
+ , horizontalVelocity(this), verticalVelocity(this), vTime(0), visibleArea(0)
+ , flickDirection(QDeclarativeFlickable::AutoFlickDirection)
+{
+}
+
+void QDeclarativeFlickablePrivate::init()
+{
+ Q_Q(QDeclarativeFlickable);
+ viewport->setParent(q);
+ QObject::connect(&timeline, SIGNAL(updated()), q, SLOT(ticked()));
+ QObject::connect(&timeline, SIGNAL(completed()), q, SLOT(movementEnding()));
+ q->setAcceptedMouseButtons(Qt::LeftButton);
+ q->setFiltersChildEvents(true);
+ QObject::connect(viewport, SIGNAL(xChanged()), q, SIGNAL(positionXChanged()));
+ QObject::connect(viewport, SIGNAL(yChanged()), q, SIGNAL(positionYChanged()));
+ QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange()));
+ QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(widthChange()));
+}
+
+void QDeclarativeFlickablePrivate::flickX(qreal velocity)
+{
+ Q_Q(QDeclarativeFlickable);
+ qreal maxDistance = -1;
+ // -ve velocity means list is moving up
+ if (velocity > 0) {
+ const qreal minX = q->minXExtent();
+ if (_moveX.value() < minX)
+ maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0));
+ flickTargetX = minX;
+ } else {
+ const qreal maxX = q->maxXExtent();
+ if (_moveX.value() > maxX)
+ maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0);
+ flickTargetX = maxX;
+ }
+ if (maxDistance > 0) {
+ qreal v = velocity;
+ if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
+ if (v < 0)
+ v = -maxVelocity;
+ else
+ v = maxVelocity;
+ }
+ timeline.reset(_moveX);
+ timeline.accel(_moveX, v, deceleration, maxDistance);
+ timeline.callback(QDeclarativeTimeLineCallback(&_moveX, fixupX_callback, this));
+ if (!flicked) {
+ flicked = true;
+ emit q->flickingChanged();
+ emit q->flickStarted();
+ }
+ } else {
+ timeline.reset(_moveX);
+ fixupX();
+ }
+}
+
+void QDeclarativeFlickablePrivate::flickY(qreal velocity)
+{
+ Q_Q(QDeclarativeFlickable);
+ qreal maxDistance = -1;
+ // -ve velocity means list is moving up
+ if (velocity > 0) {
+ const qreal minY = q->minYExtent();
+ if (_moveY.value() < minY)
+ maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0));
+ flickTargetY = minY;
+ } else {
+ const qreal maxY = q->maxYExtent();
+ if (_moveY.value() > maxY)
+ maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0);
+ flickTargetY = maxY;
+ }
+ if (maxDistance > 0) {
+ qreal v = velocity;
+ if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
+ if (v < 0)
+ v = -maxVelocity;
+ else
+ v = maxVelocity;
+ }
+ timeline.reset(_moveY);
+ timeline.accel(_moveY, v, deceleration, maxDistance);
+ timeline.callback(QDeclarativeTimeLineCallback(&_moveY, fixupY_callback, this));
+ if (!flicked) {
+ flicked = true;
+ emit q->flickingChanged();
+ emit q->flickStarted();
+ }
+ } else {
+ timeline.reset(_moveY);
+ fixupY();
+ }
+}
+
+void QDeclarativeFlickablePrivate::fixupX()
+{
+ Q_Q(QDeclarativeFlickable);
+ if (!q->xflick() || _moveX.timeLine())
+ return;
+
+ if (_moveX.value() > q->minXExtent() || (q->maxXExtent() > q->minXExtent())) {
+ timeline.reset(_moveX);
+ if (_moveX.value() != q->minXExtent()) {
+ if (fixupDuration)
+ timeline.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveY.setValue(q->minYExtent());
+ }
+ //emit flickingChanged();
+ } else if (_moveX.value() < q->maxXExtent()) {
+ timeline.reset(_moveX);
+ if (fixupDuration)
+ timeline.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveY.setValue(q->maxYExtent());
+ //emit flickingChanged();
+ } else {
+ flicked = false;
+ }
+
+ vTime = timeline.time();
+}
+
+void QDeclarativeFlickablePrivate::fixupY_callback(void *data)
+{
+ ((QDeclarativeFlickablePrivate *)data)->fixupY();
+}
+
+void QDeclarativeFlickablePrivate::fixupX_callback(void *data)
+{
+ ((QDeclarativeFlickablePrivate *)data)->fixupX();
+}
+
+void QDeclarativeFlickablePrivate::fixupY()
+{
+ Q_Q(QDeclarativeFlickable);
+ if (!q->yflick() || _moveY.timeLine())
+ return;
+
+ if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
+ timeline.reset(_moveY);
+ if (_moveY.value() != q->minYExtent()) {
+ if (fixupDuration)
+ timeline.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveY.setValue(q->minYExtent());
+ }
+ //emit flickingChanged();
+ } else if (_moveY.value() < q->maxYExtent()) {
+ timeline.reset(_moveY);
+ if (fixupDuration)
+ timeline.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveY.setValue(q->maxYExtent());
+ //emit flickingChanged();
+ } else {
+ flicked = false;
+ }
+
+ vTime = timeline.time();
+}
+
+void QDeclarativeFlickablePrivate::updateBeginningEnd()
+{
+ Q_Q(QDeclarativeFlickable);
+ bool atBoundaryChange = false;
+
+ // Vertical
+ const int maxyextent = int(-q->maxYExtent());
+ const qreal ypos = -_moveY.value();
+ bool atBeginning = (ypos <= -q->minYExtent());
+ bool atEnd = (maxyextent <= ypos);
+
+ if (atBeginning != atYBeginning) {
+ atYBeginning = atBeginning;
+ atBoundaryChange = true;
+ }
+ if (atEnd != atYEnd) {
+ atYEnd = atEnd;
+ atBoundaryChange = true;
+ }
+
+ // Horizontal
+ const int maxxextent = int(-q->maxXExtent());
+ const qreal xpos = -_moveX.value();
+ atBeginning = (xpos <= -q->minXExtent());
+ atEnd = (maxxextent <= xpos);
+
+ if (atBeginning != atXBeginning) {
+ atXBeginning = atBeginning;
+ atBoundaryChange = true;
+ }
+ if (atEnd != atXEnd) {
+ atXEnd = atEnd;
+ atBoundaryChange = true;
+ }
+
+ if (atBoundaryChange)
+ emit q->isAtBoundaryChanged();
+
+ if (visibleArea)
+ visibleArea->updateVisible();
+}
+
+/*!
+ \qmlclass Flickable QDeclarativeFlickable
+ \brief The Flickable item provides a surface that can be "flicked".
+ \inherits Item
+
+ Flickable places its children on a surface that can be dragged and flicked.
+
+ \code
+ Flickable {
+ width: 200; height: 200; viewportWidth: image.width; viewportHeight: image.height
+ Image { id: image; source: "bigimage.png" }
+ }
+ \endcode
+
+ \image flickable.gif
+
+ \note Flickable does not automatically clip its contents. If
+ it is not full-screen it is likely that \c clip should be set
+ to true.
+
+ \note Due to an implementation detail items placed inside a flickable cannot anchor to it by
+ id, use 'parent' instead.
+*/
+
+/*!
+ \qmlsignal Flickable::onMovementStarted()
+
+ This handler is called when the view begins moving due to user
+ interaction.
+*/
+
+/*!
+ \qmlsignal Flickable::onMovementEnded()
+
+ This handler is called when the view stops moving due to user
+ interaction. If a flick was generated, this handler will
+ be triggered once the flick stops. If a flick was not
+ generated, the handler will be triggered when the
+ user stops dragging - i.e. a mouse or touch release.
+*/
+
+/*!
+ \qmlsignal Flickable::onFlickStarted()
+
+ This handler is called when the view is flicked. A flick
+ starts from the point that the mouse or touch is released,
+ while still in motion.
+*/
+
+/*!
+ \qmlsignal Flickable::onFlickEnded()
+
+ This handler is called when the view stops moving due to a flick.
+*/
+
+/*!
+ \qmlproperty real Flickable::visibleArea.xPosition
+ \qmlproperty real Flickable::visibleArea.widthRatio
+ \qmlproperty real Flickable::visibleArea.yPosition
+ \qmlproperty real Flickable::visibleArea.heightRatio
+
+ These properties describe the position and size of the currently viewed area.
+ The size is defined as the percentage of the full view currently visible,
+ scaled to 0.0 - 1.0. The page position is in the range 0.0 (beginning) to
+ size ratio (end), i.e. yPosition is in the range 0.0 - heightRatio.
+
+ These properties are typically used to draw a scrollbar, for example:
+ \code
+ Rectangle {
+ opacity: 0.5; anchors.right: MyListView.right-2; width: 6
+ y: MyListView.visibleArea.yPosition * MyListView.height
+ height: MyListView.visibleArea.heightRatio * MyListView.height
+ }
+ \endcode
+*/
+
+QDeclarativeFlickable::QDeclarativeFlickable(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativeFlickablePrivate), parent)
+{
+ Q_D(QDeclarativeFlickable);
+ d->init();
+}
+
+QDeclarativeFlickable::QDeclarativeFlickable(QDeclarativeFlickablePrivate &dd, QDeclarativeItem *parent)
+ : QDeclarativeItem(dd, parent)
+{
+ Q_D(QDeclarativeFlickable);
+ d->init();
+}
+
+QDeclarativeFlickable::~QDeclarativeFlickable()
+{
+}
+
+/*!
+ \qmlproperty int Flickable::viewportX
+ \qmlproperty int Flickable::viewportY
+
+ These properties hold the surface coordinate currently at the top-left
+ corner of the Flickable. For example, if you flick an image up 100 pixels,
+ \c yPosition will be 100.
+*/
+qreal QDeclarativeFlickable::viewportX() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return -d->_moveX.value();
+}
+
+void QDeclarativeFlickable::setViewportX(qreal pos)
+{
+ Q_D(QDeclarativeFlickable);
+ pos = qRound(pos);
+ d->timeline.reset(d->_moveX);
+ d->vTime = d->timeline.time();
+ if (-pos != d->_moveX.value()) {
+ d->_moveX.setValue(-pos);
+ viewportMoved();
+ }
+}
+
+qreal QDeclarativeFlickable::viewportY() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return -d->_moveY.value();
+}
+
+void QDeclarativeFlickable::setViewportY(qreal pos)
+{
+ Q_D(QDeclarativeFlickable);
+ pos = qRound(pos);
+ d->timeline.reset(d->_moveY);
+ d->vTime = d->timeline.time();
+ if (-pos != d->_moveY.value()) {
+ d->_moveY.setValue(-pos);
+ viewportMoved();
+ }
+}
+
+/*!
+ \qmlproperty bool Flickable::interactive
+
+ A user cannot drag or flick a Flickable that is not interactive.
+
+ This property is useful for temporarily disabling flicking. This allows
+ special interaction with Flickable's children: for example, you might want to
+ freeze a flickable map while viewing detailed information on a location popup that is a child of the Flickable.
+*/
+bool QDeclarativeFlickable::isInteractive() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->interactive;
+}
+
+void QDeclarativeFlickable::setInteractive(bool interactive)
+{
+ Q_D(QDeclarativeFlickable);
+ if (interactive != d->interactive) {
+ d->interactive = interactive;
+ if (!interactive && d->flicked) {
+ d->timeline.clear();
+ d->vTime = d->timeline.time();
+ d->flicked = false;
+ emit flickingChanged();
+ emit flickEnded();
+ }
+ emit interactiveChanged();
+ }
+}
+
+/*!
+ \qmlproperty real Flickable::horizontalVelocity
+ \qmlproperty real Flickable::verticalVelocity
+ \qmlproperty real Flickable::reportedVelocitySmoothing
+
+ The instantaneous velocity of movement along the x and y axes, in pixels/sec.
+
+ The reported velocity is smoothed to avoid erratic output.
+ reportedVelocitySmoothing determines how much smoothing is applied.
+*/
+qreal QDeclarativeFlickable::horizontalVelocity() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->horizontalVelocity.value();
+}
+
+qreal QDeclarativeFlickable::verticalVelocity() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->verticalVelocity.value();
+}
+
+/*!
+ \qmlproperty bool Flickable::atXBeginning
+ \qmlproperty bool Flickable::atXEnd
+ \qmlproperty bool Flickable::atYBeginning
+ \qmlproperty bool Flickable::atYEnd
+
+ These properties are true if the flickable view is positioned at the beginning,
+ or end respecively.
+*/
+bool QDeclarativeFlickable::isAtXEnd() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->atXEnd;
+}
+
+bool QDeclarativeFlickable::isAtXBeginning() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->atXBeginning;
+}
+
+bool QDeclarativeFlickable::isAtYEnd() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->atYEnd;
+}
+
+bool QDeclarativeFlickable::isAtYBeginning() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->atYBeginning;
+}
+
+void QDeclarativeFlickable::ticked()
+{
+ viewportMoved();
+}
+
+QDeclarativeItem *QDeclarativeFlickable::viewport()
+{
+ Q_D(QDeclarativeFlickable);
+ return d->viewport;
+}
+
+QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea()
+{
+ Q_D(QDeclarativeFlickable);
+ if (!d->visibleArea)
+ d->visibleArea = new QDeclarativeFlickableVisibleArea(this);
+ return d->visibleArea;
+}
+
+/*!
+ \qmlproperty enumeration Flickable::flickDirection
+
+ This property determines which directions the view can be flicked.
+
+ \list
+ \o AutoFlickDirection (default) - allows flicking vertically if the
+ \e viewportHeight is not equal to the \e height of the Flickable.
+ Allows flicking horizontally if the \e viewportWidth is not equal
+ to the \e width of the Flickable.
+ \o HorizontalFlick - allows flicking horizontally.
+ \o VerticalFlick - allows flicking vertically.
+ \o HorizontalAndVerticalFlick - allows flicking in both directions.
+ \endlist
+*/
+QDeclarativeFlickable::FlickDirection QDeclarativeFlickable::flickDirection() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->flickDirection;
+}
+
+void QDeclarativeFlickable::setFlickDirection(FlickDirection direction)
+{
+ Q_D(QDeclarativeFlickable);
+ if (direction != d->flickDirection) {
+ d->flickDirection = direction;
+ emit flickDirectionChanged();
+ }
+}
+
+void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (interactive && timeline.isActive() && (qAbs(velocityX) > 10 || qAbs(velocityY) > 10))
+ stealMouse = true; // If we've been flicked then steal the click.
+ else
+ stealMouse = false;
+ pressed = true;
+ timeline.clear();
+ velocityX = 0;
+ velocityY = 0;
+ lastPos = QPoint();
+ QDeclarativeItemPrivate::start(lastPosTime);
+ pressPos = event->pos();
+ pressX = _moveX.value();
+ pressY = _moveY.value();
+ flicked = false;
+ QDeclarativeItemPrivate::start(pressTime);
+ QDeclarativeItemPrivate::start(velocityTime);
+}
+
+void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_Q(QDeclarativeFlickable);
+ if (!interactive || lastPosTime.isNull())
+ return;
+ bool rejectY = false;
+ bool rejectX = false;
+ bool moved = false;
+
+ if (q->yflick()) {
+ int dy = int(event->pos().y() - pressPos.y());
+ if (qAbs(dy) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) {
+ qreal newY = dy + pressY;
+ const qreal minY = q->minYExtent();
+ const qreal maxY = q->maxYExtent();
+ if (newY > minY)
+ newY = minY + (newY - minY) / 2;
+ if (newY < maxY && maxY - minY <= 0)
+ newY = maxY + (newY - maxY) / 2;
+ if (!q->overShoot() && (newY > minY || newY < maxY)) {
+ if (newY > minY)
+ newY = minY;
+ else if (newY < maxY)
+ newY = maxY;
+ else
+ rejectY = true;
+ }
+ if (!rejectY) {
+ _moveY.setValue(newY);
+ moved = true;
+ }
+ if (qAbs(dy) > QApplication::startDragDistance())
+ stealMouse = true;
+ }
+ }
+
+ if (q->xflick()) {
+ int dx = int(event->pos().x() - pressPos.x());
+ if (qAbs(dx) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) {
+ qreal newX = dx + pressX;
+ const qreal minX = q->minXExtent();
+ const qreal maxX = q->maxXExtent();
+ if (newX > minX)
+ newX = minX + (newX - minX) / 2;
+ if (newX < maxX && maxX - minX <= 0)
+ newX = maxX + (newX - maxX) / 2;
+ if (!q->overShoot() && (newX > minX || newX < maxX)) {
+ if (newX > minX)
+ newX = minX;
+ else if (newX < maxX)
+ newX = maxX;
+ else
+ rejectX = true;
+ }
+ if (!rejectX) {
+ _moveX.setValue(newX);
+ moved = true;
+ }
+
+ if (qAbs(dx) > QApplication::startDragDistance())
+ stealMouse = true;
+ }
+ }
+
+ if (!lastPos.isNull()) {
+ qreal elapsed = qreal(QDeclarativeItemPrivate::restart(lastPosTime)) / 1000.;
+ if (elapsed <= 0)
+ elapsed = 1;
+ if (q->yflick()) {
+ qreal diff = event->pos().y() - lastPos.y();
+ // average to reduce the effect of spurious moves
+ velocityY += diff / elapsed;
+ velocityY /= 2;
+ }
+
+ if (q->xflick()) {
+ qreal diff = event->pos().x() - lastPos.x();
+ // average to reduce the effect of spurious moves
+ velocityX += diff / elapsed;
+ velocityX /= 2;
+ }
+ }
+
+ if (rejectY) velocityY = 0;
+ if (rejectX) velocityX = 0;
+
+ if (moved) {
+ q->movementStarting();
+ q->viewportMoved();
+ }
+
+ lastPos = event->pos();
+}
+
+void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_Q(QDeclarativeFlickable);
+ pressed = false;
+ if (lastPosTime.isNull())
+ return;
+
+ if (QDeclarativeItemPrivate::elapsed(lastPosTime) > 100) {
+ // if we drag then pause before release we should not cause a flick.
+ velocityX = 0.0;
+ velocityY = 0.0;
+ }
+
+ vTime = timeline.time();
+ if (qAbs(velocityY) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) {
+ qreal velocity = velocityY;
+ if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
+ velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
+ flickY(velocity);
+ } else {
+ fixupY();
+ }
+
+ if (qAbs(velocityX) > 10 && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) {
+ qreal velocity = velocityX;
+ if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
+ velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
+ flickX(velocity);
+ } else {
+ fixupX();
+ }
+
+ stealMouse = false;
+ lastPosTime = QTime();
+
+ if (!timeline.isActive())
+ q->movementEnding();
+}
+
+void QDeclarativeFlickable::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->interactive) {
+ d->handleMousePressEvent(event);
+ event->accept();
+ } else {
+ QDeclarativeItem::mousePressEvent(event);
+ }
+}
+
+void QDeclarativeFlickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->interactive) {
+ d->handleMouseMoveEvent(event);
+ event->accept();
+ } else {
+ QDeclarativeItem::mouseMoveEvent(event);
+ }
+}
+
+void QDeclarativeFlickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->interactive) {
+ d->clearDelayedPress();
+ d->handleMouseReleaseEvent(event);
+ event->accept();
+ ungrabMouse();
+ } else {
+ QDeclarativeItem::mouseReleaseEvent(event);
+ }
+}
+
+void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
+{
+ Q_D(QDeclarativeFlickable);
+ if (!d->interactive) {
+ QDeclarativeItem::wheelEvent(event);
+ } else if (yflick()) {
+ if (event->delta() > 0)
+ d->velocityY = qMax(event->delta() - d->verticalVelocity.value(), qreal(250.0));
+ else
+ d->velocityY = qMin(event->delta() - d->verticalVelocity.value(), qreal(-250.0));
+ d->flicked = false;
+ d->flickY(d->velocityY);
+ event->accept();
+ } else if (xflick()) {
+ if (event->delta() > 0)
+ d->velocityX = qMax(event->delta() - d->horizontalVelocity.value(), qreal(250.0));
+ else
+ d->velocityX = qMin(event->delta() - d->horizontalVelocity.value(), qreal(-250.0));
+ d->flicked = false;
+ d->flickX(d->velocityX);
+ event->accept();
+ } else {
+ QDeclarativeItem::wheelEvent(event);
+ }
+}
+
+void QDeclarativeFlickablePrivate::captureDelayedPress(QGraphicsSceneMouseEvent *event)
+{
+ Q_Q(QDeclarativeFlickable);
+ if (!q->scene() || pressDelay <= 0)
+ return;
+ delayedPressTarget = q->scene()->mouseGrabberItem();
+ delayedPressEvent = new QGraphicsSceneMouseEvent(event->type());
+ delayedPressEvent->setAccepted(false);
+ for (int i = 0x1; i <= 0x10; i <<= 1) {
+ if (event->buttons() & i) {
+ Qt::MouseButton button = Qt::MouseButton(i);
+ delayedPressEvent->setButtonDownPos(button, event->buttonDownPos(button));
+ delayedPressEvent->setButtonDownScenePos(button, event->buttonDownScenePos(button));
+ delayedPressEvent->setButtonDownScreenPos(button, event->buttonDownScreenPos(button));
+ }
+ }
+ delayedPressEvent->setButtons(event->buttons());
+ delayedPressEvent->setButton(event->button());
+ delayedPressEvent->setPos(event->pos());
+ delayedPressEvent->setScenePos(event->scenePos());
+ delayedPressEvent->setScreenPos(event->screenPos());
+ delayedPressEvent->setLastPos(event->lastPos());
+ delayedPressEvent->setLastScenePos(event->lastScenePos());
+ delayedPressEvent->setLastScreenPos(event->lastScreenPos());
+ delayedPressEvent->setModifiers(event->modifiers());
+ delayedPressTimer.start(pressDelay, q);
+}
+
+void QDeclarativeFlickablePrivate::clearDelayedPress()
+{
+ if (delayedPressEvent) {
+ delayedPressTimer.stop();
+ delete delayedPressEvent;
+ delayedPressEvent = 0;
+ }
+}
+
+void QDeclarativeFlickablePrivate::setRoundedViewportX(qreal x)
+{
+ viewport->setX(qRound(x));
+}
+
+void QDeclarativeFlickablePrivate::setRoundedViewportY(qreal y)
+{
+ viewport->setY(qRound(y));
+}
+
+void QDeclarativeFlickable::timerEvent(QTimerEvent *event)
+{
+ Q_D(QDeclarativeFlickable);
+ if (event->timerId() == d->delayedPressTimer.timerId()) {
+ d->delayedPressTimer.stop();
+ if (d->delayedPressEvent) {
+ QDeclarativeItem *grabber = scene() ? qobject_cast<QDeclarativeItem*>(scene()->mouseGrabberItem()) : 0;
+ if (!grabber || grabber != this)
+ scene()->sendEvent(d->delayedPressTarget, d->delayedPressEvent);
+ delete d->delayedPressEvent;
+ d->delayedPressEvent = 0;
+ }
+ }
+}
+
+qreal QDeclarativeFlickable::minYExtent() const
+{
+ return 0.0;
+}
+
+qreal QDeclarativeFlickable::minXExtent() const
+{
+ return 0.0;
+}
+
+/* returns -ve */
+qreal QDeclarativeFlickable::maxXExtent() const
+{
+ return width() - vWidth();
+}
+/* returns -ve */
+qreal QDeclarativeFlickable::maxYExtent() const
+{
+ return height() - vHeight();
+}
+
+void QDeclarativeFlickable::viewportMoved()
+{
+ Q_D(QDeclarativeFlickable);
+
+ int elapsed = QDeclarativeItemPrivate::restart(d->velocityTime);
+ if (!elapsed)
+ return;
+
+ qreal prevY = d->lastFlickablePosition.x();
+ qreal prevX = d->lastFlickablePosition.y();
+ d->velocityTimeline.clear();
+ if (d->pressed) {
+ qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / elapsed;
+ qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / elapsed;
+ d->velocityTimeline.move(d->horizontalVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->horizontalVelocity, 0, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->verticalVelocity, verticalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->verticalVelocity, 0, d->reportedVelocitySmoothing);
+ } else {
+ if (d->timeline.time() > d->vTime) {
+ qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / (d->timeline.time() - d->vTime);
+ qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / (d->timeline.time() - d->vTime);
+ d->horizontalVelocity.setValue(horizontalVelocity);
+ d->verticalVelocity.setValue(verticalVelocity);
+ }
+ }
+
+ d->lastFlickablePosition = QPointF(d->_moveY.value(), d->_moveX.value());
+
+ d->vTime = d->timeline.time();
+ d->updateBeginningEnd();
+}
+
+void QDeclarativeFlickable::cancelFlick()
+{
+ Q_D(QDeclarativeFlickable);
+ d->timeline.reset(d->_moveX);
+ d->timeline.reset(d->_moveY);
+ movementEnding();
+}
+
+void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
+{
+ QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o);
+ if (i)
+ i->setParentItem(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->viewport);
+ else
+ o->setParent(prop->object);
+}
+
+QDeclarativeListProperty<QObject> QDeclarativeFlickable::flickableData()
+{
+ Q_D(QDeclarativeFlickable);
+ return QDeclarativeListProperty<QObject>(this, (void *)d, QDeclarativeFlickablePrivate::data_append);
+}
+
+QDeclarativeListProperty<QDeclarativeItem> QDeclarativeFlickable::flickableChildren()
+{
+ Q_D(QDeclarativeFlickable);
+ return d->viewport->fxChildren();
+}
+
+/*!
+ \qmlproperty bool Flickable::overShoot
+ This property holds the number of pixels the surface may overshoot the
+ Flickable's boundaries when flicked.
+
+ If overShoot is non-zero the contents can be flicked beyond the boundary
+ of the Flickable before being moved back to the boundary. This provides
+ the feeling that the edges of the view are soft, rather than a hard
+ physical boundary.
+*/
+bool QDeclarativeFlickable::overShoot() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->overShoot;
+}
+
+void QDeclarativeFlickable::setOverShoot(bool o)
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->overShoot == o)
+ return;
+ d->overShoot = o;
+ emit overShootChanged();
+}
+
+/*!
+ \qmlproperty int Flickable::viewportWidth
+ \qmlproperty int Flickable::viewportHeight
+
+ The dimensions of the viewport (the surface controlled by Flickable). Typically this
+ should be set to the combined size of the items placed in the Flickable.
+
+ \code
+ Flickable {
+ width: 320; height: 480; viewportWidth: image.width; viewportHeight: image.height
+ Image { id: image; source: "bigimage.png" }
+ }
+ \endcode
+*/
+qreal QDeclarativeFlickable::viewportWidth() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->vWidth;
+}
+
+void QDeclarativeFlickable::setViewportWidth(qreal w)
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->vWidth == w)
+ return;
+ d->vWidth = w;
+ if (w < 0)
+ d->viewport->setWidth(width());
+ else
+ d->viewport->setWidth(w);
+ // Make sure that we're entirely in view.
+ if (!d->pressed)
+ d->fixupX();
+ emit viewportWidthChanged();
+ d->updateBeginningEnd();
+}
+
+void QDeclarativeFlickable::widthChange()
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->vWidth < 0) {
+ d->viewport->setWidth(width());
+ emit viewportWidthChanged();
+ }
+ d->updateBeginningEnd();
+}
+
+void QDeclarativeFlickable::heightChange()
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->vHeight < 0) {
+ d->viewport->setHeight(height());
+ emit viewportHeightChanged();
+ }
+ d->updateBeginningEnd();
+}
+
+qreal QDeclarativeFlickable::viewportHeight() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->vHeight;
+}
+
+void QDeclarativeFlickable::setViewportHeight(qreal h)
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->vHeight == h)
+ return;
+ d->vHeight = h;
+ if (h < 0)
+ d->viewport->setHeight(height());
+ else
+ d->viewport->setHeight(h);
+ // Make sure that we're entirely in view.
+ if (!d->pressed)
+ d->fixupY();
+ emit viewportHeightChanged();
+ d->updateBeginningEnd();
+}
+
+qreal QDeclarativeFlickable::vWidth() const
+{
+ Q_D(const QDeclarativeFlickable);
+ if (d->vWidth < 0)
+ return width();
+ else
+ return d->vWidth;
+}
+
+qreal QDeclarativeFlickable::vHeight() const
+{
+ Q_D(const QDeclarativeFlickable);
+ if (d->vHeight < 0)
+ return height();
+ else
+ return d->vHeight;
+}
+
+bool QDeclarativeFlickable::xflick() const
+{
+ Q_D(const QDeclarativeFlickable);
+ if (d->flickDirection == QDeclarativeFlickable::AutoFlickDirection)
+ return vWidth() != width();
+ return d->flickDirection & QDeclarativeFlickable::HorizontalFlick;
+}
+
+bool QDeclarativeFlickable::yflick() const
+{
+ Q_D(const QDeclarativeFlickable);
+ if (d->flickDirection == QDeclarativeFlickable::AutoFlickDirection)
+ return vHeight() != height();
+ return d->flickDirection & QDeclarativeFlickable::VerticalFlick;
+}
+
+bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeFlickable);
+ QGraphicsSceneMouseEvent mouseEvent(event->type());
+ QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect();
+
+ QGraphicsScene *s = scene();
+ QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0;
+ if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
+ mouseEvent.setAccepted(false);
+ for (int i = 0x1; i <= 0x10; i <<= 1) {
+ if (event->buttons() & i) {
+ Qt::MouseButton button = Qt::MouseButton(i);
+ mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button)));
+ }
+ }
+ mouseEvent.setScenePos(event->scenePos());
+ mouseEvent.setLastScenePos(event->lastScenePos());
+ mouseEvent.setPos(mapFromScene(event->scenePos()));
+ mouseEvent.setLastPos(mapFromScene(event->lastScenePos()));
+
+ switch(mouseEvent.type()) {
+ case QEvent::GraphicsSceneMouseMove:
+ d->handleMouseMoveEvent(&mouseEvent);
+ break;
+ case QEvent::GraphicsSceneMousePress:
+ if (d->delayedPressEvent)
+ return false;
+
+ d->handleMousePressEvent(&mouseEvent);
+ d->captureDelayedPress(event);
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ if (d->delayedPressEvent) {
+ scene()->sendEvent(d->delayedPressTarget, d->delayedPressEvent);
+ d->clearDelayedPress();
+ }
+ d->handleMouseReleaseEvent(&mouseEvent);
+ break;
+ default:
+ break;
+ }
+ grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem());
+ if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this) {
+ d->clearDelayedPress();
+ grabMouse();
+ }
+
+ return d->stealMouse || d->delayedPressEvent;
+ } else if (!d->lastPosTime.isNull()) {
+ d->lastPosTime = QTime();
+ }
+ if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease)
+ d->clearDelayedPress();
+ return false;
+}
+
+bool QDeclarativeFlickable::sceneEventFilter(QGraphicsItem *i, QEvent *e)
+{
+ Q_D(QDeclarativeFlickable);
+ if (!isVisible() || !d->interactive)
+ return QDeclarativeItem::sceneEventFilter(i, e);
+ switch (e->type()) {
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMouseRelease:
+ return sendMouseEvent(static_cast<QGraphicsSceneMouseEvent *>(e));
+ default:
+ break;
+ }
+
+ return QDeclarativeItem::sceneEventFilter(i, e);
+}
+
+/*!
+ \qmlproperty real Flickable::maximumFlickVelocity
+ This property holds the maximum velocity that the user can flick the view in pixels/second.
+
+ The default is 2000 pixels/s
+*/
+qreal QDeclarativeFlickable::maximumFlickVelocity() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->maxVelocity;
+}
+
+void QDeclarativeFlickable::setMaximumFlickVelocity(qreal v)
+{
+ Q_D(QDeclarativeFlickable);
+ if (v == d->maxVelocity)
+ return;
+ d->maxVelocity = v;
+ emit maximumFlickVelocityChanged();
+}
+
+/*!
+ \qmlproperty real Flickable::flickDeceleration
+ This property holds the rate at which a flick will decelerate.
+
+ The default is 500.
+*/
+qreal QDeclarativeFlickable::flickDeceleration() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->deceleration;
+}
+
+void QDeclarativeFlickable::setFlickDeceleration(qreal deceleration)
+{
+ Q_D(QDeclarativeFlickable);
+ if (deceleration == d->deceleration)
+ return;
+ d->deceleration = deceleration;
+ emit flickDecelerationChanged();
+}
+
+/*!
+ \qmlproperty bool Flickable::flicking
+
+ This property holds whether the view is currently moving due to
+ the user flicking the view.
+*/
+bool QDeclarativeFlickable::isFlicking() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->flicked;
+}
+
+/*!
+ \qmlproperty int Flickable::pressDelay
+
+ This property holds the time to delay (ms) delivering a press to
+ children of the Flickable. This can be useful where reacting
+ to a press before a flicking action has undesireable effects.
+
+ If the flickable is dragged/flicked before the delay times out
+ the press event will not be delivered. If the button is released
+ within the timeout, both the press and release will be delivered.
+*/
+int QDeclarativeFlickable::pressDelay() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->pressDelay;
+}
+
+void QDeclarativeFlickable::setPressDelay(int delay)
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->pressDelay == delay)
+ return;
+ d->pressDelay = delay;
+ emit pressDelayChanged();
+}
+
+qreal QDeclarativeFlickable::reportedVelocitySmoothing() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->reportedVelocitySmoothing;
+}
+
+void QDeclarativeFlickable::setReportedVelocitySmoothing(qreal reportedVelocitySmoothing)
+{
+ Q_D(QDeclarativeFlickable);
+ Q_ASSERT(reportedVelocitySmoothing >= 0);
+ if (reportedVelocitySmoothing == d->reportedVelocitySmoothing)
+ return;
+ d->reportedVelocitySmoothing = reportedVelocitySmoothing;
+ emit reportedVelocitySmoothingChanged(reportedVelocitySmoothing);
+}
+
+/*!
+ \qmlproperty bool Flickable::moving
+
+ This property holds whether the view is currently moving due to
+ the user either dragging or flicking the view.
+*/
+bool QDeclarativeFlickable::isMoving() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->moving;
+}
+
+void QDeclarativeFlickable::movementStarting()
+{
+ Q_D(QDeclarativeFlickable);
+ if (!d->moving) {
+ d->moving = true;
+ emit movingChanged();
+ emit movementStarted();
+ }
+}
+
+void QDeclarativeFlickable::movementEnding()
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->moving) {
+ d->moving = false;
+ emit movingChanged();
+ emit movementEnded();
+ }
+ if (d->flicked) {
+ d->flicked = false;
+ emit flickingChanged();
+ emit flickEnded();
+ }
+ d->horizontalVelocity.setValue(0);
+ d->verticalVelocity.setValue(0);
+}
+
+void QDeclarativeFlickablePrivate::updateVelocity()
+{
+ Q_Q(QDeclarativeFlickable);
+ emit q->horizontalVelocityChanged();
+ emit q->verticalVelocityChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
new file mode 100644
index 0000000..19fb2a9
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEFLICKABLE_H
+#define QDECLARATIVEFLICKABLE_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeFlickablePrivate;
+class QDeclarativeFlickableVisibleArea;
+class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal viewportWidth READ viewportWidth WRITE setViewportWidth NOTIFY viewportWidthChanged)
+ Q_PROPERTY(qreal viewportHeight READ viewportHeight WRITE setViewportHeight NOTIFY viewportHeightChanged)
+ Q_PROPERTY(qreal viewportX READ viewportX WRITE setViewportX NOTIFY positionXChanged)
+ Q_PROPERTY(qreal viewportY READ viewportY WRITE setViewportY NOTIFY positionYChanged)
+
+ Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
+ Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
+ Q_PROPERTY(qreal reportedVelocitySmoothing READ reportedVelocitySmoothing WRITE setReportedVelocitySmoothing NOTIFY reportedVelocitySmoothingChanged)
+
+ Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot NOTIFY overShootChanged)
+ Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
+ Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
+ Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
+ Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
+ Q_PROPERTY(FlickDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickDirectionChanged)
+
+ Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
+ Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
+
+ Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
+ Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
+ Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
+ Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
+
+ Q_PROPERTY(QDeclarativeFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
+
+ Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> flickableChildren READ flickableChildren)
+ Q_CLASSINFO("DefaultProperty", "flickableData")
+
+ Q_ENUMS(FlickDirection)
+
+public:
+ QDeclarativeFlickable(QDeclarativeItem *parent=0);
+ ~QDeclarativeFlickable();
+
+ QDeclarativeListProperty<QObject> flickableData();
+ QDeclarativeListProperty<QDeclarativeItem> flickableChildren();
+
+ bool overShoot() const;
+ void setOverShoot(bool);
+
+ qreal viewportWidth() const;
+ void setViewportWidth(qreal);
+
+ qreal viewportHeight() const;
+ void setViewportHeight(qreal);
+
+ qreal viewportX() const;
+ void setViewportX(qreal pos);
+
+ qreal viewportY() const;
+ void setViewportY(qreal pos);
+
+ bool isMoving() const;
+ bool isFlicking() const;
+
+ int pressDelay() const;
+ void setPressDelay(int delay);
+
+ qreal reportedVelocitySmoothing() const;
+ void setReportedVelocitySmoothing(qreal);
+
+ qreal maximumFlickVelocity() const;
+ void setMaximumFlickVelocity(qreal);
+
+ qreal flickDeceleration() const;
+ void setFlickDeceleration(qreal);
+
+ bool isInteractive() const;
+ void setInteractive(bool);
+
+ qreal horizontalVelocity() const;
+ qreal verticalVelocity() const;
+
+ bool isAtXEnd() const;
+ bool isAtXBeginning() const;
+ bool isAtYEnd() const;
+ bool isAtYBeginning() const;
+
+ QDeclarativeItem *viewport();
+
+ enum FlickDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
+ FlickDirection flickDirection() const;
+ void setFlickDirection(FlickDirection);
+
+Q_SIGNALS:
+ void viewportWidthChanged();
+ void viewportHeightChanged();
+ void positionXChanged();
+ void positionYChanged();
+ void movingChanged();
+ void flickingChanged();
+ void movementStarted();
+ void movementEnded();
+ void flickStarted();
+ void flickEnded();
+ void reportedVelocitySmoothingChanged(int);
+ void horizontalVelocityChanged();
+ void verticalVelocityChanged();
+ void isAtBoundaryChanged();
+ void pageChanged();
+ void flickDirectionChanged();
+ void interactiveChanged();
+ void overShootChanged();
+ void maximumFlickVelocityChanged();
+ void flickDecelerationChanged();
+ void pressDelayChanged();
+
+protected:
+ virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void wheelEvent(QGraphicsSceneWheelEvent *event);
+ void timerEvent(QTimerEvent *event);
+
+ QDeclarativeFlickableVisibleArea *visibleArea();
+
+protected Q_SLOTS:
+ virtual void ticked();
+ void movementStarting();
+ void movementEnding();
+ void heightChange();
+ void widthChange();
+
+protected:
+ virtual qreal minXExtent() const;
+ virtual qreal minYExtent() const;
+ virtual qreal maxXExtent() const;
+ virtual qreal maxYExtent() const;
+ qreal vWidth() const;
+ qreal vHeight() const;
+ virtual void viewportMoved();
+ bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
+
+ bool xflick() const;
+ bool yflick() const;
+ void cancelFlick();
+
+protected:
+ QDeclarativeFlickable(QDeclarativeFlickablePrivate &dd, QDeclarativeItem *parent);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeFlickable)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeFlickable)
+ friend class QDeclarativeFlickableVisibleArea;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeFlickable)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
new file mode 100644
index 0000000..dc3a8a2
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEFLICKABLE_P_H
+#define QDECLARATIVEFLICKABLE_P_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 "qdeclarativeflickable_p.h"
+
+#include "qdeclarativeitem_p.h"
+
+#include <qdeclarative.h>
+#include <qdeclarativetimeline_p_p.h>
+#include <qdeclarativeanimation_p_p.h>
+
+#include <qdatetime.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeFlickableVisibleArea;
+class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeFlickable)
+
+public:
+ QDeclarativeFlickablePrivate();
+ void init();
+ virtual void flickX(qreal velocity);
+ virtual void flickY(qreal velocity);
+ virtual void fixupX();
+ virtual void fixupY();
+ void updateBeginningEnd();
+
+ void captureDelayedPress(QGraphicsSceneMouseEvent *event);
+ void clearDelayedPress();
+
+ void setRoundedViewportX(qreal x);
+ void setRoundedViewportY(qreal y);
+
+public:
+ QDeclarativeItem *viewport;
+ QDeclarativeTimeLineValueProxy<QDeclarativeFlickablePrivate> _moveX;
+ QDeclarativeTimeLineValueProxy<QDeclarativeFlickablePrivate> _moveY;
+ QDeclarativeTimeLine timeline;
+ qreal vWidth;
+ qreal vHeight;
+ bool overShoot : 1;
+ bool flicked : 1;
+ bool moving : 1;
+ bool stealMouse : 1;
+ bool pressed : 1;
+ bool atXEnd : 1;
+ bool atXBeginning : 1;
+ bool atYEnd : 1;
+ bool atYBeginning : 1;
+ bool interactive : 1;
+ QTime lastPosTime;
+ QPointF lastPos;
+ QPointF pressPos;
+ qreal pressX;
+ qreal pressY;
+ qreal velocityX;
+ qreal velocityY;
+ QTime pressTime;
+ qreal deceleration;
+ qreal maxVelocity;
+ QTime velocityTime;
+ QPointF lastFlickablePosition;
+ qreal reportedVelocitySmoothing;
+ qreal flickTargetX;
+ qreal flickTargetY;
+ QGraphicsSceneMouseEvent *delayedPressEvent;
+ QGraphicsItem *delayedPressTarget;
+ QBasicTimer delayedPressTimer;
+ int pressDelay;
+ int fixupDuration;
+
+ static void fixupY_callback(void *);
+ static void fixupX_callback(void *);
+
+ void updateVelocity();
+ struct Velocity : public QDeclarativeTimeLineValue
+ {
+ Velocity(QDeclarativeFlickablePrivate *p)
+ : parent(p) {}
+ virtual void setValue(qreal v) {
+ QDeclarativeTimeLineValue::setValue(v);
+ parent->updateVelocity();
+ }
+ QDeclarativeFlickablePrivate *parent;
+ };
+ Velocity horizontalVelocity;
+ Velocity verticalVelocity;
+ int vTime;
+ QDeclarativeTimeLine velocityTimeline;
+ QDeclarativeFlickableVisibleArea *visibleArea;
+ QDeclarativeFlickable::FlickDirection flickDirection;
+
+ void handleMousePressEvent(QGraphicsSceneMouseEvent *);
+ void handleMouseMoveEvent(QGraphicsSceneMouseEvent *);
+ void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *);
+
+ // flickableData property
+ static void data_append(QDeclarativeListProperty<QObject> *, QObject *);
+};
+
+class QDeclarativeFlickableVisibleArea : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal xPosition READ xPosition NOTIFY pageChanged)
+ Q_PROPERTY(qreal yPosition READ yPosition NOTIFY pageChanged)
+ Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY pageChanged)
+ Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY pageChanged)
+
+public:
+ QDeclarativeFlickableVisibleArea(QDeclarativeFlickable *parent=0);
+
+ qreal xPosition() const;
+ qreal widthRatio() const;
+ qreal yPosition() const;
+ qreal heightRatio() const;
+
+ void updateVisible();
+
+signals:
+ void pageChanged();
+
+private:
+ QDeclarativeFlickable *flickable;
+ qreal m_xPosition;
+ qreal m_widthRatio;
+ qreal m_yPosition;
+ qreal m_heightRatio;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeFlickableVisibleArea)
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
new file mode 100644
index 0000000..b36127f
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
@@ -0,0 +1,238 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeflipable_p.h"
+
+#include "qdeclarativeitem_p.h"
+
+#include <qdeclarativeinfo.h>
+
+#include <QtGui/qgraphicstransform.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeFlipablePrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeFlipable)
+public:
+ QDeclarativeFlipablePrivate() : current(QDeclarativeFlipable::Front), front(0), back(0) {}
+
+ void updateSceneTransformFromParent();
+
+ QDeclarativeFlipable::Side current;
+ QDeclarativeItem *front;
+ QDeclarativeItem *back;
+};
+
+/*!
+ \qmlclass Flipable QDeclarativeFlipable
+ \since 4.7
+ \brief The Flipable item provides a surface that can be flipped.
+ \inherits Item
+
+ Flipable allows you to specify a front and a back and then flip between those sides.
+
+ Here's an example that flips between the front and back sides when clicked:
+
+ \qml
+
+ Flipable {
+ id: flipable
+ width: 250; height: 250
+ property int angle: 0
+
+ transform: Rotation {
+ id: rotation
+ origin.x: flipable.width/2; origin.y: flipable.height/2
+ axis.x: 0; axis.y: 1; axis.z: 0 // rotate around y-axis
+ angle: flipable.angle
+ }
+
+ front: Image { source: "front.png" }
+ back: Image { source: "back.png" }
+
+ states: State {
+ name: "back"
+ PropertyChanges { target: flipable; angle: 180 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "angle"; duration: 2000 }
+ }
+
+ MouseArea {
+ // change between default and 'back' states
+ onClicked: flipable.state = (flipable.state == 'back' ? '' : 'back')
+ anchors.fill: parent
+ }
+ }
+ \endqml
+
+ \image flipable.gif
+*/
+
+/*!
+ \internal
+ \class QDeclarativeFlipable
+ \brief The QDeclarativeFlipable class provides a flipable surface.
+
+ \ingroup group_widgets
+
+ QDeclarativeFlipable allows you to specify a front and a back, as well as an
+ axis for the flip.
+*/
+
+QDeclarativeFlipable::QDeclarativeFlipable(QDeclarativeItem *parent)
+: QDeclarativeItem(*(new QDeclarativeFlipablePrivate), parent)
+{
+}
+
+QDeclarativeFlipable::~QDeclarativeFlipable()
+{
+}
+
+/*!
+ \qmlproperty Item Flipable::front
+ \qmlproperty Item Flipable::back
+
+ The front and back sides of the flipable.
+*/
+
+QDeclarativeItem *QDeclarativeFlipable::front()
+{
+ Q_D(const QDeclarativeFlipable);
+ return d->front;
+}
+
+void QDeclarativeFlipable::setFront(QDeclarativeItem *front)
+{
+ Q_D(QDeclarativeFlipable);
+ if (d->front) {
+ qmlInfo(this) << tr("front is a write-once property");
+ return;
+ }
+ d->front = front;
+ d->front->setParentItem(this);
+ if (Back == d->current)
+ d->front->setOpacity(0.);
+}
+
+QDeclarativeItem *QDeclarativeFlipable::back()
+{
+ Q_D(const QDeclarativeFlipable);
+ return d->back;
+}
+
+void QDeclarativeFlipable::setBack(QDeclarativeItem *back)
+{
+ Q_D(QDeclarativeFlipable);
+ if (d->back) {
+ qmlInfo(this) << tr("back is a write-once property");
+ return;
+ }
+ d->back = back;
+ d->back->setParentItem(this);
+ if (Front == d->current)
+ d->back->setOpacity(0.);
+}
+
+/*!
+ \qmlproperty enumeration Flipable::side
+
+ The side of the Flippable currently visible. Possible values are \c
+ Front and \c Back.
+*/
+QDeclarativeFlipable::Side QDeclarativeFlipable::side() const
+{
+ Q_D(const QDeclarativeFlipable);
+ if (d->dirtySceneTransform)
+ const_cast<QDeclarativeFlipablePrivate *>(d)->updateSceneTransformFromParent();
+
+ return d->current;
+}
+
+// determination on the currently visible side of the flipable
+// has to be done on the complete scene transform to give
+// correct results.
+void QDeclarativeFlipablePrivate::updateSceneTransformFromParent()
+{
+ Q_Q(QDeclarativeFlipable);
+
+ QDeclarativeItemPrivate::updateSceneTransformFromParent();
+ QPointF p1(0, 0);
+ QPointF p2(1, 0);
+ QPointF p3(1, 1);
+
+ p1 = sceneTransform.map(p1);
+ p2 = sceneTransform.map(p2);
+ p3 = sceneTransform.map(p3);
+
+ qreal cross = (p1.x() - p2.x()) * (p3.y() - p2.y()) -
+ (p1.y() - p2.y()) * (p3.x() - p2.x());
+
+ QDeclarativeFlipable::Side newSide;
+ if (cross > 0) {
+ newSide = QDeclarativeFlipable::Back;
+ } else {
+ newSide = QDeclarativeFlipable::Front;
+ }
+
+ if (newSide != current) {
+ current = newSide;
+ if (current == QDeclarativeFlipable::Back) {
+ QTransform mat;
+ mat.translate(back->width()/2,back->height()/2);
+ if (back->width() && p1.x() >= p2.x())
+ mat.rotate(180, Qt::YAxis);
+ if (back->height() && p2.y() >= p3.y())
+ mat.rotate(180, Qt::XAxis);
+ mat.translate(-back->width()/2,-back->height()/2);
+ back->setTransform(mat);
+ }
+ if (front)
+ front->setOpacity((current==QDeclarativeFlipable::Front)?1.:0.);
+ if (back)
+ back->setOpacity((current==QDeclarativeFlipable::Back)?1.:0.);
+ emit q->sideChanged();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable_p.h b/src/declarative/graphicsitems/qdeclarativeflipable_p.h
new file mode 100644
index 0000000..8b9c24c
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeflipable_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEFLIPABLE_H
+#define QDECLARATIVEFLIPABLE_H
+
+#include "qdeclarativeitem.h"
+
+#include <QtCore/QObject>
+#include <QtGui/QTransform>
+#include <QtGui/qvector3d.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeFlipablePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeFlipable : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_ENUMS(Side)
+ Q_PROPERTY(QDeclarativeItem *front READ front WRITE setFront)
+ Q_PROPERTY(QDeclarativeItem *back READ back WRITE setBack)
+ Q_PROPERTY(Side side READ side NOTIFY sideChanged)
+ //### flipAxis
+ //### flipRotation
+public:
+ QDeclarativeFlipable(QDeclarativeItem *parent=0);
+ ~QDeclarativeFlipable();
+
+ QDeclarativeItem *front();
+ void setFront(QDeclarativeItem *);
+
+ QDeclarativeItem *back();
+ void setBack(QDeclarativeItem *);
+
+ enum Side { Front, Back };
+ Side side() const;
+
+Q_SIGNALS:
+ void sideChanged();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeFlipable)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeFlipable)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeFlipable)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEFLIPABLE_H
diff --git a/src/declarative/graphicsitems/qdeclarativefocuspanel.cpp b/src/declarative/graphicsitems/qdeclarativefocuspanel.cpp
new file mode 100644
index 0000000..0323a59
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativefocuspanel.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativefocuspanel_p.h"
+
+#include <QtGui/qgraphicsscene.h>
+#include <QEvent>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass FocusPanel QDeclarativeFocusPanel
+ \since 4.7
+ \brief The FocusPanel item explicitly creates a focus panel.
+ \inherits Item
+
+ Focus panels assist in keyboard focus handling when building QML
+ applications. All the details are covered in the
+ \l {qmlfocus}{keyboard focus documentation}.
+*/
+
+/*!
+ \internal
+ \class QDeclarativeFocusPanel
+*/
+
+QDeclarativeFocusPanel::QDeclarativeFocusPanel(QDeclarativeItem *parent) :
+ QDeclarativeItem(parent)
+{
+ setFlag(ItemIsPanel);
+}
+
+QDeclarativeFocusPanel::~QDeclarativeFocusPanel()
+{
+}
+
+/*!
+ \qmlproperty bool FocusPanel::active
+
+ Sets whether the item is the active focus panel.
+*/
+
+bool QDeclarativeFocusPanel::sceneEvent(QEvent *event)
+{
+ if (event->type() == QEvent::WindowActivate ||
+ event->type() == QEvent::WindowDeactivate)
+ emit activeChanged();
+ return QDeclarativeItem::sceneEvent(event);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativefocuspanel_p.h b/src/declarative/graphicsitems/qdeclarativefocuspanel_p.h
new file mode 100644
index 0000000..1ad8b6e
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativefocuspanel_p.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEFOCUSPANEL_H
+#define QDECLARATIVEFOCUSPANEL_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QDeclarativeFocusPanel : public QDeclarativeItem
+{
+ Q_OBJECT
+ Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
+public:
+ QDeclarativeFocusPanel(QDeclarativeItem *parent=0);
+ virtual ~QDeclarativeFocusPanel();
+
+Q_SIGNALS:
+ void activeChanged();
+
+protected:
+ bool sceneEvent(QEvent *event);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeFocusPanel)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeFocusPanel)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEFOCUSPANEL_H
diff --git a/src/declarative/graphicsitems/qdeclarativefocusscope.cpp b/src/declarative/graphicsitems/qdeclarativefocusscope.cpp
new file mode 100644
index 0000000..384a47b
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativefocusscope.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativefocusscope_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass FocusScope QDeclarativeFocusScope
+ \since 4.7
+ \brief The FocusScope object explicitly creates a focus scope.
+ \inherits Item
+
+ Focus scopes assist in keyboard focus handling when building reusable QML
+ components. All the details are covered in the
+ \l {qmlfocus}{keyboard focus documentation}.
+*/
+
+/*!
+ \internal
+ \class QDeclarativeFocusScope
+*/
+
+QDeclarativeFocusScope::QDeclarativeFocusScope(QDeclarativeItem *parent) :
+ QDeclarativeItem(parent)
+{
+ setFlag(QGraphicsItem::ItemIsFocusScope);
+}
+
+QDeclarativeFocusScope::~QDeclarativeFocusScope()
+{
+}
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativefocusscope_p.h b/src/declarative/graphicsitems/qdeclarativefocusscope_p.h
new file mode 100644
index 0000000..cd480b4
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativefocusscope_p.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEFOCUSSCOPE_H
+#define QDECLARATIVEFOCUSSCOPE_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+//### set component root as focusscope
+class Q_DECLARATIVE_EXPORT QDeclarativeFocusScope : public QDeclarativeItem
+{
+ Q_OBJECT
+public:
+ QDeclarativeFocusScope(QDeclarativeItem *parent=0);
+ virtual ~QDeclarativeFocusScope();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeFocusScope)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEFOCUSSCOPE_H
diff --git a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
new file mode 100644
index 0000000..1977817
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
@@ -0,0 +1,269 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativegraphicsobjectcontainer_p.h"
+
+#include "qdeclarativeitem_p.h"
+
+#include <QGraphicsObject>
+#include <QGraphicsWidget>
+#include <QGraphicsSceneResizeEvent>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeGraphicsObjectContainerPrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeGraphicsObjectContainer)
+
+public:
+ QDeclarativeGraphicsObjectContainerPrivate() : QDeclarativeItemPrivate(), graphicsObject(0), syncedResize(false)
+ { }
+
+ void _q_updateSize();
+
+ void setFiltering(bool on)
+ {
+ Q_Q(QDeclarativeGraphicsObjectContainer);
+ if (graphicsObject && graphicsObject->isWidget()) {
+ if (!on) {
+ graphicsObject->removeEventFilter(q);
+ QObject::disconnect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
+ QObject::disconnect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ } else {
+ graphicsObject->installEventFilter(q);
+ QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
+ QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ }
+ }
+ }
+
+
+ QGraphicsObject *graphicsObject;
+ bool syncedResize;
+};
+
+
+/*!
+ \qmlclass GraphicsObjectContainer QDeclarativeGraphicsObjectContainer
+ \since 4.7
+ \brief The GraphicsObjectContainer element allows you to add QGraphicsObjects into Fluid UI elements.
+
+ While any QObject based class can be exposed to QML, QDeclarativeItem
+ provides a lot of important functionality, including anchors and proper
+ management of child items. GraphicsObjectContainer helps provide these
+ functions to other QGraphicsObjects, so that they can be used unaltered in
+ a QML scene. QGraphicsObjects, which are not QDeclarativeItems, and which are
+ placed in a QML scene outside of a GraphicsObjectContainer, will not appear
+ on screen at all.
+
+ A GraphicsObjectContainer can have one element inside it, and it must be a
+ QGraphicsObject or subclass which has been exposed to the QML engine.
+ The graphics object inside the GraphicsObjectContainer can then be used
+ like any other item in QML with the exception of not being reparentable
+ and not having the standard properties of QML items (such as anchors).
+
+ As the contained object is positioned relative to the container, anchors
+ affecting the container item will affect the onscreen position of the
+ contained item. If synchronizedResizing is set to true, then anchors
+ affecting the container item's size will also affect the contained item's
+ size.
+
+ Example:
+ \code
+ import Qt 4.6
+ import MyApp 2.1 as Widgets
+ Rectangle{
+ id: rect
+ property alias widgetPropertyThree: widget.myThirdProperty;
+ GraphicsObjectContainer{
+ synchronizedResizing: true
+ anchors.margins: 10
+ anchors.fill: parent
+ Widgets.MyWidget{
+ myProperty: "A Value"
+ myOtherProperty: rect.color
+ }
+ }
+ }
+ \endcode
+*/
+
+/*!
+ \internal
+ \class QDeclarativeGraphicsObjectContainer
+ \brief The QDeclarativeGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications.
+*/
+
+QDeclarativeGraphicsObjectContainer::QDeclarativeGraphicsObjectContainer(QDeclarativeItem *parent)
+: QDeclarativeItem(*new QDeclarativeGraphicsObjectContainerPrivate, parent)
+{
+}
+
+QDeclarativeGraphicsObjectContainer::~QDeclarativeGraphicsObjectContainer()
+{
+}
+
+QGraphicsObject *QDeclarativeGraphicsObjectContainer::graphicsObject() const
+{
+ Q_D(const QDeclarativeGraphicsObjectContainer);
+ return d->graphicsObject;
+}
+
+/*!
+ \qmlproperty QGraphicsObject GraphicsObjectContainer::graphicsObject
+ The QGraphicsObject associated with this element.
+*/
+void QDeclarativeGraphicsObjectContainer::setGraphicsObject(QGraphicsObject *object)
+{
+ Q_D(QDeclarativeGraphicsObjectContainer);
+ if (object == d->graphicsObject)
+ return;
+
+ //### remove previously set item?
+
+ d->setFiltering(false);
+
+ d->graphicsObject = object;
+
+ if (d->graphicsObject) {
+ d->graphicsObject->setParentItem(this);
+
+ if (d->syncedResize && d->graphicsObject->isWidget()) {
+ QGraphicsWidget *gw = static_cast<QGraphicsWidget*>(d->graphicsObject);
+ QSizeF gwSize = gw->size(); //### should we use sizeHint?
+ QSizeF newSize = gwSize;
+ if (heightValid())
+ newSize.setHeight(height());
+ if (widthValid())
+ newSize.setWidth(width());
+ if (gwSize != newSize)
+ gw->resize(newSize);
+
+ gwSize = gw->size();
+ setImplicitWidth(gwSize.width());
+ setImplicitHeight(gwSize.height());
+
+ d->setFiltering(true);
+ }
+ }
+}
+
+QVariant QDeclarativeGraphicsObjectContainer::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ Q_D(QDeclarativeGraphicsObjectContainer);
+ if (change == ItemSceneHasChanged) {
+ QGraphicsObject *o = d->graphicsObject;
+ d->graphicsObject = 0;
+ setGraphicsObject(o);
+ }
+ return QDeclarativeItem::itemChange(change, value);
+}
+
+bool QDeclarativeGraphicsObjectContainer::eventFilter(QObject *watched, QEvent *e)
+{
+ Q_D(QDeclarativeGraphicsObjectContainer);
+ if (watched == d->graphicsObject && e->type() == QEvent::GraphicsSceneResize) {
+ if (d->graphicsObject && d->graphicsObject->isWidget() && d->syncedResize) {
+ QSizeF newSize = static_cast<QGraphicsWidget*>(d->graphicsObject)->size();
+ setImplicitWidth(newSize.width());
+ setImplicitHeight(newSize.height());
+ }
+ }
+ return QDeclarativeItem::eventFilter(watched, e);
+}
+
+/*!
+ \qmlproperty bool GraphicsObjectContainer::synchronizedResizing
+
+ This property determines whether or not the container and graphics object will synchronize their
+ sizes.
+
+ \note This property only applies when wrapping a QGraphicsWidget.
+
+ If synchronizedResizing is enabled, the container and widget will
+ synchronize their sizes as follows.
+ \list
+ \o If a size has been set on the container, the widget will be resized to the container.
+ Any changes in the container's size will be reflected in the widget.
+
+ \o \e Otherwise, the container will initially be sized to the preferred size of the widget.
+ Any changes to the container's size will be reflected in the widget, and any changes to the
+ widget's size will be reflected in the container.
+ \endlist
+*/
+bool QDeclarativeGraphicsObjectContainer::synchronizedResizing() const
+{
+ Q_D(const QDeclarativeGraphicsObjectContainer);
+ return d->syncedResize;
+}
+
+void QDeclarativeGraphicsObjectContainer::setSynchronizedResizing(bool on)
+{
+ Q_D(QDeclarativeGraphicsObjectContainer);
+ if (on == d->syncedResize)
+ return;
+
+ d->syncedResize = on;
+ d->setFiltering(on);
+}
+
+void QDeclarativeGraphicsObjectContainerPrivate::_q_updateSize()
+{
+ if (!graphicsObject || !graphicsObject->isWidget() || !syncedResize)
+ return;
+
+ QGraphicsWidget *gw = static_cast<QGraphicsWidget*>(graphicsObject);
+ const QSizeF newSize(width, height);
+ gw->resize(newSize);
+
+ //### will respecting the widgets min/max ever get us in trouble? (all other items always
+ // size to exactly what you tell them)
+ /*QSizeF constrainedSize = newSize.expandedTo(gw->minimumSize()).boundedTo(gw->maximumSize());
+ gw->resize(constrainedSize);
+ if (constrainedSize != newSize) {
+ setImplicitWidth(constrainedSize.width());
+ setImplicitHeight(constrainedSize.height());
+ }*/
+}
+
+#include <moc_qdeclarativegraphicsobjectcontainer_p.cpp>
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h
new file mode 100644
index 0000000..95d7a4b
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEGRAPHICSOBJECTCONTAINER_H
+#define QDECLARATIVEGRAPHICSOBJECTCONTAINER_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QGraphicsObject;
+class QDeclarativeGraphicsObjectContainerPrivate;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeGraphicsObjectContainer : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_CLASSINFO("DefaultProperty", "graphicsObject")
+ Q_PROPERTY(QGraphicsObject *graphicsObject READ graphicsObject WRITE setGraphicsObject)
+ Q_PROPERTY(bool synchronizedResizing READ synchronizedResizing WRITE setSynchronizedResizing)
+
+public:
+ QDeclarativeGraphicsObjectContainer(QDeclarativeItem *parent = 0);
+ ~QDeclarativeGraphicsObjectContainer();
+
+ QGraphicsObject *graphicsObject() const;
+ void setGraphicsObject(QGraphicsObject *);
+
+ bool synchronizedResizing() const;
+ void setSynchronizedResizing(bool on);
+
+protected:
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+ bool eventFilter(QObject *watched, QEvent *e);
+
+private:
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeGraphicsObjectContainer)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QGraphicsObject)
+QML_DECLARE_TYPE(QDeclarativeGraphicsObjectContainer)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEGRAPHICSOBJECTCONTAINER_H
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
new file mode 100644
index 0000000..aae5571
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -0,0 +1,1723 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativegridview_p.h"
+
+#include "qdeclarativevisualitemmodel_p.h"
+#include "qdeclarativeflickable_p_p.h"
+
+#include <qdeclarativeeasefollow_p.h>
+
+#include <qlistmodelinterface_p.h>
+#include <QKeyEvent>
+
+QT_BEGIN_NAMESPACE
+
+QHash<QObject*, QDeclarativeGridViewAttached*> QDeclarativeGridViewAttached::attachedProperties;
+
+
+//----------------------------------------------------------------------------
+
+class FxGridItem
+{
+public:
+ FxGridItem(QDeclarativeItem *i, QDeclarativeGridView *v) : item(i), view(v) {
+ attached = QDeclarativeGridViewAttached::properties(item);
+ attached->m_view = view;
+ }
+ ~FxGridItem() {}
+
+ qreal rowPos() const { return (view->flow() == QDeclarativeGridView::LeftToRight ? item->y() : item->x()); }
+ qreal colPos() const { return (view->flow() == QDeclarativeGridView::LeftToRight ? item->x() : item->y()); }
+ qreal endRowPos() const {
+ return view->flow() == QDeclarativeGridView::LeftToRight
+ ? item->y() + view->cellHeight() - 1
+ : item->x() + view->cellWidth() - 1;
+ }
+ void setPosition(qreal col, qreal row) {
+ if (view->flow() == QDeclarativeGridView::LeftToRight) {
+ item->setPos(QPointF(col, row));
+ } else {
+ item->setPos(QPointF(row, col));
+ }
+ }
+
+ QDeclarativeItem *item;
+ QDeclarativeGridView *view;
+ QDeclarativeGridViewAttached *attached;
+ int index;
+};
+
+//----------------------------------------------------------------------------
+
+class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeGridView)
+
+public:
+ QDeclarativeGridViewPrivate()
+ : currentItem(0), flow(QDeclarativeGridView::LeftToRight)
+ , visiblePos(0), visibleIndex(0) , currentIndex(-1)
+ , cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1)
+ , highlightComponent(0), highlight(0), trackedItem(0)
+ , moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0)
+ , bufferMode(NoBuffer)
+ , ownModel(false), wrap(false), autoHighlight(true)
+ , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false)
+ , deferredRelease(false) {}
+
+ void init();
+ void clear();
+ FxGridItem *createItem(int modelIndex);
+ void releaseItem(FxGridItem *item);
+ void refill(qreal from, qreal to, bool doBuffer=false);
+
+ void updateGrid();
+ void scheduleLayout();
+ void layout(bool removed=false);
+ void updateUnrequestedIndexes();
+ void updateUnrequestedPositions();
+ void updateTrackedItem();
+ void createHighlight();
+ void updateHighlight();
+ void updateCurrent(int modelIndex);
+
+ FxGridItem *visibleItem(int modelIndex) const {
+ if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) {
+ for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) {
+ FxGridItem *item = visibleItems.at(i);
+ if (item->index == modelIndex)
+ return item;
+ }
+ }
+ return 0;
+ }
+
+ qreal position() const {
+ Q_Q(const QDeclarativeGridView);
+ return flow == QDeclarativeGridView::LeftToRight ? q->viewportY() : q->viewportX();
+ }
+ void setPosition(qreal pos) {
+ Q_Q(QDeclarativeGridView);
+ if (flow == QDeclarativeGridView::LeftToRight)
+ q->setViewportY(pos);
+ else
+ q->setViewportX(pos);
+ }
+ int size() const {
+ Q_Q(const QDeclarativeGridView);
+ return flow == QDeclarativeGridView::LeftToRight ? q->height() : q->width();
+ }
+ qreal startPosition() const {
+ qreal pos = 0;
+ if (!visibleItems.isEmpty())
+ pos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize();
+ return pos;
+ }
+
+ qreal endPosition() const {
+ qreal pos = 0;
+ if (model && model->count())
+ pos = rowPosAt(model->count() - 1) + rowSize();
+ return pos;
+ }
+
+ bool isValid() const {
+ return model && model->count() && model->isValid();
+ }
+
+ int rowSize() const {
+ return flow == QDeclarativeGridView::LeftToRight ? cellHeight : cellWidth;
+ }
+ int colSize() const {
+ return flow == QDeclarativeGridView::LeftToRight ? cellWidth : cellHeight;
+ }
+
+ qreal colPosAt(int modelIndex) const {
+ if (FxGridItem *item = visibleItem(modelIndex))
+ return item->colPos();
+ if (!visibleItems.isEmpty()) {
+ if (modelIndex < visibleIndex) {
+ int count = (visibleIndex - modelIndex) % columns;
+ int col = visibleItems.first()->colPos() / colSize();
+ col = (columns - count + col) % columns;
+ return col * colSize();
+ } else {
+ int count = columns - 1 - (modelIndex - visibleItems.last()->index - 1) % columns;
+ return visibleItems.last()->colPos() - count * colSize();
+ }
+ } else {
+ return (modelIndex % columns) * colSize();
+ }
+ return 0;
+ }
+ qreal rowPosAt(int modelIndex) const {
+ if (FxGridItem *item = visibleItem(modelIndex))
+ return item->rowPos();
+ if (!visibleItems.isEmpty()) {
+ if (modelIndex < visibleIndex) {
+ int firstCol = visibleItems.first()->colPos() / colSize();
+ int col = visibleIndex - modelIndex + (columns - firstCol - 1);
+ int rows = col / columns;
+ return visibleItems.first()->rowPos() - rows * rowSize();
+ } else {
+ int count = modelIndex - visibleItems.last()->index;
+ int col = visibleItems.last()->colPos() + count * colSize();
+ int rows = col / (columns * colSize());
+ return visibleItems.last()->rowPos() + rows * rowSize();
+ }
+ } else {
+ return (modelIndex / columns) * rowSize();
+ }
+ return 0;
+ }
+
+ FxGridItem *firstVisibleItem() const {
+ const qreal pos = position();
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxGridItem *item = visibleItems.at(i);
+ if (item->index != -1 && item->endRowPos() > pos)
+ return item;
+ }
+ return visibleItems.count() ? visibleItems.first() : 0;
+ }
+
+ // Map a model index to visibleItems list index.
+ // These may differ if removed items are still present in the visible list,
+ // e.g. doing a removal animation
+ int mapFromModel(int modelIndex) const {
+ if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count())
+ return -1;
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxGridItem *listItem = visibleItems.at(i);
+ if (listItem->index == modelIndex)
+ return i + visibleIndex;
+ if (listItem->index > modelIndex)
+ return -1;
+ }
+ return -1; // Not in visibleList
+ }
+
+ // for debugging only
+ void checkVisible() const {
+ int skip = 0;
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxGridItem *listItem = visibleItems.at(i);
+ if (listItem->index == -1) {
+ ++skip;
+ } else if (listItem->index != visibleIndex + i - skip) {
+ for (int j = 0; j < visibleItems.count(); j++)
+ qDebug() << " index" << j << "item index" << visibleItems.at(j)->index;
+ qFatal("index %d %d %d", visibleIndex, i, listItem->index);
+ }
+ }
+ }
+
+ QGuard<QDeclarativeVisualModel> model;
+ QVariant modelVariant;
+ QList<FxGridItem*> visibleItems;
+ QHash<QDeclarativeItem*,int> unrequestedItems;
+ FxGridItem *currentItem;
+ QDeclarativeGridView::Flow flow;
+ int visiblePos;
+ int visibleIndex;
+ int currentIndex;
+ int cellWidth;
+ int cellHeight;
+ int columns;
+ int requestedIndex;
+ QDeclarativeComponent *highlightComponent;
+ FxGridItem *highlight;
+ FxGridItem *trackedItem;
+ enum MovementReason { Other, SetIndex, Mouse };
+ MovementReason moveReason;
+ int buffer;
+ QDeclarativeEaseFollow *highlightXAnimator;
+ QDeclarativeEaseFollow *highlightYAnimator;
+ enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 };
+ BufferMode bufferMode;
+
+ bool ownModel : 1;
+ bool wrap : 1;
+ bool autoHighlight : 1;
+ bool fixCurrentVisibility : 1;
+ bool lazyRelease : 1;
+ bool layoutScheduled : 1;
+ bool deferredRelease : 1;
+};
+
+void QDeclarativeGridViewPrivate::init()
+{
+ Q_Q(QDeclarativeGridView);
+ q->setFlag(QGraphicsItem::ItemIsFocusScope);
+ QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(sizeChange()));
+ QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(sizeChange()));
+ q->setFlickDirection(QDeclarativeFlickable::VerticalFlick);
+}
+
+void QDeclarativeGridViewPrivate::clear()
+{
+ for (int i = 0; i < visibleItems.count(); ++i)
+ releaseItem(visibleItems.at(i));
+ visibleItems.clear();
+ visiblePos = 0;
+ visibleIndex = 0;
+ releaseItem(currentItem);
+ currentItem = 0;
+ createHighlight();
+ trackedItem = 0;
+}
+
+FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex)
+{
+ Q_Q(QDeclarativeGridView);
+ // create object
+ requestedIndex = modelIndex;
+ FxGridItem *listItem = 0;
+ if (QDeclarativeItem *item = model->item(modelIndex, false)) {
+ listItem = new FxGridItem(item, q);
+ listItem->index = modelIndex;
+ // complete
+ model->completeItem();
+ listItem->item->setZValue(1);
+ listItem->item->setParent(q->viewport());
+ unrequestedItems.remove(listItem->item);
+ }
+ requestedIndex = 0;
+ return listItem;
+}
+
+
+void QDeclarativeGridViewPrivate::releaseItem(FxGridItem *item)
+{
+ Q_Q(QDeclarativeGridView);
+ if (!item || !model)
+ return;
+ if (trackedItem == item) {
+ QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
+ QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
+ trackedItem = 0;
+ }
+ if (model->release(item->item) == 0) {
+ // item was not destroyed, and we no longer reference it.
+ unrequestedItems.insert(item->item, model->indexOf(item->item, q));
+ }
+ delete item;
+}
+
+void QDeclarativeGridViewPrivate::refill(qreal from, qreal to, bool doBuffer)
+{
+ Q_Q(QDeclarativeGridView);
+ if (!isValid() || !q->isComponentComplete())
+ return;
+
+ qreal bufferFrom = from - buffer;
+ qreal bufferTo = to + buffer;
+ qreal fillFrom = from;
+ qreal fillTo = to;
+ if (doBuffer && (bufferMode & BufferAfter))
+ fillTo = bufferTo;
+ if (doBuffer && (bufferMode & BufferBefore))
+ fillFrom = bufferFrom;
+
+ bool changed = false;
+
+ int colPos = colPosAt(visibleIndex);
+ int rowPos = rowPosAt(visibleIndex);
+ int modelIndex = visibleIndex;
+ if (visibleItems.count()) {
+ rowPos = visibleItems.last()->rowPos();
+ colPos = visibleItems.last()->colPos() + colSize();
+ if (colPos > colSize() * (columns-1)) {
+ colPos = 0;
+ rowPos += rowSize();
+ }
+ int i = visibleItems.count() - 1;
+ while (i > 0 && visibleItems.at(i)->index == -1)
+ --i;
+ modelIndex = visibleItems.at(i)->index + 1;
+ }
+ int colNum = colPos / colSize();
+
+ FxGridItem *item = 0;
+
+ // Item creation and release is staggered in order to avoid
+ // creating/releasing multiple items in one frame
+ // while flicking (as much as possible).
+ while (modelIndex < model->count() && rowPos <= fillTo + rowSize()*(columns - colNum)/(columns+1)) {
+// qDebug() << "refill: append item" << modelIndex;
+ if (!(item = createItem(modelIndex)))
+ break;
+ item->setPosition(colPos, rowPos);
+ visibleItems.append(item);
+ colPos += colSize();
+ colNum++;
+ if (colPos > colSize() * (columns-1)) {
+ colPos = 0;
+ colNum = 0;
+ rowPos += rowSize();
+ }
+ ++modelIndex;
+ changed = true;
+ if (doBuffer) // never buffer more than one item per frame
+ break;
+ }
+
+ if (visibleItems.count()) {
+ rowPos = visibleItems.first()->rowPos();
+ colPos = visibleItems.first()->colPos() - colSize();
+ if (colPos < 0) {
+ colPos = colSize() * (columns - 1);
+ rowPos -= rowSize();
+ }
+ }
+ colNum = colPos / colSize();
+ while (visibleIndex > 0 && rowPos + rowSize() - 1 >= fillFrom - rowSize()*(colNum+1)/(columns+1)){
+// qDebug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos;
+ if (!(item = createItem(visibleIndex-1)))
+ break;
+ --visibleIndex;
+ item->setPosition(colPos, rowPos);
+ visibleItems.prepend(item);
+ colPos -= colSize();
+ colNum--;
+ if (colPos < 0) {
+ colPos = colSize() * (columns - 1);
+ colNum = columns-1;
+ rowPos -= rowSize();
+ }
+ changed = true;
+ if (doBuffer) // never buffer more than one item per frame
+ break;
+ }
+
+ if (!lazyRelease || !changed || deferredRelease) { // avoid destroying items in the same frame that we create
+ while (visibleItems.count() > 1
+ && (item = visibleItems.first())
+ && item->endRowPos() < bufferFrom - rowSize()*(item->colPos()/colSize()+1)/(columns+1)) {
+ if (item->attached->delayRemove())
+ break;
+// qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endRowPos();
+ if (item->index != -1)
+ visibleIndex++;
+ visibleItems.removeFirst();
+ releaseItem(item);
+ changed = true;
+ }
+ while (visibleItems.count() > 1
+ && (item = visibleItems.last())
+ && item->rowPos() > bufferTo + rowSize()*(columns - item->colPos()/colSize())/(columns+1)) {
+ if (item->attached->delayRemove())
+ break;
+// qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1;
+ visibleItems.removeLast();
+ releaseItem(item);
+ changed = true;
+ }
+ deferredRelease = false;
+ } else {
+ deferredRelease = true;
+ }
+ if (changed) {
+ if (flow == QDeclarativeGridView::LeftToRight)
+ q->setViewportHeight(endPosition() - startPosition());
+ else
+ q->setViewportWidth(endPosition() - startPosition());
+ } else if (!doBuffer && buffer && bufferMode != NoBuffer) {
+ refill(from, to, true);
+ }
+ lazyRelease = false;
+}
+
+void QDeclarativeGridViewPrivate::updateGrid()
+{
+ Q_Q(QDeclarativeGridView);
+ columns = (int)qMax((flow == QDeclarativeGridView::LeftToRight ? q->width() : q->height()) / colSize(), qreal(1.));
+ if (isValid()) {
+ if (flow == QDeclarativeGridView::LeftToRight)
+ q->setViewportHeight(endPosition() - startPosition());
+ else
+ q->setViewportWidth(endPosition() - startPosition());
+ }
+}
+
+void QDeclarativeGridViewPrivate::scheduleLayout()
+{
+ Q_Q(QDeclarativeGridView);
+ if (!layoutScheduled) {
+ layoutScheduled = true;
+ QMetaObject::invokeMethod(q, "layout", Qt::QueuedConnection);
+ }
+}
+
+void QDeclarativeGridViewPrivate::layout(bool removed)
+{
+ Q_Q(QDeclarativeGridView);
+ layoutScheduled = false;
+ if (visibleItems.count()) {
+ qreal rowPos = visibleItems.first()->rowPos();
+ qreal colPos = visibleItems.first()->colPos();
+ int col = visibleIndex % columns;
+ if (colPos != col * colSize()) {
+ if (removed)
+ rowPos -= rowSize();
+ colPos = col * colSize();
+ visibleItems.first()->setPosition(colPos, rowPos);
+ }
+ for (int i = 1; i < visibleItems.count(); ++i) {
+ FxGridItem *item = visibleItems.at(i);
+ colPos += colSize();
+ if (colPos > colSize() * (columns-1)) {
+ colPos = 0;
+ rowPos += rowSize();
+ }
+ item->setPosition(colPos, rowPos);
+ }
+ }
+ q->refill();
+ updateHighlight();
+ moveReason = Other;
+ if (flow == QDeclarativeGridView::LeftToRight) {
+ q->setViewportHeight(endPosition() - startPosition());
+ fixupY();
+ } else {
+ q->setViewportWidth(endPosition() - startPosition());
+ fixupX();
+ }
+ updateUnrequestedPositions();
+}
+
+void QDeclarativeGridViewPrivate::updateUnrequestedIndexes()
+{
+ Q_Q(QDeclarativeGridView);
+ QHash<QDeclarativeItem*,int>::iterator it;
+ for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it)
+ *it = model->indexOf(it.key(), q);
+}
+
+void QDeclarativeGridViewPrivate::updateUnrequestedPositions()
+{
+ QHash<QDeclarativeItem*,int>::const_iterator it;
+ for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) {
+ if (flow == QDeclarativeGridView::LeftToRight) {
+ it.key()->setPos(QPointF(colPosAt(*it), rowPosAt(*it)));
+ } else {
+ it.key()->setPos(QPointF(rowPosAt(*it), colPosAt(*it)));
+ }
+ }
+}
+
+void QDeclarativeGridViewPrivate::updateTrackedItem()
+{
+ Q_Q(QDeclarativeGridView);
+ FxGridItem *item = currentItem;
+ if (highlight)
+ item = highlight;
+
+ FxGridItem *oldTracked = trackedItem;
+
+ if (trackedItem && item != trackedItem) {
+ QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
+ QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
+ trackedItem = 0;
+ }
+
+ if (!trackedItem && item) {
+ trackedItem = item;
+ QObject::connect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
+ QObject::connect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
+ }
+ if (trackedItem && trackedItem != oldTracked)
+ q->trackedPositionChanged();
+}
+
+void QDeclarativeGridViewPrivate::createHighlight()
+{
+ Q_Q(QDeclarativeGridView);
+ bool changed = false;
+ if (highlight) {
+ if (trackedItem == highlight)
+ trackedItem = 0;
+ delete highlight->item;
+ delete highlight;
+ highlight = 0;
+ delete highlightXAnimator;
+ delete highlightYAnimator;
+ highlightXAnimator = 0;
+ highlightYAnimator = 0;
+ changed = true;
+ }
+
+ if (currentItem) {
+ QDeclarativeItem *item = 0;
+ if (highlightComponent) {
+ QDeclarativeContext *highlightContext = new QDeclarativeContext(qmlContext(q));
+ QObject *nobj = highlightComponent->create(highlightContext);
+ if (nobj) {
+ highlightContext->setParent(nobj);
+ item = qobject_cast<QDeclarativeItem *>(nobj);
+ if (!item)
+ delete nobj;
+ } else {
+ delete highlightContext;
+ }
+ } else {
+ item = new QDeclarativeItem;
+ item->setParent(q->viewport());
+ }
+ if (item) {
+ item->setParent(q->viewport());
+ highlight = new FxGridItem(item, q);
+ highlightXAnimator = new QDeclarativeEaseFollow(q);
+ highlightXAnimator->setTarget(QDeclarativeMetaProperty(highlight->item, QLatin1String("x")));
+ highlightXAnimator->setDuration(150);
+ highlightXAnimator->setEnabled(autoHighlight);
+ highlightYAnimator = new QDeclarativeEaseFollow(q);
+ highlightYAnimator->setTarget(QDeclarativeMetaProperty(highlight->item, QLatin1String("y")));
+ highlightYAnimator->setDuration(150);
+ highlightYAnimator->setEnabled(autoHighlight);
+ changed = true;
+ }
+ }
+ if (changed)
+ emit q->highlightChanged();
+}
+
+void QDeclarativeGridViewPrivate::updateHighlight()
+{
+ if ((!currentItem && highlight) || (currentItem && !highlight))
+ createHighlight();
+ if (currentItem && autoHighlight && highlight && !moving) {
+ // auto-update highlight
+ highlightXAnimator->setSourceValue(currentItem->item->x());
+ highlightYAnimator->setSourceValue(currentItem->item->y());
+ highlight->item->setWidth(currentItem->item->width());
+ highlight->item->setHeight(currentItem->item->height());
+ }
+ updateTrackedItem();
+}
+
+void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex)
+{
+ Q_Q(QDeclarativeGridView);
+ if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) {
+ if (currentItem) {
+ currentItem->attached->setIsCurrentItem(false);
+ releaseItem(currentItem);
+ currentItem = 0;
+ currentIndex = -1;
+ updateHighlight();
+ emit q->currentIndexChanged();
+ }
+ return;
+ }
+
+ if (currentItem && currentIndex == modelIndex) {
+ updateHighlight();
+ return;
+ }
+
+ FxGridItem *oldCurrentItem = currentItem;
+ currentIndex = modelIndex;
+ currentItem = createItem(modelIndex);
+ fixCurrentVisibility = true;
+ if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item))
+ oldCurrentItem->attached->setIsCurrentItem(false);
+ if (currentItem) {
+ currentItem->setPosition(colPosAt(modelIndex), rowPosAt(modelIndex));
+ currentItem->item->setFocus(true);
+ currentItem->attached->setIsCurrentItem(true);
+ }
+ updateHighlight();
+ emit q->currentIndexChanged();
+ releaseItem(oldCurrentItem);
+}
+
+//----------------------------------------------------------------------------
+
+/*!
+ \qmlclass GridView QDeclarativeGridView
+ \inherits Flickable
+ \brief The GridView item provides a grid view of items provided by a model.
+
+ The model is typically provided by a QAbstractListModel "C++ model object",
+ but can also be created directly in QML.
+
+ The items are laid out top to bottom (vertically) or left to right (horizontally)
+ and may be flicked to scroll.
+
+ The below example creates a very simple grid, using a QML model.
+
+ \image gridview.png
+
+ \snippet doc/src/snippets/declarative/gridview/gridview.qml 3
+
+ The model is defined as a ListModel using QML:
+ \quotefile doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml
+
+ In this case ListModel is a handy way for us to test our UI. In practice
+ the model would be implemented in C++, or perhaps via a SQL data source.
+*/
+QDeclarativeGridView::QDeclarativeGridView(QDeclarativeItem *parent)
+ : QDeclarativeFlickable(*(new QDeclarativeGridViewPrivate), parent)
+{
+ Q_D(QDeclarativeGridView);
+ d->init();
+}
+
+QDeclarativeGridView::~QDeclarativeGridView()
+{
+ Q_D(QDeclarativeGridView);
+ d->clear();
+ if (d->ownModel)
+ delete d->model;
+}
+
+/*!
+ \qmlattachedproperty bool GridView::isCurrentItem
+ This attched property is true if this delegate is the current item; otherwise false.
+
+ It is attached to each instance of the delegate.
+*/
+
+/*!
+ \qmlattachedproperty GridView GridView::view
+ This attached property holds the view that manages this delegate instance.
+
+ It is attached to each instance of the delegate.
+*/
+
+/*!
+ \qmlattachedproperty bool GridView::delayRemove
+ This attached property holds whether the delegate may be destroyed.
+
+ It is attached to each instance of the delegate.
+
+ It is sometimes necessary to delay the destruction of an item
+ until an animation completes.
+
+ The example below ensures that the animation completes before
+ the item is removed from the grid.
+
+ \code
+ Component {
+ id: myDelegate
+ Item {
+ id: wrapper
+ GridView.onRemove: SequentialAnimation {
+ PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: true }
+ NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
+ PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: false }
+ }
+ }
+ }
+ \endcode
+*/
+
+/*!
+ \qmlattachedsignal GridView::onAdd()
+ This attached handler is called immediately after an item is added to the view.
+*/
+
+/*!
+ \qmlattachedsignal GridView::onRemove()
+ This attached handler is called immediately before an item is removed from the view.
+*/
+
+
+/*!
+ \qmlproperty model GridView::model
+ This property holds the model providing data for the grid.
+
+ The model provides a set of data that is used to create the items
+ for the view. For large or dynamic datasets the model is usually
+ provided by a C++ model object. The C++ model object must be a \l
+ {QAbstractItemModel} subclass, a VisualModel, or a simple list.
+
+ \sa {qmlmodels}{Data Models}
+*/
+QVariant QDeclarativeGridView::model() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->modelVariant;
+}
+
+void QDeclarativeGridView::setModel(const QVariant &model)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->model) {
+ disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
+ disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
+ disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
+ disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
+ }
+ d->clear();
+ d->modelVariant = model;
+ QObject *object = qvariant_cast<QObject*>(model);
+ QDeclarativeVisualModel *vim = 0;
+ if (object && (vim = qobject_cast<QDeclarativeVisualModel *>(object))) {
+ if (d->ownModel) {
+ delete d->model;
+ d->ownModel = false;
+ }
+ d->model = vim;
+ } else {
+ if (!d->ownModel) {
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->ownModel = true;
+ }
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
+ dataModel->setModel(model);
+ }
+ if (d->model) {
+ if (isComponentComplete()) {
+ refill();
+ if (d->currentIndex >= d->model->count() || d->currentIndex < 0) {
+ setCurrentIndex(0);
+ } else {
+ d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
+ d->updateCurrent(d->currentIndex);
+ }
+ }
+ connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
+ connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
+ connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
+ connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
+ emit countChanged();
+ }
+}
+
+/*!
+ \qmlproperty component GridView::delegate
+
+ The delegate provides a template defining each item instantiated by the view.
+ The index is exposed as an accessible \c index property. Properties of the
+ model are also available depending upon the type of \l {qmlmodels}{Data Model}.
+
+ Note that the GridView will layout the items based on the size of the root item
+ in the delegate.
+
+ Here is an example delegate:
+ \snippet doc/src/snippets/declarative/gridview/gridview.qml 0
+*/
+QDeclarativeComponent *QDeclarativeGridView::delegate() const
+{
+ Q_D(const QDeclarativeGridView);
+ if (d->model) {
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
+ return dataModel->delegate();
+ }
+
+ return 0;
+}
+
+void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate)
+{
+ Q_D(QDeclarativeGridView);
+ if (delegate == this->delegate())
+ return;
+
+ if (!d->ownModel) {
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->ownModel = true;
+ }
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) {
+ dataModel->setDelegate(delegate);
+ if (isComponentComplete()) {
+ refill();
+ d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
+ d->updateCurrent(d->currentIndex);
+ }
+ }
+}
+
+/*!
+ \qmlproperty int GridView::currentIndex
+ \qmlproperty Item GridView::currentItem
+
+ \c currentIndex holds the index of the current item.
+ \c currentItem is the current item. Note that the position of the current item
+ may only be approximate until it becomes visible in the view.
+*/
+int QDeclarativeGridView::currentIndex() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->currentIndex;
+}
+
+void QDeclarativeGridView::setCurrentIndex(int index)
+{
+ Q_D(QDeclarativeGridView);
+ if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) {
+ d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
+ cancelFlick();
+ d->updateCurrent(index);
+ } else {
+ d->currentIndex = index;
+ }
+}
+
+QDeclarativeItem *QDeclarativeGridView::currentItem()
+{
+ Q_D(QDeclarativeGridView);
+ if (!d->currentItem)
+ return 0;
+ return d->currentItem->item;
+}
+
+/*!
+ \qmlproperty Item GridView::highlightItem
+
+ \c highlightItem holds the highlight item, which was created
+ from the \l highlight component.
+
+ The highlightItem is managed by the view unless
+ \l highlightFollowsCurrentItem is set to false.
+
+ \sa highlight, highlightFollowsCurrentItem
+*/
+QDeclarativeItem *QDeclarativeGridView::highlightItem()
+{
+ Q_D(QDeclarativeGridView);
+ if (!d->highlight)
+ return 0;
+ return d->highlight->item;
+}
+
+/*!
+ \qmlproperty int GridView::count
+ This property holds the number of items in the view.
+*/
+int QDeclarativeGridView::count() const
+{
+ Q_D(const QDeclarativeGridView);
+ if (d->model)
+ return d->model->count();
+ return 0;
+}
+
+/*!
+ \qmlproperty component GridView::highlight
+ This property holds the component to use as the highlight.
+
+ An instance of the highlight component will be created for each view.
+ The geometry of the resultant component instance will be managed by the view
+ so as to stay with the current item, unless the highlightFollowsCurrentItem property is false.
+
+ The below example demonstrates how to make a simple highlight:
+ \snippet doc/src/snippets/declarative/gridview/gridview.qml 1
+
+ \sa highlightItem, highlightFollowsCurrentItem
+*/
+QDeclarativeComponent *QDeclarativeGridView::highlight() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->highlightComponent;
+}
+
+void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight)
+{
+ Q_D(QDeclarativeGridView);
+ if (highlight != d->highlightComponent) {
+ d->highlightComponent = highlight;
+ d->updateCurrent(d->currentIndex);
+ }
+}
+
+/*!
+ \qmlproperty bool GridView::highlightFollowsCurrentItem
+ This property sets whether the highlight is managed by the view.
+
+ If highlightFollowsCurrentItem is true, the highlight will be moved smoothly
+ to follow the current item. If highlightFollowsCurrentItem is false, the
+ highlight will not be moved by the view, and must be implemented
+ by the highlight component, for example:
+
+ \code
+ Component {
+ id: myHighlight
+ Rectangle {
+ id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60
+ y: SpringFollow { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
+ x: SpringFollow { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
+ }
+ }
+ \endcode
+*/
+bool QDeclarativeGridView::highlightFollowsCurrentItem() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->autoHighlight;
+}
+
+void QDeclarativeGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->autoHighlight != autoHighlight) {
+ d->autoHighlight = autoHighlight;
+ if (d->highlightXAnimator) {
+ d->highlightXAnimator->setEnabled(d->autoHighlight);
+ d->highlightYAnimator->setEnabled(d->autoHighlight);
+ }
+ d->updateHighlight();
+ }
+}
+
+/*!
+ \qmlproperty enumeration GridView::flow
+ This property holds the flow of the grid.
+
+ Possible values are \c LeftToRight (default) and \c TopToBottom.
+
+ If \a flow is \c LeftToRight, the view will scroll vertically.
+ If \a flow is \c TopToBottom, the view will scroll horizontally.
+*/
+QDeclarativeGridView::Flow QDeclarativeGridView::flow() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->flow;
+}
+
+void QDeclarativeGridView::setFlow(Flow flow)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->flow != flow) {
+ d->flow = flow;
+ if (d->flow == LeftToRight) {
+ setViewportWidth(-1);
+ setFlickDirection(QDeclarativeFlickable::VerticalFlick);
+ } else {
+ setViewportHeight(-1);
+ setFlickDirection(QDeclarativeFlickable::HorizontalFlick);
+ }
+ d->clear();
+ d->updateGrid();
+ refill();
+ d->updateCurrent(d->currentIndex);
+ }
+}
+
+/*!
+ \qmlproperty bool GridView::keyNavigationWraps
+ This property holds whether the grid wraps key navigation
+
+ If this property is true then key presses to move off of one end of the grid will cause the
+ selection to jump to the other side.
+*/
+bool QDeclarativeGridView::isWrapEnabled() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->wrap;
+}
+
+void QDeclarativeGridView::setWrapEnabled(bool wrap)
+{
+ Q_D(QDeclarativeGridView);
+ d->wrap = wrap;
+}
+
+/*!
+ \qmlproperty int GridView::cacheBuffer
+ This property holds the number of off-screen pixels to cache.
+
+ This property determines the number of pixels above the top of the view
+ and below the bottom of the view to cache. Setting this value can make
+ scrolling the view smoother at the expense of additional memory usage.
+*/
+int QDeclarativeGridView::cacheBuffer() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->buffer;
+}
+
+void QDeclarativeGridView::setCacheBuffer(int buffer)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->buffer != buffer) {
+ d->buffer = buffer;
+ if (isComponentComplete())
+ refill();
+ }
+}
+
+/*!
+ \qmlproperty int GridView::cellWidth
+ \qmlproperty int GridView::cellHeight
+
+ These properties holds the width and height of each cell in the grid
+
+ The default cell size is 100x100.
+*/
+int QDeclarativeGridView::cellWidth() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->cellWidth;
+}
+
+void QDeclarativeGridView::setCellWidth(int cellWidth)
+{
+ Q_D(QDeclarativeGridView);
+ if (cellWidth != d->cellWidth && cellWidth > 0) {
+ d->cellWidth = qMax(1, cellWidth);
+ d->updateGrid();
+ emit cellWidthChanged();
+ d->layout();
+ }
+}
+
+int QDeclarativeGridView::cellHeight() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->cellHeight;
+}
+
+void QDeclarativeGridView::setCellHeight(int cellHeight)
+{
+ Q_D(QDeclarativeGridView);
+ if (cellHeight != d->cellHeight && cellHeight > 0) {
+ d->cellHeight = qMax(1, cellHeight);
+ d->updateGrid();
+ emit cellHeightChanged();
+ d->layout();
+ }
+}
+
+void QDeclarativeGridView::sizeChange()
+{
+ Q_D(QDeclarativeGridView);
+ if (isComponentComplete()) {
+ d->updateGrid();
+ d->layout();
+ }
+}
+
+void QDeclarativeGridView::viewportMoved()
+{
+ Q_D(QDeclarativeGridView);
+ QDeclarativeFlickable::viewportMoved();
+ d->lazyRelease = true;
+ if (d->flicked) {
+ if (yflick()) {
+ if (d->velocityY > 0)
+ d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore;
+ else if (d->velocityY < 0)
+ d->bufferMode = QDeclarativeGridViewPrivate::BufferAfter;
+ }
+
+ if (xflick()) {
+ if (d->velocityX > 0)
+ d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore;
+ else if (d->velocityX < 0)
+ d->bufferMode = QDeclarativeGridViewPrivate::BufferAfter;
+ }
+ }
+ refill();
+}
+
+qreal QDeclarativeGridView::minYExtent() const
+{
+ Q_D(const QDeclarativeGridView);
+ if (d->flow == QDeclarativeGridView::TopToBottom)
+ return QDeclarativeFlickable::minYExtent();
+ return -d->startPosition();
+}
+
+qreal QDeclarativeGridView::maxYExtent() const
+{
+ Q_D(const QDeclarativeGridView);
+ if (d->flow == QDeclarativeGridView::TopToBottom)
+ return QDeclarativeFlickable::maxYExtent();
+ qreal extent = -(d->endPosition() - height());
+ const qreal minY = minYExtent();
+ if (extent > minY)
+ extent = minY;
+ return extent;
+}
+
+qreal QDeclarativeGridView::minXExtent() const
+{
+ Q_D(const QDeclarativeGridView);
+ if (d->flow == QDeclarativeGridView::LeftToRight)
+ return QDeclarativeFlickable::minXExtent();
+ return -d->startPosition();
+}
+
+qreal QDeclarativeGridView::maxXExtent() const
+{
+ Q_D(const QDeclarativeGridView);
+ if (d->flow == QDeclarativeGridView::LeftToRight)
+ return QDeclarativeFlickable::maxXExtent();
+ qreal extent = -(d->endPosition() - width());
+ const qreal minX = minXExtent();
+ if (extent > minX)
+ extent = minX;
+ return extent;
+}
+
+void QDeclarativeGridView::keyPressEvent(QKeyEvent *event)
+{
+ Q_D(QDeclarativeGridView);
+ QDeclarativeFlickable::keyPressEvent(event);
+ if (event->isAccepted())
+ return;
+ if (d->model && d->model->count() && d->interactive) {
+ d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
+ int oldCurrent = currentIndex();
+ switch (event->key()) {
+ case Qt::Key_Up:
+ moveCurrentIndexUp();
+ break;
+ case Qt::Key_Down:
+ moveCurrentIndexDown();
+ break;
+ case Qt::Key_Left:
+ moveCurrentIndexLeft();
+ break;
+ case Qt::Key_Right:
+ moveCurrentIndexRight();
+ break;
+ default:
+ break;
+ }
+ if (oldCurrent != currentIndex()) {
+ event->accept();
+ return;
+ }
+ }
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
+ event->ignore();
+}
+
+/*!
+ \qmlmethod GridView::moveCurrentIndexUp()
+
+ Move the currentIndex up one item in the view.
+ The current index will wrap if keyNavigationWraps is true and it
+ is currently at the end.
+*/
+void QDeclarativeGridView::moveCurrentIndexUp()
+{
+ Q_D(QDeclarativeGridView);
+ if (d->flow == QDeclarativeGridView::LeftToRight) {
+ if (currentIndex() >= d->columns || d->wrap) {
+ int index = currentIndex() - d->columns;
+ setCurrentIndex(index >= 0 ? index : d->model->count()-1);
+ }
+ } else {
+ if (currentIndex() > 0 || d->wrap) {
+ int index = currentIndex() - 1;
+ setCurrentIndex(index >= 0 ? index : d->model->count()-1);
+ }
+ }
+}
+
+/*!
+ \qmlmethod GridView::moveCurrentIndexDown()
+
+ Move the currentIndex down one item in the view.
+ The current index will wrap if keyNavigationWraps is true and it
+ is currently at the end.
+*/
+void QDeclarativeGridView::moveCurrentIndexDown()
+{
+ Q_D(QDeclarativeGridView);
+ if (d->flow == QDeclarativeGridView::LeftToRight) {
+ if (currentIndex() < d->model->count() - d->columns || d->wrap) {
+ int index = currentIndex()+d->columns;
+ setCurrentIndex(index < d->model->count() ? index : 0);
+ }
+ } else {
+ if (currentIndex() < d->model->count() - 1 || d->wrap) {
+ int index = currentIndex() + 1;
+ setCurrentIndex(index < d->model->count() ? index : 0);
+ }
+ }
+}
+
+/*!
+ \qmlmethod GridView::moveCurrentIndexLeft()
+
+ Move the currentIndex left one item in the view.
+ The current index will wrap if keyNavigationWraps is true and it
+ is currently at the end.
+*/
+void QDeclarativeGridView::moveCurrentIndexLeft()
+{
+ Q_D(QDeclarativeGridView);
+ if (d->flow == QDeclarativeGridView::LeftToRight) {
+ if (currentIndex() > 0 || d->wrap) {
+ int index = currentIndex() - 1;
+ setCurrentIndex(index >= 0 ? index : d->model->count()-1);
+ }
+ } else {
+ if (currentIndex() >= d->columns || d->wrap) {
+ int index = currentIndex() - d->columns;
+ setCurrentIndex(index >= 0 ? index : d->model->count()-1);
+ }
+ }
+}
+
+/*!
+ \qmlmethod GridView::moveCurrentIndexRight()
+
+ Move the currentIndex right one item in the view.
+ The current index will wrap if keyNavigationWraps is true and it
+ is currently at the end.
+*/
+void QDeclarativeGridView::moveCurrentIndexRight()
+{
+ Q_D(QDeclarativeGridView);
+ if (d->flow == QDeclarativeGridView::LeftToRight) {
+ if (currentIndex() < d->model->count() - 1 || d->wrap) {
+ int index = currentIndex() + 1;
+ setCurrentIndex(index < d->model->count() ? index : 0);
+ }
+ } else {
+ if (currentIndex() < d->model->count() - d->columns || d->wrap) {
+ int index = currentIndex()+d->columns;
+ setCurrentIndex(index < d->model->count() ? index : 0);
+ }
+ }
+}
+
+void QDeclarativeGridView::positionViewAtIndex(int index)
+{
+ Q_D(QDeclarativeGridView);
+ if (!d->isValid() || index < 0 || index >= d->model->count())
+ return;
+
+ qreal maxExtent = d->flow == QDeclarativeGridView::LeftToRight ? -maxYExtent() : -maxXExtent();
+ FxGridItem *item = d->visibleItem(index);
+ if (item) {
+ // Already created - just move to top of view
+ int pos = qMin(item->rowPos(), maxExtent);
+ d->setPosition(pos);
+ } else {
+ int pos = d->rowPosAt(index);
+ // save the currently visible items in case any of them end up visible again
+ QList<FxGridItem*> oldVisible = d->visibleItems;
+ d->visibleItems.clear();
+ d->visibleIndex = index - index % d->columns;
+ d->setPosition(pos);
+ // setPosition() will cause refill. Adjust if we have moved beyond range
+ if (d->position() > maxExtent)
+ d->setPosition(maxExtent);
+ // now release the reference to all the old visible items.
+ for (int i = 0; i < oldVisible.count(); ++i)
+ d->releaseItem(oldVisible.at(i));
+ }
+}
+
+
+void QDeclarativeGridView::componentComplete()
+{
+ Q_D(QDeclarativeGridView);
+ QDeclarativeFlickable::componentComplete();
+ d->updateGrid();
+ refill();
+ if (d->currentIndex < 0)
+ d->updateCurrent(0);
+ else
+ d->updateCurrent(d->currentIndex);
+}
+
+void QDeclarativeGridView::trackedPositionChanged()
+{
+ Q_D(QDeclarativeGridView);
+ if (!d->trackedItem || !d->currentItem)
+ return;
+ if (!isFlicking() && !d->moving && d->moveReason == QDeclarativeGridViewPrivate::SetIndex) {
+ const qreal viewPos = d->position();
+ if (d->trackedItem->rowPos() < viewPos && d->currentItem->rowPos() < viewPos) {
+ d->setPosition(d->currentItem->rowPos() < d->trackedItem->rowPos() ? d->trackedItem->rowPos() : d->currentItem->rowPos());
+ } else if (d->trackedItem->endRowPos() > viewPos + d->size()
+ && d->currentItem->endRowPos() > viewPos + d->size()) {
+ qreal pos;
+ if (d->trackedItem->endRowPos() < d->currentItem->endRowPos()) {
+ pos = d->trackedItem->endRowPos() - d->size();
+ if (d->rowSize() > d->size())
+ pos = d->trackedItem->rowPos();
+ } else {
+ pos = d->currentItem->endRowPos() - d->size();
+ if (d->rowSize() > d->size())
+ pos = d->currentItem->rowPos();
+ }
+ d->setPosition(pos);
+ }
+ }
+}
+
+void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
+{
+ Q_D(QDeclarativeGridView);
+ if (!d->visibleItems.count() || d->model->count() <= 1) {
+ refill();
+ d->updateCurrent(qMax(0, qMin(d->currentIndex, d->model->count()-1)));
+ emit countChanged();
+ return;
+ }
+
+ int index = d->mapFromModel(modelIndex);
+ if (index == -1) {
+ int i = d->visibleItems.count() - 1;
+ while (i > 0 && d->visibleItems.at(i)->index == -1)
+ --i;
+ if (d->visibleItems.at(i)->index + 1 == modelIndex) {
+ // Special case of appending an item to the model.
+ index = d->visibleIndex + d->visibleItems.count();
+ } else {
+ if (modelIndex <= d->visibleIndex) {
+ // Insert before visible items
+ d->visibleIndex += count;
+ for (int i = 0; i < d->visibleItems.count(); ++i) {
+ FxGridItem *listItem = d->visibleItems.at(i);
+ if (listItem->index != -1 && listItem->index >= modelIndex)
+ listItem->index += count;
+ }
+ }
+ if (d->currentIndex >= modelIndex) {
+ // adjust current item index
+ d->currentIndex += count;
+ if (d->currentItem)
+ d->currentItem->index = d->currentIndex;
+ }
+ d->layout();
+ emit countChanged();
+ return;
+ }
+ }
+
+ // At least some of the added items will be visible
+ int insertCount = count;
+ if (index < d->visibleIndex) {
+ insertCount -= d->visibleIndex - index;
+ index = d->visibleIndex;
+ modelIndex = d->visibleIndex;
+ }
+
+ index -= d->visibleIndex;
+ int to = d->buffer+d->position()+d->size()-1;
+ int colPos, rowPos;
+ if (index < d->visibleItems.count()) {
+ colPos = d->visibleItems.at(index)->colPos();
+ rowPos = d->visibleItems.at(index)->rowPos();
+ } else {
+ // appending items to visible list
+ colPos = d->visibleItems.at(index-1)->colPos() + d->colSize();
+ rowPos = d->visibleItems.at(index-1)->rowPos();
+ if (colPos > d->colSize() * (d->columns-1)) {
+ colPos = 0;
+ rowPos += d->rowSize();
+ }
+ }
+
+ QList<FxGridItem*> added;
+ int i = 0;
+ while (i < insertCount && rowPos <= to + d->rowSize()*(d->columns - (colPos/d->colSize()))/qreal(d->columns)) {
+ FxGridItem *item = d->createItem(modelIndex + i);
+ d->visibleItems.insert(index, item);
+ item->setPosition(colPos, rowPos);
+ added.append(item);
+ colPos += d->colSize();
+ if (colPos > d->colSize() * (d->columns-1)) {
+ colPos = 0;
+ rowPos += d->rowSize();
+ }
+ ++index;
+ ++i;
+ }
+ if (i < insertCount) {
+ // We didn't insert all our new items, which means anything
+ // beyond the current index is not visible - remove it.
+ while (d->visibleItems.count() > index) {
+ d->releaseItem(d->visibleItems.takeLast());
+ }
+ }
+
+ if (d->currentIndex >= modelIndex) {
+ // adjust current item index
+ d->currentIndex += count;
+ if (d->currentItem) {
+ d->currentItem->index = d->currentIndex;
+ d->currentItem->setPosition(d->colPosAt(d->currentIndex), d->rowPosAt(d->currentIndex));
+ }
+ }
+ // Update the indexes of the following visible items.
+ for (; index < d->visibleItems.count(); ++index) {
+ FxGridItem *listItem = d->visibleItems.at(index);
+ if (listItem->index != -1)
+ listItem->index += count;
+ }
+
+ // everything is in order now - emit add() signal
+ for (int j = 0; j < added.count(); ++j)
+ added.at(j)->attached->emitAdd();
+ d->layout();
+ emit countChanged();
+}
+
+void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
+{
+ Q_D(QDeclarativeGridView);
+ bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count;
+ bool removedVisible = false;
+
+ // Remove the items from the visible list, skipping anything already marked for removal
+ QList<FxGridItem*>::Iterator it = d->visibleItems.begin();
+ while (it != d->visibleItems.end()) {
+ FxGridItem *item = *it;
+ if (item->index == -1 || item->index < modelIndex) {
+ // already removed, or before removed items
+ if (item->index < modelIndex)
+ removedVisible = true;
+ ++it;
+ } else if (item->index >= modelIndex + count) {
+ // after removed items
+ item->index -= count;
+ ++it;
+ } else {
+ // removed item
+ removedVisible = true;
+ item->attached->emitRemove();
+ if (item->attached->delayRemove()) {
+ item->index = -1;
+ connect(item->attached, SIGNAL(delayRemoveChanged()), this, SLOT(destroyRemoved()), Qt::QueuedConnection);
+ ++it;
+ } else {
+ it = d->visibleItems.erase(it);
+ d->releaseItem(item);
+ }
+ }
+ }
+
+ // fix current
+ if (d->currentIndex >= modelIndex + count) {
+ d->currentIndex -= count;
+ if (d->currentItem)
+ d->currentItem->index -= count;
+ } else if (currentRemoved) {
+ // current item has been removed.
+ d->releaseItem(d->currentItem);
+ d->currentItem = 0;
+ d->currentIndex = -1;
+ d->updateCurrent(qMin(modelIndex, d->model->count()-1));
+ }
+
+ // update visibleIndex
+ for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
+ if ((*it)->index != -1) {
+ d->visibleIndex = (*it)->index;
+ break;
+ }
+ }
+
+ if (removedVisible) {
+ if (d->visibleItems.isEmpty()) {
+ d->visibleIndex = 0;
+ d->setPosition(0);
+ refill();
+ } else {
+ // Correct the positioning of the items
+ d->scheduleLayout();
+ }
+ }
+
+ emit countChanged();
+}
+
+void QDeclarativeGridView::layout()
+{
+ Q_D(QDeclarativeGridView);
+ if (d->layoutScheduled)
+ d->layout();
+}
+
+void QDeclarativeGridView::destroyRemoved()
+{
+ Q_D(QDeclarativeGridView);
+ for (QList<FxGridItem*>::Iterator it = d->visibleItems.begin();
+ it != d->visibleItems.end();) {
+ FxGridItem *listItem = *it;
+ if (listItem->index == -1 && listItem->attached->delayRemove() == false) {
+ d->releaseItem(listItem);
+ it = d->visibleItems.erase(it);
+ } else {
+ ++it;
+ }
+ }
+
+ // Correct the positioning of the items
+ d->layout();
+}
+
+void QDeclarativeGridView::itemsMoved(int from, int to, int count)
+{
+ Q_D(QDeclarativeGridView);
+ QHash<int,FxGridItem*> moved;
+
+ bool removedBeforeVisible = false;
+ FxGridItem *firstItem = d->firstVisibleItem();
+
+ if (from < to && from < d->visibleIndex && to > d->visibleIndex)
+ removedBeforeVisible = true;
+
+ QList<FxGridItem*>::Iterator it = d->visibleItems.begin();
+ while (it != d->visibleItems.end()) {
+ FxGridItem *item = *it;
+ if (item->index >= from && item->index < from + count) {
+ // take the items that are moving
+ item->index += (to-from);
+ moved.insert(item->index, item);
+ it = d->visibleItems.erase(it);
+ if (item->rowPos() < firstItem->rowPos())
+ removedBeforeVisible = true;
+ } else {
+ if (item->index > from && item->index != -1) {
+ // move everything after the moved items.
+ item->index -= count;
+ if (item->index < d->visibleIndex)
+ d->visibleIndex = item->index;
+ } else if (item->index != -1) {
+ removedBeforeVisible = true;
+ }
+ ++it;
+ }
+ }
+
+ int remaining = count;
+ int endIndex = d->visibleIndex;
+ it = d->visibleItems.begin();
+ while (it != d->visibleItems.end()) {
+ FxGridItem *item = *it;
+ if (remaining && item->index >= to && item->index < to + count) {
+ // place items in the target position, reusing any existing items
+ FxGridItem *movedItem = moved.take(item->index);
+ if (!movedItem)
+ movedItem = d->createItem(item->index);
+ it = d->visibleItems.insert(it, movedItem);
+ ++it;
+ --remaining;
+ } else {
+ if (item->index != -1) {
+ if (item->index >= to) {
+ // update everything after the moved items.
+ item->index += count;
+ }
+ endIndex = item->index;
+ }
+ ++it;
+ }
+ }
+
+ // If we have moved items to the end of the visible items
+ // then add any existing moved items that we have
+ while (FxGridItem *item = moved.take(endIndex+1)) {
+ d->visibleItems.append(item);
+ ++endIndex;
+ }
+
+ // update visibleIndex
+ for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
+ if ((*it)->index != -1) {
+ d->visibleIndex = (*it)->index;
+ break;
+ }
+ }
+
+ // Fix current index
+ if (d->currentIndex >= 0 && d->currentItem) {
+ int oldCurrent = d->currentIndex;
+ d->currentIndex = d->model->indexOf(d->currentItem->item, this);
+ if (oldCurrent != d->currentIndex) {
+ d->currentItem->index = d->currentIndex;
+ emit currentIndexChanged();
+ }
+ }
+
+ // Whatever moved items remain are no longer visible items.
+ while (moved.count()) {
+ int idx = moved.begin().key();
+ FxGridItem *item = moved.take(idx);
+ if (item->item == d->currentItem->item)
+ item->setPosition(d->colPosAt(idx), d->rowPosAt(idx));
+ d->releaseItem(item);
+ }
+
+ d->layout(removedBeforeVisible);
+}
+
+void QDeclarativeGridView::createdItem(int index, QDeclarativeItem *item)
+{
+ Q_D(QDeclarativeGridView);
+ item->setParentItem(this);
+ if (d->requestedIndex != index) {
+ item->setParentItem(this);
+ d->unrequestedItems.insert(item, index);
+ if (d->flow == QDeclarativeGridView::LeftToRight) {
+ item->setPos(QPointF(d->colPosAt(index), d->rowPosAt(index)));
+ } else {
+ item->setPos(QPointF(d->rowPosAt(index), d->colPosAt(index)));
+ }
+ }
+}
+
+void QDeclarativeGridView::destroyingItem(QDeclarativeItem *item)
+{
+ Q_D(QDeclarativeGridView);
+ d->unrequestedItems.remove(item);
+}
+
+
+void QDeclarativeGridView::refill()
+{
+ Q_D(QDeclarativeGridView);
+ d->refill(d->position(), d->position()+d->size()-1);
+}
+
+
+QDeclarativeGridViewAttached *QDeclarativeGridView::qmlAttachedProperties(QObject *obj)
+{
+ return QDeclarativeGridViewAttached::properties(obj);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
new file mode 100644
index 0000000..b36c4aa
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -0,0 +1,222 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEGRIDVIEW_H
+#define QDECLARATIVEGRIDVIEW_H
+
+#include "qdeclarativeflickable_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+class QDeclarativeVisualModel;
+class QDeclarativeGridViewAttached;
+class QDeclarativeGridViewPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeGridView : public QDeclarativeFlickable
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeGridView)
+
+ Q_PROPERTY(QVariant model READ model WRITE setModel)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
+ Q_PROPERTY(QDeclarativeItem *currentItem READ currentItem NOTIFY currentIndexChanged)
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+
+ Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight)
+ Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightChanged)
+ Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
+
+ Q_PROPERTY(Flow flow READ flow WRITE setFlow)
+ Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
+ Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
+ Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged)
+ Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged)
+ Q_CLASSINFO("DefaultProperty", "data")
+
+public:
+ QDeclarativeGridView(QDeclarativeItem *parent=0);
+ ~QDeclarativeGridView();
+
+ QVariant model() const;
+ void setModel(const QVariant &);
+
+ QDeclarativeComponent *delegate() const;
+ void setDelegate(QDeclarativeComponent *);
+
+ int currentIndex() const;
+ void setCurrentIndex(int idx);
+
+ QDeclarativeItem *currentItem();
+ QDeclarativeItem *highlightItem();
+ int count() const;
+
+ QDeclarativeComponent *highlight() const;
+ void setHighlight(QDeclarativeComponent *highlight);
+
+ bool highlightFollowsCurrentItem() const;
+ void setHighlightFollowsCurrentItem(bool);
+
+ Q_ENUMS(Flow)
+ enum Flow { LeftToRight, TopToBottom };
+ Flow flow() const;
+ void setFlow(Flow);
+
+ bool isWrapEnabled() const;
+ void setWrapEnabled(bool);
+
+ int cacheBuffer() const;
+ void setCacheBuffer(int);
+
+ int cellWidth() const;
+ void setCellWidth(int);
+
+ int cellHeight() const;
+ void setCellHeight(int);
+
+ static QDeclarativeGridViewAttached *qmlAttachedProperties(QObject *);
+
+public Q_SLOTS:
+ void moveCurrentIndexUp();
+ void moveCurrentIndexDown();
+ void moveCurrentIndexLeft();
+ void moveCurrentIndexRight();
+ void positionViewAtIndex(int index);
+
+Q_SIGNALS:
+ void countChanged();
+ void currentIndexChanged();
+ void cellWidthChanged();
+ void cellHeightChanged();
+ void highlightChanged();
+
+protected:
+ virtual void viewportMoved();
+ virtual qreal minYExtent() const;
+ virtual qreal maxYExtent() const;
+ virtual qreal minXExtent() const;
+ virtual qreal maxXExtent() const;
+ virtual void keyPressEvent(QKeyEvent *);
+ virtual void componentComplete();
+
+private Q_SLOTS:
+ void trackedPositionChanged();
+ void itemsInserted(int index, int count);
+ void itemsRemoved(int index, int count);
+ void itemsMoved(int from, int to, int count);
+ void destroyRemoved();
+ void createdItem(int index, QDeclarativeItem *item);
+ void destroyingItem(QDeclarativeItem *item);
+ void sizeChange();
+ void layout();
+
+private:
+ void refill();
+};
+
+class QDeclarativeGridViewAttached : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeGridViewAttached(QObject *parent)
+ : QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
+ ~QDeclarativeGridViewAttached() {
+ attachedProperties.remove(parent());
+ }
+
+ Q_PROPERTY(QDeclarativeGridView *view READ view CONSTANT)
+ QDeclarativeGridView *view() { return m_view; }
+
+ Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
+ bool isCurrentItem() const { return m_isCurrent; }
+ void setIsCurrentItem(bool c) {
+ if (m_isCurrent != c) {
+ m_isCurrent = c;
+ emit currentItemChanged();
+ }
+ }
+
+ Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
+ bool delayRemove() const { return m_delayRemove; }
+ void setDelayRemove(bool delay) {
+ if (m_delayRemove != delay) {
+ m_delayRemove = delay;
+ emit delayRemoveChanged();
+ }
+ }
+
+ static QDeclarativeGridViewAttached *properties(QObject *obj) {
+ QDeclarativeGridViewAttached *rv = attachedProperties.value(obj);
+ if (!rv) {
+ rv = new QDeclarativeGridViewAttached(obj);
+ attachedProperties.insert(obj, rv);
+ }
+ return rv;
+ }
+
+ void emitAdd() { emit add(); }
+ void emitRemove() { emit remove(); }
+
+Q_SIGNALS:
+ void currentItemChanged();
+ void delayRemoveChanged();
+ void add();
+ void remove();
+
+public:
+ QDeclarativeGridView *m_view;
+ bool m_isCurrent;
+ bool m_delayRemove;
+
+ static QHash<QObject*, QDeclarativeGridViewAttached*> attachedProperties;
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeGridView)
+QML_DECLARE_TYPEINFO(QDeclarativeGridView, QML_HAS_ATTACHED_PROPERTIES)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
new file mode 100644
index 0000000..33b38e0
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -0,0 +1,368 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeimage_p.h"
+#include "qdeclarativeimage_p_p.h"
+
+#include <QKeyEvent>
+#include <QPainter>
+
+QT_BEGIN_NAMESPACE
+
+
+/*!
+ \qmlclass Image QDeclarativeImage
+ \since 4.7
+ \brief The Image element allows you to add bitmaps to a scene.
+ \inherits Item
+
+ The Image element supports untransformed, stretched and tiled.
+
+ For an explanation of stretching and tiling, see the fillMode property description.
+
+ Examples:
+ \table
+ \row
+ \o \image declarative-qtlogo1.png
+ \o Untransformed
+ \qml
+ Image { source: "pics/qtlogo.png" }
+ \endqml
+ \row
+ \o \image declarative-qtlogo2.png
+ \o fillMode: Stretch (default)
+ \qml
+ Image {
+ width: 160
+ height: 160
+ source: "pics/qtlogo.png"
+ }
+ \endqml
+ \row
+ \o \image declarative-qtlogo3.png
+ \o fillMode: Tile
+ \qml
+ Image {
+ fillMode: Image.Tile
+ width: 160; height: 160
+ source: "pics/qtlogo.png"
+ }
+ \endqml
+ \row
+ \o \image declarative-qtlogo6.png
+ \o fillMode: TileVertically
+ \qml
+ Image {
+ fillMode: Image.TileVertically
+ width: 160; height: 160
+ source: "pics/qtlogo.png"
+ }
+ \endqml
+ \row
+ \o \image declarative-qtlogo5.png
+ \o fillMode: TileHorizontally
+ \qml
+ Image {
+ fillMode: Image.TileHorizontally
+ width: 160; height: 160
+ source: "pics/qtlogo.png"
+ }
+ \endqml
+ \endtable
+ */
+
+/*!
+ \internal
+ \class QDeclarativeImage Image
+ \brief The QDeclarativeImage class provides an image item that you can add to a QDeclarativeView.
+
+ \ingroup group_coreitems
+
+ Example:
+ \qml
+ Image { source: "pics/star.png" }
+ \endqml
+
+ A QDeclarativeImage object can be instantiated in Qml using the tag \l Image.
+*/
+
+QDeclarativeImage::QDeclarativeImage(QDeclarativeItem *parent)
+ : QDeclarativeImageBase(*(new QDeclarativeImagePrivate), parent)
+{
+ connect(this, SIGNAL(sourceChanged(QUrl)), this, SLOT(updatePaintedGeometry()));
+}
+
+QDeclarativeImage::QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent)
+ : QDeclarativeImageBase(dd, parent)
+{
+}
+
+QDeclarativeImage::~QDeclarativeImage()
+{
+}
+
+void QDeclarativeImage::setSource(const QUrl &url)
+{
+ QDeclarativeImageBase::setSource(url);
+ updatePaintedGeometry();
+}
+
+/*!
+ \qmlproperty QPixmap Image::pixmap
+
+ This property holds the QPixmap image to display.
+
+ This is useful for displaying images provided by a C++ implementation,
+ for example, a model may provide a data role of type QPixmap.
+*/
+
+QPixmap QDeclarativeImage::pixmap() const
+{
+ Q_D(const QDeclarativeImage);
+ return d->pix;
+}
+
+void QDeclarativeImage::setPixmap(const QPixmap &pix)
+{
+ Q_D(QDeclarativeImage);
+ if (!d->url.isEmpty())
+ return;
+ d->setPixmap(pix);
+}
+
+void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
+{
+ Q_Q(QDeclarativeImage);
+ pix = pixmap;
+
+ q->setImplicitWidth(pix.width());
+ q->setImplicitHeight(pix.height());
+ status = pix.isNull() ? QDeclarativeImageBase::Null : QDeclarativeImageBase::Ready;
+
+ q->update();
+ emit q->pixmapChanged();
+}
+
+/*!
+ \qmlproperty enumeration Image::fillMode
+
+ Set this property to define what happens when the image set for the item is smaller
+ than the size of the item.
+
+ \list
+ \o Stretch - the image is scaled to fit
+ \o PreserveAspectFit - the image is scaled uniformly to fit without cropping
+ \o PreserveAspectCrop - the image is scaled uniformly to fill, cropping if necessary
+ \o Tile - the image is duplicated horizontally and vertically
+ \o TileVertically - the image is stretched horizontally and tiled vertically
+ \o TileHorizontally - the image is stretched vertically and tiled horizontally
+ \endlist
+
+ \image declarative-image_fillMode.gif
+*/
+QDeclarativeImage::FillMode QDeclarativeImage::fillMode() const
+{
+ Q_D(const QDeclarativeImage);
+ return d->fillMode;
+}
+
+void QDeclarativeImage::setFillMode(FillMode mode)
+{
+ Q_D(QDeclarativeImage);
+ if (d->fillMode == mode)
+ return;
+ d->fillMode = mode;
+ update();
+ updatePaintedGeometry();
+ emit fillModeChanged();
+}
+
+qreal QDeclarativeImage::paintedWidth() const
+{
+ Q_D(const QDeclarativeImage);
+ return d->paintedWidth;
+}
+
+qreal QDeclarativeImage::paintedHeight() const
+{
+ Q_D(const QDeclarativeImage);
+ return d->paintedHeight;
+}
+
+/*!
+ \qmlproperty enum Image::status
+
+ This property holds the status of image loading. It can be one of:
+ \list
+ \o Null - no image has been set
+ \o Ready - the image has been loaded
+ \o Loading - the image is currently being loaded
+ \o Error - an error occurred while loading the image
+ \endlist
+
+ \sa progress
+*/
+
+/*!
+ \qmlproperty real Image::progress
+
+ This property holds the progress of image loading, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+
+ \sa status
+*/
+
+/*!
+ \qmlproperty bool Image::smooth
+
+ Set this property if you want the image to be smoothly filtered when scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the image is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the image is stationary on
+ the screen. A common pattern when animating an image is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+*/
+
+void QDeclarativeImage::updatePaintedGeometry()
+{
+ Q_D(QDeclarativeImage);
+
+ if (d->fillMode == PreserveAspectFit) {
+ qreal widthScale = width() / qreal(d->pix.width());
+ qreal heightScale = height() / qreal(d->pix.height());
+ if (!d->pix.width() || !d->pix.height())
+ return;
+ if (widthScale <= heightScale) {
+ d->paintedWidth = width();
+ d->paintedHeight = widthScale * qreal(d->pix.height());
+ } else if(heightScale < widthScale) {
+ d->paintedWidth = heightScale * qreal(d->pix.width());
+ d->paintedHeight = height();
+ }
+ } else {
+ d->paintedWidth = width();
+ d->paintedHeight = height();
+ }
+ emit paintedGeometryChanged();
+}
+
+void QDeclarativeImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ QDeclarativeImageBase::geometryChanged(newGeometry, oldGeometry);
+ updatePaintedGeometry();
+}
+
+/*!
+ \qmlproperty url Image::source
+
+ Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.
+
+ The URL may be absolute, or relative to the URL of the component.
+*/
+
+void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ Q_D(QDeclarativeImage);
+ if (d->pix.isNull())
+ return;
+
+ bool oldAA = p->testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
+ if (d->smooth)
+ p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+
+ if (width() != d->pix.width() || height() != d->pix.height()) {
+ if (d->fillMode >= Tile) {
+ if (d->fillMode == Tile)
+ p->drawTiledPixmap(QRectF(0,0,width(),height()), d->pix);
+ else if (d->fillMode == TileVertically)
+ p->drawTiledPixmap(QRectF(0,0,d->pix.width(),height()), d->pix);
+ else
+ p->drawTiledPixmap(QRectF(0,0,width(),d->pix.height()), d->pix);
+ } else {
+ qreal widthScale = width() / qreal(d->pix.width());
+ qreal heightScale = height() / qreal(d->pix.height());
+
+ QTransform scale;
+
+ if (d->fillMode == PreserveAspectFit) {
+ if (widthScale <= heightScale) {
+ heightScale = widthScale;
+ scale.translate(0, (height() - heightScale * d->pix.height()) / 2);
+ } else if(heightScale < widthScale) {
+ widthScale = heightScale;
+ scale.translate((width() - widthScale * d->pix.width()) / 2, 0);
+ }
+ } else if (d->fillMode == PreserveAspectCrop) {
+ if (widthScale < heightScale) {
+ widthScale = heightScale;
+ scale.translate((width() - widthScale * d->pix.width()) / 2, 0);
+ } else if(heightScale < widthScale) {
+ heightScale = widthScale;
+ scale.translate(0, (height() - heightScale * d->pix.height()) / 2);
+ }
+ }
+ if (clip()) {
+ p->save();
+ p->setClipRect(boundingRect(), Qt::IntersectClip);
+ }
+ scale.scale(widthScale, heightScale);
+ QTransform old = p->transform();
+ p->setWorldTransform(scale * old);
+ p->drawPixmap(0, 0, d->pix);
+ p->setWorldTransform(old);
+ if (clip()) {
+ p->restore();
+ }
+ }
+ } else {
+ p->drawPixmap(0, 0, d->pix);
+ }
+
+ if (d->smooth) {
+ p->setRenderHint(QPainter::Antialiasing, oldAA);
+ p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p.h b/src/declarative/graphicsitems/qdeclarativeimage_p.h
new file mode 100644
index 0000000..5b365e7
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimage_p.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEIMAGE_H
+#define QDECLARATIVEIMAGE_H
+
+#include "qdeclarativeimagebase_p.h"
+
+#include <QtNetwork/qnetworkreply.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeImagePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeImage : public QDeclarativeImageBase
+{
+ Q_OBJECT
+ Q_ENUMS(FillMode)
+
+ Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap NOTIFY pixmapChanged DESIGNABLE false)
+ Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
+ Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedGeometryChanged)
+ Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedGeometryChanged)
+
+public:
+ QDeclarativeImage(QDeclarativeItem *parent=0);
+ ~QDeclarativeImage();
+
+ enum FillMode { Stretch, PreserveAspectFit, PreserveAspectCrop, Tile, TileVertically, TileHorizontally };
+ FillMode fillMode() const;
+ void setFillMode(FillMode);
+
+ QPixmap pixmap() const;
+ void setPixmap(const QPixmap &);
+
+ qreal paintedWidth() const;
+ qreal paintedHeight() const;
+
+ void setSource(const QUrl &url);
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+Q_SIGNALS:
+ void fillModeChanged();
+ void paintedGeometryChanged();
+
+protected:
+ QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent);
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
+
+protected Q_SLOTS:
+ void updatePaintedGeometry();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeImage)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeImage)
+};
+
+QT_END_NAMESPACE
+QML_DECLARE_TYPE(QDeclarativeImage)
+QT_END_HEADER
+
+#endif // QDECLARATIVEIMAGE_H
diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p_p.h b/src/declarative/graphicsitems/qdeclarativeimage_p_p.h
new file mode 100644
index 0000000..8102237
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimage_p_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEIMAGE_P_H
+#define QDECLARATIVEIMAGE_P_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 "qdeclarativeitem_p.h"
+#include "qdeclarativeimagebase_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeImagePrivate : public QDeclarativeImageBasePrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeImage)
+
+public:
+ QDeclarativeImagePrivate()
+ : fillMode(QDeclarativeImage::Stretch), paintedWidth(0), paintedHeight(0)
+ {
+ }
+
+ QDeclarativeImage::FillMode fillMode;
+ qreal paintedWidth;
+ qreal paintedHeight;
+ void setPixmap(const QPixmap &pix);
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEIMAGE_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
new file mode 100644
index 0000000..18053d3
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeimagebase_p.h"
+#include "qdeclarativeimagebase_p_p.h"
+
+#include <qdeclarativeengine.h>
+#include <qdeclarativepixmapcache_p.h>
+
+#include <QFile>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeImageBase::QDeclarativeImageBase(QDeclarativeImageBasePrivate &dd, QDeclarativeItem *parent)
+ : QDeclarativeItem(dd, parent)
+{
+ setFlag(QGraphicsItem::ItemHasNoContents, false);
+}
+
+QDeclarativeImageBase::~QDeclarativeImageBase()
+{
+ Q_D(QDeclarativeImageBase);
+ if (d->pendingPixmapCache)
+ QDeclarativePixmapCache::cancel(d->url, this);
+}
+
+QDeclarativeImageBase::Status QDeclarativeImageBase::status() const
+{
+ Q_D(const QDeclarativeImageBase);
+ return d->status;
+}
+
+
+qreal QDeclarativeImageBase::progress() const
+{
+ Q_D(const QDeclarativeImageBase);
+ return d->progress;
+}
+
+QUrl QDeclarativeImageBase::source() const
+{
+ Q_D(const QDeclarativeImageBase);
+ return d->url;
+}
+
+void QDeclarativeImageBase::setSource(const QUrl &url)
+{
+ Q_D(QDeclarativeImageBase);
+ //equality is fairly expensive, so we bypass for simple, common case
+ if ((d->url.isEmpty() == url.isEmpty()) && url == d->url)
+ return;
+
+ if (d->pendingPixmapCache) {
+ QDeclarativePixmapCache::cancel(d->url, this);
+ d->pendingPixmapCache = false;
+ }
+
+ d->url = url;
+ if (d->progress != 0.0) {
+ d->progress = 0.0;
+ emit progressChanged(d->progress);
+ }
+
+ if (url.isEmpty()) {
+ d->pix = QPixmap();
+ d->status = Null;
+ setImplicitWidth(0);
+ setImplicitHeight(0);
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit pixmapChanged();
+ update();
+ } else {
+ d->status = Loading;
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix);
+ if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) {
+ QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url);
+ d->pendingPixmapCache = true;
+
+ static int replyDownloadProgress = -1;
+ static int replyFinished = -1;
+ static int thisRequestProgress = -1;
+ static int thisRequestFinished = -1;
+ if (replyDownloadProgress == -1) {
+ replyDownloadProgress =
+ QDeclarativePixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
+ replyFinished =
+ QDeclarativePixmapReply::staticMetaObject.indexOfSignal("finished()");
+ thisRequestProgress =
+ QDeclarativeImageBase::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)");
+ thisRequestFinished =
+ QDeclarativeImageBase::staticMetaObject.indexOfSlot("requestFinished()");
+ }
+
+ QMetaObject::connect(reply, replyFinished, this,
+ thisRequestFinished, Qt::DirectConnection);
+ QMetaObject::connect(reply, replyDownloadProgress, this,
+ thisRequestProgress, Qt::DirectConnection);
+ } else {
+ //### should be unified with requestFinished
+ if (status == QDeclarativePixmapReply::Ready) {
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->status == Loading)
+ d->status = Ready;
+ } else {
+ d->status = Error;
+ }
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(d->progress);
+ emit pixmapChanged();
+ update();
+ }
+ }
+
+ emit statusChanged(d->status);
+}
+
+void QDeclarativeImageBase::requestFinished()
+{
+ Q_D(QDeclarativeImageBase);
+
+ d->pendingPixmapCache = false;
+
+ if (QDeclarativePixmapCache::get(d->url, &d->pix) != QDeclarativePixmapReply::Ready)
+ d->status = Error;
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->status == Loading)
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(1.0);
+ emit pixmapChanged();
+ update();
+}
+
+void QDeclarativeImageBase::requestProgress(qint64 received, qint64 total)
+{
+ Q_D(QDeclarativeImageBase);
+ if (d->status == Loading && total > 0) {
+ d->progress = qreal(received)/total;
+ emit progressChanged(d->progress);
+ }
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
new file mode 100644
index 0000000..47be139
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEIMAGEBASE_H
+#define QDECLARATIVEIMAGEBASE_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeImageBasePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeImageBase : public QDeclarativeItem
+{
+ Q_OBJECT
+ Q_ENUMS(Status)
+
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+
+public:
+ ~QDeclarativeImageBase();
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+ qreal progress() const;
+
+ QUrl source() const;
+ virtual void setSource(const QUrl &url);
+
+Q_SIGNALS:
+ void sourceChanged(const QUrl &);
+ void statusChanged(Status);
+ void progressChanged(qreal progress);
+ void pixmapChanged();
+
+protected:
+ QDeclarativeImageBase(QDeclarativeImageBasePrivate &dd, QDeclarativeItem *parent);
+
+private Q_SLOTS:
+ virtual void requestFinished();
+ void requestProgress(qint64,qint64);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeImageBase)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeImageBase)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEIMAGEBASE_H
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
new file mode 100644
index 0000000..d540e40
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEIMAGEBASE_P_H
+#define QDECLARATIVEIMAGEBASE_P_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 "qdeclarativeitem_p.h"
+
+#include <QtCore/QPointer>
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkReply;
+class QDeclarativeImageBasePrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeImageBase)
+
+public:
+ QDeclarativeImageBasePrivate()
+ : status(QDeclarativeImageBase::Null),
+ progress(0.0),
+ pendingPixmapCache(false)
+ {
+ }
+
+ QPixmap pix;
+ QDeclarativeImageBase::Status status;
+ QUrl url;
+ qreal progress;
+ bool pendingPixmapCache;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
new file mode 100644
index 0000000..5dd44fa
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -0,0 +1,2838 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeitem_p.h"
+#include "qdeclarativeitem.h"
+
+#include "qdeclarativeevents_p_p.h"
+
+#include <qfxperf_p_p.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativeopenmetaobject_p.h>
+#include <qdeclarativestate_p.h>
+#include <qdeclarativeview.h>
+#include <qdeclarativestategroup_p.h>
+#include <qdeclarativecomponent.h>
+
+#include <QDebug>
+#include <QPen>
+#include <QFile>
+#include <QEvent>
+#include <QGraphicsSceneMouseEvent>
+#include <QtCore/qnumeric.h>
+#include <QtScript/qscriptengine.h>
+#include <QtGui/qgraphicstransform.h>
+#include <QtGui/qgraphicseffect.h>
+#include <qlistmodelinterface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef FLT_MAX
+#define FLT_MAX 1E+37
+#endif
+
+#include "qdeclarativeeffects.cpp"
+
+/*!
+ \qmlclass Transform QGraphicsTransform
+ \since 4.7
+ \brief The Transform elements provide a way of building advanced transformations on Items.
+
+ The Transform elements let you create and control advanced transformations that can be configured
+ independently using specialized properties.
+
+ You can assign any number of Transform elements to an Item. Each Transform is applied in order,
+ one at a time, to the Item it's assigned to.
+
+ \sa Rotation, Scale
+*/
+
+/*!
+ \qmlclass Scale QGraphicsScale
+ \since 4.7
+ \brief The Scale object provides a way to scale an Item.
+
+ The Scale object gives more control over scaling than using Item's scale property. Specifically,
+ it allows a different scale for the x and y axes, and allows the scale to be relative to an
+ arbitrary point.
+
+ The following example scales the X axis of the Rectangle, relative to its interior point 25, 25:
+ \qml
+ Rectangle {
+ width: 100; height: 100
+ color: "blue"
+ transform: Scale { origin.x: 25; origin.y: 25; xScale: 3}
+ }
+ \endqml
+*/
+
+/*!
+ \qmlproperty real Scale::origin.x
+ \qmlproperty real Scale::origin.y
+
+ The point that the item is scaled from (i.e., the point that stays fixed relative to the parent as
+ the rest of the item grows). By default the origin is 0, 0.
+*/
+
+/*!
+ \qmlproperty real Scale::xScale
+
+ The scaling factor for the X axis.
+*/
+
+/*!
+ \qmlproperty real Scale::yScale
+
+ The scaling factor for the Y axis.
+*/
+
+/*!
+ \qmlclass Rotation QGraphicsRotation
+ \since 4.7
+ \brief The Rotation object provides a way to rotate an Item.
+
+ The Rotation object gives more control over rotation than using Item's rotation property.
+ Specifically, it allows (z axis) rotation to be relative to an arbitrary point.
+
+ The following example rotates a Rectangle around its interior point 25, 25:
+ \qml
+ Rectangle {
+ width: 100; height: 100
+ color: "blue"
+ transform: Rotation { origin.x: 25; origin.y: 25; angle: 45}
+ }
+ \endqml
+
+ Rotation also provides a way to specify 3D-like rotations for Items. For these types of
+ rotations you must specify the axis to rotate around in addition to the origin point.
+
+ The following example shows various 3D-like rotations applied to an \l Image.
+ \snippet doc/src/snippets/declarative/rotation.qml 0
+
+ \image axisrotation.png
+*/
+
+/*!
+ \qmlproperty real Rotation::origin.x
+ \qmlproperty real Rotation::origin.y
+
+ The origin point of the rotation (i.e., the point that stays fixed relative to the parent as
+ the rest of the item rotates). By default the origin is 0, 0.
+*/
+
+/*!
+ \qmlproperty real Rotation::axis.x
+ \qmlproperty real Rotation::axis.y
+ \qmlproperty real Rotation::axis.z
+
+ The axis to rotate around. For simple (2D) rotation around a point, you do not need to specify an axis,
+ as the default axis is the z axis (\c{ axis { x: 0; y: 0; z: 1 } }).
+
+ For a typical 3D-like rotation you will usually specify both the origin and the axis.
+
+ \image 3d-rotation-axis.png
+*/
+
+/*!
+ \qmlproperty real Rotation::angle
+
+ The angle to rotate, in degrees clockwise.
+*/
+
+
+/*!
+ \group group_animation
+ \title Animation
+*/
+
+/*!
+ \group group_coreitems
+ \title Basic Items
+*/
+
+/*!
+ \group group_effects
+ \title Effects
+*/
+
+/*!
+ \group group_layouts
+ \title Layouts
+*/
+
+/*!
+ \group group_states
+ \title States and Transitions
+*/
+
+/*!
+ \group group_utility
+ \title Utility
+*/
+
+/*!
+ \group group_views
+ \title Views
+*/
+
+/*!
+ \group group_widgets
+ \title Widgets
+*/
+
+/*!
+ \internal
+ \class QDeclarativeContents
+ \ingroup group_utility
+ \brief The QDeclarativeContents class gives access to the height and width of an item's contents.
+
+*/
+
+QDeclarativeContents::QDeclarativeContents() : m_x(0), m_y(0), m_width(0), m_height(0)
+{
+}
+
+/*!
+ \qmlproperty real Item::childrenRect.x
+ \qmlproperty real Item::childrenRect.y
+ \qmlproperty real Item::childrenRect.width
+ \qmlproperty real Item::childrenRect.height
+
+ The childrenRect properties allow an item access to the geometry of its
+ children. This property is useful if you have an item that needs to be
+ sized to fit its children.
+*/
+
+QRectF QDeclarativeContents::rectF() const
+{
+ return QRectF(m_x, m_y, m_width, m_height);
+}
+
+//TODO: optimization: only check sender(), if there is one
+void QDeclarativeContents::calcHeight()
+{
+ qreal oldy = m_y;
+ qreal oldheight = m_height;
+
+ qreal top = FLT_MAX;
+ qreal bottom = 0;
+
+ QList<QGraphicsItem *> children = m_item->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
+ if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
+ continue;
+ qreal y = child->y();
+ if (y + child->height() > bottom)
+ bottom = y + child->height();
+ if (y < top)
+ top = y;
+ }
+ if (!children.isEmpty())
+ m_y = top;
+ m_height = qMax(bottom - top, qreal(0.0));
+
+ if (m_height != oldheight || m_y != oldy)
+ emit rectChanged();
+}
+
+//TODO: optimization: only check sender(), if there is one
+void QDeclarativeContents::calcWidth()
+{
+ qreal oldx = m_x;
+ qreal oldwidth = m_width;
+
+ qreal left = FLT_MAX;
+ qreal right = 0;
+
+ QList<QGraphicsItem *> children = m_item->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
+ if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
+ continue;
+ qreal x = child->x();
+ if (x + child->width() > right)
+ right = x + child->width();
+ if (x < left)
+ left = x;
+ }
+ if (!children.isEmpty())
+ m_x = left;
+ m_width = qMax(right - left, qreal(0.0));
+
+ if (m_width != oldwidth || m_x != oldx)
+ emit rectChanged();
+}
+
+void QDeclarativeContents::setItem(QDeclarativeItem *item)
+{
+ m_item = item;
+
+ QList<QGraphicsItem *> children = m_item->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
+ if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
+ continue;
+ connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight()));
+ connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight()));
+ connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth()));
+ connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth()));
+ connect(this, SIGNAL(rectChanged()), m_item, SIGNAL(childrenRectChanged()));
+ }
+
+ calcHeight();
+ calcWidth();
+}
+
+QDeclarativeItemKeyFilter::QDeclarativeItemKeyFilter(QDeclarativeItem *item)
+: m_next(0)
+{
+ QDeclarativeItemPrivate *p =
+ item?static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(item)):0;
+ if (p) {
+ m_next = p->keyHandler;
+ p->keyHandler = this;
+ }
+}
+
+QDeclarativeItemKeyFilter::~QDeclarativeItemKeyFilter()
+{
+}
+
+void QDeclarativeItemKeyFilter::keyPressed(QKeyEvent *event)
+{
+ if (m_next) m_next->keyPressed(event);
+}
+
+void QDeclarativeItemKeyFilter::keyReleased(QKeyEvent *event)
+{
+ if (m_next) m_next->keyReleased(event);
+}
+
+void QDeclarativeItemKeyFilter::inputMethodEvent(QInputMethodEvent *event)
+{
+ if (m_next) m_next->inputMethodEvent(event);
+}
+
+QVariant QDeclarativeItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ if (m_next) return m_next->inputMethodQuery(query);
+ return QVariant();
+}
+
+void QDeclarativeItemKeyFilter::componentComplete()
+{
+ if (m_next) m_next->componentComplete();
+}
+
+
+/*!
+ \qmlclass KeyNavigation
+ \since 4.7
+ \brief The KeyNavigation attached property supports key navigation by arrow keys.
+
+ It is common in key-based UIs to use arrow keys to navigate
+ between focussed items. The KeyNavigation property provides a
+ convenient way of specifying which item will gain focus
+ when an arrow key is pressed. The following example provides
+ key navigation for a 2x2 grid of items.
+
+ \code
+ Grid {
+ columns: 2
+ width: 100; height: 100
+ Rectangle {
+ id: item1
+ focus: true
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.right: item2
+ KeyNavigation.down: item3
+ }
+ Rectangle {
+ id: item2
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.left: item1
+ KeyNavigation.down: item4
+ }
+ Rectangle {
+ id: item3
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.right: item4
+ KeyNavigation.up: item1
+ }
+ Rectangle {
+ id: item4
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.left: item3
+ KeyNavigation.up: item2
+ }
+ }
+ \endcode
+
+ KeyNavigation receives key events after the item it is attached to.
+ If the item accepts an arrow key event, the KeyNavigation
+ attached property will not receive an event for that key.
+
+ If an item has been set for a direction and the KeyNavigation
+ attached property receives the corresponding
+ key press and release events, the events will be accepted by
+ KeyNaviagtion and will not propagate any further.
+
+ \sa {Keys}{Keys attached property}
+*/
+
+/*!
+ \qmlproperty Item KeyNavigation::left
+ \qmlproperty Item KeyNavigation::right
+ \qmlproperty Item KeyNavigation::up
+ \qmlproperty Item KeyNavigation::down
+
+ These properties hold the item to assign focus to
+ when Key_Left, Key_Right, Key_Up or Key_Down are
+ pressed.
+*/
+
+QDeclarativeKeyNavigationAttached::QDeclarativeKeyNavigationAttached(QObject *parent)
+: QObject(*(new QDeclarativeKeyNavigationAttachedPrivate), parent),
+ QDeclarativeItemKeyFilter(qobject_cast<QDeclarativeItem*>(parent))
+{
+}
+
+QDeclarativeKeyNavigationAttached *
+QDeclarativeKeyNavigationAttached::qmlAttachedProperties(QObject *obj)
+{
+ return new QDeclarativeKeyNavigationAttached(obj);
+}
+
+QDeclarativeItem *QDeclarativeKeyNavigationAttached::left() const
+{
+ Q_D(const QDeclarativeKeyNavigationAttached);
+ return d->left;
+}
+
+void QDeclarativeKeyNavigationAttached::setLeft(QDeclarativeItem *i)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
+ d->left = i;
+ emit changed();
+}
+
+QDeclarativeItem *QDeclarativeKeyNavigationAttached::right() const
+{
+ Q_D(const QDeclarativeKeyNavigationAttached);
+ return d->right;
+}
+
+void QDeclarativeKeyNavigationAttached::setRight(QDeclarativeItem *i)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
+ d->right = i;
+ emit changed();
+}
+
+QDeclarativeItem *QDeclarativeKeyNavigationAttached::up() const
+{
+ Q_D(const QDeclarativeKeyNavigationAttached);
+ return d->up;
+}
+
+void QDeclarativeKeyNavigationAttached::setUp(QDeclarativeItem *i)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
+ d->up = i;
+ emit changed();
+}
+
+QDeclarativeItem *QDeclarativeKeyNavigationAttached::down() const
+{
+ Q_D(const QDeclarativeKeyNavigationAttached);
+ return d->down;
+}
+
+void QDeclarativeKeyNavigationAttached::setDown(QDeclarativeItem *i)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
+ d->down = i;
+ emit changed();
+}
+
+void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
+
+ event->ignore();
+
+ switch(event->key()) {
+ case Qt::Key_Left:
+ if (d->left) {
+ d->left->setFocus(true);
+ event->accept();
+ }
+ break;
+ case Qt::Key_Right:
+ if (d->right) {
+ d->right->setFocus(true);
+ event->accept();
+ }
+ break;
+ case Qt::Key_Up:
+ if (d->up) {
+ d->up->setFocus(true);
+ event->accept();
+ }
+ break;
+ case Qt::Key_Down:
+ if (d->down) {
+ d->down->setFocus(true);
+ event->accept();
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event);
+}
+
+void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
+
+ event->ignore();
+
+ switch(event->key()) {
+ case Qt::Key_Left:
+ if (d->left) {
+ event->accept();
+ }
+ break;
+ case Qt::Key_Right:
+ if (d->right) {
+ event->accept();
+ }
+ break;
+ case Qt::Key_Up:
+ if (d->up) {
+ event->accept();
+ }
+ break;
+ case Qt::Key_Down:
+ if (d->down) {
+ event->accept();
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event);
+}
+
+/*!
+ \qmlclass Keys
+ \since 4.7
+ \brief The Keys attached property provides key handling to Items.
+
+ All visual primitives support key handling via the \e Keys
+ attached property. Keys can be handled via the \e onPressed
+ and \e onReleased signal properties.
+
+ The signal properties have a \l KeyEvent parameter, named
+ \e event which contains details of the event. If a key is
+ handled \e event.accepted should be set to true to prevent the
+ event from propagating up the item heirarchy.
+
+ \code
+ Item {
+ focus: true
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Left) {
+ console.log("move left");
+ event.accepted = true;
+ }
+ }
+ }
+ \endcode
+
+ Some keys may alternatively be handled via specific signal properties,
+ for example \e onSelectPressed. These handlers automatically set
+ \e event.accepted to true.
+
+ \code
+ Item {
+ focus: true
+ Keys.onLeftPressed: console.log("move left")
+ }
+ \endcode
+
+ See \l {Qt::Key}{Qt.Key} for the list of keyboard codes.
+
+ \sa KeyEvent, {KeyNavigation}{KeyNavigation attached property}
+*/
+
+/*!
+ \qmlproperty bool Keys::enabled
+
+ This flags enables key handling if true (default); otherwise
+ no key handlers will be called.
+*/
+
+/*!
+ \qmlproperty List<Object> Keys::forwardTo
+
+ This property provides a way to forward key presses, key releases, and keyboard input
+ coming from input methods to other items. This can be useful when you want
+ one item to handle some keys (e.g. the up and down arrow keys), and another item to
+ handle other keys (e.g. the left and right arrow keys). Once an item that has been
+ forwarded keys accepts the event it is no longer forwarded to items later in the
+ list.
+
+ This example forwards key events to two lists:
+ \qml
+ ListView { id: list1 ... }
+ ListView { id: list2 ... }
+ Keys.forwardTo: [list1, list2]
+ focus: true
+ \endqml
+*/
+
+/*!
+ \qmlsignal Keys::onPressed(event)
+
+ This handler is called when a key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onReleased(event)
+
+ This handler is called when a key has been released. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDigit0Pressed(event)
+
+ This handler is called when the digit '0' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDigit1Pressed(event)
+
+ This handler is called when the digit '1' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDigit2Pressed(event)
+
+ This handler is called when the digit '2' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDigit3Pressed(event)
+
+ This handler is called when the digit '3' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDigit4Pressed(event)
+
+ This handler is called when the digit '4' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDigit5Pressed(event)
+
+ This handler is called when the digit '5' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDigit6Pressed(event)
+
+ This handler is called when the digit '6' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDigit7Pressed(event)
+
+ This handler is called when the digit '7' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDigit8Pressed(event)
+
+ This handler is called when the digit '8' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDigit9Pressed(event)
+
+ This handler is called when the digit '9' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onLeftPressed(event)
+
+ This handler is called when the Left arrow has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onRightPressed(event)
+
+ This handler is called when the Right arrow has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onUpPressed(event)
+
+ This handler is called when the Up arrow has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDownPressed(event)
+
+ This handler is called when the Down arrow has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onAsteriskPressed(event)
+
+ This handler is called when the Asterisk '*' has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onEscapePressed(event)
+
+ This handler is called when the Escape key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onReturnPressed(event)
+
+ This handler is called when the Return key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onEnterPressed(event)
+
+ This handler is called when the Enter key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onDeletePressed(event)
+
+ This handler is called when the Delete key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onSpacePressed(event)
+
+ This handler is called when the Space key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onBackPressed(event)
+
+ This handler is called when the Back key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onCancelPressed(event)
+
+ This handler is called when the Cancel key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onSelectPressed(event)
+
+ This handler is called when the Select key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onYesPressed(event)
+
+ This handler is called when the Yes key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onNoPressed(event)
+
+ This handler is called when the No key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onContext1Pressed(event)
+
+ This handler is called when the Context1 key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onContext2Pressed(event)
+
+ This handler is called when the Context2 key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onContext3Pressed(event)
+
+ This handler is called when the Context3 key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onContext4Pressed(event)
+
+ This handler is called when the Context4 key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onCallPressed(event)
+
+ This handler is called when the Call key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onHangupPressed(event)
+
+ This handler is called when the Hangup key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onFlipPressed(event)
+
+ This handler is called when the Flip key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onMenuPressed(event)
+
+ This handler is called when the Menu key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onVolumeUpPressed(event)
+
+ This handler is called when the VolumeUp key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+/*!
+ \qmlsignal Keys::onVolumeDownPressed(event)
+
+ This handler is called when the VolumeDown key has been pressed. The \a event
+ parameter provides information about the event.
+*/
+
+const QDeclarativeKeysAttached::SigMap QDeclarativeKeysAttached::sigMap[] = {
+ { Qt::Key_Left, "leftPressed" },
+ { Qt::Key_Right, "rightPressed" },
+ { Qt::Key_Up, "upPressed" },
+ { Qt::Key_Down, "downPressed" },
+ { Qt::Key_Asterisk, "asteriskPressed" },
+ { Qt::Key_NumberSign, "numberSignPressed" },
+ { Qt::Key_Escape, "escapePressed" },
+ { Qt::Key_Return, "returnPressed" },
+ { Qt::Key_Enter, "enterPressed" },
+ { Qt::Key_Delete, "deletePressed" },
+ { Qt::Key_Space, "spacePressed" },
+ { Qt::Key_Back, "backPressed" },
+ { Qt::Key_Cancel, "cancelPressed" },
+ { Qt::Key_Select, "selectPressed" },
+ { Qt::Key_Yes, "yesPressed" },
+ { Qt::Key_No, "noPressed" },
+ { Qt::Key_Context1, "context1Pressed" },
+ { Qt::Key_Context2, "context2Pressed" },
+ { Qt::Key_Context3, "context3Pressed" },
+ { Qt::Key_Context4, "context4Pressed" },
+ { Qt::Key_Call, "callPressed" },
+ { Qt::Key_Hangup, "hangupPressed" },
+ { Qt::Key_Flip, "flipPressed" },
+ { Qt::Key_Menu, "menuPressed" },
+ { Qt::Key_VolumeUp, "volumeUpPressed" },
+ { Qt::Key_VolumeDown, "volumeDownPressed" },
+ { 0, 0 }
+};
+
+bool QDeclarativeKeysAttachedPrivate::isConnected(const char *signalName)
+{
+ return isSignalConnected(signalIndex(signalName));
+}
+
+QDeclarativeKeysAttached::QDeclarativeKeysAttached(QObject *parent)
+: QObject(*(new QDeclarativeKeysAttachedPrivate), parent),
+ QDeclarativeItemKeyFilter(qobject_cast<QDeclarativeItem*>(parent))
+{
+ Q_D(QDeclarativeKeysAttached);
+ d->item = qobject_cast<QDeclarativeItem*>(parent);
+}
+
+QDeclarativeKeysAttached::~QDeclarativeKeysAttached()
+{
+}
+
+void QDeclarativeKeysAttached::componentComplete()
+{
+ Q_D(QDeclarativeKeysAttached);
+ if (d->item) {
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QGraphicsItem *targetItem = d->finalFocusProxy(d->targets.at(ii));
+ if (targetItem && (targetItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) {
+ d->item->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
+ break;
+ }
+ }
+ }
+}
+
+void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event)
+{
+ Q_D(QDeclarativeKeysAttached);
+ if (!d->enabled || d->inPress) {
+ event->ignore();
+ return;
+ }
+
+ // first process forwards
+ if (d->item && d->item->scene()) {
+ d->inPress = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii));
+ if (i) {
+ d->item->scene()->sendEvent(i, event);
+ if (event->isAccepted()) {
+ d->inPress = false;
+ return;
+ }
+ }
+ }
+ d->inPress = false;
+ }
+
+ QDeclarativeKeyEvent ke(*event);
+ QByteArray keySignal = keyToSignal(event->key());
+ if (!keySignal.isEmpty()) {
+ keySignal += "(QDeclarativeKeyEvent*)";
+ if (d->isConnected(keySignal)) {
+ // If we specifically handle a key then default to accepted
+ ke.setAccepted(true);
+ int idx = QDeclarativeKeysAttached::staticMetaObject.indexOfSignal(keySignal);
+ metaObject()->method(idx).invoke(this, Qt::DirectConnection, Q_ARG(QDeclarativeKeyEvent*, &ke));
+ }
+ }
+ if (!ke.isAccepted())
+ emit pressed(&ke);
+ event->setAccepted(ke.isAccepted());
+
+ if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event);
+}
+
+void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event)
+{
+ Q_D(QDeclarativeKeysAttached);
+ if (!d->enabled || d->inRelease) {
+ event->ignore();
+ return;
+ }
+
+ if (d->item && d->item->scene()) {
+ d->inRelease = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii));
+ if (i) {
+ d->item->scene()->sendEvent(i, event);
+ if (event->isAccepted()) {
+ d->inRelease = false;
+ return;
+ }
+ }
+ }
+ d->inRelease = false;
+ }
+
+ QDeclarativeKeyEvent ke(*event);
+ emit released(&ke);
+ event->setAccepted(ke.isAccepted());
+
+ if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event);
+}
+
+void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event)
+{
+ Q_D(QDeclarativeKeysAttached);
+ if (d->item && !d->inIM && d->item->scene()) {
+ d->inIM = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii));
+ if (i && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod)) {
+ d->item->scene()->sendEvent(i, event);
+ if (event->isAccepted()) {
+ d->imeItem = i;
+ d->inIM = false;
+ return;
+ }
+ }
+ }
+ d->inIM = false;
+ }
+ if (!event->isAccepted()) QDeclarativeItemKeyFilter::inputMethodEvent(event);
+}
+
+class QDeclarativeItemAccessor : public QGraphicsItem
+{
+public:
+ QVariant doInputMethodQuery(Qt::InputMethodQuery query) const {
+ return QGraphicsItem::inputMethodQuery(query);
+ }
+};
+
+QVariant QDeclarativeKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ Q_D(const QDeclarativeKeysAttached);
+ if (d->item) {
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii));
+ if (i && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod) && i == d->imeItem) { //### how robust is i == d->imeItem check?
+ QVariant v = static_cast<QDeclarativeItemAccessor *>(i)->doInputMethodQuery(query);
+ if (v.userType() == QVariant::RectF)
+ v = d->item->mapRectFromItem(i, v.toRectF()); //### cost?
+ return v;
+ }
+ }
+ }
+ return QDeclarativeItemKeyFilter::inputMethodQuery(query);
+}
+
+QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObject *obj)
+{
+ return new QDeclarativeKeysAttached(obj);
+}
+
+/*!
+ \class QDeclarativeItem
+ \since 4.7
+ \brief The QDeclarativeItem class provides the most basic of all visual items in QML.
+
+ All visual items in Qt Declarative inherit from QDeclarativeItem. Although QDeclarativeItem
+ has no visual appearance, it defines all the properties that are
+ common across visual items - such as the x and y position, the
+ width and height, \l {anchor-layout}{anchoring} and key handling.
+
+ You can subclass QDeclarativeItem to provide your own custom visual item that inherits
+ these features.
+*/
+
+/*!
+ \qmlclass Item QDeclarativeItem
+ \since 4.7
+ \brief The Item is the most basic of all visual items in QML.
+
+ All visual items in Qt Declarative inherit from Item. Although Item
+ has no visual appearance, it defines all the properties that are
+ common across visual items - such as the x and y position, the
+ width and height, \l {anchor-layout}{anchoring} and key handling.
+
+ Item is also useful for grouping items together.
+
+ \qml
+ Item {
+ Image {
+ source: "tile.png"
+ }
+ Image {
+ x: 80
+ width: 100
+ height: 100
+ source: "tile.png"
+ }
+ Image {
+ x: 190
+ width: 100
+ height: 100
+ fillMode: Image.Tile
+ source: "tile.png"
+ }
+ }
+ \endqml
+
+ \section1 Identity
+
+ Each item has an "id" - the identifier of the Item.
+
+ The identifier can be used in bindings and other expressions to
+ refer to the item. For example:
+
+ \qml
+ Text { id: myText; ... }
+ Text { text: myText.text }
+ \endqml
+
+ The identifier is available throughout to the \l {components}{component}
+ where it is declared. The identifier must be unique in the component.
+
+ The id should not be thought of as a "property" - it makes no sense
+ to write \c myText.id, for example.
+
+ \section1 Key Handling
+
+ Key handling is available to all Item-based visual elements via the \l {Keys}{Keys}
+ attached property. The \e Keys attached property provides basic handlers such
+ as \l {Keys::onPressed}{onPressed} and \l {Keys::onReleased}{onReleased},
+ as well as handlers for specific keys, such as
+ \l {Keys::onCancelPressed}{onCancelPressed}. The example below
+ assigns \l {qmlfocus}{focus} to the item and handles
+ the Left key via the general \e onPressed handler and the Select key via the
+ onSelectPressed handler:
+
+ \qml
+ Item {
+ focus: true
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Left) {
+ console.log("move left");
+ event.accepted = true;
+ }
+ }
+ Keys.onSelectPressed: console.log("Selected");
+ }
+ \endqml
+
+ See the \l {Keys}{Keys} attached property for detailed documentation.
+
+ \ingroup group_coreitems
+*/
+
+/*!
+ \property QDeclarativeItem::baseline
+ \internal
+*/
+
+/*!
+ \property QDeclarativeItem::effect
+ \internal
+*/
+
+/*!
+ \property QDeclarativeItem::focus
+ \internal
+*/
+
+/*!
+ \property QDeclarativeItem::wantsFocus
+ \internal
+*/
+
+/*!
+ \property QDeclarativeItem::transformOrigin
+ \internal
+*/
+
+/*!
+ \fn void QDeclarativeItem::childrenRectChanged()
+ \internal
+*/
+
+/*!
+ \fn void QDeclarativeItem::baselineOffsetChanged()
+ \internal
+*/
+
+/*!
+ \fn void QDeclarativeItem::widthChanged()
+ \internal
+*/
+
+/*!
+ \fn void QDeclarativeItem::heightChanged()
+ \internal
+*/
+
+/*!
+ \fn void QDeclarativeItem::stateChanged(const QString &state)
+ \internal
+*/
+
+/*!
+ \fn void QDeclarativeItem::parentChanged()
+ \internal
+*/
+
+/*! \fn void QDeclarativeItem::transformOriginChanged(TransformOrigin)
+ \internal
+*/
+
+/*!
+ \fn void QDeclarativeItem::childrenChanged()
+ \internal
+*/
+
+/*!
+ \fn void QDeclarativeItem::focusChanged()
+ \internal
+*/
+
+/*!
+ \fn void QDeclarativeItem::wantsFocusChanged()
+ \internal
+*/
+
+// ### Must fix
+struct RegisterAnchorLineAtStartup {
+ RegisterAnchorLineAtStartup() {
+ qRegisterMetaType<QDeclarativeAnchorLine>("QDeclarativeAnchorLine");
+ }
+};
+static RegisterAnchorLineAtStartup registerAnchorLineAtStartup;
+
+
+/*!
+ \fn QDeclarativeItem::QDeclarativeItem(QDeclarativeItem *parent)
+
+ Constructs a QDeclarativeItem with the given \a parent.
+*/
+QDeclarativeItem::QDeclarativeItem(QDeclarativeItem* parent)
+ : QGraphicsObject(*(new QDeclarativeItemPrivate), parent, 0)
+{
+ Q_D(QDeclarativeItem);
+ d->init(parent);
+}
+
+/*! \internal
+*/
+QDeclarativeItem::QDeclarativeItem(QDeclarativeItemPrivate &dd, QDeclarativeItem *parent)
+ : QGraphicsObject(dd, parent, 0)
+{
+ Q_D(QDeclarativeItem);
+ d->init(parent);
+}
+
+/*!
+ Destroys the QDeclarativeItem.
+*/
+QDeclarativeItem::~QDeclarativeItem()
+{
+ Q_D(QDeclarativeItem);
+ for (int ii = 0; ii < d->changeListeners.count(); ++ii) {
+ QDeclarativeAnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate();
+ if (anchor)
+ anchor->clearItem(this);
+ }
+ if (!d->parent || (parentItem() && !parentItem()->QGraphicsItem::d_ptr->inDestructor)) {
+ for (int ii = 0; ii < d->changeListeners.count(); ++ii) {
+ QDeclarativeAnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate();
+ if (anchor && anchor->item && anchor->item->parentItem() != this) //child will be deleted anyway
+ anchor->updateOnComplete();
+ }
+ }
+ for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
+ const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
+ if (change.types & QDeclarativeItemPrivate::Destroyed)
+ change.listener->itemDestroyed(this);
+ }
+ d->changeListeners.clear();
+ delete d->_anchorLines; d->_anchorLines = 0;
+ delete d->_anchors; d->_anchors = 0;
+ delete d->_stateGroup; d->_stateGroup = 0;
+}
+
+/*!
+ \qmlproperty enum Item::transformOrigin
+ This property holds the origin point around which scale and rotation transform.
+
+ Nine transform origins are available, as shown in the image below.
+
+ \image declarative-transformorigin.png
+
+ This example rotates an image around its bottom-right corner.
+ \qml
+ Image {
+ source: "myimage.png"
+ transformOrigin: Item.BottomRight
+ rotate: 45
+ }
+ \endqml
+
+ The default transform origin is \c Center.
+*/
+
+/*!
+ \qmlproperty Item Item::parent
+ This property holds the parent of the item.
+*/
+
+/*!
+ \property QDeclarativeItem::parent
+ This property holds the parent of the item.
+*/
+void QDeclarativeItem::setParentItem(QDeclarativeItem *parent)
+{
+ QDeclarativeItem *oldParent = parentItem();
+ if (parent == oldParent || !parent) return;
+
+ QObject::setParent(parent);
+ QGraphicsObject::setParentItem(parent);
+}
+
+/*!
+ \fn void QDeclarativeItem::setParent(QDeclarativeItem *parent)
+ \overload
+ Sets both the parent object and parent item to \a parent. This
+ function avoids the programming error of calling setParent()
+ when you mean setParentItem().
+*/
+
+/*!
+ Returns the QDeclarativeItem parent of this item.
+*/
+QDeclarativeItem *QDeclarativeItem::parentItem() const
+{
+ return qobject_cast<QDeclarativeItem *>(QGraphicsObject::parentItem());
+}
+
+/*!
+ \qmlproperty list<Item> Item::children
+ \qmlproperty list<Object> Item::resources
+
+ The children property contains the list of visual children of this item.
+ The resources property contains non-visual resources that you want to
+ reference by name.
+
+ Generally you can rely on Item's default property to handle all this for
+ you, but it can come in handy in some cases.
+
+ \qml
+ Item {
+ children: [
+ Text {},
+ Rectangle {}
+ ]
+ resources: [
+ Component {
+ id: myComponent
+ Text {}
+ }
+ ]
+ }
+ \endqml
+*/
+
+/*!
+ \property QDeclarativeItem::children
+ \internal
+*/
+
+/*!
+ \property QDeclarativeItem::resources
+ \internal
+*/
+
+/*!
+ Returns true if construction of the QML component is complete; otherwise
+ returns false.
+
+ It is often desireable to delay some processing until the component is
+ completed.
+
+ \sa componentComplete()
+*/
+bool QDeclarativeItem::isComponentComplete() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->_componentComplete;
+}
+
+/*!
+ \property QDeclarativeItem::anchors
+ \internal
+*/
+
+/*! \internal */
+QDeclarativeAnchors *QDeclarativeItem::anchors()
+{
+ Q_D(QDeclarativeItem);
+ return d->anchors();
+}
+
+void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
+{
+ QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o);
+ if (i)
+ i->setParentItem(static_cast<QDeclarativeItem *>(prop->object));
+ else
+ o->setParent(static_cast<QDeclarativeItem *>(prop->object));
+}
+
+QObject *QDeclarativeItemPrivate::resources_at(QDeclarativeListProperty<QObject> *prop, int index)
+{
+ QObjectList children = prop->object->children();
+ if (index < children.count())
+ return children.at(index);
+ else
+ return 0;
+}
+
+void QDeclarativeItemPrivate::resources_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
+{
+ o->setParent(prop->object);
+}
+
+int QDeclarativeItemPrivate::resources_count(QDeclarativeListProperty<QObject> *prop)
+{
+ return prop->object->children().count();
+}
+
+QDeclarativeItem *QDeclarativeItemPrivate::children_at(QDeclarativeListProperty<QDeclarativeItem> *prop, int index)
+{
+ QList<QGraphicsItem *> children = static_cast<QDeclarativeItem*>(prop->object)->childItems();
+
+ if (index < children.count())
+ return qobject_cast<QDeclarativeItem *>(children.at(index));
+ else
+ return 0;
+}
+
+void QDeclarativeItemPrivate::children_append(QDeclarativeListProperty<QDeclarativeItem> *prop, QDeclarativeItem *i)
+{
+ if (i)
+ i->setParentItem(static_cast<QDeclarativeItem*>(prop->object));
+}
+
+int QDeclarativeItemPrivate::children_count(QDeclarativeListProperty<QDeclarativeItem> *prop)
+{
+ return static_cast<QDeclarativeItem*>(prop->object)->childItems().count();
+}
+
+int QDeclarativeItemPrivate::transform_count(QDeclarativeListProperty<QGraphicsTransform> *list)
+{
+ QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
+ if (object) {
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
+ return d->transformData ? d->transformData->graphicsTransforms.size() : 0;
+ } else {
+ return 0;
+ }
+}
+
+void QDeclarativeItemPrivate::transform_append(QDeclarativeListProperty<QGraphicsTransform> *list, QGraphicsTransform *item)
+{
+ QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
+ if (object)
+ QGraphicsItemPrivate::get(object)->appendGraphicsTransform(item);
+}
+
+QGraphicsTransform *QDeclarativeItemPrivate::transform_at(QDeclarativeListProperty<QGraphicsTransform> *list, int idx)
+{
+ QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
+ if (object) {
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
+ if (!d->transformData)
+ return 0;
+ return d->transformData->graphicsTransforms.at(idx);
+ } else {
+ return 0;
+ }
+}
+
+void QDeclarativeItemPrivate::transform_clear(QDeclarativeListProperty<QGraphicsTransform> *list)
+{
+ QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
+ if (object) {
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
+ if (!d->transformData)
+ return;
+ object->setTransformations(QList<QGraphicsTransform *>());
+ }
+}
+
+/*!
+ \qmlproperty list<Object> Item::data
+ \default
+
+ The data property is allows you to freely mix visual children and resources
+ of an item. If you assign a visual item to the data list it becomes
+ a child and if you assign any other object type, it is added as a resource.
+
+ So you can write:
+ \qml
+ Item {
+ Text {}
+ Rectangle {}
+ Script {}
+ }
+ \endqml
+
+ instead of:
+ \qml
+ Item {
+ children: [
+ Text {},
+ Rectangle {}
+ ]
+ resources: [
+ Script {}
+ ]
+ }
+ \endqml
+
+ data is a behind-the-scenes property: you should never need to explicitly
+ specify it.
+ */
+
+/*!
+ \property QDeclarativeItem::data
+ \internal
+*/
+
+/*! \internal */
+QDeclarativeListProperty<QObject> QDeclarativeItem::data()
+{
+ return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::data_append);
+}
+
+/*!
+ \property QDeclarativeItem::childrenRect
+ \brief The geometry of an item's children.
+
+ childrenRect provides an easy way to access the (collective) position and size of the item's children.
+*/
+QRectF QDeclarativeItem::childrenRect()
+{
+ Q_D(QDeclarativeItem);
+ if (!d->_contents) {
+ d->_contents = new QDeclarativeContents;
+ d->_contents->setParent(this);
+ d->_contents->setItem(this);
+ }
+ return d->_contents->rectF();
+}
+
+bool QDeclarativeItem::clip() const
+{
+ return flags() & ItemClipsChildrenToShape;
+}
+
+void QDeclarativeItem::setClip(bool c)
+{
+ if (clip() == c)
+ return;
+ setFlag(ItemClipsChildrenToShape, c);
+ emit clipChanged();
+}
+
+/*!
+ \qmlproperty real Item::x
+ \qmlproperty real Item::y
+ \qmlproperty real Item::width
+ \qmlproperty real Item::height
+
+ Defines the item's position and size relative to its parent.
+
+ \qml
+ Item { x: 100; y: 100; width: 100; height: 100 }
+ \endqml
+ */
+
+/*!
+ \property QDeclarativeItem::width
+
+ Defines the item's width relative to its parent.
+ */
+
+/*!
+ \property QDeclarativeItem::height
+
+ Defines the item's height relative to its parent.
+ */
+
+/*!
+ \qmlproperty real Item::z
+
+ Sets the stacking order of the item. By default the stacking order is 0.
+
+ Items with a higher stacking value are drawn on top of items with a
+ lower stacking order. Items with the same stacking value are drawn
+ bottom up in the order they appear. Items with a negative stacking
+ value are drawn under their parent's content.
+
+ The following example shows the various effects of stacking order.
+
+ \table
+ \row
+ \o \image declarative-item_stacking1.png
+ \o Same \c z - later children above earlier children:
+ \qml
+ Item {
+ Rectangle {
+ color: "red"
+ width: 100; height: 100
+ }
+ Rectangle {
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
+ \endqml
+ \row
+ \o \image declarative-item_stacking2.png
+ \o Higher \c z on top:
+ \qml
+ Item {
+ Rectangle {
+ z: 1
+ color: "red"
+ width: 100; height: 100
+ }
+ Rectangle {
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
+ \endqml
+ \row
+ \o \image declarative-item_stacking3.png
+ \o Same \c z - children above parents:
+ \qml
+ Item {
+ Rectangle {
+ color: "red"
+ width: 100; height: 100
+ Rectangle {
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
+ }
+ \endqml
+ \row
+ \o \image declarative-item_stacking4.png
+ \o Lower \c z below:
+ \qml
+ Item {
+ Rectangle {
+ color: "red"
+ width: 100; height: 100
+ Rectangle {
+ z: -1
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
+ }
+ \endqml
+ \endtable
+ */
+
+/*!
+ \qmlproperty bool Item::visible
+
+ Whether the item is visible. By default this is true.
+
+ \note visible is not linked to actual visibility; if an item
+ moves off screen, or the opacity changes to 0, this will
+ not affect the visible property.
+*/
+
+
+/*!
+ This function is called to handle this item's changes in
+ geometry from \a oldGeometry to \a newGeometry. If the two
+ geometries are the same, it doesn't do anything.
+ */
+void QDeclarativeItem::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
+{
+ Q_D(QDeclarativeItem);
+
+ if (d->_anchors)
+ d->_anchors->d_func()->updateMe();
+
+ if (transformOrigin() != QDeclarativeItem::TopLeft)
+ setTransformOriginPoint(d->computeTransformOrigin());
+
+ if (newGeometry.x() != oldGeometry.x())
+ emit xChanged();
+ if (newGeometry.width() != oldGeometry.width())
+ emit widthChanged();
+ if (newGeometry.y() != oldGeometry.y())
+ emit yChanged();
+ if (newGeometry.height() != oldGeometry.height())
+ emit heightChanged();
+
+ for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
+ const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
+ if (change.types & QDeclarativeItemPrivate::Geometry)
+ change.listener->itemGeometryChanged(this, newGeometry, oldGeometry);
+ }
+}
+
+void QDeclarativeItemPrivate::removeItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)
+{
+ ChangeListener change(listener, types);
+ changeListeners.removeOne(change);
+}
+
+/*! \internal */
+void QDeclarativeItem::keyPressEvent(QKeyEvent *event)
+{
+ Q_D(QDeclarativeItem);
+ if (d->keyHandler)
+ d->keyHandler->keyPressed(event);
+ else
+ event->ignore();
+}
+
+/*! \internal */
+void QDeclarativeItem::keyReleaseEvent(QKeyEvent *event)
+{
+ Q_D(QDeclarativeItem);
+ if (d->keyHandler)
+ d->keyHandler->keyReleased(event);
+ else
+ event->ignore();
+}
+
+/*! \internal */
+void QDeclarativeItem::inputMethodEvent(QInputMethodEvent *event)
+{
+ Q_D(QDeclarativeItem);
+ if (d->keyHandler)
+ d->keyHandler->inputMethodEvent(event);
+ else
+ event->ignore();
+}
+
+/*! \internal */
+QVariant QDeclarativeItem::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ Q_D(const QDeclarativeItem);
+ QVariant v;
+ if (d->keyHandler)
+ v = d->keyHandler->inputMethodQuery(query);
+
+ if (!v.isValid())
+ v = QGraphicsObject::inputMethodQuery(query);
+
+ return v;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeItem::left() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->anchorLines()->left;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeItem::right() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->anchorLines()->right;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeItem::horizontalCenter() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->anchorLines()->hCenter;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeItem::top() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->anchorLines()->top;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeItem::bottom() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->anchorLines()->bottom;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeItem::verticalCenter() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->anchorLines()->vCenter;
+}
+
+
+/*!
+ \internal
+*/
+QDeclarativeAnchorLine QDeclarativeItem::baseline() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->anchorLines()->baseline;
+}
+
+/*!
+ \property QDeclarativeItem::top
+ \internal
+*/
+
+/*!
+ \property QDeclarativeItem::bottom
+ \internal
+*/
+
+/*!
+ \property QDeclarativeItem::left
+ \internal
+*/
+
+/*!
+ \property QDeclarativeItem::right
+ \internal
+*/
+
+/*!
+ \property QDeclarativeItem::horizontalCenter
+ \internal
+*/
+
+/*!
+ \property QDeclarativeItem::verticalCenter
+ \internal
+*/
+
+/*!
+ \qmlproperty AnchorLine Item::top
+ \qmlproperty AnchorLine Item::bottom
+ \qmlproperty AnchorLine Item::left
+ \qmlproperty AnchorLine Item::right
+ \qmlproperty AnchorLine Item::horizontalCenter
+ \qmlproperty AnchorLine Item::verticalCenter
+ \qmlproperty AnchorLine Item::baseline
+
+ The anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \qmlproperty AnchorLine Item::anchors.top
+ \qmlproperty AnchorLine Item::anchors.bottom
+ \qmlproperty AnchorLine Item::anchors.left
+ \qmlproperty AnchorLine Item::anchors.right
+ \qmlproperty AnchorLine Item::anchors.horizontalCenter
+ \qmlproperty AnchorLine Item::anchors.verticalCenter
+ \qmlproperty AnchorLine Item::anchors.baseline
+
+ \qmlproperty Item Item::anchors.fill
+ \qmlproperty Item Item::anchors.centerIn
+
+ \qmlproperty real Item::anchors.margins
+ \qmlproperty real Item::anchors.topMargin
+ \qmlproperty real Item::anchors.bottomMargin
+ \qmlproperty real Item::anchors.leftMargin
+ \qmlproperty real Item::anchors.rightMargin
+ \qmlproperty real Item::anchors.horizontalCenterOffset
+ \qmlproperty real Item::anchors.verticalCenterOffset
+ \qmlproperty real Item::anchors.baselineOffset
+
+ Anchors provide a way to position an item by specifying its
+ relationship with other items.
+
+ Margins apply to top, bottom, left, right, and fill anchors.
+ The margins property can be used to set all of the various margins at once, to the same value.
+
+ Offsets apply for horizontal center, vertical center, and baseline anchors.
+
+ \table
+ \row
+ \o \image declarative-anchors_example.png
+ \o Text anchored to Image, horizontally centered and vertically below, with a margin.
+ \qml
+ Image { id: pic; ... }
+ Text {
+ id: label
+ anchors.horizontalCenter: pic.horizontalCenter
+ anchors.top: pic.bottom
+ anchors.topMargin: 5
+ ...
+ }
+ \endqml
+ \row
+ \o \image declarative-anchors_example2.png
+ \o
+ Left of Text anchored to right of Image, with a margin. The y
+ property of both defaults to 0.
+
+ \qml
+ Image { id: pic; ... }
+ Text {
+ id: label
+ anchors.left: pic.right
+ anchors.leftMargin: 5
+ ...
+ }
+ \endqml
+ \endtable
+
+ anchors.fill provides a convenient way for one item to have the
+ same geometry as another item, and is equivalent to connecting all
+ four directional anchors.
+
+ \note You can only anchor an item to siblings or a parent.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QDeclarativeItem::baselineOffset
+ \brief The position of the item's baseline in local coordinates.
+
+ The baseline of a Text item is the imaginary line on which the text
+ sits. Controls containing text usually set their baseline to the
+ baseline of their text.
+
+ For non-text items, a default baseline offset of 0 is used.
+*/
+qreal QDeclarativeItem::baselineOffset() const
+{
+ Q_D(const QDeclarativeItem);
+ if (!d->_baselineOffset.isValid()) {
+ return 0.0;
+ } else
+ return d->_baselineOffset;
+}
+
+void QDeclarativeItem::setBaselineOffset(qreal offset)
+{
+ Q_D(QDeclarativeItem);
+ if (offset == d->_baselineOffset)
+ return;
+
+ d->_baselineOffset = offset;
+ emit baselineOffsetChanged();
+
+ for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
+ const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
+ if (change.types & QDeclarativeItemPrivate::Geometry) {
+ QDeclarativeAnchorsPrivate *anchor = change.listener->anchorPrivate();
+ if (anchor)
+ anchor->updateVerticalAnchors();
+ }
+ }
+}
+
+/*!
+ \qmlproperty real Item::rotation
+ This property holds the rotation of the item in degrees clockwise.
+
+ This specifies how many degrees to rotate the item around its transformOrigin.
+ The default rotation is 0 degrees (i.e. not rotated at all).
+
+ \table
+ \row
+ \o \image declarative-rotation.png
+ \o
+ \qml
+ Rectangle {
+ color: "blue"
+ width: 100; height: 100
+ Rectangle {
+ color: "red"
+ x: 25; y: 25; width: 50; height: 50
+ rotation: 30
+ }
+ }
+ \endqml
+ \endtable
+*/
+
+/*!
+ \qmlproperty real Item::scale
+ This property holds the scale of the item.
+
+ A scale of less than 1 means the item will be displayed smaller than
+ normal, and a scale of greater than 1 means the item will be
+ displayed larger than normal. A negative scale means the item will
+ be mirrored.
+
+ By default, items are displayed at a scale of 1 (i.e. at their
+ normal size).
+
+ Scaling is from the item's transformOrigin.
+
+ \table
+ \row
+ \o \image declarative-scale.png
+ \o
+ \qml
+ Rectangle {
+ color: "blue"
+ width: 100; height: 100
+ Rectangle {
+ color: "green"
+ width: 25; height: 25
+ }
+ Rectangle {
+ color: "red"
+ x: 25; y: 25; width: 50; height: 50
+ scale: 1.4
+ }
+ }
+ \endqml
+ \endtable
+*/
+
+/*!
+ \qmlproperty real Item::opacity
+
+ The opacity of the item. Opacity is specified as a number between 0
+ (fully transparent) and 1 (fully opaque). The default is 1.
+
+ Opacity is an \e inherited attribute. That is, the opacity is
+ also applied individually to child items. In almost all cases this
+ is what you want. If you can spot the issue in the following
+ example, you might need to use an \l Opacity effect instead.
+
+ \table
+ \row
+ \o \image declarative-item_opacity1.png
+ \o
+ \qml
+ Item {
+ Rectangle {
+ color: "red"
+ width: 100; height: 100
+ Rectangle {
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
+ }
+ \endqml
+ \row
+ \o \image declarative-item_opacity2.png
+ \o
+ \qml
+ Item {
+ Rectangle {
+ opacity: 0.5
+ color: "red"
+ width: 100; height: 100
+ Rectangle {
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
+ }
+ \endqml
+ \endtable
+*/
+
+/*!
+ Returns a value indicating whether mouse input should
+ remain with this item exclusively.
+
+ \sa setKeepMouseGrab()
+ */
+bool QDeclarativeItem::keepMouseGrab() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->_keepMouse;
+}
+
+/*!
+ The flag indicating whether the mouse should remain
+ with this item is set to \a keep.
+
+ This is useful for items that wish to grab and keep mouse
+ interaction following a predefined gesture. For example,
+ an item that is interested in horizontal mouse movement
+ may set keepMouseGrab to true once a threshold has been
+ exceeded. Once keepMouseGrab has been set to true, filtering
+ items will not react to mouse events.
+
+ If the item does not indicate that it wishes to retain mouse grab,
+ a filtering item may steal the grab. For example, Flickable may attempt
+ to steal a mouse grab if it detects that the user has begun to
+ move the viewport.
+
+ \sa keepMouseGrab()
+ */
+void QDeclarativeItem::setKeepMouseGrab(bool keep)
+{
+ Q_D(QDeclarativeItem);
+ d->_keepMouse = keep;
+}
+
+/*!
+ \internal
+
+ This function emits the \e focusChanged signal.
+
+ Subclasses overriding this function should call up
+ to their base class.
+*/
+void QDeclarativeItem::focusChanged(bool flag)
+{
+ Q_UNUSED(flag);
+ emit focusChanged();
+}
+
+/*! \internal */
+QDeclarativeListProperty<QDeclarativeItem> QDeclarativeItem::fxChildren()
+{
+ return QDeclarativeListProperty<QDeclarativeItem>(this, 0, QDeclarativeItemPrivate::children_append,
+ QDeclarativeItemPrivate::children_count,
+ QDeclarativeItemPrivate::children_at);
+}
+
+/*! \internal */
+QDeclarativeListProperty<QObject> QDeclarativeItem::resources()
+{
+ return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::resources_append,
+ QDeclarativeItemPrivate::resources_count,
+ QDeclarativeItemPrivate::resources_at);
+}
+
+/*!
+ \qmlproperty list<State> Item::states
+ This property holds a list of states defined by the item.
+
+ \qml
+ Item {
+ states: [
+ State { ... },
+ State { ... }
+ ...
+ ]
+ }
+ \endqml
+
+ \sa {qmlstate}{States}
+*/
+
+/*!
+ \property QDeclarativeItem::states
+ \internal
+*/
+/*! \internal */
+QDeclarativeListProperty<QDeclarativeState> QDeclarativeItem::states()
+{
+ Q_D(QDeclarativeItem);
+ return d->states()->statesProperty();
+}
+
+/*!
+ \qmlproperty list<Transition> Item::transitions
+ This property holds a list of transitions defined by the item.
+
+ \qml
+ Item {
+ transitions: [
+ Transition { ... },
+ Transition { ... }
+ ...
+ ]
+ }
+ \endqml
+
+ \sa {state-transitions}{Transitions}
+*/
+
+/*!
+ \property QDeclarativeItem::transitions
+ \internal
+*/
+
+/*! \internal */
+QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeItem::transitions()
+{
+ Q_D(QDeclarativeItem);
+ return d->states()->transitionsProperty();
+}
+
+/*
+ \qmlproperty list<Filter> Item::filter
+ This property holds a list of graphical filters to be applied to the item.
+
+ \l {Filter}{Filters} include things like \l {Blur}{blurring}
+ the item, or giving it a \l Reflection. Some
+ filters may not be available on all canvases; if a filter is not
+ available on a certain canvas, it will simply not be applied for
+ that canvas (but the QML will still be considered valid).
+
+ \qml
+ Item {
+ filter: [
+ Blur { ... },
+ Relection { ... }
+ ...
+ ]
+ }
+ \endqml
+*/
+
+/*!
+ \qmlproperty bool Item::clip
+ This property holds whether clipping is enabled.
+
+ if clipping is enabled, an item will clip its own painting, as well
+ as the painting of its children, to its bounding rectangle.
+
+ Non-rectangular clipping regions are not supported for performance reasons.
+*/
+
+/*!
+ \property QDeclarativeItem::clip
+ This property holds whether clipping is enabled.
+
+ if clipping is enabled, an item will clip its own painting, as well
+ as the painting of its children, to its bounding rectangle.
+
+ Non-rectangular clipping regions are not supported for performance reasons.
+*/
+
+/*!
+ \qmlproperty string Item::state
+
+ This property holds the name of the current state of the item.
+
+ This property is often used in scripts to change between states. For
+ example:
+
+ \qml
+ Script {
+ function toggle() {
+ if (button.state == 'On')
+ button.state = 'Off';
+ else
+ button.state = 'On';
+ }
+ }
+ \endqml
+
+ If the item is in its base state (i.e. no explicit state has been
+ set), \c state will be a blank string. Likewise, you can return an
+ item to its base state by setting its current state to \c ''.
+
+ \sa {qmlstates}{States}
+*/
+
+/*!
+ \property QDeclarativeItem::state
+ \internal
+*/
+
+/*! \internal */
+QString QDeclarativeItem::state() const
+{
+ Q_D(const QDeclarativeItem);
+ if (!d->_stateGroup)
+ return QString();
+ else
+ return d->_stateGroup->state();
+}
+
+/*! \internal */
+void QDeclarativeItem::setState(const QString &state)
+{
+ Q_D(QDeclarativeItem);
+ d->states()->setState(state);
+}
+
+/*!
+ \qmlproperty list<Transform> Item::transform
+ This property holds the list of transformations to apply.
+
+ For more information see \l Transform.
+*/
+
+/*!
+ \property QDeclarativeItem::transform
+ \internal
+*/
+
+/*! \internal */
+QDeclarativeListProperty<QGraphicsTransform> QDeclarativeItem::transform()
+{
+ Q_D(QDeclarativeItem);
+ return QDeclarativeListProperty<QGraphicsTransform>(this, 0, d->transform_append, d->transform_count,
+ d->transform_at, d->transform_clear);
+}
+
+/*!
+ \internal
+
+ classBegin() is called when the item is constructed, but its
+ properties have not yet been set.
+
+ \sa componentComplete(), isComponentComplete()
+*/
+void QDeclarativeItem::classBegin()
+{
+ Q_D(QDeclarativeItem);
+ d->_componentComplete = false;
+ if (d->_stateGroup)
+ d->_stateGroup->classBegin();
+ if (d->_anchors)
+ d->_anchors->classBegin();
+}
+
+/*!
+ \internal
+
+ componentComplete() is called when all items in the component
+ have been constructed. It is often desireable to delay some
+ processing until the component is complete an all bindings in the
+ component have been resolved.
+*/
+void QDeclarativeItem::componentComplete()
+{
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::ItemComponentComplete> cc;
+#endif
+
+ Q_D(QDeclarativeItem);
+ d->_componentComplete = true;
+ if (d->_stateGroup)
+ d->_stateGroup->componentComplete();
+ if (d->_anchors) {
+ d->_anchors->componentComplete();
+ d->_anchors->d_func()->updateOnComplete();
+ }
+ if (d->keyHandler)
+ d->keyHandler->componentComplete();
+}
+
+QDeclarativeStateGroup *QDeclarativeItemPrivate::states()
+{
+ Q_Q(QDeclarativeItem);
+ if (!_stateGroup) {
+ _stateGroup = new QDeclarativeStateGroup;
+ if (!_componentComplete)
+ _stateGroup->classBegin();
+ QObject::connect(_stateGroup, SIGNAL(stateChanged(QString)),
+ q, SIGNAL(stateChanged(QString)));
+ }
+
+ return _stateGroup;
+}
+
+QDeclarativeItemPrivate::AnchorLines::AnchorLines(QDeclarativeItem *q)
+{
+ left.item = q;
+ left.anchorLine = QDeclarativeAnchorLine::Left;
+ right.item = q;
+ right.anchorLine = QDeclarativeAnchorLine::Right;
+ hCenter.item = q;
+ hCenter.anchorLine = QDeclarativeAnchorLine::HCenter;
+ top.item = q;
+ top.anchorLine = QDeclarativeAnchorLine::Top;
+ bottom.item = q;
+ bottom.anchorLine = QDeclarativeAnchorLine::Bottom;
+ vCenter.item = q;
+ vCenter.anchorLine = QDeclarativeAnchorLine::VCenter;
+ baseline.item = q;
+ baseline.anchorLine = QDeclarativeAnchorLine::Baseline;
+}
+
+QPointF QDeclarativeItemPrivate::computeTransformOrigin() const
+{
+ Q_Q(const QDeclarativeItem);
+
+ QRectF br = q->boundingRect();
+
+ switch(origin) {
+ default:
+ case QDeclarativeItem::TopLeft:
+ return QPointF(0, 0);
+ case QDeclarativeItem::Top:
+ return QPointF(br.width() / 2., 0);
+ case QDeclarativeItem::TopRight:
+ return QPointF(br.width(), 0);
+ case QDeclarativeItem::Left:
+ return QPointF(0, br.height() / 2.);
+ case QDeclarativeItem::Center:
+ return QPointF(br.width() / 2., br.height() / 2.);
+ case QDeclarativeItem::Right:
+ return QPointF(br.width(), br.height() / 2.);
+ case QDeclarativeItem::BottomLeft:
+ return QPointF(0, br.height());
+ case QDeclarativeItem::Bottom:
+ return QPointF(br.width() / 2., br.height());
+ case QDeclarativeItem::BottomRight:
+ return QPointF(br.width(), br.height());
+ }
+}
+
+/*! \internal */
+bool QDeclarativeItem::sceneEvent(QEvent *event)
+{
+ bool rv = QGraphicsItem::sceneEvent(event);
+
+ if (event->type() == QEvent::FocusIn ||
+ event->type() == QEvent::FocusOut) {
+ focusChanged(hasFocus());
+ }
+
+ return rv;
+}
+
+/*! \internal */
+QVariant QDeclarativeItem::itemChange(GraphicsItemChange change,
+ const QVariant &value)
+{
+ Q_D(const QDeclarativeItem);
+ switch (change) {
+ case ItemParentHasChanged:
+ emit parentChanged();
+ break;
+ case ItemChildAddedChange:
+ case ItemChildRemovedChange:
+ emit childrenChanged();
+ break;
+ case ItemVisibleHasChanged: {
+ for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
+ const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
+ if (change.types & QDeclarativeItemPrivate::Visibility) {
+ change.listener->itemVisibilityChanged(this);
+ }
+ }
+ }
+ break;
+ case ItemOpacityHasChanged: {
+ for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
+ const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
+ if (change.types & QDeclarativeItemPrivate::Opacity) {
+ change.listener->itemOpacityChanged(this);
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return QGraphicsItem::itemChange(change, value);
+}
+
+/*! \internal */
+QRectF QDeclarativeItem::boundingRect() const
+{
+ Q_D(const QDeclarativeItem);
+ return QRectF(0, 0, d->width, d->height);
+}
+
+/*!
+ \enum QDeclarativeItem::TransformOrigin
+
+ Controls the point about which simple transforms like scale apply.
+
+ \value TopLeft The top-left corner of the item.
+ \value Top The center point of the top of the item.
+ \value TopRight The top-right corner of the item.
+ \value Left The left most point of the vertical middle.
+ \value Center The center of the item.
+ \value Right The right most point of the vertical middle.
+ \value BottomLeft The bottom-left corner of the item.
+ \value Bottom The center point of the bottom of the item.
+ \value BottomRight The bottom-right corner of the item.
+*/
+
+/*!
+ Returns the current transform origin.
+*/
+QDeclarativeItem::TransformOrigin QDeclarativeItem::transformOrigin() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->origin;
+}
+
+/*!
+ Set the transform \a origin.
+*/
+void QDeclarativeItem::setTransformOrigin(TransformOrigin origin)
+{
+ Q_D(QDeclarativeItem);
+ if (origin != d->origin) {
+ d->origin = origin;
+ QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin());
+ emit transformOriginChanged(d->origin);
+ }
+}
+
+/*!
+ \property QDeclarativeItem::smooth
+ \brief whether the item is smoothly transformed.
+
+ This property is provided purely for the purpose of optimization. Turning
+ smooth transforms off is faster, but looks worse; turning smooth
+ transformations on is slower, but looks better.
+
+ By default smooth transformations are off.
+*/
+
+/*!
+ Returns true if the item should be drawn with antialiasing and
+ smooth pixmap filtering, false otherwise.
+
+ The default is false.
+
+ \sa setSmooth()
+*/
+bool QDeclarativeItem::smooth() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->smooth;
+}
+
+/*!
+ Sets whether the item should be drawn with antialiasing and
+ smooth pixmap filtering to \a smooth.
+
+ \sa smooth()
+*/
+void QDeclarativeItem::setSmooth(bool smooth)
+{
+ Q_D(QDeclarativeItem);
+ if (d->smooth == smooth)
+ return;
+ d->smooth = smooth;
+ emit smoothChanged();
+ update();
+}
+
+qreal QDeclarativeItem::width() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->width;
+}
+
+void QDeclarativeItem::setWidth(qreal w)
+{
+ Q_D(QDeclarativeItem);
+ if (qIsNaN(w))
+ return;
+
+ d->widthValid = true;
+ if (d->width == w)
+ return;
+
+ qreal oldWidth = d->width;
+
+ prepareGeometryChange();
+ d->width = w;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), oldWidth, height()));
+}
+
+void QDeclarativeItem::resetWidth()
+{
+ Q_D(QDeclarativeItem);
+ d->widthValid = false;
+ setImplicitWidth(implicitWidth());
+}
+
+/*!
+ Returns the width of the item that is implied by other properties that determine the content.
+*/
+qreal QDeclarativeItem::implicitWidth() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->implicitWidth;
+}
+
+/*!
+ Sets the implied width of the item to \a w.
+ This is the width implied by other properties that determine the content.
+*/
+void QDeclarativeItem::setImplicitWidth(qreal w)
+{
+ Q_D(QDeclarativeItem);
+ d->implicitWidth = w;
+ if (d->width == w || widthValid())
+ return;
+
+ qreal oldWidth = d->width;
+
+ prepareGeometryChange();
+ d->width = w;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), oldWidth, height()));
+}
+
+/*!
+ Returns whether the width property has been set explicitly.
+*/
+bool QDeclarativeItem::widthValid() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->widthValid;
+}
+
+qreal QDeclarativeItem::height() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->height;
+}
+
+void QDeclarativeItem::setHeight(qreal h)
+{
+ Q_D(QDeclarativeItem);
+ if (qIsNaN(h))
+ return;
+
+ d->heightValid = true;
+ if (d->height == h)
+ return;
+
+ qreal oldHeight = d->height;
+
+ prepareGeometryChange();
+ d->height = h;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), width(), oldHeight));
+}
+
+void QDeclarativeItem::resetHeight()
+{
+ Q_D(QDeclarativeItem);
+ d->heightValid = false;
+ setImplicitHeight(implicitHeight());
+}
+
+/*!
+ Returns the height of the item that is implied by other properties that determine the content.
+*/
+qreal QDeclarativeItem::implicitHeight() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->implicitHeight;
+}
+
+/*!
+ Sets the implied height of the item to \a h.
+ This is the height implied by other properties that determine the content.
+*/
+void QDeclarativeItem::setImplicitHeight(qreal h)
+{
+ Q_D(QDeclarativeItem);
+ d->implicitHeight = h;
+ if (d->height == h || heightValid())
+ return;
+
+ qreal oldHeight = d->height;
+
+ prepareGeometryChange();
+ d->height = h;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), width(), oldHeight));
+}
+
+/*!
+ Returns whether the height property has been set explicitly.
+*/
+bool QDeclarativeItem::heightValid() const
+{
+ Q_D(const QDeclarativeItem);
+ return d->heightValid;
+}
+
+/*!
+ \qmlproperty bool Item::wantsFocus
+
+ This property indicates whether the item has has an active focus request.
+
+ \sa {qmlfocus}{Keyboard Focus}
+*/
+
+/*! \internal */
+bool QDeclarativeItem::wantsFocus() const
+{
+ return focusItem() != 0;
+}
+
+/*!
+ \qmlproperty bool Item::focus
+ This property indicates whether the item has keyboard input focus. Set this
+ property to true to request focus.
+
+ \sa {qmlfocus}{Keyboard Focus}
+*/
+
+/*! \internal */
+bool QDeclarativeItem::hasFocus() const
+{
+ return QGraphicsItem::hasFocus();
+}
+
+/*! \internal */
+void QDeclarativeItem::setFocus(bool focus)
+{
+ if (focus)
+ QGraphicsItem::setFocus(Qt::OtherFocusReason);
+ else
+ QGraphicsItem::clearFocus();
+}
+
+/*!
+ \reimp
+ \internal
+*/
+void QDeclarativeItem::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
+{
+}
+
+/*!
+ \reimp
+ \internal
+*/
+bool QDeclarativeItem::event(QEvent *ev)
+{
+ return QGraphicsObject::event(ev);
+}
+
+QDebug operator<<(QDebug debug, QDeclarativeItem *item)
+{
+ if (!item) {
+ debug << "QDeclarativeItem(0)";
+ return debug;
+ }
+
+ debug << item->metaObject()->className() << "(this =" << ((void*)item)
+ << ", parent =" << ((void*)item->parentItem())
+ << ", geometry =" << QRectF(item->pos(), QSizeF(item->width(), item->height()))
+ << ", z =" << item->zValue() << ')';
+ return debug;
+}
+
+int QDeclarativeItemPrivate::consistentTime = -1;
+void QDeclarativeItemPrivate::setConsistentTime(int t)
+{
+ consistentTime = t;
+}
+
+QTime QDeclarativeItemPrivate::currentTime()
+{
+ if (consistentTime == -1)
+ return QTime::currentTime();
+ else
+ return QTime(0, 0).addMSecs(consistentTime);
+}
+
+void QDeclarativeItemPrivate::start(QTime &t)
+{
+ t = currentTime();
+}
+
+int QDeclarativeItemPrivate::elapsed(QTime &t)
+{
+ int n = t.msecsTo(currentTime());
+ if (n < 0) // passed midnight
+ n += 86400 * 1000;
+ return n;
+}
+
+int QDeclarativeItemPrivate::restart(QTime &t)
+{
+ QTime time = currentTime();
+ int n = t.msecsTo(time);
+ if (n < 0) // passed midnight
+ n += 86400*1000;
+ t = time;
+ return n;
+}
+
+QT_END_NAMESPACE
+
+#include <moc_qdeclarativeitem.cpp>
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
new file mode 100644
index 0000000..3ae404d
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEITEM_H
+#define QDECLARATIVEITEM_H
+
+#include <qdeclarative.h>
+#include <qdeclarativecomponent.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QList>
+#include <QtGui/qgraphicsitem.h>
+#include <QtGui/qgraphicstransform.h>
+#include <QtGui/qfont.h>
+#include <QtGui/qaction.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeState;
+class QDeclarativeAnchorLine;
+class QDeclarativeTransition;
+class QDeclarativeKeyEvent;
+class QDeclarativeAnchors;
+class QDeclarativeItemPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeItem : public QGraphicsObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativeParserStatus)
+
+ Q_PROPERTY(QDeclarativeItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL)
+ Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data DESIGNABLE false)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> children READ fxChildren DESIGNABLE false NOTIFY childrenChanged)
+ Q_PROPERTY(QDeclarativeListProperty<QObject> resources READ resources DESIGNABLE false)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeState> states READ states DESIGNABLE false)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeTransition> transitions READ transitions DESIGNABLE false)
+ Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
+ Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL)
+ Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL)
+ Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL)
+ Q_PROPERTY(QDeclarativeAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine left READ left CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine right READ right CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine top READ top CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline CONSTANT FINAL)
+ Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
+ Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged) // ### move to QGI/QGO, NOTIFY
+ Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
+ Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged)
+ Q_PROPERTY(QDeclarativeListProperty<QGraphicsTransform> transform READ transform DESIGNABLE false FINAL)
+ Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged)
+ Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
+ Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect)
+ Q_ENUMS(TransformOrigin)
+ Q_CLASSINFO("DefaultProperty", "data")
+
+public:
+ enum TransformOrigin {
+ TopLeft, Top, TopRight,
+ Left, Center, Right,
+ BottomLeft, Bottom, BottomRight
+ };
+
+ QDeclarativeItem(QDeclarativeItem *parent = 0);
+ virtual ~QDeclarativeItem();
+
+ QDeclarativeItem *parentItem() const;
+ void setParentItem(QDeclarativeItem *parent);
+ void setParent(QDeclarativeItem *parent) { setParentItem(parent); }
+
+ QDeclarativeListProperty<QObject> data();
+ QDeclarativeListProperty<QDeclarativeItem> fxChildren();
+ QDeclarativeListProperty<QObject> resources();
+
+ QDeclarativeAnchors *anchors();
+ QRectF childrenRect();
+
+ bool clip() const;
+ void setClip(bool);
+
+ QDeclarativeListProperty<QDeclarativeState> states();
+ QDeclarativeListProperty<QDeclarativeTransition> transitions();
+
+ QString state() const;
+ void setState(const QString &);
+
+ qreal baselineOffset() const;
+ void setBaselineOffset(qreal);
+
+ QDeclarativeListProperty<QGraphicsTransform> transform();
+
+ qreal width() const;
+ void setWidth(qreal);
+ void resetWidth();
+ qreal implicitWidth() const;
+
+ qreal height() const;
+ void setHeight(qreal);
+ void resetHeight();
+ qreal implicitHeight() const;
+
+ TransformOrigin transformOrigin() const;
+ void setTransformOrigin(TransformOrigin);
+
+ bool smooth() const;
+ void setSmooth(bool);
+
+ QRectF boundingRect() const;
+ virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+ bool wantsFocus() const;
+ bool hasFocus() const;
+ void setFocus(bool);
+
+ bool keepMouseGrab() const;
+ void setKeepMouseGrab(bool);
+
+ QDeclarativeAnchorLine left() const;
+ QDeclarativeAnchorLine right() const;
+ QDeclarativeAnchorLine horizontalCenter() const;
+ QDeclarativeAnchorLine top() const;
+ QDeclarativeAnchorLine bottom() const;
+ QDeclarativeAnchorLine verticalCenter() const;
+ QDeclarativeAnchorLine baseline() const;
+
+Q_SIGNALS:
+ void widthChanged();
+ void heightChanged();
+ void childrenChanged();
+ void childrenRectChanged();
+ void baselineOffsetChanged();
+ void stateChanged(const QString &);
+ void focusChanged();
+ void wantsFocusChanged();
+ void parentChanged();
+ void transformOriginChanged(TransformOrigin);
+ void smoothChanged();
+ void clipChanged();
+
+protected:
+ bool isComponentComplete() const;
+ virtual bool sceneEvent(QEvent *);
+ virtual bool event(QEvent *);
+ virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
+
+ void setImplicitWidth(qreal);
+ bool widthValid() const; // ### better name?
+ void setImplicitHeight(qreal);
+ bool heightValid() const; // ### better name?
+
+ virtual void classBegin();
+ virtual void componentComplete();
+ virtual void focusChanged(bool);
+ virtual void keyPressEvent(QKeyEvent *event);
+ virtual void keyReleaseEvent(QKeyEvent *event);
+ virtual void inputMethodEvent(QInputMethodEvent *);
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
+
+protected:
+ QDeclarativeItem(QDeclarativeItemPrivate &dd, QDeclarativeItem *parent = 0);
+
+private:
+ friend class QDeclarativeStatePrivate;
+ friend class QDeclarativeAnchors;
+ Q_DISABLE_COPY(QDeclarativeItem)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem)
+};
+
+template<typename T>
+ T qobject_cast(QGraphicsObject *o)
+{
+ QObject *obj = o;
+ return qobject_cast<T>(obj);
+}
+
+// ### move to QGO
+template<typename T>
+T qobject_cast(QGraphicsItem *item)
+{
+ if (!item) return 0;
+ QObject *o = item->toGraphicsObject();
+ return qobject_cast<T>(o);
+}
+
+QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, QDeclarativeItem *item);
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeItem)
+QML_DECLARE_TYPE(QGraphicsTransform)
+QML_DECLARE_TYPE(QGraphicsScale)
+QML_DECLARE_TYPE(QGraphicsRotation)
+QML_DECLARE_TYPE(QAction)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEITEM_H
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
new file mode 100644
index 0000000..81c5688
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -0,0 +1,471 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEITEM_P_H
+#define QDECLARATIVEITEM_P_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 "qdeclarativeitem.h"
+
+#include "qdeclarativeanchors_p.h"
+#include "qdeclarativeanchors_p_p.h"
+#include "qdeclarativeitemchangelistener_p.h"
+#include <private/qpodvector_p.h>
+
+#include "../util/qdeclarativestate_p.h"
+#include "../util/qdeclarativenullablevalue_p_p.h"
+#include <qdeclarative.h>
+#include <qdeclarativecontext.h>
+
+#include <QtCore/qlist.h>
+#include <QtCore/qdebug.h>
+
+#include <private/qgraphicsitem_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkReply;
+class QDeclarativeItemKeyFilter;
+
+//### merge into private?
+class QDeclarativeContents : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeContents();
+
+ QRectF rectF() const;
+
+ void setItem(QDeclarativeItem *item);
+
+public Q_SLOTS:
+ void calcHeight();
+ void calcWidth();
+
+Q_SIGNALS:
+ void rectChanged();
+
+private:
+ QDeclarativeItem *m_item;
+ qreal m_x;
+ qreal m_y;
+ qreal m_width;
+ qreal m_height;
+};
+
+class QDeclarativeItemPrivate : public QGraphicsItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeItem)
+
+public:
+ QDeclarativeItemPrivate()
+ : _anchors(0), _contents(0),
+ _baselineOffset(0),
+ _anchorLines(0),
+ _stateGroup(0), origin(QDeclarativeItem::Center),
+ widthValid(false), heightValid(false),
+ _componentComplete(true), _keepMouse(false),
+ smooth(false), keyHandler(0),
+ width(0), height(0), implicitWidth(0), implicitHeight(0)
+ {
+ QGraphicsItemPrivate::acceptedMouseButtons = 0;
+ QGraphicsItemPrivate::flags = QGraphicsItem::GraphicsItemFlags(
+ QGraphicsItem::ItemHasNoContents
+ | QGraphicsItem::ItemIsFocusable
+ | QGraphicsItem::ItemNegativeZStacksBehindParent);
+
+ }
+
+ void init(QDeclarativeItem *parent)
+ {
+ Q_Q(QDeclarativeItem);
+
+ if (parent)
+ q->setParentItem(parent);
+ _baselineOffset.invalidate();
+ mouseSetsFocus = false;
+ }
+
+ QString _id;
+
+ // data property
+ static void data_append(QDeclarativeListProperty<QObject> *, QObject *);
+
+ // resources property
+ static QObject *resources_at(QDeclarativeListProperty<QObject> *, int);
+ static void resources_append(QDeclarativeListProperty<QObject> *, QObject *);
+ static int resources_count(QDeclarativeListProperty<QObject> *);
+
+ // children property
+ static QDeclarativeItem *children_at(QDeclarativeListProperty<QDeclarativeItem> *, int);
+ static void children_append(QDeclarativeListProperty<QDeclarativeItem> *, QDeclarativeItem *);
+ static int children_count(QDeclarativeListProperty<QDeclarativeItem> *);
+
+ // transform property
+ static int transform_count(QDeclarativeListProperty<QGraphicsTransform> *list);
+ static void transform_append(QDeclarativeListProperty<QGraphicsTransform> *list, QGraphicsTransform *);
+ static QGraphicsTransform *transform_at(QDeclarativeListProperty<QGraphicsTransform> *list, int);
+ static void transform_clear(QDeclarativeListProperty<QGraphicsTransform> *list);
+
+ QDeclarativeAnchors *anchors() {
+ if (!_anchors) {
+ Q_Q(QDeclarativeItem);
+ _anchors = new QDeclarativeAnchors(q);
+ if (!_componentComplete)
+ _anchors->classBegin();
+ }
+ return _anchors;
+ }
+ QDeclarativeAnchors *_anchors;
+ QDeclarativeContents *_contents;
+
+ QDeclarativeNullableValue<qreal> _baselineOffset;
+
+ struct AnchorLines {
+ AnchorLines(QDeclarativeItem *);
+ QDeclarativeAnchorLine left;
+ QDeclarativeAnchorLine right;
+ QDeclarativeAnchorLine hCenter;
+ QDeclarativeAnchorLine top;
+ QDeclarativeAnchorLine bottom;
+ QDeclarativeAnchorLine vCenter;
+ QDeclarativeAnchorLine baseline;
+ };
+ mutable AnchorLines *_anchorLines;
+ AnchorLines *anchorLines() const {
+ Q_Q(const QDeclarativeItem);
+ if (!_anchorLines) _anchorLines =
+ new AnchorLines(const_cast<QDeclarativeItem *>(q));
+ return _anchorLines;
+ }
+
+ enum ChangeType {
+ Geometry = 0x01,
+ SiblingOrder = 0x02,
+ Visibility = 0x04,
+ Opacity = 0x08,
+ Destroyed = 0x10
+ };
+
+ Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
+
+ struct ChangeListener {
+ ChangeListener(QDeclarativeItemChangeListener *l, QDeclarativeItemPrivate::ChangeTypes t) : listener(l), types(t) {}
+ QDeclarativeItemChangeListener *listener;
+ QDeclarativeItemPrivate::ChangeTypes types;
+ bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; }
+ };
+
+ void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types) {
+ changeListeners.append(ChangeListener(listener, types));
+ }
+ void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types);
+ QPODVector<ChangeListener,4> changeListeners;
+
+ QDeclarativeStateGroup *states();
+ QDeclarativeStateGroup *_stateGroup;
+
+ QDeclarativeItem::TransformOrigin origin:4;
+ bool widthValid:1;
+ bool heightValid:1;
+ bool _componentComplete:1;
+ bool _keepMouse:1;
+ bool smooth:1;
+
+ QDeclarativeItemKeyFilter *keyHandler;
+
+ qreal width;
+ qreal height;
+ qreal implicitWidth;
+ qreal implicitHeight;
+
+ QPointF computeTransformOrigin() const;
+
+ virtual void setPosHelper(const QPointF &pos)
+ {
+ Q_Q(QDeclarativeItem);
+ QRectF oldGeometry(this->pos.x(), this->pos.y(), width, height);
+ QGraphicsItemPrivate::setPosHelper(pos);
+ q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), width, height), oldGeometry);
+ }
+
+ // Reimplemented from QGraphicsItemPrivate
+ virtual void subFocusItemChange()
+ {
+ emit q_func()->wantsFocusChanged();
+ }
+
+ // Reimplemented from QGraphicsItemPrivate
+ virtual void siblingOrderChange()
+ {
+ Q_Q(QDeclarativeItem);
+ for(int ii = 0; ii < changeListeners.count(); ++ii) {
+ const QDeclarativeItemPrivate::ChangeListener &change = changeListeners.at(ii);
+ if (change.types & QDeclarativeItemPrivate::SiblingOrder) {
+ change.listener->itemSiblingOrderChanged(q);
+ }
+ }
+ }
+
+ static int consistentTime;
+ static QTime currentTime();
+ static void Q_DECLARATIVE_EXPORT setConsistentTime(int t);
+ static void start(QTime &);
+ static int elapsed(QTime &);
+ static int restart(QTime &);
+};
+
+/*
+ Key filters can be installed on a QDeclarativeItem, but not removed. Currently they
+ are only used by attached objects (which are only destroyed on Item
+ destruction), so this isn't a problem. If in future this becomes any form
+ of public API, they will have to support removal too.
+*/
+class QDeclarativeItemKeyFilter
+{
+public:
+ QDeclarativeItemKeyFilter(QDeclarativeItem * = 0);
+ virtual ~QDeclarativeItemKeyFilter();
+
+ virtual void keyPressed(QKeyEvent *event);
+ virtual void keyReleased(QKeyEvent *event);
+ virtual void inputMethodEvent(QInputMethodEvent *event);
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+ virtual void componentComplete();
+
+private:
+ QDeclarativeItemKeyFilter *m_next;
+};
+
+class QDeclarativeKeyNavigationAttachedPrivate : public QObjectPrivate
+{
+public:
+ QDeclarativeKeyNavigationAttachedPrivate()
+ : QObjectPrivate(), left(0), right(0), up(0), down(0) {}
+
+ QDeclarativeItem *left;
+ QDeclarativeItem *right;
+ QDeclarativeItem *up;
+ QDeclarativeItem *down;
+};
+
+class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeItemKeyFilter
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeKeyNavigationAttached)
+
+ Q_PROPERTY(QDeclarativeItem *left READ left WRITE setLeft NOTIFY changed)
+ Q_PROPERTY(QDeclarativeItem *right READ right WRITE setRight NOTIFY changed)
+ Q_PROPERTY(QDeclarativeItem *up READ up WRITE setUp NOTIFY changed)
+ Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY changed)
+public:
+ QDeclarativeKeyNavigationAttached(QObject * = 0);
+
+ QDeclarativeItem *left() const;
+ void setLeft(QDeclarativeItem *);
+ QDeclarativeItem *right() const;
+ void setRight(QDeclarativeItem *);
+ QDeclarativeItem *up() const;
+ void setUp(QDeclarativeItem *);
+ QDeclarativeItem *down() const;
+ void setDown(QDeclarativeItem *);
+
+ static QDeclarativeKeyNavigationAttached *qmlAttachedProperties(QObject *);
+
+Q_SIGNALS:
+ void changed();
+
+private:
+ virtual void keyPressed(QKeyEvent *event);
+ virtual void keyReleased(QKeyEvent *event);
+};
+
+class QDeclarativeKeysAttachedPrivate : public QObjectPrivate
+{
+public:
+ QDeclarativeKeysAttachedPrivate()
+ : QObjectPrivate(), inPress(false), inRelease(false)
+ , inIM(false), enabled(true), imeItem(0), item(0)
+ {}
+
+ bool isConnected(const char *signalName);
+
+ QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const
+ {
+ QGraphicsItem *fp;
+ while ((fp = item->focusProxy()))
+ item = fp;
+ return item;
+ }
+
+ //loop detection
+ bool inPress:1;
+ bool inRelease:1;
+ bool inIM:1;
+
+ bool enabled : 1;
+
+ QGraphicsItem *imeItem;
+ QList<QDeclarativeItem *> targets;
+ QDeclarativeItem *item;
+};
+
+class QDeclarativeKeysAttached : public QObject, public QDeclarativeItemKeyFilter
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeKeysAttached)
+
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> forwardTo READ forwardTo)
+
+public:
+ QDeclarativeKeysAttached(QObject *parent=0);
+ ~QDeclarativeKeysAttached();
+
+ bool enabled() const { Q_D(const QDeclarativeKeysAttached); return d->enabled; }
+ void setEnabled(bool enabled) {
+ Q_D(QDeclarativeKeysAttached);
+ if (enabled != d->enabled) {
+ d->enabled = enabled;
+ emit enabledChanged();
+ }
+ }
+
+ QDeclarativeListProperty<QDeclarativeItem> forwardTo() {
+ Q_D(QDeclarativeKeysAttached);
+ return QDeclarativeListProperty<QDeclarativeItem>(this, d->targets);
+ }
+
+ virtual void componentComplete();
+
+ static QDeclarativeKeysAttached *qmlAttachedProperties(QObject *);
+
+Q_SIGNALS:
+ void enabledChanged();
+ void pressed(QDeclarativeKeyEvent *event);
+ void released(QDeclarativeKeyEvent *event);
+ void digit0Pressed(QDeclarativeKeyEvent *event);
+ void digit1Pressed(QDeclarativeKeyEvent *event);
+ void digit2Pressed(QDeclarativeKeyEvent *event);
+ void digit3Pressed(QDeclarativeKeyEvent *event);
+ void digit4Pressed(QDeclarativeKeyEvent *event);
+ void digit5Pressed(QDeclarativeKeyEvent *event);
+ void digit6Pressed(QDeclarativeKeyEvent *event);
+ void digit7Pressed(QDeclarativeKeyEvent *event);
+ void digit8Pressed(QDeclarativeKeyEvent *event);
+ void digit9Pressed(QDeclarativeKeyEvent *event);
+
+ void leftPressed(QDeclarativeKeyEvent *event);
+ void rightPressed(QDeclarativeKeyEvent *event);
+ void upPressed(QDeclarativeKeyEvent *event);
+ void downPressed(QDeclarativeKeyEvent *event);
+
+ void asteriskPressed(QDeclarativeKeyEvent *event);
+ void numberSignPressed(QDeclarativeKeyEvent *event);
+ void escapePressed(QDeclarativeKeyEvent *event);
+ void returnPressed(QDeclarativeKeyEvent *event);
+ void enterPressed(QDeclarativeKeyEvent *event);
+ void deletePressed(QDeclarativeKeyEvent *event);
+ void spacePressed(QDeclarativeKeyEvent *event);
+ void backPressed(QDeclarativeKeyEvent *event);
+ void cancelPressed(QDeclarativeKeyEvent *event);
+ void selectPressed(QDeclarativeKeyEvent *event);
+ void yesPressed(QDeclarativeKeyEvent *event);
+ void noPressed(QDeclarativeKeyEvent *event);
+ void context1Pressed(QDeclarativeKeyEvent *event);
+ void context2Pressed(QDeclarativeKeyEvent *event);
+ void context3Pressed(QDeclarativeKeyEvent *event);
+ void context4Pressed(QDeclarativeKeyEvent *event);
+ void callPressed(QDeclarativeKeyEvent *event);
+ void hangupPressed(QDeclarativeKeyEvent *event);
+ void flipPressed(QDeclarativeKeyEvent *event);
+ void menuPressed(QDeclarativeKeyEvent *event);
+ void volumeUpPressed(QDeclarativeKeyEvent *event);
+ void volumeDownPressed(QDeclarativeKeyEvent *event);
+
+private:
+ virtual void keyPressed(QKeyEvent *event);
+ virtual void keyReleased(QKeyEvent *event);
+ virtual void inputMethodEvent(QInputMethodEvent *);
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+
+ const QByteArray keyToSignal(int key) {
+ QByteArray keySignal;
+ if (key >= Qt::Key_0 && key <= Qt::Key_9) {
+ keySignal = "digit0Pressed";
+ keySignal[5] = '0' + (key - Qt::Key_0);
+ } else {
+ int i = 0;
+ while (sigMap[i].key && sigMap[i].key != key)
+ ++i;
+ keySignal = sigMap[i].sig;
+ }
+ return keySignal;
+ }
+
+ struct SigMap {
+ int key;
+ const char *sig;
+ };
+
+ static const SigMap sigMap[];
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeItemPrivate::ChangeTypes);
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeKeysAttached)
+QML_DECLARE_TYPEINFO(QDeclarativeKeysAttached, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(QDeclarativeKeyNavigationAttached)
+QML_DECLARE_TYPEINFO(QDeclarativeKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES)
+
+#endif // QDECLARATIVEITEM_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativeitemchangelistener_p.h b/src/declarative/graphicsitems/qdeclarativeitemchangelistener_p.h
new file mode 100644
index 0000000..4da3bf7
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeitemchangelistener_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEITEMCHANGELISTENER
+#define QDECLARATIVEITEMCHANGELISTENER
+
+//
+// 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>
+
+QT_BEGIN_NAMESPACE
+
+class QRectF;
+class QDeclarativeItem;
+class QDeclarativeAnchorsPrivate;
+class QDeclarativeItemChangeListener
+{
+public:
+ virtual void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &) {}
+ virtual void itemSiblingOrderChanged(QDeclarativeItem *) {}
+ virtual void itemVisibilityChanged(QDeclarativeItem *) {}
+ virtual void itemOpacityChanged(QDeclarativeItem *) {}
+ virtual void itemDestroyed(QDeclarativeItem *) {}
+ virtual QDeclarativeAnchorsPrivate *anchorPrivate() { return 0; }
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEITEMCHANGELISTENER
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
new file mode 100644
index 0000000..f3b9385
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeitemsmodule_p.h"
+
+#include <QtGui/qaction.h>
+#include <QtGui/qvalidator.h>
+#include <QtGui/qgraphicseffect.h>
+
+#include "qdeclarativeevents_p_p.h"
+#include "qdeclarativeeffects_p.h"
+#include "qdeclarativescalegrid_p_p.h"
+#include "qdeclarativeanimatedimage_p.h"
+#include "qdeclarativeborderimage_p.h"
+#include "qdeclarativepositioners_p.h"
+#include "qdeclarativemousearea_p.h"
+#include "qdeclarativeflickable_p.h"
+#include "qdeclarativeflickable_p_p.h"
+#include "qdeclarativeflipable_p.h"
+#include "qdeclarativefocuspanel_p.h"
+#include "qdeclarativefocusscope_p.h"
+#include "qdeclarativegraphicsobjectcontainer_p.h"
+#include "qdeclarativegridview_p.h"
+#include "qdeclarativeimage_p.h"
+#include "qdeclarativeitem_p.h"
+#include "qdeclarativelayoutitem_p.h"
+#include "qdeclarativelistview_p.h"
+#include "qdeclarativeloader_p.h"
+#include "qdeclarativemousearea_p.h"
+#include "qdeclarativeparticles_p.h"
+#include "qdeclarativepath_p.h"
+#include "qdeclarativepathview_p.h"
+#include "qdeclarativerectangle_p.h"
+#include "qdeclarativerepeater_p.h"
+#include "qdeclarativetext_p.h"
+#include "qdeclarativetextedit_p.h"
+#include "qdeclarativetextinput_p.h"
+#include "qdeclarativevisualitemmodel_p.h"
+#ifdef QT_WEBKIT_LIB
+#include "qdeclarativewebview_p.h"
+#include "qdeclarativewebview_p_p.h"
+#endif
+#include "qdeclarativeanchors_p.h"
+
+void QDeclarativeItemModule::defineModule()
+{
+ QML_REGISTER_TYPE(Qt,4,6,AnimatedImage,QDeclarativeAnimatedImage);
+ QML_REGISTER_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect);
+ QML_REGISTER_TYPE(Qt,4,6,BorderImage,QDeclarativeBorderImage);
+ QML_REGISTER_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect);
+ QML_REGISTER_TYPE(Qt,4,6,Column,QDeclarativeColumn);
+ QML_REGISTER_TYPE(Qt,4,6,Drag,QDeclarativeDrag);
+ QML_REGISTER_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect);
+ QML_REGISTER_TYPE(Qt,4,6,Flickable,QDeclarativeFlickable);
+ QML_REGISTER_TYPE(Qt,4,6,Flipable,QDeclarativeFlipable);
+ QML_REGISTER_TYPE(Qt,4,6,Flow,QDeclarativeFlow);
+ QML_REGISTER_TYPE(Qt,4,6,FocusPanel,QDeclarativeFocusPanel);
+ QML_REGISTER_TYPE(Qt,4,6,FocusScope,QDeclarativeFocusScope);
+ QML_REGISTER_TYPE(Qt,4,6,Gradient,QDeclarativeGradient);
+ QML_REGISTER_TYPE(Qt,4,6,GradientStop,QDeclarativeGradientStop);
+ QML_REGISTER_TYPE(Qt,4,6,GraphicsObjectContainer,QDeclarativeGraphicsObjectContainer);
+ QML_REGISTER_TYPE(Qt,4,6,Grid,QDeclarativeGrid);
+ QML_REGISTER_TYPE(Qt,4,6,GridView,QDeclarativeGridView);
+ QML_REGISTER_TYPE(Qt,4,6,Image,QDeclarativeImage);
+ QML_REGISTER_TYPE(Qt,4,6,Item,QDeclarativeItem);
+ QML_REGISTER_TYPE(Qt,4,6,KeyNavigation,QDeclarativeKeyNavigationAttached);
+ QML_REGISTER_TYPE(Qt,4,6,Keys,QDeclarativeKeysAttached);
+ QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QDeclarativeLayoutItem);
+ QML_REGISTER_TYPE(Qt,4,6,ListView,QDeclarativeListView);
+ QML_REGISTER_TYPE(Qt,4,6,Loader,QDeclarativeLoader);
+ QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QDeclarativeMouseArea);
+ QML_REGISTER_TYPE(Qt,4,6,MouseArea,QDeclarativeMouseArea);
+ QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect);
+ QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QDeclarativeParticleMotion);
+ QML_REGISTER_TYPE(Qt,4,6,ParticleMotionGravity,QDeclarativeParticleMotionGravity);
+ QML_REGISTER_TYPE(Qt,4,6,ParticleMotionLinear,QDeclarativeParticleMotionLinear);
+ QML_REGISTER_TYPE(Qt,4,6,ParticleMotionWander,QDeclarativeParticleMotionWander);
+ QML_REGISTER_TYPE(Qt,4,6,Particles,QDeclarativeParticles);
+ QML_REGISTER_TYPE(Qt,4,6,Path,QDeclarativePath);
+ QML_REGISTER_TYPE(Qt,4,6,PathAttribute,QDeclarativePathAttribute);
+ QML_REGISTER_TYPE(Qt,4,6,PathCubic,QDeclarativePathCubic);
+ QML_REGISTER_TYPE(Qt,4,6,PathLine,QDeclarativePathLine);
+ QML_REGISTER_TYPE(Qt,4,6,PathPercent,QDeclarativePathPercent);
+ QML_REGISTER_TYPE(Qt,4,6,PathQuad,QDeclarativePathQuad);
+ QML_REGISTER_TYPE(Qt,4,6,PathView,QDeclarativePathView);
+ QML_REGISTER_TYPE(Qt,4,6,Pen,QDeclarativePen);
+ QML_REGISTER_TYPE(Qt,4,6,QIntValidator,QIntValidator);
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
+ QML_REGISTER_TYPE(Qt,4,7,QDoubleValidator,QDoubleValidator);
+ QML_REGISTER_TYPE(Qt,4,7,QRegExpValidator,QRegExpValidator);
+#endif
+ QML_REGISTER_TYPE(Qt,4,6,Rectangle,QDeclarativeRectangle);
+ QML_REGISTER_TYPE(Qt,4,6,Repeater,QDeclarativeRepeater);
+ QML_REGISTER_TYPE(Qt,4,6,Rotation,QGraphicsRotation);
+ QML_REGISTER_TYPE(Qt,4,6,Row,QDeclarativeRow);
+ QML_REGISTER_TYPE(Qt,4,6,Scale,QGraphicsScale);
+ QML_REGISTER_TYPE(Qt,4,6,Text,QDeclarativeText);
+ QML_REGISTER_TYPE(Qt,4,6,TextEdit,QDeclarativeTextEdit);
+ QML_REGISTER_TYPE(Qt,4,6,TextInput,QDeclarativeTextInput);
+ QML_REGISTER_TYPE(Qt,4,6,ViewSection,QDeclarativeViewSection);
+ QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QDeclarativeFlickableVisibleArea);
+ QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QDeclarativeVisualDataModel);
+ QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QDeclarativeVisualItemModel);
+#ifdef QT_WEBKIT_LIB
+ QML_REGISTER_TYPE(Qt,4,6,WebView,QDeclarativeWebView);
+#endif
+
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors);
+ QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect);
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeKeyEvent);
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeMouseEvent);
+ QML_REGISTER_NOCREATE_TYPE(QGraphicsObject);
+ QML_REGISTER_NOCREATE_TYPE(QGraphicsTransform);
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativePathElement);
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeCurve);
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeScaleGrid);
+ QML_REGISTER_NOCREATE_TYPE(QValidator);
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeVisualModel);
+ QML_REGISTER_NOCREATE_TYPE(QAction);
+#ifdef QT_WEBKIT_LIB
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeWebSettings);
+#endif
+}
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule_p.h b/src/declarative/graphicsitems/qdeclarativeitemsmodule_p.h
new file mode 100644
index 0000000..5c49040
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule_p.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEITEMMODULE_H
+#define QDECLARATIVEITEMMODULE_H
+
+#include <qdeclarative.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeItemModule
+{
+public:
+ static void defineModule();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEITEMMODULE_H
diff --git a/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp b/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp
new file mode 100644
index 0000000..a23ea65
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativelayoutitem_p.h"
+
+#include <QDebug>
+
+#include <limits.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass LayoutItem QDeclarativeLayoutItem
+ \since 4.7
+ \brief The LayoutItem element allows you to place your Fluid UI elements inside a classical Qt layout.
+
+ LayoutItem is a variant of Item with a couple of additional properties. These properties provide the size hints
+ needed for items to work in conjunction with Qt Layouts. The Qt Layout will resize the LayoutItem as appropriate,
+ taking its size hints into account, and you can propagate this to the other elements in your UI via anchors and bindings.
+
+ This is a QGraphicsLayoutItem subclass, and the properties merely expose the QGraphicsLayoutItem functionality to QML.
+ See the QGraphicsLayoutItem documentation for further details.
+*/
+
+/*!
+ \internal
+ \class QDeclarativeLayoutItem
+ \brief The QDeclarativeLayoutItem class allows you to place your Fluid UI elements inside a classical Qt layout.
+*/
+
+
+/*!
+ \qmlproperty QSizeF LayoutItem::maximumSize
+
+ The maximumSize property can be set to specify the maximum desired size of this LayoutItem
+*/
+
+/*!
+ \qmlproperty QSizeF LayoutItem::minimumSize
+
+ The minimumSize property can be set to specify the minimum desired size of this LayoutItem
+*/
+
+/*!
+ \qmlproperty QSizeF LayoutItem::preferredSize
+
+ The preferredSize property can be set to specify the preferred size of this LayoutItem
+*/
+
+QDeclarativeLayoutItem::QDeclarativeLayoutItem(QDeclarativeItem* parent)
+ : QDeclarativeItem(parent), m_maximumSize(INT_MAX,INT_MAX), m_minimumSize(0,0), m_preferredSize(0,0)
+{
+ setGraphicsItem(this);
+}
+
+void QDeclarativeLayoutItem::setGeometry(const QRectF & rect)
+{
+ setX(rect.x());
+ setY(rect.y());
+ setWidth(rect.width());
+ setHeight(rect.height());
+}
+
+QSizeF QDeclarativeLayoutItem::sizeHint(Qt::SizeHint w, const QSizeF &constraint) const
+{
+ Q_UNUSED(constraint);
+ if(w == Qt::MinimumSize){
+ return m_minimumSize;
+ }else if(w == Qt::MaximumSize){
+ return m_maximumSize;
+ }else{
+ return m_preferredSize;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativelayoutitem_p.h b/src/declarative/graphicsitems/qdeclarativelayoutitem_p.h
new file mode 100644
index 0000000..b35f2f5
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativelayoutitem_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEGRAPHICSLAYOUTITEM_H
+#define QDECLARATIVEGRAPHICSLAYOUTITEM_H
+#include "qdeclarativeitem.h"
+
+#include <QGraphicsLayoutItem>
+#include <QSizeF>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeLayoutItem : public QDeclarativeItem, public QGraphicsLayoutItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsLayoutItem)
+ Q_PROPERTY(QSizeF maximumSize READ maximumSize WRITE setMaximumSize NOTIFY maximumSizeChanged)
+ Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize NOTIFY minimumSizeChanged)
+ Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize NOTIFY preferredSizeChanged)
+public:
+ QDeclarativeLayoutItem(QDeclarativeItem* parent=0);
+
+ QSizeF maximumSize() const { return m_maximumSize; }
+ void setMaximumSize(const QSizeF &s) { if(s==m_maximumSize) return; m_maximumSize = s; emit maximumSizeChanged(); }
+
+ QSizeF minimumSize() const { return m_minimumSize; }
+ void setMinimumSize(const QSizeF &s) { if(s==m_minimumSize) return; m_minimumSize = s; emit minimumSizeChanged(); }
+
+ QSizeF preferredSize() const { return m_preferredSize; }
+ void setPreferredSize(const QSizeF &s) { if(s==m_preferredSize) return; m_preferredSize = s; emit preferredSizeChanged(); }
+
+ virtual void setGeometry(const QRectF & rect);
+protected:
+ virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+
+Q_SIGNALS:
+ void maximumSizeChanged();
+ void minimumSizeChanged();
+ void preferredSizeChanged();
+
+private:
+ QSizeF m_maximumSize;
+ QSizeF m_minimumSize;
+ QSizeF m_preferredSize;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeLayoutItem)
+
+QT_END_HEADER
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
new file mode 100644
index 0000000..d471749
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -0,0 +1,2716 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativelistview_p.h"
+
+#include "qdeclarativeflickable_p_p.h"
+#include "qdeclarativevisualitemmodel_p.h"
+
+#include <qdeclarativeeasefollow_p.h>
+#include <qdeclarativeexpression.h>
+#include <qdeclarativeengine.h>
+
+#include <qlistmodelinterface_p.h>
+#include <QKeyEvent>
+
+QT_BEGIN_NAMESPACE
+
+void QDeclarativeViewSection::setProperty(const QString &property)
+{
+ if (property != m_property) {
+ m_property = property;
+ emit changed();
+ }
+}
+
+void QDeclarativeViewSection::setCriteria(QDeclarativeViewSection::SectionCriteria criteria)
+{
+ if (criteria != m_criteria) {
+ m_criteria = criteria;
+ emit changed();
+ }
+}
+
+void QDeclarativeViewSection::setDelegate(QDeclarativeComponent *delegate)
+{
+ if (delegate != m_delegate) {
+ m_delegate = delegate;
+ emit delegateChanged();
+ }
+}
+
+QString QDeclarativeViewSection::sectionString(const QString &value)
+{
+ if (m_criteria == FirstCharacter)
+ return value.isEmpty() ? QString() : value.at(0);
+ else
+ return value;
+}
+
+//----------------------------------------------------------------------------
+
+class FxListItem
+{
+public:
+ FxListItem(QDeclarativeItem *i, QDeclarativeListView *v) : item(i), section(0), view(v) {
+ attached = static_cast<QDeclarativeListViewAttached*>(qmlAttachedPropertiesObject<QDeclarativeListView>(item));
+ if (attached)
+ attached->m_view = view;
+ }
+ ~FxListItem() {}
+ qreal position() const {
+ if (section)
+ return (view->orientation() == QDeclarativeListView::Vertical ? section->y() : section->x());
+ else
+ return (view->orientation() == QDeclarativeListView::Vertical ? item->y() : item->x());
+ }
+ int size() const {
+ if (section)
+ return (view->orientation() == QDeclarativeListView::Vertical ? item->height()+section->height() : item->width()+section->height());
+ else
+ return (view->orientation() == QDeclarativeListView::Vertical ? item->height() : item->width());
+ }
+ qreal endPosition() const {
+ return (view->orientation() == QDeclarativeListView::Vertical
+ ? item->y() + (item->height() > 0 ? item->height() : 1)
+ : item->x() + (item->width() > 0 ? item->width() : 1)) - 1;
+ }
+ void setPosition(qreal pos) {
+ if (view->orientation() == QDeclarativeListView::Vertical) {
+ if (section) {
+ section->setY(pos);
+ pos += section->height();
+ }
+ item->setY(pos);
+ } else {
+ if (section) {
+ section->setX(pos);
+ pos += section->width();
+ }
+ item->setX(pos);
+ }
+ }
+
+ QDeclarativeItem *item;
+ QDeclarativeItem *section;
+ QDeclarativeListView *view;
+ QDeclarativeListViewAttached *attached;
+ int index;
+};
+
+//----------------------------------------------------------------------------
+
+class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate, private QDeclarativeItemChangeListener
+{
+ Q_DECLARE_PUBLIC(QDeclarativeListView)
+
+public:
+ QDeclarativeListViewPrivate()
+ : currentItem(0), orient(QDeclarativeListView::Vertical)
+ , visiblePos(0), visibleIndex(0)
+ , averageSize(100.0), currentIndex(-1), requestedIndex(-1)
+ , highlightRangeStart(0), highlightRangeEnd(0)
+ , highlightComponent(0), highlight(0), trackedItem(0)
+ , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0)
+ , sectionCriteria(0), spacing(0.0)
+ , highlightMoveSpeed(400), highlightResizeSpeed(400), highlightRange(QDeclarativeListView::NoHighlightRange)
+ , snapMode(QDeclarativeListView::NoSnap), overshootDist(0.0)
+ , footerComponent(0), footer(0), headerComponent(0), header(0)
+ , bufferMode(NoBuffer)
+ , ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false)
+ , correctFlick(true), inFlickCorrection(false), lazyRelease(false)
+ , deferredRelease(false), minExtentDirty(true), maxExtentDirty(true)
+ {}
+
+ void init();
+ void clear();
+ FxListItem *createItem(int modelIndex);
+ void releaseItem(FxListItem *item);
+
+ FxListItem *visibleItem(int modelIndex) const {
+ if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) {
+ for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) {
+ FxListItem *item = visibleItems.at(i);
+ if (item->index == modelIndex)
+ return item;
+ }
+ }
+ return 0;
+ }
+
+ FxListItem *firstVisibleItem() const {
+ const qreal pos = position();
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxListItem *item = visibleItems.at(i);
+ if (item->index != -1 && item->endPosition() > pos)
+ return item;
+ }
+ return visibleItems.count() ? visibleItems.first() : 0;
+ }
+
+ FxListItem *nextVisibleItem() const {
+ const qreal pos = position();
+ bool foundFirst = false;
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxListItem *item = visibleItems.at(i);
+ if (item->index != -1) {
+ if (foundFirst)
+ return item;
+ else if (item->position() < pos && item->endPosition() > pos)
+ foundFirst = true;
+ }
+ }
+ return 0;
+ }
+
+ qreal position() const {
+ Q_Q(const QDeclarativeListView);
+ return orient == QDeclarativeListView::Vertical ? q->viewportY() : q->viewportX();
+ }
+ void setPosition(qreal pos) {
+ Q_Q(QDeclarativeListView);
+ if (orient == QDeclarativeListView::Vertical)
+ q->setViewportY(pos);
+ else
+ q->setViewportX(pos);
+ }
+ qreal size() const {
+ Q_Q(const QDeclarativeListView);
+ return orient == QDeclarativeListView::Vertical ? q->height() : q->width();
+ }
+
+ qreal startPosition() const {
+ qreal pos = 0;
+ if (!visibleItems.isEmpty()) {
+ pos = (*visibleItems.constBegin())->position();
+ if (visibleIndex > 0)
+ pos -= visibleIndex * (averageSize + spacing) - spacing;
+ }
+ return pos;
+ }
+
+ qreal endPosition() const {
+ qreal pos = 0;
+ if (!visibleItems.isEmpty()) {
+ int invisibleCount = visibleItems.count() - visibleIndex;
+ for (int i = visibleItems.count()-1; i >= 0; --i) {
+ if (visibleItems.at(i)->index != -1) {
+ invisibleCount = model->count() - visibleItems.at(i)->index - 1;
+ break;
+ }
+ }
+ pos = (*(--visibleItems.constEnd()))->endPosition() + invisibleCount * (averageSize + spacing);
+ }
+ return pos;
+ }
+
+ qreal positionAt(int modelIndex) const {
+ if (FxListItem *item = visibleItem(modelIndex))
+ return item->position();
+ if (!visibleItems.isEmpty()) {
+ if (modelIndex < visibleIndex) {
+ int count = visibleIndex - modelIndex;
+ return (*visibleItems.constBegin())->position() - count * (averageSize + spacing);
+ } else {
+ int idx = visibleItems.count() - 1;
+ while (idx >= 0 && visibleItems.at(idx)->index == -1)
+ --idx;
+ if (idx < 0)
+ idx = visibleIndex;
+ else
+ idx = visibleItems.at(idx)->index;
+ int count = modelIndex - idx - 1;
+ return (*(--visibleItems.constEnd()))->endPosition() + spacing + count * (averageSize + spacing) + 1;
+ }
+ }
+ return 0;
+ }
+
+ QString sectionAt(int modelIndex) {
+ if (FxListItem *item = visibleItem(modelIndex))
+ return item->attached->section();
+
+ QString section;
+ if (sectionCriteria) {
+ QString propValue = model->stringValue(modelIndex, sectionCriteria->property());
+ section = sectionCriteria->sectionString(propValue);
+ }
+
+ return section;
+ }
+
+ bool isValid() const {
+ return model && model->count() && model->isValid();
+ }
+
+ int snapIndex() {
+ int index = currentIndex;
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxListItem *item = visibleItems[i];
+ if (item->index == -1)
+ continue;
+ qreal itemTop = item->position();
+ if (itemTop >= highlight->position()-item->size()/2 && itemTop < highlight->position()+item->size()/2)
+ return item->index;
+ }
+ return index;
+ }
+
+ qreal snapPosAt(qreal pos) {
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxListItem *item = visibleItems[i];
+ if (item->index == -1)
+ continue;
+ qreal itemTop = item->position();
+ if (item->index == model->count()-1 || (itemTop+item->size()/2 >= pos))
+ return item->position();
+ }
+ if (visibleItems.count()) {
+ qreal firstPos = visibleItems.first()->position();
+ qreal endPos = visibleItems.last()->position();
+ if (pos < firstPos) {
+ return firstPos - qRound((firstPos - pos) / averageSize) * averageSize;
+ } else if (pos > endPos)
+ return endPos + qRound((pos - endPos) / averageSize) * averageSize;
+ }
+ return qRound((pos - startPosition()) / averageSize) * averageSize + startPosition();
+ }
+
+ FxListItem *snapItemAt(qreal pos) {
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxListItem *item = visibleItems[i];
+ if (item->index == -1)
+ continue;
+ qreal itemTop = item->position();
+ if (item->index == model->count()-1 || (itemTop+item->size()/2 >= pos))
+ return item;
+ }
+ if (visibleItems.count() && visibleItems.first()->position() <= pos)
+ return visibleItems.first();
+ return 0;
+ }
+
+ int lastVisibleIndex() const {
+ int lastIndex = -1;
+ for (int i = visibleItems.count()-1; i >= 0; --i) {
+ FxListItem *listItem = visibleItems.at(i);
+ if (listItem->index != -1) {
+ lastIndex = listItem->index;
+ break;
+ }
+ }
+ return lastIndex;
+ }
+
+ // map a model index to visibleItems index.
+ // These may differ if removed items are still present in the visible list,
+ // e.g. doing a removal animation
+ int mapFromModel(int modelIndex) const {
+ if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count())
+ return -1;
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxListItem *listItem = visibleItems.at(i);
+ if (listItem->index == modelIndex)
+ return i + visibleIndex;
+ if (listItem->index > modelIndex)
+ return -1;
+ }
+ return -1; // Not in visibleList
+ }
+
+ bool mapRangeFromModel(int &index, int &count) const {
+ if (index + count < visibleIndex)
+ return false;
+
+ int lastIndex = -1;
+ for (int i = visibleItems.count()-1; i >= 0; --i) {
+ FxListItem *listItem = visibleItems.at(i);
+ if (listItem->index != -1) {
+ lastIndex = listItem->index;
+ break;
+ }
+ }
+
+ if (index > lastIndex)
+ return false;
+
+ int last = qMin(index + count - 1, lastIndex);
+ index = qMax(index, visibleIndex);
+ count = last - index + 1;
+
+ return true;
+ }
+
+ void updateViewport() {
+ Q_Q(QDeclarativeListView);
+ if (orient == QDeclarativeListView::Vertical) {
+ q->setViewportHeight(endPosition() - startPosition() + 1);
+ } else {
+ q->setViewportWidth(endPosition() - startPosition() + 1);
+ }
+ }
+
+ void itemGeometryChanged(QDeclarativeItem *, const QRectF &newGeometry, const QRectF &oldGeometry) {
+ if ((orient == QDeclarativeListView::Vertical && newGeometry.height() != oldGeometry.height())
+ || newGeometry.width() != oldGeometry.width()) {
+ layout();
+ fixupPosition();
+ }
+ }
+
+ // for debugging only
+ void checkVisible() const {
+ int skip = 0;
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxListItem *listItem = visibleItems.at(i);
+ if (listItem->index == -1) {
+ ++skip;
+ } else if (listItem->index != visibleIndex + i - skip) {
+ qFatal("index %d %d %d", visibleIndex, i, listItem->index);
+ }
+ }
+ }
+
+ void refill(qreal from, qreal to, bool doBuffer = false);
+ void layout();
+ void updateUnrequestedIndexes();
+ void updateUnrequestedPositions();
+ void updateTrackedItem();
+ void createHighlight();
+ void updateHighlight();
+ void createSection(FxListItem *);
+ void updateSections();
+ void updateCurrentSection();
+ void updateCurrent(int);
+ void updateAverage();
+ void updateHeader();
+ void updateFooter();
+ void fixupPosition();
+ virtual void fixupY();
+ virtual void fixupX();
+ virtual void flickX(qreal velocity);
+ virtual void flickY(qreal velocity);
+
+ QGuard<QDeclarativeVisualModel> model;
+ QVariant modelVariant;
+ QList<FxListItem*> visibleItems;
+ QHash<QDeclarativeItem*,int> unrequestedItems;
+ FxListItem *currentItem;
+ QDeclarativeListView::Orientation orient;
+ int visiblePos;
+ int visibleIndex;
+ qreal averageSize;
+ int currentIndex;
+ int requestedIndex;
+ qreal highlightRangeStart;
+ qreal highlightRangeEnd;
+ QDeclarativeComponent *highlightComponent;
+ FxListItem *highlight;
+ FxListItem *trackedItem;
+ enum MovementReason { Other, SetIndex, Mouse };
+ MovementReason moveReason;
+ int buffer;
+ QDeclarativeEaseFollow *highlightPosAnimator;
+ QDeclarativeEaseFollow *highlightSizeAnimator;
+ QDeclarativeViewSection *sectionCriteria;
+ QString currentSection;
+ static const int sectionCacheSize = 3;
+ QDeclarativeItem *sectionCache[sectionCacheSize];
+ qreal spacing;
+ qreal highlightMoveSpeed;
+ qreal highlightResizeSpeed;
+ QDeclarativeListView::HighlightRangeMode highlightRange;
+ QDeclarativeListView::SnapMode snapMode;
+ qreal overshootDist;
+ QDeclarativeComponent *footerComponent;
+ FxListItem *footer;
+ QDeclarativeComponent *headerComponent;
+ FxListItem *header;
+ enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 };
+ int bufferMode;
+ mutable qreal minExtent;
+ mutable qreal maxExtent;
+
+ bool ownModel : 1;
+ bool wrap : 1;
+ bool autoHighlight : 1;
+ bool haveHighlightRange : 1;
+ bool correctFlick : 1;
+ bool inFlickCorrection : 1;
+ bool lazyRelease : 1;
+ bool deferredRelease : 1;
+ mutable bool minExtentDirty : 1;
+ mutable bool maxExtentDirty : 1;
+};
+
+void QDeclarativeListViewPrivate::init()
+{
+ Q_Q(QDeclarativeListView);
+ q->setFlag(QGraphicsItem::ItemIsFocusScope);
+ addItemChangeListener(this, Geometry);
+ QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped()));
+ q->setFlickDirection(QDeclarativeFlickable::VerticalFlick);
+ ::memset(sectionCache, 0, sizeof(QDeclarativeItem*) * sectionCacheSize);
+}
+
+void QDeclarativeListViewPrivate::clear()
+{
+ for (int i = 0; i < visibleItems.count(); ++i)
+ releaseItem(visibleItems.at(i));
+ visibleItems.clear();
+ for (int i = 0; i < sectionCacheSize; ++i) {
+ delete sectionCache[i];
+ sectionCache[i] = 0;
+ }
+ visiblePos = header ? header->size() : 0;
+ visibleIndex = 0;
+ releaseItem(currentItem);
+ currentItem = 0;
+ createHighlight();
+ trackedItem = 0;
+ minExtentDirty = true;
+ maxExtentDirty = true;
+}
+
+FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex)
+{
+ Q_Q(QDeclarativeListView);
+ // create object
+ requestedIndex = modelIndex;
+ FxListItem *listItem = 0;
+ if (QDeclarativeItem *item = model->item(modelIndex, false)) {
+ listItem = new FxListItem(item, q);
+ listItem->index = modelIndex;
+ // initialise attached properties
+ if (sectionCriteria) {
+ QString propValue = model->stringValue(modelIndex, sectionCriteria->property());
+ listItem->attached->m_section = sectionCriteria->sectionString(propValue);
+ if (modelIndex > 0) {
+ if (FxListItem *item = visibleItem(modelIndex-1))
+ listItem->attached->m_prevSection = item->attached->section();
+ else
+ listItem->attached->m_prevSection = sectionAt(modelIndex-1);
+ }
+ }
+ // complete
+ model->completeItem();
+ listItem->item->setZValue(1);
+ listItem->item->setParent(q->viewport());
+ QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
+ itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ if (sectionCriteria && sectionCriteria->delegate()) {
+ if (listItem->attached->m_prevSection != listItem->attached->m_section)
+ createSection(listItem);
+ }
+ unrequestedItems.remove(listItem->item);
+ }
+ requestedIndex = -1;
+
+ return listItem;
+}
+
+void QDeclarativeListViewPrivate::releaseItem(FxListItem *item)
+{
+ Q_Q(QDeclarativeListView);
+ if (!item || !model)
+ return;
+ if (trackedItem == item) {
+ const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
+ const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
+ QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
+ QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
+ trackedItem = 0;
+ }
+ QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item->item));
+ itemPrivate->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ if (model->release(item->item) == 0) {
+ // item was not destroyed, and we no longer reference it.
+ unrequestedItems.insert(item->item, model->indexOf(item->item, q));
+ }
+ if (item->section) {
+ int i = 0;
+ do {
+ if (!sectionCache[i]) {
+ sectionCache[i] = item->section;
+ sectionCache[i]->setVisible(false);
+ item->section = 0;
+ break;
+ }
+ ++i;
+ } while (i < sectionCacheSize);
+ delete item->section;
+ }
+ delete item;
+}
+
+void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
+{
+ Q_Q(QDeclarativeListView);
+ if (!isValid() || !q->isComponentComplete())
+ return;
+ qreal bufferFrom = from - buffer;
+ qreal bufferTo = to + buffer;
+ qreal fillFrom = from;
+ qreal fillTo = to;
+ if (doBuffer && (bufferMode & BufferAfter))
+ fillTo = bufferTo;
+ if (doBuffer && (bufferMode & BufferBefore))
+ fillFrom = bufferFrom;
+
+ int modelIndex = visibleIndex;
+ qreal itemEnd = visiblePos-1;
+ if (!visibleItems.isEmpty()) {
+ visiblePos = (*visibleItems.constBegin())->position();
+ itemEnd = (*(--visibleItems.constEnd()))->endPosition() + spacing;
+ int i = visibleItems.count() - 1;
+ while (i > 0 && visibleItems.at(i)->index == -1)
+ --i;
+ modelIndex = visibleItems.at(i)->index + 1;
+ }
+
+ bool changed = false;
+ FxListItem *item = 0;
+ int pos = itemEnd + 1;
+ while (modelIndex < model->count() && pos <= fillTo) {
+ //qDebug() << "refill: append item" << modelIndex << "pos" << pos;
+ if (!(item = createItem(modelIndex)))
+ break;
+ item->setPosition(pos);
+ pos += item->size() + spacing;
+ visibleItems.append(item);
+ ++modelIndex;
+ changed = true;
+ if (doBuffer) // never buffer more than one item per frame
+ break;
+ }
+ while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos > fillFrom) {
+ //qDebug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos;
+ if (!(item = createItem(visibleIndex-1)))
+ break;
+ --visibleIndex;
+ visiblePos -= item->size() + spacing;
+ item->setPosition(visiblePos);
+ visibleItems.prepend(item);
+ changed = true;
+ if (doBuffer) // never buffer more than one item per frame
+ break;
+ }
+
+ if (!lazyRelease || !changed || deferredRelease) { // avoid destroying items in the same frame that we create
+ while (visibleItems.count() > 1 && (item = visibleItems.first()) && item->endPosition() < bufferFrom) {
+ if (item->attached->delayRemove())
+ break;
+ //qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endPosition();
+ if (item->index != -1)
+ visibleIndex++;
+ visibleItems.removeFirst();
+ releaseItem(item);
+ changed = true;
+ }
+ while (visibleItems.count() > 1 && (item = visibleItems.last()) && item->position() > bufferTo) {
+ if (item->attached->delayRemove())
+ break;
+ //qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1;
+ visibleItems.removeLast();
+ releaseItem(item);
+ changed = true;
+ }
+ deferredRelease = false;
+ } else {
+ deferredRelease = true;
+ }
+ if (changed) {
+ minExtentDirty = true;
+ maxExtentDirty = true;
+ if (visibleItems.count())
+ visiblePos = (*visibleItems.constBegin())->position();
+ updateAverage();
+ if (sectionCriteria)
+ updateCurrentSection();
+ if (header)
+ updateHeader();
+ if (footer)
+ updateFooter();
+ updateViewport();
+ updateUnrequestedPositions();
+ } else if (!doBuffer && buffer && bufferMode != NoBuffer) {
+ refill(from, to, true);
+ }
+ lazyRelease = false;
+}
+
+void QDeclarativeListViewPrivate::layout()
+{
+ Q_Q(QDeclarativeListView);
+ updateSections();
+ if (!visibleItems.isEmpty()) {
+ int oldEnd = visibleItems.last()->endPosition();
+ int pos = visibleItems.first()->endPosition() + spacing + 1;
+ for (int i=1; i < visibleItems.count(); ++i) {
+ FxListItem *item = visibleItems.at(i);
+ item->setPosition(pos);
+ pos += item->size() + spacing;
+ }
+ // move current item if it is after the visible items.
+ if (currentItem && currentIndex > lastVisibleIndex())
+ currentItem->setPosition(currentItem->position() + (visibleItems.last()->endPosition() - oldEnd));
+ }
+ if (!isValid())
+ return;
+ q->refill();
+ minExtentDirty = true;
+ maxExtentDirty = true;
+ updateHighlight();
+ fixupPosition();
+ q->refill();
+ if (header)
+ updateHeader();
+ if (footer)
+ updateFooter();
+ updateViewport();
+}
+
+void QDeclarativeListViewPrivate::updateUnrequestedIndexes()
+{
+ Q_Q(QDeclarativeListView);
+ QHash<QDeclarativeItem*,int>::iterator it;
+ for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it)
+ *it = model->indexOf(it.key(), q);
+}
+
+void QDeclarativeListViewPrivate::updateUnrequestedPositions()
+{
+ Q_Q(QDeclarativeListView);
+ if (unrequestedItems.count()) {
+ qreal pos = position();
+ QHash<QDeclarativeItem*,int>::const_iterator it;
+ for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) {
+ QDeclarativeItem *item = it.key();
+ if (orient == QDeclarativeListView::Vertical) {
+ if (item->y() + item->height() > pos && item->y() < pos + q->height())
+ item->setY(positionAt(*it));
+ } else {
+ if (item->x() + item->width() > pos && item->x() < pos + q->width())
+ item->setX(positionAt(*it));
+ }
+ }
+ }
+}
+
+void QDeclarativeListViewPrivate::updateTrackedItem()
+{
+ Q_Q(QDeclarativeListView);
+ FxListItem *item = currentItem;
+ if (highlight)
+ item = highlight;
+
+ FxListItem *oldTracked = trackedItem;
+
+ const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
+ const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
+
+ if (trackedItem && item != trackedItem) {
+ QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
+ QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
+ trackedItem = 0;
+ }
+
+ if (!trackedItem && item) {
+ trackedItem = item;
+ QObject::connect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
+ QObject::connect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
+ }
+ if (trackedItem && trackedItem != oldTracked)
+ q->trackedPositionChanged();
+}
+
+void QDeclarativeListViewPrivate::createHighlight()
+{
+ Q_Q(QDeclarativeListView);
+ bool changed = false;
+ if (highlight) {
+ if (trackedItem == highlight)
+ trackedItem = 0;
+ delete highlight->item;
+ delete highlight;
+ highlight = 0;
+ delete highlightPosAnimator;
+ delete highlightSizeAnimator;
+ highlightPosAnimator = 0;
+ highlightSizeAnimator = 0;
+ changed = true;
+ }
+
+ if (currentItem) {
+ QDeclarativeItem *item = 0;
+ if (highlightComponent) {
+ QDeclarativeContext *highlightContext = new QDeclarativeContext(qmlContext(q));
+ QObject *nobj = highlightComponent->create(highlightContext);
+ if (nobj) {
+ highlightContext->setParent(nobj);
+ item = qobject_cast<QDeclarativeItem *>(nobj);
+ if (!item)
+ delete nobj;
+ } else {
+ delete highlightContext;
+ }
+ } else {
+ item = new QDeclarativeItem;
+ }
+ if (item) {
+ item->setParent(q->viewport());
+ highlight = new FxListItem(item, q);
+ if (orient == QDeclarativeListView::Vertical)
+ highlight->item->setHeight(currentItem->item->height());
+ else
+ highlight->item->setWidth(currentItem->item->width());
+ const QLatin1String posProp(orient == QDeclarativeListView::Vertical ? "y" : "x");
+ highlightPosAnimator = new QDeclarativeEaseFollow(q);
+ highlightPosAnimator->setTarget(QDeclarativeMetaProperty(highlight->item, posProp));
+ highlightPosAnimator->setVelocity(highlightMoveSpeed);
+ highlightPosAnimator->setEnabled(autoHighlight);
+ const QLatin1String sizeProp(orient == QDeclarativeListView::Vertical ? "height" : "width");
+ highlightSizeAnimator = new QDeclarativeEaseFollow(q);
+ highlightSizeAnimator->setVelocity(highlightResizeSpeed);
+ highlightSizeAnimator->setTarget(QDeclarativeMetaProperty(highlight->item, sizeProp));
+ highlightSizeAnimator->setEnabled(autoHighlight);
+ changed = true;
+ }
+ }
+ if (changed)
+ emit q->highlightChanged();
+}
+
+void QDeclarativeListViewPrivate::updateHighlight()
+{
+ if ((!currentItem && highlight) || (currentItem && !highlight))
+ createHighlight();
+ if (currentItem && autoHighlight && highlight && !moving) {
+ // auto-update highlight
+ highlightPosAnimator->setSourceValue(currentItem->position());
+ highlightSizeAnimator->setSourceValue(currentItem->size());
+ if (orient == QDeclarativeListView::Vertical) {
+ if (highlight->item->width() == 0)
+ highlight->item->setWidth(currentItem->item->width());
+ } else {
+ if (highlight->item->height() == 0)
+ highlight->item->setHeight(currentItem->item->height());
+ }
+ }
+ updateTrackedItem();
+}
+
+void QDeclarativeListViewPrivate::createSection(FxListItem *listItem)
+{
+ Q_Q(QDeclarativeListView);
+ if (!sectionCriteria || !sectionCriteria->delegate())
+ return;
+ if (listItem->attached->m_prevSection != listItem->attached->m_section) {
+ if (!listItem->section) {
+ int i = sectionCacheSize-1;
+ while (i >= 0 && !sectionCache[i])
+ --i;
+ if (i >= 0) {
+ listItem->section = sectionCache[i];
+ sectionCache[i] = 0;
+ listItem->section->setVisible(true);
+ QDeclarativeContext *context = QDeclarativeEngine::contextForObject(listItem->section)->parentContext();
+ context->setContextProperty(QLatin1String("section"), listItem->attached->m_section);
+ } else {
+ QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q));
+ context->setContextProperty(QLatin1String("section"), listItem->attached->m_section);
+ QObject *nobj = sectionCriteria->delegate()->create(context);
+ if (nobj) {
+ context->setParent(nobj);
+ listItem->section = qobject_cast<QDeclarativeItem *>(nobj);
+ if (!listItem->section) {
+ delete nobj;
+ } else {
+ listItem->section->setZValue(1);
+ listItem->section->setParent(q->viewport());
+ }
+ } else {
+ delete context;
+ }
+ }
+ }
+ } else if (listItem->section) {
+ int i = 0;
+ do {
+ if (!sectionCache[i]) {
+ sectionCache[i] = listItem->section;
+ sectionCache[i]->setVisible(false);
+ listItem->section = 0;
+ return;
+ }
+ ++i;
+ } while (i < sectionCacheSize);
+ delete listItem->section;
+ listItem->section = 0;
+ }
+}
+
+void QDeclarativeListViewPrivate::updateSections()
+{
+ if (sectionCriteria) {
+ QString prevSection;
+ if (visibleIndex > 0)
+ prevSection = sectionAt(visibleIndex-1);
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ if (visibleItems.at(i)->index != -1) {
+ QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached;
+ attached->setPrevSection(prevSection);
+ createSection(visibleItems.at(i));
+ prevSection = attached->section();
+ }
+ }
+ }
+}
+
+void QDeclarativeListViewPrivate::updateCurrentSection()
+{
+ if (!sectionCriteria || visibleItems.isEmpty()) {
+ currentSection = QString();
+ return;
+ }
+ int index = 0;
+ while (visibleItems.at(index)->endPosition() < position() && index < visibleItems.count())
+ ++index;
+
+ if (index < visibleItems.count())
+ currentSection = visibleItems.at(index)->attached->section();
+ else
+ currentSection = visibleItems.first()->attached->section();
+}
+
+void QDeclarativeListViewPrivate::updateCurrent(int modelIndex)
+{
+ Q_Q(QDeclarativeListView);
+ if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) {
+ if (currentItem) {
+ currentItem->attached->setIsCurrentItem(false);
+ releaseItem(currentItem);
+ currentItem = 0;
+ currentIndex = -1;
+ updateHighlight();
+ emit q->currentIndexChanged();
+ }
+ return;
+ }
+
+ if (currentItem && currentIndex == modelIndex) {
+ updateHighlight();
+ return;
+ }
+ FxListItem *oldCurrentItem = currentItem;
+ currentIndex = modelIndex;
+ currentItem = createItem(modelIndex);
+ if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item))
+ oldCurrentItem->attached->setIsCurrentItem(false);
+ if (currentItem) {
+ if (modelIndex == visibleIndex - 1) {
+ // We can calculate exact postion in this case
+ currentItem->setPosition(visibleItems.first()->position() - currentItem->size() - spacing);
+ } else {
+ // Create current item now and position as best we can.
+ // Its position will be corrected when it becomes visible.
+ currentItem->setPosition(positionAt(modelIndex));
+ }
+ currentItem->item->setFocus(true);
+ currentItem->attached->setIsCurrentItem(true);
+ }
+ updateHighlight();
+ emit q->currentIndexChanged();
+ // Release the old current item
+ releaseItem(oldCurrentItem);
+}
+
+void QDeclarativeListViewPrivate::updateAverage()
+{
+ if (!visibleItems.count())
+ return;
+ qreal sum = 0.0;
+ for (int i = 0; i < visibleItems.count(); ++i)
+ sum += visibleItems.at(i)->size();
+ averageSize = sum / visibleItems.count();
+}
+
+void QDeclarativeListViewPrivate::updateFooter()
+{
+ Q_Q(QDeclarativeListView);
+ if (!footer && footerComponent) {
+ QDeclarativeItem *item = 0;
+ QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q));
+ QObject *nobj = footerComponent->create(context);
+ if (nobj) {
+ context->setParent(nobj);
+ item = qobject_cast<QDeclarativeItem *>(nobj);
+ if (!item)
+ delete nobj;
+ } else {
+ delete context;
+ }
+ if (item) {
+ item->setParent(q->viewport());
+ item->setZValue(1);
+ footer = new FxListItem(item, q);
+ }
+ }
+ if (footer) {
+ if (visibleItems.count()) {
+ qreal endPos = endPosition();
+ if (lastVisibleIndex() == model->count()-1) {
+ footer->setPosition(endPos);
+ } else {
+ qreal visiblePos = position() + q->height();
+ if (endPos <= visiblePos || footer->position() < endPos)
+ footer->setPosition(endPos);
+ }
+ } else {
+ footer->setPosition(visiblePos);
+ }
+ }
+}
+
+void QDeclarativeListViewPrivate::updateHeader()
+{
+ Q_Q(QDeclarativeListView);
+ if (!header && headerComponent) {
+ QDeclarativeItem *item = 0;
+ QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q));
+ QObject *nobj = headerComponent->create(context);
+ if (nobj) {
+ context->setParent(nobj);
+ item = qobject_cast<QDeclarativeItem *>(nobj);
+ if (!item)
+ delete nobj;
+ } else {
+ delete context;
+ }
+ if (item) {
+ item->setParent(q->viewport());
+ item->setZValue(1);
+ header = new FxListItem(item, q);
+ if (visibleItems.isEmpty())
+ visiblePos = header->size();
+ }
+ }
+ if (header) {
+ if (visibleItems.count()) {
+ qreal startPos = startPosition();
+ if (visibleIndex == 0) {
+ header->setPosition(startPos - header->size());
+ } else {
+ if (position() <= startPos || header->position() > startPos - header->size())
+ header->setPosition(startPos - header->size());
+ }
+ } else {
+ header->setPosition(0);
+ }
+ }
+}
+
+void QDeclarativeListViewPrivate::fixupPosition()
+{
+ moveReason = Other;
+ if (orient == QDeclarativeListView::Vertical)
+ fixupY();
+ else
+ fixupX();
+}
+
+void QDeclarativeListViewPrivate::fixupY()
+{
+ Q_Q(QDeclarativeListView);
+ if (orient == QDeclarativeListView::Horizontal)
+ return;
+ if (!q->yflick() || _moveY.timeLine())
+ return;
+
+ int oldDuration = fixupDuration;
+ fixupDuration = moveReason == Mouse ? fixupDuration : 0;
+
+ if (haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) {
+ if (currentItem && currentItem->position() - position() != highlightRangeStart) {
+ qreal pos = currentItem->position() - highlightRangeStart;
+ timeline.reset(_moveY);
+ if (fixupDuration)
+ timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveY.setValue(-pos);
+ vTime = timeline.time();
+ }
+ } else if (snapMode != QDeclarativeListView::NoSnap) {
+ if (FxListItem *item = snapItemAt(position())) {
+ qreal pos = qMin(item->position() - highlightRangeStart, -q->maxYExtent());
+ qreal dist = qAbs(_moveY + pos);
+ if (dist > 0) {
+ timeline.reset(_moveY);
+ if (fixupDuration)
+ timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveY.setValue(-pos);
+ vTime = timeline.time();
+ }
+ }
+ } else {
+ QDeclarativeFlickablePrivate::fixupY();
+ }
+ fixupDuration = oldDuration;
+}
+
+void QDeclarativeListViewPrivate::fixupX()
+{
+ Q_Q(QDeclarativeListView);
+ if (orient == QDeclarativeListView::Vertical)
+ return;
+ if (!q->xflick() || _moveX.timeLine())
+ return;
+
+ int oldDuration = fixupDuration;
+ fixupDuration = moveReason == Mouse ? fixupDuration : 0;
+
+ if (haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) {
+ if (currentItem && currentItem->position() - position() != highlightRangeStart) {
+ qreal pos = currentItem->position() - highlightRangeStart;
+ timeline.reset(_moveX);
+ if (fixupDuration)
+ timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveX.setValue(-pos);
+ vTime = timeline.time();
+ }
+ } else if (snapMode != QDeclarativeListView::NoSnap) {
+ if (FxListItem *item = snapItemAt(position())) {
+ qreal pos = qMin(item->position() - highlightRangeStart, -q->maxXExtent());
+ qreal dist = qAbs(_moveX + pos);
+ if (dist > 0) {
+ timeline.reset(_moveX);
+ if (fixupDuration)
+ timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveX.setValue(-pos);
+ vTime = timeline.time();
+ }
+ }
+ } else {
+ QDeclarativeFlickablePrivate::fixupX();
+ }
+ fixupDuration = oldDuration;
+}
+
+void QDeclarativeListViewPrivate::flickX(qreal velocity)
+{
+ Q_Q(QDeclarativeListView);
+
+ moveReason = Mouse;
+ if ((!haveHighlightRange || highlightRange != QDeclarativeListView::StrictlyEnforceRange) && snapMode == QDeclarativeListView::NoSnap) {
+ QDeclarativeFlickablePrivate::flickX(velocity);
+ return;
+ }
+ qreal maxDistance = -1;
+ const qreal maxX = q->maxXExtent();
+ const qreal minX = q->minXExtent();
+ // -ve velocity means list is moving up
+ if (velocity > 0) {
+ if (snapMode == QDeclarativeListView::SnapOneItem) {
+ if (FxListItem *item = firstVisibleItem())
+ maxDistance = qAbs(item->position() + _moveX.value());
+ } else if (_moveX.value() < minX) {
+ maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0));
+ }
+ if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
+ flickTargetX = minX;
+ } else {
+ if (snapMode == QDeclarativeListView::SnapOneItem) {
+ if (FxListItem *item = nextVisibleItem())
+ maxDistance = qAbs(item->position() + _moveX.value());
+ } else if (_moveX.value() > maxX) {
+ maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0);
+ }
+ if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
+ flickTargetX = maxX;
+ }
+ if (maxDistance > 0 && (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)) {
+ // These modes require the list to stop exactly on an item boundary.
+ // The initial flick will estimate the boundary to stop on.
+ // Since list items can have variable sizes, the boundary will be
+ // reevaluated and adjusted as we approach the boundary.
+ qreal v = velocity;
+ if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
+ if (v < 0)
+ v = -maxVelocity;
+ else
+ v = maxVelocity;
+ }
+ if (!flicked) {
+ // the initial flick - estimate boundary
+ qreal accel = deceleration;
+ qreal v2 = v * v;
+ qreal maxAccel = v2 / (2.0f * maxDistance);
+ if (maxAccel < accel) {
+ qreal dist = v2 / (accel * 2.0);
+ if (v > 0)
+ dist = -dist;
+ flickTargetX = -snapPosAt(-(_moveX.value() - highlightRangeStart) + dist) + highlightRangeStart;
+ dist = -flickTargetX + _moveX.value();
+ accel = v2 / (2.0f * qAbs(dist));
+ overshootDist = 0.0;
+ } else {
+ flickTargetX = velocity > 0 ? minX : maxX;
+ overshootDist = overShoot ? 30 : 0;
+ }
+ timeline.reset(_moveX);
+ timeline.accel(_moveX, v, accel, maxDistance + overshootDist);
+ timeline.callback(QDeclarativeTimeLineCallback(&_moveX, fixupX_callback, this));
+ flicked = true;
+ emit q->flickingChanged();
+ emit q->flickStarted();
+ correctFlick = true;
+ } else {
+ // reevaluate the target boundary.
+ qreal newtarget = flickTargetX;
+ if (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)
+ newtarget = -snapPosAt(-(flickTargetX - highlightRangeStart)) + highlightRangeStart;
+ if (velocity < 0 && newtarget < maxX)
+ newtarget = maxX;
+ else if (velocity > 0 && newtarget > minX)
+ newtarget = minX;
+ if (newtarget == flickTargetX) // boundary unchanged - nothing to do
+ return;
+ flickTargetX = newtarget;
+ qreal dist = -newtarget + _moveX.value();
+ if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) {
+ correctFlick = false;
+ timeline.reset(_moveX);
+ fixupX();
+ return;
+ }
+ timeline.reset(_moveX);
+ timeline.accelDistance(_moveX, v, -dist + (v < 0 ? -overshootDist : overshootDist));
+ timeline.callback(QDeclarativeTimeLineCallback(&_moveX, fixupX_callback, this));
+ }
+ } else {
+ correctFlick = false;
+ timeline.reset(_moveX);
+ fixupX();
+ }
+}
+
+void QDeclarativeListViewPrivate::flickY(qreal velocity)
+{
+ Q_Q(QDeclarativeListView);
+
+ moveReason = Mouse;
+ if ((!haveHighlightRange || highlightRange != QDeclarativeListView::StrictlyEnforceRange) && snapMode == QDeclarativeListView::NoSnap) {
+ QDeclarativeFlickablePrivate::flickY(velocity);
+ return;
+ }
+ qreal maxDistance = -1;
+ const qreal maxY = q->maxYExtent();
+ const qreal minY = q->minYExtent();
+ // -ve velocity means list is moving up
+ if (velocity > 0) {
+ if (snapMode == QDeclarativeListView::SnapOneItem) {
+ if (FxListItem *item = firstVisibleItem())
+ maxDistance = qAbs(item->position() + _moveY.value());
+ } else if (_moveY.value() < minY) {
+ maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0));
+ }
+ if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
+ flickTargetY = minY;
+ } else {
+ if (snapMode == QDeclarativeListView::SnapOneItem) {
+ if (FxListItem *item = nextVisibleItem())
+ maxDistance = qAbs(item->position() + _moveY.value());
+ } else if (_moveY.value() > maxY) {
+ maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0);
+ }
+ if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
+ flickTargetY = maxY;
+ }
+ if (maxDistance > 0 && (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)) {
+ // These modes require the list to stop exactly on an item boundary.
+ // The initial flick will estimate the boundary to stop on.
+ // Since list items can have variable sizes, the boundary will be
+ // reevaluated and adjusted as we approach the boundary.
+ qreal v = velocity;
+ if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
+ if (v < 0)
+ v = -maxVelocity;
+ else
+ v = maxVelocity;
+ }
+ if (!flicked) {
+ // the initial flick - estimate boundary
+ qreal accel = deceleration;
+ qreal v2 = v * v;
+ qreal maxAccel = v2 / (2.0f * maxDistance);
+ if (maxAccel < accel) {
+ qreal dist = v2 / (accel * 2.0);
+ if (v > 0)
+ dist = -dist;
+ flickTargetY = -snapPosAt(-(_moveY.value() - highlightRangeStart) + dist) + highlightRangeStart;
+ dist = -flickTargetY + _moveY.value();
+ accel = v2 / (2.0f * qAbs(dist));
+ overshootDist = 0.0;
+ } else {
+ flickTargetY = velocity > 0 ? minY : maxY;
+ overshootDist = overShoot ? 30 : 0;
+ }
+ timeline.reset(_moveY);
+ timeline.accel(_moveY, v, accel, maxDistance + overshootDist);
+ timeline.callback(QDeclarativeTimeLineCallback(&_moveY, fixupY_callback, this));
+ flicked = true;
+ emit q->flickingChanged();
+ emit q->flickStarted();
+ correctFlick = true;
+ } else {
+ // reevaluate the target boundary.
+ qreal newtarget = flickTargetY;
+ if (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)
+ newtarget = -snapPosAt(-(flickTargetY - highlightRangeStart)) + highlightRangeStart;
+ if (velocity < 0 && newtarget < maxY)
+ newtarget = maxY;
+ else if (velocity > 0 && newtarget > minY)
+ newtarget = minY;
+ if (newtarget == flickTargetY) // boundary unchanged - nothing to do
+ return;
+ flickTargetY = newtarget;
+ qreal dist = -newtarget + _moveY.value();
+ if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) {
+ correctFlick = false;
+ timeline.reset(_moveY);
+ fixupY();
+ return;
+ }
+ timeline.reset(_moveY);
+ timeline.accelDistance(_moveY, v, -dist + (v < 0 ? -overshootDist : overshootDist));
+ timeline.callback(QDeclarativeTimeLineCallback(&_moveY, fixupY_callback, this));
+ }
+ } else {
+ correctFlick = false;
+ timeline.reset(_moveY);
+ fixupY();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+/*!
+ \qmlclass ListView QDeclarativeListView
+ \since 4.7
+ \inherits Flickable
+ \brief The ListView item provides a list view of items provided by a model.
+
+ The model is typically provided by a QAbstractListModel "C++ model object",
+ but can also be created directly in QML. The items are laid out vertically
+ or horizontally and may be flicked to scroll.
+
+ The below example creates a very simple vertical list, using a QML model.
+ \image trivialListView.png
+
+ The user interface defines a delegate to display an item, a highlight,
+ and the ListView which uses the above.
+
+ \snippet doc/src/snippets/declarative/listview/listview.qml 3
+
+ The model is defined as a ListModel using QML:
+ \quotefile doc/src/snippets/declarative/listview/dummydata/ContactModel.qml
+
+ In this case ListModel is a handy way for us to test our UI. In practice
+ the model would be implemented in C++, or perhaps via a SQL data source.
+*/
+
+QDeclarativeListView::QDeclarativeListView(QDeclarativeItem *parent)
+ : QDeclarativeFlickable(*(new QDeclarativeListViewPrivate), parent)
+{
+ Q_D(QDeclarativeListView);
+ d->init();
+}
+
+QDeclarativeListView::~QDeclarativeListView()
+{
+ Q_D(QDeclarativeListView);
+ d->clear();
+ if (d->ownModel)
+ delete d->model;
+ delete d->header;
+ delete d->footer;
+}
+
+/*!
+ \qmlattachedproperty bool ListView::isCurrentItem
+ This attached property is true if this delegate is the current item; otherwise false.
+
+ It is attached to each instance of the delegate.
+
+ This property may be used to adjust the appearance of the current item, for example:
+
+ \snippet doc/src/snippets/declarative/listview/highlight.qml 0
+*/
+
+/*!
+ \qmlattachedproperty ListView ListView::view
+ This attached property holds the view that manages this delegate instance.
+
+ It is attached to each instance of the delegate.
+*/
+
+/*!
+ \qmlattachedproperty string ListView::prevSection
+ This attached property holds the section of the previous element.
+
+ It is attached to each instance of the delegate.
+
+ The section is evaluated using the \l {ListView::section.property}{section} properties.
+*/
+
+/*!
+ \qmlattachedproperty string ListView::section
+ This attached property holds the section of this element.
+
+ It is attached to each instance of the delegate.
+
+ The section is evaluated using the \l {ListView::section.property}{section} properties.
+*/
+
+/*!
+ \qmlattachedproperty bool ListView::delayRemove
+ This attached property holds whether the delegate may be destroyed.
+
+ It is attached to each instance of the delegate.
+
+ It is sometimes necessary to delay the destruction of an item
+ until an animation completes.
+
+ The example below ensures that the animation completes before
+ the item is removed from the list.
+
+ \code
+ Component {
+ id: myDelegate
+ Item {
+ id: wrapper
+ ListView.onRemove: SequentialAnimation {
+ PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: true }
+ NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
+ PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: false }
+ }
+ }
+ }
+ \endcode
+*/
+
+/*!
+ \qmlattachedsignal ListView::onAdd()
+ This attached handler is called immediately after an item is added to the view.
+*/
+
+/*!
+ \qmlattachedsignal ListView::onRemove()
+ This attached handler is called immediately before an item is removed from the view.
+*/
+
+/*!
+ \qmlproperty model ListView::model
+ This property holds the model providing data for the list.
+
+ The model provides a set of data that is used to create the items
+ for the view. For large or dynamic datasets the model is usually
+ provided by a C++ model object. The C++ model object must be a \l
+ {QAbstractItemModel} subclass or a simple list.
+
+ Models can also be created directly in QML, using a \l{ListModel},
+ \l{XmlListModel} or \l{VisualItemModel}.
+
+ \sa {qmlmodels}{Data Models}
+*/
+QVariant QDeclarativeListView::model() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->modelVariant;
+}
+
+void QDeclarativeListView::setModel(const QVariant &model)
+{
+ Q_D(QDeclarativeListView);
+ if (d->model) {
+ disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
+ disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
+ disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
+ disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
+ }
+ d->clear();
+ d->modelVariant = model;
+ QObject *object = qvariant_cast<QObject*>(model);
+ QDeclarativeVisualModel *vim = 0;
+ if (object && (vim = qobject_cast<QDeclarativeVisualModel *>(object))) {
+ if (d->ownModel) {
+ delete d->model;
+ d->ownModel = false;
+ }
+ d->model = vim;
+ } else {
+ if (!d->ownModel) {
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->ownModel = true;
+ }
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
+ dataModel->setModel(model);
+ }
+ if (d->model) {
+ if (isComponentComplete()) {
+ refill();
+ if (d->currentIndex >= d->model->count() || d->currentIndex < 0) {
+ setCurrentIndex(0);
+ } else {
+ d->moveReason = QDeclarativeListViewPrivate::SetIndex;
+ d->updateCurrent(d->currentIndex);
+ }
+ }
+ connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
+ connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
+ connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
+ connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
+ emit countChanged();
+ }
+}
+
+/*!
+ \qmlproperty component ListView::delegate
+
+ The delegate provides a template defining each item instantiated by the view.
+ The index is exposed as an accessible \c index property. Properties of the
+ model are also available depending upon the type of \l {qmlmodels}{Data Model}.
+
+ Note that the ListView will layout the items based on the size of the root item
+ in the delegate.
+
+ Here is an example delegate:
+ \snippet doc/src/snippets/declarative/listview/listview.qml 0
+*/
+QDeclarativeComponent *QDeclarativeListView::delegate() const
+{
+ Q_D(const QDeclarativeListView);
+ if (d->model) {
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
+ return dataModel->delegate();
+ }
+
+ return 0;
+}
+
+void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate)
+{
+ Q_D(QDeclarativeListView);
+ if (delegate == this->delegate())
+ return;
+ if (!d->ownModel) {
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->ownModel = true;
+ }
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) {
+ dataModel->setDelegate(delegate);
+ if (isComponentComplete()) {
+ for (int i = 0; i < d->visibleItems.count(); ++i)
+ d->releaseItem(d->visibleItems.at(i));
+ d->visibleItems.clear();
+ refill();
+ d->moveReason = QDeclarativeListViewPrivate::SetIndex;
+ d->updateCurrent(d->currentIndex);
+ }
+ }
+}
+
+/*!
+ \qmlproperty int ListView::currentIndex
+ \qmlproperty Item ListView::currentItem
+
+ \c currentIndex holds the index of the current item.
+ \c currentItem is the current item. Note that the position of the current item
+ may only be approximate until it becomes visible in the view.
+*/
+int QDeclarativeListView::currentIndex() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->currentIndex;
+}
+
+void QDeclarativeListView::setCurrentIndex(int index)
+{
+ Q_D(QDeclarativeListView);
+ if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) {
+ d->moveReason = QDeclarativeListViewPrivate::SetIndex;
+ cancelFlick();
+ d->updateCurrent(index);
+ } else {
+ d->currentIndex = index;
+ }
+}
+
+QDeclarativeItem *QDeclarativeListView::currentItem()
+{
+ Q_D(QDeclarativeListView);
+ if (!d->currentItem)
+ return 0;
+ return d->currentItem->item;
+}
+
+/*!
+ \qmlproperty Item ListView::highlightItem
+
+ \c highlightItem holds the highlight item, which was created
+ from the \l highlight component.
+
+ The highlightItem is managed by the view unless
+ \l highlightFollowsCurrentItem is set to false.
+
+ \sa highlight, highlightFollowsCurrentItem
+*/
+QDeclarativeItem *QDeclarativeListView::highlightItem()
+{
+ Q_D(QDeclarativeListView);
+ if (!d->highlight)
+ return 0;
+ return d->highlight->item;
+}
+
+/*!
+ \qmlproperty int ListView::count
+ This property holds the number of items in the view.
+*/
+int QDeclarativeListView::count() const
+{
+ Q_D(const QDeclarativeListView);
+ if (d->model)
+ return d->model->count();
+ return 0;
+}
+
+/*!
+ \qmlproperty component ListView::highlight
+ This property holds the component to use as the highlight.
+
+ An instance of the highlight component will be created for each list.
+ The geometry of the resultant component instance will be managed by the list
+ so as to stay with the current item, unless the highlightFollowsCurrentItem
+ property is false.
+
+ The below example demonstrates how to make a simple highlight
+ for a vertical list.
+
+ \snippet doc/src/snippets/declarative/listview/listview.qml 1
+ \image trivialListView.png
+
+ \sa highlightItem, highlightFollowsCurrentItem
+*/
+QDeclarativeComponent *QDeclarativeListView::highlight() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->highlightComponent;
+}
+
+void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight)
+{
+ Q_D(QDeclarativeListView);
+ if (highlight != d->highlightComponent) {
+ d->highlightComponent = highlight;
+ d->createHighlight();
+ if (d->currentItem)
+ d->updateHighlight();
+ }
+}
+
+/*!
+ \qmlproperty bool ListView::highlightFollowsCurrentItem
+ This property holds whether the highlight is managed by the view.
+
+ If highlightFollowsCurrentItem is true, the highlight will be moved smoothly
+ to follow the current item. If highlightFollowsCurrentItem is false, the
+ highlight will not be moved by the view, and must be implemented
+ by the highlight. The following example creates a highlight with
+ its motion defined by the spring \l {SpringFollow}:
+
+ \snippet doc/src/snippets/declarative/listview/highlight.qml 1
+
+ Note that the highlight animation also affects the way that the view
+ is scrolled. This is because the view moves to maintain the
+ highlight within the preferred highlight range (or visible viewport).
+
+ \sa highlight, highlightMoveSpeed
+*/
+bool QDeclarativeListView::highlightFollowsCurrentItem() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->autoHighlight;
+}
+
+void QDeclarativeListView::setHighlightFollowsCurrentItem(bool autoHighlight)
+{
+ Q_D(QDeclarativeListView);
+ if (d->autoHighlight != autoHighlight) {
+ d->autoHighlight = autoHighlight;
+ if (d->highlightPosAnimator) {
+ d->highlightPosAnimator->setEnabled(d->autoHighlight);
+ d->highlightSizeAnimator->setEnabled(d->autoHighlight);
+ }
+ d->updateHighlight();
+ }
+}
+
+//###Possibly rename these properties, since they are very useful even without a highlight?
+/*!
+ \qmlproperty real ListView::preferredHighlightBegin
+ \qmlproperty real ListView::preferredHighlightEnd
+ \qmlproperty enumeration ListView::highlightRangeMode
+
+ These properties set the preferred range of the highlight (current item)
+ within the view.
+
+ Note that this is the correct way to influence where the
+ current item ends up when the list scrolls. For example, if you want the
+ currently selected item to be in the middle of the list, then set the
+ highlight range to be where the middle item would go. Then, when the list scrolls,
+ the currently selected item will be the item at that spot. This also applies to
+ when the currently selected item changes - it will scroll to within the preferred
+ highlight range. Furthermore, the behaviour of the current item index will occur
+ whether or not a highlight exists.
+
+ If highlightRangeMode is set to \e ApplyRange the view will
+ attempt to maintain the highlight within the range, however
+ the highlight can move outside of the range at the ends of the list
+ or due to a mouse interaction.
+
+ If highlightRangeMode is set to \e StrictlyEnforceRange the highlight will never
+ move outside of the range. This means that the current item will change
+ if a keyboard or mouse action would cause the highlight to move
+ outside of the range.
+
+ The default value is \e NoHighlightRange.
+
+ Note that a valid range requires preferredHighlightEnd to be greater
+ than or equal to preferredHighlightBegin.
+*/
+qreal QDeclarativeListView::preferredHighlightBegin() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->highlightRangeStart;
+}
+
+void QDeclarativeListView::setPreferredHighlightBegin(qreal start)
+{
+ Q_D(QDeclarativeListView);
+ d->highlightRangeStart = start;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+}
+
+qreal QDeclarativeListView::preferredHighlightEnd() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->highlightRangeEnd;
+}
+
+void QDeclarativeListView::setPreferredHighlightEnd(qreal end)
+{
+ Q_D(QDeclarativeListView);
+ d->highlightRangeEnd = end;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+}
+
+QDeclarativeListView::HighlightRangeMode QDeclarativeListView::highlightRangeMode() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->highlightRange;
+}
+
+void QDeclarativeListView::setHighlightRangeMode(HighlightRangeMode mode)
+{
+ Q_D(QDeclarativeListView);
+ d->highlightRange = mode;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+}
+
+/*!
+ \qmlproperty real ListView::spacing
+
+ This property holds the spacing to leave between items.
+*/
+qreal QDeclarativeListView::spacing() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->spacing;
+}
+
+void QDeclarativeListView::setSpacing(qreal spacing)
+{
+ Q_D(QDeclarativeListView);
+ if (spacing != d->spacing) {
+ d->spacing = spacing;
+ d->layout();
+ emit spacingChanged();
+ }
+}
+
+/*!
+ \qmlproperty enumeration ListView::orientation
+ This property holds the orientation of the list.
+
+ Possible values are \c Vertical (default) and \c Horizontal.
+
+ Vertical Example:
+ \image trivialListView.png
+ Horizontal Example:
+ \image ListViewHorizontal.png
+*/
+QDeclarativeListView::Orientation QDeclarativeListView::orientation() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->orient;
+}
+
+void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orientation)
+{
+ Q_D(QDeclarativeListView);
+ if (d->orient != orientation) {
+ d->orient = orientation;
+ if (d->orient == QDeclarativeListView::Vertical) {
+ setViewportWidth(-1);
+ setFlickDirection(VerticalFlick);
+ } else {
+ setViewportHeight(-1);
+ setFlickDirection(HorizontalFlick);
+ }
+ d->clear();
+ refill();
+ emit orientationChanged();
+ d->updateCurrent(d->currentIndex);
+ }
+}
+
+/*!
+ \qmlproperty bool ListView::keyNavigationWraps
+ This property holds whether the list wraps key navigation
+
+ If this property is true then key presses to move off of one end of the list will cause the
+ current item to jump to the other end.
+*/
+bool QDeclarativeListView::isWrapEnabled() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->wrap;
+}
+
+void QDeclarativeListView::setWrapEnabled(bool wrap)
+{
+ Q_D(QDeclarativeListView);
+ d->wrap = wrap;
+}
+
+/*!
+ \qmlproperty int ListView::cacheBuffer
+ This property holds the number of off-screen pixels to cache.
+
+ This property determines the number of pixels above the top of the list
+ and below the bottom of the list to cache. Setting this value can make
+ scrolling the list smoother at the expense of additional memory usage.
+*/
+int QDeclarativeListView::cacheBuffer() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->buffer;
+}
+
+void QDeclarativeListView::setCacheBuffer(int b)
+{
+ Q_D(QDeclarativeListView);
+ if (d->buffer != b) {
+ d->buffer = b;
+ if (isComponentComplete()) {
+ d->bufferMode = QDeclarativeListViewPrivate::BufferBefore | QDeclarativeListViewPrivate::BufferAfter;
+ refill();
+ }
+ }
+}
+
+/*!
+ \qmlproperty string ListView::section.property
+ \qmlproperty enumeration ListView::section.criteria
+ These properties hold the expression to be evaluated for the section attached property.
+
+ section.property hold the name of the property to use to determine
+ the section the item is in.
+
+ section.criteria holds the criteria to use to get the section. It
+ can be either:
+ \list
+ \o ViewSection.FullString (default) - section is the value of the property.
+ \o ViewSection.FirstCharacter - section is the first character of the property value.
+ \endlist
+
+ Each item in the list has attached properties named \c ListView.section and
+ \c ListView.prevSection. These may be used to place a section header for
+ related items. The example below assumes that the model is sorted by size of
+ pet. The section expression is the size property. If \c ListView.section and
+ \c ListView.prevSection differ, the item will display a section header.
+
+ \snippet examples/declarative/listview/sections.qml 0
+
+ \image ListViewSections.png
+*/
+QDeclarativeViewSection *QDeclarativeListView::sectionCriteria()
+{
+ Q_D(QDeclarativeListView);
+ if (!d->sectionCriteria)
+ d->sectionCriteria = new QDeclarativeViewSection(this);
+ return d->sectionCriteria;
+}
+
+/*!
+ \qmlproperty string ListView::currentSection
+ This property holds the section that is currently at the beginning of the view.
+*/
+QString QDeclarativeListView::currentSection() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->currentSection;
+}
+
+/*!
+ \qmlproperty real ListView::highlightMoveSpeed
+ \qmlproperty real ListView::highlightResizeSpeed
+ These properties hold the move and resize animation speed of the highlight delegate.
+
+ highlightFollowsCurrentItem must be true for these properties
+ to have effect.
+
+ The default value for these properties is 400 pixels/second.
+
+ \sa highlightFollowsCurrentItem
+*/
+qreal QDeclarativeListView::highlightMoveSpeed() const
+{
+ Q_D(const QDeclarativeListView);\
+ return d->highlightMoveSpeed;
+}
+
+void QDeclarativeListView::setHighlightMoveSpeed(qreal speed)
+{
+ Q_D(QDeclarativeListView);\
+ if (d->highlightMoveSpeed != speed) {
+ d->highlightMoveSpeed = speed;
+ if (d->highlightPosAnimator)
+ d->highlightPosAnimator->setVelocity(d->highlightMoveSpeed);
+ emit highlightMoveSpeedChanged();
+ }
+}
+
+qreal QDeclarativeListView::highlightResizeSpeed() const
+{
+ Q_D(const QDeclarativeListView);\
+ return d->highlightResizeSpeed;
+}
+
+void QDeclarativeListView::setHighlightResizeSpeed(qreal speed)
+{
+ Q_D(QDeclarativeListView);\
+ if (d->highlightResizeSpeed != speed) {
+ d->highlightResizeSpeed = speed;
+ if (d->highlightSizeAnimator)
+ d->highlightSizeAnimator->setVelocity(d->highlightResizeSpeed);
+ emit highlightResizeSpeedChanged();
+ }
+}
+
+/*!
+ \qmlproperty enumeration ListView::snapMode
+
+ This property determines where the view will settle following a drag or flick.
+ The allowed values are:
+
+ \list
+ \o NoSnap (default) - the view will stop anywhere within the visible area.
+ \o SnapToItem - the view will settle with an item aligned with the start of
+ the view.
+ \o SnapOneItem - the view will settle no more than one item away from the first
+ visible item at the time the mouse button is released. This mode is particularly
+ useful for moving one page at a time.
+ \endlist
+*/
+QDeclarativeListView::SnapMode QDeclarativeListView::snapMode() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->snapMode;
+}
+
+void QDeclarativeListView::setSnapMode(SnapMode mode)
+{
+ Q_D(QDeclarativeListView);
+ if (d->snapMode != mode) {
+ d->snapMode = mode;
+ }
+}
+
+QDeclarativeComponent *QDeclarativeListView::footer() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->footerComponent;
+}
+
+void QDeclarativeListView::setFooter(QDeclarativeComponent *footer)
+{
+ Q_D(QDeclarativeListView);
+ if (d->footerComponent != footer) {
+ if (d->footer) {
+ delete d->footer;
+ d->footer = 0;
+ }
+ d->footerComponent = footer;
+ d->minExtentDirty = true;
+ d->maxExtentDirty = true;
+ d->updateFooter();
+ d->updateViewport();
+ }
+}
+
+QDeclarativeComponent *QDeclarativeListView::header() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->headerComponent;
+}
+
+void QDeclarativeListView::setHeader(QDeclarativeComponent *header)
+{
+ Q_D(QDeclarativeListView);
+ if (d->headerComponent != header) {
+ if (d->header) {
+ delete d->header;
+ d->header = 0;
+ }
+ d->headerComponent = header;
+ d->minExtentDirty = true;
+ d->maxExtentDirty = true;
+ d->updateHeader();
+ d->updateFooter();
+ d->updateViewport();
+ }
+}
+
+void QDeclarativeListView::viewportMoved()
+{
+ Q_D(QDeclarativeListView);
+ QDeclarativeFlickable::viewportMoved();
+ d->lazyRelease = true;
+ refill();
+ if (isFlicking() || d->moving)
+ d->moveReason = QDeclarativeListViewPrivate::Mouse;
+ if (d->moveReason != QDeclarativeListViewPrivate::SetIndex) {
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
+ // reposition highlight
+ qreal pos = d->highlight->position();
+ if (pos > d->position() + d->highlightRangeEnd - 1 - d->highlight->size())
+ pos = d->position() + d->highlightRangeEnd - 1 - d->highlight->size();
+ if (pos < d->position() + d->highlightRangeStart)
+ pos = d->position() + d->highlightRangeStart;
+ d->highlight->setPosition(pos);
+
+ // update current index
+ int idx = d->snapIndex();
+ if (idx >= 0 && idx != d->currentIndex)
+ d->updateCurrent(idx);
+ }
+ }
+
+ if (d->flicked && d->correctFlick && !d->inFlickCorrection) {
+ d->inFlickCorrection = true;
+ // Near an end and it seems that the extent has changed?
+ // Recalculate the flick so that we don't end up in an odd position.
+ if (yflick()) {
+ if (d->velocityY > 0) {
+ const qreal minY = minYExtent();
+ if ((minY - d->_moveY.value() < height()/2 || d->flickTargetY - d->_moveY.value() < height()/2)
+ && minY != d->flickTargetY)
+ d->flickY(-d->verticalVelocity.value());
+ d->bufferMode = QDeclarativeListViewPrivate::BufferBefore;
+ } else if (d->velocityY < 0) {
+ const qreal maxY = maxYExtent();
+ if ((d->_moveY.value() - maxY < height()/2 || d->_moveY.value() - d->flickTargetY < height()/2)
+ && maxY != d->flickTargetY)
+ d->flickY(-d->verticalVelocity.value());
+ d->bufferMode = QDeclarativeListViewPrivate::BufferAfter;
+ }
+ }
+
+ if (xflick()) {
+ if (d->velocityX > 0) {
+ const qreal minX = minXExtent();
+ if ((minX - d->_moveX.value() < height()/2 || d->flickTargetX - d->_moveX.value() < height()/2)
+ && minX != d->flickTargetX)
+ d->flickX(-d->horizontalVelocity.value());
+ d->bufferMode = QDeclarativeListViewPrivate::BufferBefore;
+ } else if (d->velocityX < 0) {
+ const qreal maxX = maxXExtent();
+ if ((d->_moveX.value() - maxX < height()/2 || d->_moveX.value() - d->flickTargetX < height()/2)
+ && maxX != d->flickTargetX)
+ d->flickX(-d->horizontalVelocity.value());
+ d->bufferMode = QDeclarativeListViewPrivate::BufferAfter;
+ }
+ }
+ d->inFlickCorrection = false;
+ }
+}
+
+qreal QDeclarativeListView::minYExtent() const
+{
+ Q_D(const QDeclarativeListView);
+ if (d->orient == QDeclarativeListView::Horizontal)
+ return QDeclarativeFlickable::minYExtent();
+ if (d->minExtentDirty) {
+ d->minExtent = -d->startPosition();
+ if (d->header && d->visibleItems.count())
+ d->minExtent += d->header->size();
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ d->minExtent += d->highlightRangeStart;
+ d->minExtentDirty = false;
+ }
+
+ return d->minExtent;
+}
+
+qreal QDeclarativeListView::maxYExtent() const
+{
+ Q_D(const QDeclarativeListView);
+ if (d->orient == QDeclarativeListView::Horizontal)
+ return height();
+ if (d->maxExtentDirty) {
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ d->maxExtent = -(d->positionAt(count()-1) - d->highlightRangeEnd);
+ else
+ d->maxExtent = -(d->endPosition() - height() + 1);
+ if (d->footer)
+ d->maxExtent -= d->footer->size();
+ qreal minY = minYExtent();
+ if (d->maxExtent > minY)
+ d->maxExtent = minY;
+ d->maxExtentDirty = false;
+ }
+ return d->maxExtent;
+}
+
+qreal QDeclarativeListView::minXExtent() const
+{
+ Q_D(const QDeclarativeListView);
+ if (d->orient == QDeclarativeListView::Vertical)
+ return QDeclarativeFlickable::minXExtent();
+ if (d->minExtentDirty) {
+ d->minExtent = -d->startPosition();
+ if (d->header)
+ d->minExtent += d->header->size();
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ d->minExtent += d->highlightRangeStart;
+ d->minExtentDirty = false;
+ }
+
+ return d->minExtent;
+}
+
+qreal QDeclarativeListView::maxXExtent() const
+{
+ Q_D(const QDeclarativeListView);
+ if (d->orient == QDeclarativeListView::Vertical)
+ return width();
+ if (d->maxExtentDirty) {
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ d->maxExtent = -(d->positionAt(count()-1) - d->highlightRangeEnd);
+ else
+ d->maxExtent = -(d->endPosition() - width() + 1);
+ if (d->footer)
+ d->maxExtent -= d->footer->size();
+ qreal minX = minXExtent();
+ if (d->maxExtent > minX)
+ d->maxExtent = minX;
+ d->maxExtentDirty = false;
+ }
+
+ return d->maxExtent;
+}
+
+void QDeclarativeListView::keyPressEvent(QKeyEvent *event)
+{
+ Q_D(QDeclarativeListView);
+ QDeclarativeFlickable::keyPressEvent(event);
+ if (event->isAccepted())
+ return;
+
+ if (d->model && d->model->count() && d->interactive) {
+ if ((d->orient == QDeclarativeListView::Horizontal && event->key() == Qt::Key_Left)
+ || (d->orient == QDeclarativeListView::Vertical && event->key() == Qt::Key_Up)) {
+ if (currentIndex() > 0 || (d->wrap && !event->isAutoRepeat())) {
+ decrementCurrentIndex();
+ event->accept();
+ return;
+ } else if (d->wrap) {
+ event->accept();
+ return;
+ }
+ } else if ((d->orient == QDeclarativeListView::Horizontal && event->key() == Qt::Key_Right)
+ || (d->orient == QDeclarativeListView::Vertical && event->key() == Qt::Key_Down)) {
+ if (currentIndex() < d->model->count() - 1 || (d->wrap && !event->isAutoRepeat())) {
+ incrementCurrentIndex();
+ event->accept();
+ return;
+ } else if (d->wrap) {
+ event->accept();
+ return;
+ }
+ }
+ }
+ event->ignore();
+}
+
+/*!
+ \qmlmethod ListView::incrementCurrentIndex()
+
+ Increments the current index. The current index will wrap
+ if keyNavigationWraps is true and it is currently at the end.
+*/
+void QDeclarativeListView::incrementCurrentIndex()
+{
+ Q_D(QDeclarativeListView);
+ if (currentIndex() < d->model->count() - 1 || d->wrap) {
+ d->moveReason = QDeclarativeListViewPrivate::SetIndex;
+ int index = currentIndex()+1;
+ cancelFlick();
+ d->updateCurrent(index < d->model->count() ? index : 0);
+ }
+}
+
+/*!
+ \qmlmethod ListView::decrementCurrentIndex()
+
+ Decrements the current index. The current index will wrap
+ if keyNavigationWraps is true and it is currently at the beginning.
+*/
+void QDeclarativeListView::decrementCurrentIndex()
+{
+ Q_D(QDeclarativeListView);
+ if (currentIndex() > 0 || d->wrap) {
+ d->moveReason = QDeclarativeListViewPrivate::SetIndex;
+ int index = currentIndex()-1;
+ cancelFlick();
+ d->updateCurrent(index >= 0 ? index : d->model->count()-1);
+ }
+}
+
+/*!
+ \qmlmethod ListView::positionViewAtIndex(int index)
+
+ Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view.
+ If positioning the view at the index would cause empty space to be displayed at
+ the end of the view, the view will be positioned at the end.
+*/
+void QDeclarativeListView::positionViewAtIndex(int index)
+{
+ Q_D(QDeclarativeListView);
+ if (!d->isValid() || index < 0 || index >= d->model->count())
+ return;
+
+ qreal maxExtent = d->orient == QDeclarativeListView::Vertical ? -maxYExtent() : -maxXExtent();
+ FxListItem *item = d->visibleItem(index);
+ if (item) {
+ // Already created - just move to top of view
+ int pos = qMin(item->position(), maxExtent);
+ d->setPosition(pos);
+ } else {
+ int pos = d->positionAt(index);
+ // save the currently visible items in case any of them end up visible again
+ QList<FxListItem*> oldVisible = d->visibleItems;
+ d->visibleItems.clear();
+ d->visiblePos = pos;
+ d->visibleIndex = index;
+ d->setPosition(pos);
+ // setPosition() will cause refill. Adjust if we have moved beyond range.
+ if (d->position() > maxExtent)
+ d->setPosition(maxExtent);
+ // now release the reference to all the old visible items.
+ for (int i = 0; i < oldVisible.count(); ++i)
+ d->releaseItem(oldVisible.at(i));
+ }
+ d->fixupPosition();
+}
+
+
+void QDeclarativeListView::componentComplete()
+{
+ Q_D(QDeclarativeListView);
+ QDeclarativeFlickable::componentComplete();
+ refill();
+ d->moveReason = QDeclarativeListViewPrivate::SetIndex;
+ if (d->currentIndex < 0)
+ d->updateCurrent(0);
+ else
+ d->updateCurrent(d->currentIndex);
+ d->fixupPosition();
+}
+
+void QDeclarativeListView::refill()
+{
+ Q_D(QDeclarativeListView);
+ d->refill(d->position(), d->position()+d->size()-1);
+}
+
+void QDeclarativeListView::trackedPositionChanged()
+{
+ Q_D(QDeclarativeListView);
+ if (!d->trackedItem || !d->currentItem)
+ return;
+ if (!isFlicking() && !d->moving && d->moveReason == QDeclarativeListViewPrivate::SetIndex) {
+ const qreal trackedPos = d->trackedItem->position();
+ const qreal viewPos = d->position();
+ if (d->haveHighlightRange) {
+ if (d->highlightRange == StrictlyEnforceRange) {
+ qreal pos = viewPos;
+ if (trackedPos > pos + d->highlightRangeEnd - d->trackedItem->size())
+ pos = trackedPos - d->highlightRangeEnd + d->trackedItem->size();
+ if (trackedPos < pos + d->highlightRangeStart)
+ pos = trackedPos - d->highlightRangeStart;
+ d->setPosition(pos);
+ } else {
+ qreal pos = viewPos;
+ if (trackedPos < d->startPosition() + d->highlightRangeStart) {
+ pos = d->startPosition();
+ } else if (d->trackedItem->endPosition() > d->endPosition() - d->size() + d->highlightRangeEnd) {
+ pos = d->endPosition() - d->size();
+ if (pos < d->startPosition())
+ pos = d->startPosition();
+ } else {
+ if (trackedPos < viewPos + d->highlightRangeStart) {
+ pos = trackedPos - d->highlightRangeStart;
+ } else if (trackedPos > viewPos + d->highlightRangeEnd - d->trackedItem->size()) {
+ pos = trackedPos - d->highlightRangeEnd + d->trackedItem->size();
+ }
+ }
+ d->setPosition(pos);
+ }
+ } else {
+ if (trackedPos < viewPos && d->currentItem->position() < viewPos) {
+ d->setPosition(d->currentItem->position() < trackedPos ? trackedPos : d->currentItem->position());
+ } else if (d->trackedItem->endPosition() > viewPos + d->size()
+ && d->currentItem->endPosition() > viewPos + d->size()) {
+ qreal pos;
+ if (d->trackedItem->endPosition() < d->currentItem->endPosition()) {
+ pos = d->trackedItem->endPosition() - d->size();
+ if (d->trackedItem->size() > d->size())
+ pos = trackedPos;
+ } else {
+ pos = d->currentItem->endPosition() - d->size();
+ if (d->currentItem->size() > d->size())
+ pos = d->currentItem->position();
+ }
+ d->setPosition(pos);
+ }
+ }
+ }
+}
+
+void QDeclarativeListView::itemsInserted(int modelIndex, int count)
+{
+ Q_D(QDeclarativeListView);
+ d->updateUnrequestedIndexes();
+ d->moveReason = QDeclarativeListViewPrivate::Other;
+ if (!d->visibleItems.count() || d->model->count() <= 1) {
+ d->layout();
+ d->updateCurrent(qMax(0, qMin(d->currentIndex, d->model->count()-1)));
+ emit countChanged();
+ return;
+ }
+
+ int overlapCount = count;
+ if (!d->mapRangeFromModel(modelIndex, overlapCount)) {
+ int i = d->visibleItems.count() - 1;
+ while (i > 0 && d->visibleItems.at(i)->index == -1)
+ --i;
+ if (d->visibleItems.at(i)->index + 1 == modelIndex) {
+ // Special case of appending an item to the model.
+ modelIndex = d->visibleIndex + d->visibleItems.count();
+ } else {
+ if (modelIndex < d->visibleIndex) {
+ // Insert before visible items
+ d->visibleIndex += count;
+ for (int i = 0; i < d->visibleItems.count(); ++i) {
+ FxListItem *listItem = d->visibleItems.at(i);
+ if (listItem->index != -1 && listItem->index >= modelIndex)
+ listItem->index += count;
+ }
+ }
+ if (d->currentIndex >= modelIndex) {
+ // adjust current item index
+ d->currentIndex += count;
+ if (d->currentItem)
+ d->currentItem->index = d->currentIndex;
+ }
+ d->layout();
+ emit countChanged();
+ return;
+ }
+ }
+
+ // At least some of the added items will be visible
+
+ int index = modelIndex - d->visibleIndex;
+ // index can be the next item past the end of the visible items list (i.e. appended)
+ int pos = index < d->visibleItems.count() ? d->visibleItems.at(index)->position()
+ : d->visibleItems.at(index-1)->endPosition()+d->spacing+1;
+ int initialPos = pos;
+ int diff = 0;
+ QList<FxListItem*> added;
+ bool addedVisible = false;
+ FxListItem *firstVisible = d->firstVisibleItem();
+ if (firstVisible && pos < firstVisible->position()) {
+ // Insert items before the visible item.
+ int insertionIdx = index;
+ int i = 0;
+ int from = d->position() - d->buffer;
+ for (i = count-1; i >= 0 && pos > from; --i) {
+ addedVisible = true;
+ FxListItem *item = d->createItem(modelIndex + i);
+ d->visibleItems.insert(insertionIdx, item);
+ pos -= item->size() + d->spacing;
+ item->setPosition(pos);
+ index++;
+ }
+ if (i >= 0) {
+ // If we didn't insert all our new items - anything
+ // before the current index is not visible - remove it.
+ while (insertionIdx--) {
+ FxListItem *item = d->visibleItems.takeFirst();
+ if (item->index != -1)
+ d->visibleIndex++;
+ d->releaseItem(item);
+ }
+ } else {
+ // adjust pos of items before inserted items.
+ for (int i = insertionIdx-1; i >= 0; i--) {
+ FxListItem *listItem = d->visibleItems.at(i);
+ listItem->setPosition(listItem->position() - (initialPos - pos));
+ }
+ }
+ } else {
+ int i = 0;
+ int to = d->buffer+d->position()+d->size()-1;
+ for (i = 0; i < count && pos <= to; ++i) {
+ addedVisible = true;
+ FxListItem *item = d->createItem(modelIndex + i);
+ d->visibleItems.insert(index, item);
+ item->setPosition(pos);
+ added.append(item);
+ pos += item->size() + d->spacing;
+ ++index;
+ }
+ if (i != count) {
+ // We didn't insert all our new items, which means anything
+ // beyond the current index is not visible - remove it.
+ while (d->visibleItems.count() > index)
+ d->releaseItem(d->visibleItems.takeLast());
+ }
+ diff = pos - initialPos;
+ }
+ if (d->currentIndex >= modelIndex) {
+ // adjust current item index
+ d->currentIndex += count;
+ if (d->currentItem) {
+ d->currentItem->index = d->currentIndex;
+ d->currentItem->setPosition(d->currentItem->position() + diff);
+ }
+ }
+ // Update the indexes of the following visible items.
+ for (; index < d->visibleItems.count(); ++index) {
+ FxListItem *listItem = d->visibleItems.at(index);
+ if (d->currentItem && listItem->item != d->currentItem->item)
+ listItem->setPosition(listItem->position() + diff);
+ if (listItem->index != -1)
+ listItem->index += count;
+ }
+ // everything is in order now - emit add() signal
+ for (int j = 0; j < added.count(); ++j)
+ added.at(j)->attached->emitAdd();
+
+ if (addedVisible)
+ d->layout();
+ emit countChanged();
+}
+
+void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
+{
+ Q_D(QDeclarativeListView);
+ d->moveReason = QDeclarativeListViewPrivate::Other;
+ d->updateUnrequestedIndexes();
+
+ FxListItem *firstVisible = d->firstVisibleItem();
+ int preRemovedSize = 0;
+ bool removedVisible = false;
+ // Remove the items from the visible list, skipping anything already marked for removal
+ QList<FxListItem*>::Iterator it = d->visibleItems.begin();
+ while (it != d->visibleItems.end()) {
+ FxListItem *item = *it;
+ if (item->index == -1 || item->index < modelIndex) {
+ // already removed, or before removed items
+ ++it;
+ } else if (item->index >= modelIndex + count) {
+ // after removed items
+ item->index -= count;
+ ++it;
+ } else {
+ // removed item
+ removedVisible = true;
+ item->attached->emitRemove();
+ if (item->attached->delayRemove()) {
+ item->index = -1;
+ connect(item->attached, SIGNAL(delayRemoveChanged()), this, SLOT(destroyRemoved()), Qt::QueuedConnection);
+ ++it;
+ } else {
+ if (item == firstVisible)
+ firstVisible = 0;
+ if (firstVisible && item->position() < firstVisible->position())
+ preRemovedSize += item->size();
+ it = d->visibleItems.erase(it);
+ d->releaseItem(item);
+ }
+ }
+ }
+
+ if (firstVisible && d->visibleItems.first() != firstVisible)
+ d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + preRemovedSize);
+
+ // fix current
+ if (d->currentIndex >= modelIndex + count) {
+ d->currentIndex -= count;
+ if (d->currentItem)
+ d->currentItem->index -= count;
+ } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
+ // current item has been removed.
+ d->currentItem->attached->setIsCurrentItem(false);
+ d->releaseItem(d->currentItem);
+ d->currentItem = 0;
+ d->currentIndex = -1;
+ d->updateCurrent(qMin(modelIndex, d->model->count()-1));
+ }
+
+ // update visibleIndex
+ for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
+ if ((*it)->index != -1) {
+ d->visibleIndex = (*it)->index;
+ break;
+ }
+ }
+
+ if (removedVisible) {
+ if (d->visibleItems.isEmpty()) {
+ d->visibleIndex = 0;
+ d->visiblePos = d->header ? d->header->size() : 0;
+ d->timeline.clear();
+ d->setPosition(0);
+ if (d->model->count() == 0)
+ update();
+ else
+ refill();
+ } else {
+ // Correct the positioning of the items
+ d->layout();
+ }
+ }
+
+ emit countChanged();
+}
+
+void QDeclarativeListView::destroyRemoved()
+{
+ Q_D(QDeclarativeListView);
+ for (QList<FxListItem*>::Iterator it = d->visibleItems.begin();
+ it != d->visibleItems.end();) {
+ FxListItem *listItem = *it;
+ if (listItem->index == -1 && listItem->attached->delayRemove() == false) {
+ d->releaseItem(listItem);
+ it = d->visibleItems.erase(it);
+ } else {
+ ++it;
+ }
+ }
+
+ // Correct the positioning of the items
+ d->layout();
+}
+
+void QDeclarativeListView::itemsMoved(int from, int to, int count)
+{
+ Q_D(QDeclarativeListView);
+ d->updateUnrequestedIndexes();
+
+ if (d->visibleItems.isEmpty()) {
+ refill();
+ return;
+ }
+
+ d->moveReason = QDeclarativeListViewPrivate::Other;
+ FxListItem *firstVisible = d->firstVisibleItem();
+ qreal firstItemPos = firstVisible->position();
+ QHash<int,FxListItem*> moved;
+ int moveBy = 0;
+
+ QList<FxListItem*>::Iterator it = d->visibleItems.begin();
+ while (it != d->visibleItems.end()) {
+ FxListItem *item = *it;
+ if (item->index >= from && item->index < from + count) {
+ // take the items that are moving
+ item->index += (to-from);
+ moved.insert(item->index, item);
+ if (item->position() < firstItemPos)
+ moveBy += item->size();
+ it = d->visibleItems.erase(it);
+ } else {
+ // move everything after the moved items.
+ if (item->index > from && item->index != -1)
+ item->index -= count;
+ ++it;
+ }
+ }
+
+ int remaining = count;
+ int endIndex = d->visibleIndex;
+ it = d->visibleItems.begin();
+ while (it != d->visibleItems.end()) {
+ FxListItem *item = *it;
+ if (remaining && item->index >= to && item->index < to + count) {
+ // place items in the target position, reusing any existing items
+ FxListItem *movedItem = moved.take(item->index);
+ if (!movedItem)
+ movedItem = d->createItem(item->index);
+ if (item->index <= firstVisible->index)
+ moveBy -= movedItem->size();
+ it = d->visibleItems.insert(it, movedItem);
+ ++it;
+ --remaining;
+ } else {
+ if (item->index != -1) {
+ if (item->index >= to) {
+ // update everything after the moved items.
+ item->index += count;
+ }
+ endIndex = item->index;
+ }
+ ++it;
+ }
+ }
+
+ // If we have moved items to the end of the visible items
+ // then add any existing moved items that we have
+ while (FxListItem *item = moved.take(endIndex+1)) {
+ d->visibleItems.append(item);
+ ++endIndex;
+ }
+
+ // update visibleIndex
+ for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
+ if ((*it)->index != -1) {
+ d->visibleIndex = (*it)->index;
+ break;
+ }
+ }
+
+ // Fix current index
+ if (d->currentIndex >= 0 && d->currentItem) {
+ int oldCurrent = d->currentIndex;
+ d->currentIndex = d->model->indexOf(d->currentItem->item, this);
+ if (oldCurrent != d->currentIndex) {
+ d->currentItem->index = d->currentIndex;
+ emit currentIndexChanged();
+ }
+ }
+
+ // Whatever moved items remain are no longer visible items.
+ while (moved.count()) {
+ int idx = moved.begin().key();
+ FxListItem *item = moved.take(idx);
+ if (item->item == d->currentItem->item)
+ item->setPosition(d->positionAt(idx));
+ d->releaseItem(item);
+ }
+
+ // Ensure we don't cause an ugly list scroll.
+ d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + moveBy);
+
+ d->layout();
+}
+
+void QDeclarativeListView::createdItem(int index, QDeclarativeItem *item)
+{
+ Q_D(QDeclarativeListView);
+ if (d->requestedIndex != index) {
+ item->setParentItem(viewport());
+ d->unrequestedItems.insert(item, index);
+ if (d->orient == QDeclarativeListView::Vertical)
+ item->setY(d->positionAt(index));
+ else
+ item->setX(d->positionAt(index));
+ }
+}
+
+void QDeclarativeListView::destroyingItem(QDeclarativeItem *item)
+{
+ Q_D(QDeclarativeListView);
+ d->unrequestedItems.remove(item);
+}
+
+void QDeclarativeListView::animStopped()
+{
+ Q_D(QDeclarativeListView);
+ d->moveReason = QDeclarativeListViewPrivate::Other;
+ d->bufferMode = QDeclarativeListViewPrivate::NoBuffer;
+}
+
+QDeclarativeListViewAttached *QDeclarativeListView::qmlAttachedProperties(QObject *obj)
+{
+ return new QDeclarativeListViewAttached(obj);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
new file mode 100644
index 0000000..1b6276e
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -0,0 +1,305 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVELISTVIEW_H
+#define QDECLARATIVELISTVIEW_H
+
+#include "qdeclarativeflickable_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QDeclarativeViewSection : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY changed)
+ Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY changed)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_ENUMS(SectionCriteria)
+public:
+ QDeclarativeViewSection(QObject *parent=0) : QObject(parent), m_criteria(FullString), m_delegate(0) {}
+
+ QString property() const { return m_property; }
+ void setProperty(const QString &);
+
+ enum SectionCriteria { FullString, FirstCharacter };
+ SectionCriteria criteria() const { return m_criteria; }
+ void setCriteria(SectionCriteria);
+
+ QDeclarativeComponent *delegate() const { return m_delegate; }
+ void setDelegate(QDeclarativeComponent *delegate);
+
+ QString sectionString(const QString &value);
+
+Q_SIGNALS:
+ void changed();
+ void delegateChanged();
+
+private:
+ QString m_property;
+ SectionCriteria m_criteria;
+ QDeclarativeComponent *m_delegate;
+};
+
+
+class QDeclarativeVisualModel;
+class QDeclarativeListViewAttached;
+class QDeclarativeListViewPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeListView : public QDeclarativeFlickable
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeListView)
+
+ Q_PROPERTY(QVariant model READ model WRITE setModel)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
+ Q_PROPERTY(QDeclarativeItem *currentItem READ currentItem NOTIFY currentIndexChanged)
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+
+ Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight)
+ Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightChanged)
+ Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
+ Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
+ Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
+
+ Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin)
+ Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd)
+ Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode)
+
+ Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
+ Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
+ Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
+ Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
+ Q_PROPERTY(QDeclarativeViewSection *section READ sectionCriteria CONSTANT)
+ Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
+
+ Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode)
+
+ Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader)
+ Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter)
+
+ Q_ENUMS(HighlightRangeMode)
+ Q_ENUMS(Orientation)
+ Q_ENUMS(SnapMode)
+ Q_CLASSINFO("DefaultProperty", "data")
+
+public:
+ QDeclarativeListView(QDeclarativeItem *parent=0);
+ ~QDeclarativeListView();
+
+ QVariant model() const;
+ void setModel(const QVariant &);
+
+ QDeclarativeComponent *delegate() const;
+ void setDelegate(QDeclarativeComponent *);
+
+ int currentIndex() const;
+ void setCurrentIndex(int idx);
+
+ QDeclarativeItem *currentItem();
+ QDeclarativeItem *highlightItem();
+ int count() const;
+
+ QDeclarativeComponent *highlight() const;
+ void setHighlight(QDeclarativeComponent *highlight);
+
+ bool highlightFollowsCurrentItem() const;
+ void setHighlightFollowsCurrentItem(bool);
+
+ enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
+ HighlightRangeMode highlightRangeMode() const;
+ void setHighlightRangeMode(HighlightRangeMode mode);
+
+ qreal preferredHighlightBegin() const;
+ void setPreferredHighlightBegin(qreal);
+
+ qreal preferredHighlightEnd() const;
+ void setPreferredHighlightEnd(qreal);
+
+ qreal spacing() const;
+ void setSpacing(qreal spacing);
+
+ enum Orientation { Horizontal = Qt::Horizontal, Vertical = Qt::Vertical };
+ Orientation orientation() const;
+ void setOrientation(Orientation);
+
+ bool isWrapEnabled() const;
+ void setWrapEnabled(bool);
+
+ int cacheBuffer() const;
+ void setCacheBuffer(int);
+
+ QDeclarativeViewSection *sectionCriteria();
+ QString currentSection() const;
+
+ qreal highlightMoveSpeed() const;
+ void setHighlightMoveSpeed(qreal);
+
+ qreal highlightResizeSpeed() const;
+ void setHighlightResizeSpeed(qreal);
+
+ enum SnapMode { NoSnap, SnapToItem, SnapOneItem };
+ SnapMode snapMode() const;
+ void setSnapMode(SnapMode mode);
+
+ QDeclarativeComponent *footer() const;
+ void setFooter(QDeclarativeComponent *);
+
+ QDeclarativeComponent *header() const;
+ void setHeader(QDeclarativeComponent *);
+
+ static QDeclarativeListViewAttached *qmlAttachedProperties(QObject *);
+
+public Q_SLOTS:
+ void incrementCurrentIndex();
+ void decrementCurrentIndex();
+ void positionViewAtIndex(int index);
+
+Q_SIGNALS:
+ void countChanged();
+ void spacingChanged();
+ void orientationChanged();
+ void currentIndexChanged();
+ void currentSectionChanged();
+ void highlightMoveSpeedChanged();
+ void highlightResizeSpeedChanged();
+ void highlightChanged();
+
+protected:
+ virtual void viewportMoved();
+ virtual qreal minYExtent() const;
+ virtual qreal maxYExtent() const;
+ virtual qreal minXExtent() const;
+ virtual qreal maxXExtent() const;
+ virtual void keyPressEvent(QKeyEvent *);
+ virtual void componentComplete();
+
+private Q_SLOTS:
+ void refill();
+ void trackedPositionChanged();
+ void itemsInserted(int index, int count);
+ void itemsRemoved(int index, int count);
+ void itemsMoved(int from, int to, int count);
+ void destroyRemoved();
+ void createdItem(int index, QDeclarativeItem *item);
+ void destroyingItem(QDeclarativeItem *item);
+ void animStopped();
+};
+
+class QDeclarativeListViewAttached : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeListViewAttached(QObject *parent)
+ : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {}
+ ~QDeclarativeListViewAttached() {}
+
+ Q_PROPERTY(QDeclarativeListView *view READ view CONSTANT)
+ QDeclarativeListView *view() { return m_view; }
+
+ Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
+ bool isCurrentItem() const { return m_isCurrent; }
+ void setIsCurrentItem(bool c) {
+ if (m_isCurrent != c) {
+ m_isCurrent = c;
+ emit currentItemChanged();
+ }
+ }
+
+ Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged)
+ QString prevSection() const { return m_prevSection; }
+ void setPrevSection(const QString &sect) {
+ if (m_prevSection != sect) {
+ m_prevSection = sect;
+ emit prevSectionChanged();
+ }
+ }
+
+ Q_PROPERTY(QString section READ section NOTIFY sectionChanged)
+ QString section() const { return m_section; }
+ void setSection(const QString &sect) {
+ if (m_section != sect) {
+ m_section = sect;
+ emit sectionChanged();
+ }
+ }
+
+ Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
+ bool delayRemove() const { return m_delayRemove; }
+ void setDelayRemove(bool delay) {
+ if (m_delayRemove != delay) {
+ m_delayRemove = delay;
+ emit delayRemoveChanged();
+ }
+ }
+
+ void emitAdd() { emit add(); }
+ void emitRemove() { emit remove(); }
+
+Q_SIGNALS:
+ void currentItemChanged();
+ void sectionChanged();
+ void prevSectionChanged();
+ void delayRemoveChanged();
+ void add();
+ void remove();
+
+public:
+ QDeclarativeListView *m_view;
+ bool m_isCurrent;
+ mutable QString m_section;
+ QString m_prevSection;
+ bool m_delayRemove;
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPEINFO(QDeclarativeListView, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(QDeclarativeListView)
+QML_DECLARE_TYPE(QDeclarativeViewSection)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
new file mode 100644
index 0000000..bd89321
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -0,0 +1,488 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeloader_p_p.h"
+
+#include <qdeclarativeengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeLoaderPrivate::QDeclarativeLoaderPrivate()
+ : item(0), component(0), ownComponent(false)
+ , resizeMode(QDeclarativeLoader::SizeLoaderToItem)
+{
+}
+
+QDeclarativeLoaderPrivate::~QDeclarativeLoaderPrivate()
+{
+}
+
+void QDeclarativeLoaderPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ if (resizeItem == item && resizeMode == QDeclarativeLoader::SizeLoaderToItem) {
+ _q_updateSize();
+ }
+ QDeclarativeItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry);
+}
+
+void QDeclarativeLoaderPrivate::clear()
+{
+ if (ownComponent) {
+ delete component;
+ component = 0;
+ ownComponent = false;
+ }
+ source = QUrl();
+
+ if (item) {
+ if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(item)) {
+ if (resizeMode == QDeclarativeLoader::SizeLoaderToItem) {
+ QDeclarativeItemPrivate *p =
+ static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(qmlItem));
+ p->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ }
+ }
+
+ // We can't delete immediately because our item may have triggered
+ // the Loader to load a different item.
+ item->setVisible(false);
+ item->setParentItem(0);
+ item->deleteLater();
+ item = 0;
+ }
+}
+
+void QDeclarativeLoaderPrivate::initResize()
+{
+ Q_Q(QDeclarativeLoader);
+ if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(item)) {
+ if (resizeMode == QDeclarativeLoader::SizeLoaderToItem) {
+ QDeclarativeItemPrivate *p =
+ static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(qmlItem));
+ p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
+ }
+ } else if (item && item->isWidget()) {
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item);
+ if (resizeMode == QDeclarativeLoader::SizeLoaderToItem) {
+ widget->installEventFilter(q);
+ }
+ }
+ _q_updateSize();
+}
+
+/*!
+ \qmlclass Loader QDeclarativeLoader
+ \since 4.7
+ \inherits Item
+
+ \brief The Loader item allows dynamically loading an Item-based
+ subtree from a QML URL or Component.
+
+ Loader instantiates an item from a component. The component to
+ instantiate may be specified directly by the \c sourceComponent
+ property, or loaded from a URL via the \c source property.
+
+ It is also an effective means of delaying the creation of a component
+ until it is required:
+ \code
+ Loader { id: pageLoader }
+ Rectangle {
+ MouseArea { anchors.fill: parent; onClicked: pageLoader.source = "Page1.qml" }
+ }
+ \endcode
+
+ If the Loader source is changed, any previous items instantiated
+ will be destroyed. Setting \c source to an empty string
+ will destroy the currently instantiated items, freeing resources
+ and leaving the Loader empty. For example:
+
+ \code
+ pageLoader.source = ""
+ \endcode
+
+ unloads "Page1.qml" and frees resources consumed by it.
+
+ \sa {dynamic-object-creation}{Dynamic Object Creation}
+*/
+
+/*!
+ \internal
+ \class QDeclarativeLoader
+ \qmlclass Loader
+ */
+
+/*!
+ Create a new QDeclarativeLoader instance.
+ */
+QDeclarativeLoader::QDeclarativeLoader(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativeLoaderPrivate), parent)
+{
+}
+
+/*!
+ Destroy the loader instance.
+ */
+QDeclarativeLoader::~QDeclarativeLoader()
+{
+}
+
+/*!
+ \qmlproperty url Loader::source
+ This property holds the URL of the QML component to
+ instantiate.
+
+ \sa sourceComponent, status, progress
+*/
+QUrl QDeclarativeLoader::source() const
+{
+ Q_D(const QDeclarativeLoader);
+ return d->source;
+}
+
+void QDeclarativeLoader::setSource(const QUrl &url)
+{
+ Q_D(QDeclarativeLoader);
+ if (d->source == url)
+ return;
+
+ d->clear();
+
+ d->source = url;
+ if (d->source.isEmpty()) {
+ emit sourceChanged();
+ emit statusChanged();
+ emit progressChanged();
+ emit itemChanged();
+ return;
+ }
+
+ d->component = new QDeclarativeComponent(qmlEngine(this), d->source, this);
+ d->ownComponent = true;
+ if (!d->component->isLoading()) {
+ d->_q_sourceLoaded();
+ } else {
+ connect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
+ this, SLOT(_q_sourceLoaded()));
+ connect(d->component, SIGNAL(progressChanged(qreal)),
+ this, SIGNAL(progressChanged()));
+ emit statusChanged();
+ emit progressChanged();
+ emit sourceChanged();
+ emit itemChanged();
+ }
+}
+
+/*!
+ \qmlproperty Component Loader::sourceComponent
+ The sourceComponent property holds the \l{Component} to instantiate.
+
+ \qml
+ Item {
+ Component {
+ id: redSquare
+ Rectangle { color: "red"; width: 10; height: 10 }
+ }
+
+ Loader { sourceComponent: redSquare }
+ Loader { sourceComponent: redSquare; x: 10 }
+ }
+ \endqml
+
+ \sa source, progress
+*/
+
+QDeclarativeComponent *QDeclarativeLoader::sourceComponent() const
+{
+ Q_D(const QDeclarativeLoader);
+ return d->component;
+}
+
+void QDeclarativeLoader::setSourceComponent(QDeclarativeComponent *comp)
+{
+ Q_D(QDeclarativeLoader);
+ if (comp == d->component)
+ return;
+
+ d->clear();
+
+ d->component = comp;
+ d->ownComponent = false;
+ if (!d->component) {
+ emit sourceChanged();
+ emit statusChanged();
+ emit progressChanged();
+ emit itemChanged();
+ return;
+ }
+
+ if (!d->component->isLoading()) {
+ d->_q_sourceLoaded();
+ } else {
+ connect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
+ this, SLOT(_q_sourceLoaded()));
+ connect(d->component, SIGNAL(progressChanged(qreal)),
+ this, SIGNAL(progressChanged()));
+ emit progressChanged();
+ emit sourceChanged();
+ emit statusChanged();
+ emit itemChanged();
+ }
+}
+
+void QDeclarativeLoaderPrivate::_q_sourceLoaded()
+{
+ Q_Q(QDeclarativeLoader);
+
+ if (component) {
+ QDeclarativeContext *ctxt = new QDeclarativeContext(qmlContext(q));
+ ctxt->addDefaultObject(q);
+
+ if (!component->errors().isEmpty()) {
+ qWarning() << component->errors();
+ emit q->sourceChanged();
+ emit q->statusChanged();
+ emit q->progressChanged();
+ return;
+ }
+
+ QObject *obj = component->create(ctxt);
+ if (obj) {
+ ctxt->setParent(obj);
+ item = qobject_cast<QGraphicsObject *>(obj);
+ if (item) {
+ if (QDeclarativeItem* qmlItem = qobject_cast<QDeclarativeItem *>(item)) {
+ qmlItem->setParentItem(q);
+ } else {
+ item->setParentItem(q);
+ item->setParent(q);
+ }
+// item->setFocus(true);
+ initResize();
+ }
+ } else {
+ delete obj;
+ delete ctxt;
+ source = QUrl();
+ }
+ emit q->sourceChanged();
+ emit q->statusChanged();
+ emit q->progressChanged();
+ emit q->itemChanged();
+ }
+}
+
+/*!
+ \qmlproperty enum Loader::status
+
+ This property holds the status of QML loading. It can be one of:
+ \list
+ \o Null - no QML source has been set
+ \o Ready - the QML source has been loaded
+ \o Loading - the QML source is currently being loaded
+ \o Error - an error occurred while loading the QML source
+ \endlist
+
+ \sa progress
+*/
+
+QDeclarativeLoader::Status QDeclarativeLoader::status() const
+{
+ Q_D(const QDeclarativeLoader);
+
+ if (d->component)
+ return static_cast<QDeclarativeLoader::Status>(d->component->status());
+
+ if (d->item)
+ return Ready;
+
+ return d->source.isEmpty() ? Null : Error;
+}
+
+/*!
+ \qmlproperty real Loader::progress
+
+ This property holds the progress of QML data loading, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+
+ \sa status
+*/
+qreal QDeclarativeLoader::progress() const
+{
+ Q_D(const QDeclarativeLoader);
+
+ if (d->item)
+ return 1.0;
+
+ if (d->component)
+ return d->component->progress();
+
+ return 0.0;
+}
+
+/*!
+ \qmlproperty enum Loader::resizeMode
+
+ This property determines how the Loader or item are resized:
+ \list
+ \o NoResize - no item will be resized
+ \o SizeLoaderToItem - the Loader will be sized to the size of the item, unless the size of the Loader has been otherwise specified.
+ \o SizeItemToLoader - the item will be sized to the size of the Loader.
+ \endlist
+
+ Note that changing from SizeItemToLoader to SizeLoaderToItem
+ after the component is loaded will not return the item or Loader
+ to it's original size. This is due to the item size being adjusted
+ to the Loader size, thereby losing the original size of the item.
+ Future changes to the item's size will affect the loader, however.
+
+ The default resizeMode is SizeLoaderToItem.
+*/
+QDeclarativeLoader::ResizeMode QDeclarativeLoader::resizeMode() const
+{
+ Q_D(const QDeclarativeLoader);
+ return d->resizeMode;
+}
+
+void QDeclarativeLoader::setResizeMode(ResizeMode mode)
+{
+ Q_D(QDeclarativeLoader);
+ if (mode == d->resizeMode)
+ return;
+
+ if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(d->item)) {
+ if (d->resizeMode == SizeLoaderToItem) {
+ QDeclarativeItemPrivate *p =
+ static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(qmlItem));
+ p->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry);
+ }
+ } else if (d->item && d->item->isWidget()) {
+ if (d->resizeMode == SizeLoaderToItem)
+ d->item->removeEventFilter(this);
+ }
+
+ d->resizeMode = mode;
+ emit resizeModeChanged();
+ d->initResize();
+}
+
+void QDeclarativeLoaderPrivate::_q_updateSize()
+{
+ Q_Q(QDeclarativeLoader);
+ if (!item)
+ return;
+ if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(item)) {
+ if (resizeMode == QDeclarativeLoader::SizeLoaderToItem) {
+ q->setWidth(qmlItem->width());
+ q->setHeight(qmlItem->height());
+ } else if (resizeMode == QDeclarativeLoader::SizeItemToLoader) {
+ qmlItem->setWidth(q->width());
+ qmlItem->setHeight(q->height());
+ }
+ } else if (item && item->isWidget()) {
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item);
+ if (resizeMode == QDeclarativeLoader::SizeLoaderToItem) {
+ QSizeF newSize = widget->size();
+ if (newSize.isValid()) {
+ q->setWidth(newSize.width());
+ q->setHeight(newSize.height());
+ }
+ } else if (resizeMode == QDeclarativeLoader::SizeItemToLoader) {
+ QSizeF oldSize = widget->size();
+ QSizeF newSize = oldSize;
+ if (q->heightValid())
+ newSize.setHeight(q->height());
+ if (q->widthValid())
+ newSize.setWidth(q->width());
+ if (oldSize != newSize)
+ widget->resize(newSize);
+ }
+ }
+}
+
+/*!
+ \qmlproperty Item Loader::item
+ This property holds the top-level item created from source.
+*/
+QGraphicsObject *QDeclarativeLoader::item() const
+{
+ Q_D(const QDeclarativeLoader);
+ return d->item;
+}
+
+void QDeclarativeLoader::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ Q_D(QDeclarativeLoader);
+ if (newGeometry != oldGeometry) {
+ if (d->resizeMode == SizeItemToLoader) {
+ d->_q_updateSize();
+ }
+ }
+ QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+QVariant QDeclarativeLoader::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ Q_D(QDeclarativeLoader);
+ if (change == ItemSceneHasChanged) {
+ if (d->item && d->item->isWidget()) {
+ if (d->resizeMode == SizeLoaderToItem) {
+ d->item->removeEventFilter(this);
+ d->item->installEventFilter(this);
+ }
+ }
+ }
+ return QDeclarativeItem::itemChange(change, value);
+}
+
+bool QDeclarativeLoader::eventFilter(QObject *watched, QEvent *e)
+{
+ Q_D(QDeclarativeLoader);
+ if (watched == d->item && e->type() == QEvent::GraphicsSceneResize) {
+ if (d->item && d->item->isWidget() && d->resizeMode == SizeLoaderToItem) {
+ d->_q_updateSize();
+ }
+ }
+ return QDeclarativeItem::eventFilter(watched, e);
+}
+
+#include <moc_qdeclarativeloader_p.cpp>
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p.h b/src/declarative/graphicsitems/qdeclarativeloader_p.h
new file mode 100644
index 0000000..65538a8
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeloader_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVELOADER_H
+#define QDECLARATIVELOADER_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeLoaderPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeLoader : public QDeclarativeItem
+{
+ Q_OBJECT
+ Q_ENUMS(Status)
+ Q_ENUMS(ResizeMode)
+
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(QDeclarativeComponent *sourceComponent READ sourceComponent WRITE setSourceComponent NOTIFY sourceChanged)
+ Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode NOTIFY resizeModeChanged)
+ Q_PROPERTY(QGraphicsObject *item READ item NOTIFY itemChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+
+public:
+ QDeclarativeLoader(QDeclarativeItem *parent=0);
+ virtual ~QDeclarativeLoader();
+
+ QUrl source() const;
+ void setSource(const QUrl &);
+
+ QDeclarativeComponent *sourceComponent() const;
+ void setSourceComponent(QDeclarativeComponent *);
+
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+ qreal progress() const;
+
+ enum ResizeMode { NoResize, SizeLoaderToItem, SizeItemToLoader };
+ ResizeMode resizeMode() const;
+ void setResizeMode(ResizeMode mode);
+
+ QGraphicsObject *item() const;
+
+Q_SIGNALS:
+ void itemChanged();
+ void sourceChanged();
+ void statusChanged();
+ void progressChanged();
+ void resizeModeChanged();
+
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+ bool eventFilter(QObject *watched, QEvent *e);
+private:
+ Q_DISABLE_COPY(QDeclarativeLoader)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeLoader)
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLoaded())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeLoader)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVELOADER_H
diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p_p.h b/src/declarative/graphicsitems/qdeclarativeloader_p_p.h
new file mode 100644
index 0000000..fc5e665
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeloader_p_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVELOADER_P_H
+#define QDECLARATIVELOADER_P_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 "qdeclarativeloader_p.h"
+
+#include "qdeclarativeitem_p.h"
+#include "qdeclarativeitemchangelistener_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeContext;
+class QDeclarativeLoaderPrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener
+{
+ Q_DECLARE_PUBLIC(QDeclarativeLoader)
+
+public:
+ QDeclarativeLoaderPrivate();
+ ~QDeclarativeLoaderPrivate();
+
+ void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
+ void clear();
+ void initResize();
+
+ QUrl source;
+ QGraphicsObject *item;
+ QDeclarativeComponent *component;
+ bool ownComponent : 1;
+ QDeclarativeLoader::ResizeMode resizeMode;
+
+ void _q_sourceLoaded();
+ void _q_updateSize();
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVELOADER_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
new file mode 100644
index 0000000..ab6be1c
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -0,0 +1,685 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativemousearea_p.h"
+#include "qdeclarativemousearea_p_p.h"
+
+#include "qdeclarativeevents_p_p.h"
+
+#include <QGraphicsSceneMouseEvent>
+
+QT_BEGIN_NAMESPACE
+static const int PressAndHoldDelay = 800;
+
+QDeclarativeDrag::QDeclarativeDrag(QObject *parent)
+: QObject(parent), _target(0), _axis(XandYAxis), _xmin(0), _xmax(0), _ymin(0), _ymax(0)
+{
+}
+
+QDeclarativeDrag::~QDeclarativeDrag()
+{
+}
+
+QDeclarativeItem *QDeclarativeDrag::target() const
+{
+ return _target;
+}
+
+void QDeclarativeDrag::setTarget(QDeclarativeItem *t)
+{
+ if (_target == t)
+ return;
+ _target = t;
+ emit targetChanged();
+}
+
+QDeclarativeDrag::Axis QDeclarativeDrag::axis() const
+{
+ return _axis;
+}
+
+void QDeclarativeDrag::setAxis(QDeclarativeDrag::Axis a)
+{
+ if (_axis == a)
+ return;
+ _axis = a;
+ emit axisChanged();
+}
+
+qreal QDeclarativeDrag::xmin() const
+{
+ return _xmin;
+}
+
+void QDeclarativeDrag::setXmin(qreal m)
+{
+ if (_xmin == m)
+ return;
+ _xmin = m;
+ emit minimumXChanged();
+}
+
+qreal QDeclarativeDrag::xmax() const
+{
+ return _xmax;
+}
+
+void QDeclarativeDrag::setXmax(qreal m)
+{
+ if (_xmax == m)
+ return;
+ _xmax = m;
+ emit maximumXChanged();
+}
+
+qreal QDeclarativeDrag::ymin() const
+{
+ return _ymin;
+}
+
+void QDeclarativeDrag::setYmin(qreal m)
+{
+ if (_ymin == m)
+ return;
+ _ymin = m;
+ emit minimumYChanged();
+}
+
+qreal QDeclarativeDrag::ymax() const
+{
+ return _ymax;
+}
+
+void QDeclarativeDrag::setYmax(qreal m)
+{
+ if (_ymax == m)
+ return;
+ _ymax = m;
+ emit maximumYChanged();
+}
+
+QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate()
+{
+ delete drag;
+}
+
+
+/*!
+ \qmlclass MouseRegion QDeclarativeMouseRegion
+ \since 4.7
+ \brief The MouseArea item enables simple mouse handling.
+ \inherits Item
+
+ A MouseArea is typically used in conjunction with a visible item,
+ where the MouseArea effectively 'proxies' mouse handling for that
+ item. For example, we can put a MouseArea in a Rectangle that changes
+ the Rectangle color to red when clicked:
+ \snippet doc/src/snippets/declarative/mouseregion.qml 0
+
+ Many MouseArea signals pass a \l {MouseEvent}{mouse} parameter that contains
+ additional information about the mouse event, such as the position, button,
+ and any key modifiers.
+
+ Below we have the previous
+ example extended so as to give a different color when you right click.
+ \snippet doc/src/snippets/declarative/mouseregion.qml 1
+
+ For basic key handling, see the \l {Keys}{Keys attached property}.
+
+ MouseArea is an invisible item: it is never painted.
+
+ \sa MouseEvent
+*/
+
+/*!
+ \qmlsignal MouseArea::onEntered()
+
+ This handler is called when the mouse enters the mouse region.
+
+ By default the onEntered handler is only called while a button is
+ pressed. Setting hoverEnabled to true enables handling of
+ onExited when no mouse button is pressed.
+
+ \sa hoverEnabled
+*/
+
+/*!
+ \qmlsignal MouseArea::onExited()
+
+ This handler is called when the mouse exists the mouse region.
+
+ By default the onExited handler is only called while a button is
+ pressed. Setting hoverEnabled to true enables handling of
+ onExited when no mouse button is pressed.
+
+ \sa hoverEnabled
+*/
+
+/*!
+ \qmlsignal MouseArea::onPositionChanged(MouseEvent mouse)
+
+ This handler is called when the mouse position changes.
+
+ The \l {MouseEvent}{mouse} parameter provides information about the mouse, including the x and y
+ position, and any buttons currently pressed.
+
+ The \e accepted property of the MouseEvent parameter is ignored in this handler.
+
+ By default the onPositionChanged handler is only called while a button is
+ pressed. Setting hoverEnabled to true enables handling of
+ onPositionChanged when no mouse button is pressed.
+*/
+
+/*!
+ \qmlsignal MouseArea::onClicked(mouse)
+
+ This handler is called when there is a click. A click is defined as a press followed by a release,
+ both inside the MouseArea (pressing, moving outside the MouseArea, and then moving back inside and
+ releasing is also considered a click).
+
+ The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
+ position of the release of the click, and whether the click wasHeld.
+
+ The \e accepted property of the MouseEvent parameter is ignored in this handler.
+*/
+
+/*!
+ \qmlsignal MouseArea::onPressed(mouse)
+
+ This handler is called when there is a press.
+ The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
+ position and which button was pressed.
+
+ The \e accepted property of the MouseEvent parameter determines whether this MouseArea
+ will handle the press and all future mouse events until release. The default is to accept
+ the event and not allow other MouseArea beneath this one to handle the event. If \e accepted
+ is set to false, no further events will be sent to this MouseArea until the button is next
+ pressed.
+*/
+
+/*!
+ \qmlsignal MouseArea::onReleased(mouse)
+
+ This handler is called when there is a release.
+ The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
+ position of the release of the click, and whether the click wasHeld.
+
+ The \e accepted property of the MouseEvent parameter is ignored in this handler.
+*/
+
+/*!
+ \qmlsignal MouseArea::onPressAndHold(mouse)
+
+ This handler is called when there is a long press (currently 800ms).
+ The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
+ position of the press, and which button is pressed.
+
+ The \e accepted property of the MouseEvent parameter is ignored in this handler.
+*/
+
+/*!
+ \qmlsignal MouseArea::onDoubleClicked(mouse)
+
+ This handler is called when there is a double-click (a press followed by a release followed by a press).
+ The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
+ position of the release of the click, and whether the click wasHeld.
+
+ The \e accepted property of the MouseEvent parameter is ignored in this handler.
+*/
+
+/*!
+ \internal
+ \class QDeclarativeMouseArea
+ \brief The QDeclarativeMouseArea class provides a simple mouse handling abstraction for use within Qml.
+
+ \ingroup group_coreitems
+
+ All QDeclarativeItem derived classes can do mouse handling but the QDeclarativeMouseArea class exposes mouse
+ handling data as properties and tracks flicking and dragging of the mouse.
+
+ A QDeclarativeMouseArea object can be instantiated in Qml using the tag \l MouseArea.
+ */
+QDeclarativeMouseArea::QDeclarativeMouseArea(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativeMouseAreaPrivate), parent)
+{
+ Q_D(QDeclarativeMouseArea);
+ d->init();
+}
+
+QDeclarativeMouseArea::~QDeclarativeMouseArea()
+{
+}
+
+/*!
+ \qmlproperty real MouseArea::mouseX
+ \qmlproperty real MouseArea::mouseY
+ These properties hold the coordinates of the mouse.
+
+ If the hoverEnabled property is false then these properties will only be valid
+ while a button is pressed, and will remain valid as long as the button is held
+ even if the mouse is moved outside the region.
+
+ If hoverEnabled is true then these properties will be valid:
+ \list
+ \i when no button is pressed, but the mouse is within the MouseArea (containsMouse is true).
+ \i if a button is pressed and held, even if it has since moved out of the region.
+ \endlist
+
+ The coordinates are relative to the MouseArea.
+*/
+qreal QDeclarativeMouseArea::mouseX() const
+{
+ Q_D(const QDeclarativeMouseArea);
+ return d->lastPos.x();
+}
+
+qreal QDeclarativeMouseArea::mouseY() const
+{
+ Q_D(const QDeclarativeMouseArea);
+ return d->lastPos.y();
+}
+
+/*!
+ \qmlproperty bool MouseArea::enabled
+ This property holds whether the item accepts mouse events.
+*/
+bool QDeclarativeMouseArea::isEnabled() const
+{
+ Q_D(const QDeclarativeMouseArea);
+ return d->absorb;
+}
+
+void QDeclarativeMouseArea::setEnabled(bool a)
+{
+ Q_D(QDeclarativeMouseArea);
+ if (a != d->absorb) {
+ d->absorb = a;
+ emit enabledChanged();
+ }
+}
+/*!
+ \qmlproperty MouseButtons MouseArea::pressedButtons
+ This property holds the mouse buttons currently pressed.
+
+ It contains a bitwise combination of:
+ \list
+ \o Qt.LeftButton
+ \o Qt.RightButton
+ \o Qt.MidButton
+ \endlist
+
+ The code below displays "right" when the right mouse buttons is pressed:
+ \code
+ Text {
+ text: mr.pressedButtons & Qt.RightButton ? "right" : ""
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ MouseArea {
+ id: mr
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ anchors.fill: parent
+ }
+ }
+ \endcode
+
+ \sa acceptedButtons
+*/
+Qt::MouseButtons QDeclarativeMouseArea::pressedButtons() const
+{
+ Q_D(const QDeclarativeMouseArea);
+ return d->lastButtons;
+}
+
+void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeMouseArea);
+ d->moved = false;
+ if (!d->absorb)
+ QDeclarativeItem::mousePressEvent(event);
+ else {
+ d->longPress = false;
+ d->saveEvent(event);
+ if (d->drag) {
+ d->dragX = drag()->axis() & QDeclarativeDrag::XAxis;
+ d->dragY = drag()->axis() & QDeclarativeDrag::YAxis;
+ }
+ d->dragged = false;
+ setHovered(true);
+ d->start = event->pos();
+ d->startScene = event->scenePos();
+ // we should only start timer if pressAndHold is connected to.
+ if (d->isConnected("pressAndHold(QDeclarativeMouseEvent*)"))
+ d->pressAndHoldTimer.start(PressAndHoldDelay, this);
+ setKeepMouseGrab(false);
+ event->setAccepted(setPressed(true));
+ }
+}
+
+void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeMouseArea);
+ if (!d->absorb) {
+ QDeclarativeItem::mouseMoveEvent(event);
+ return;
+ }
+
+ d->saveEvent(event);
+
+ // ### we should skip this if these signals aren't used
+ // ### can GV handle this for us?
+ bool contains = boundingRect().contains(d->lastPos);
+ if (d->hovered && !contains)
+ setHovered(false);
+ else if (!d->hovered && contains)
+ setHovered(true);
+
+ if (d->drag && d->drag->target()) {
+ if (!d->moved) {
+ if (d->dragX) d->startX = drag()->target()->x();
+ if (d->dragY) d->startY = drag()->target()->y();
+ }
+
+ QPointF startLocalPos;
+ QPointF curLocalPos;
+ if (drag()->target()->parent()) {
+ startLocalPos = drag()->target()->parentItem()->mapFromScene(d->startScene);
+ curLocalPos = drag()->target()->parentItem()->mapFromScene(event->scenePos());
+ } else {
+ startLocalPos = d->startScene;
+ curLocalPos = event->scenePos();
+ }
+
+ const int dragThreshold = QApplication::startDragDistance();
+ qreal dx = qAbs(curLocalPos.x() - startLocalPos.x());
+ qreal dy = qAbs(curLocalPos.y() - startLocalPos.y());
+ if ((d->dragX && !(dx < dragThreshold)) || (d->dragY && !(dy < dragThreshold)))
+ d->dragged = true;
+ if (!keepMouseGrab()) {
+ if ((!d->dragY && dy < dragThreshold && d->dragX && dx > dragThreshold)
+ || (!d->dragX && dx < dragThreshold && d->dragY && dy > dragThreshold)
+ || (d->dragX && d->dragY)) {
+ setKeepMouseGrab(true);
+ }
+ }
+
+ if (d->dragX) {
+ qreal x = (curLocalPos.x() - startLocalPos.x()) + d->startX;
+ if (x < drag()->xmin())
+ x = drag()->xmin();
+ else if (x > drag()->xmax())
+ x = drag()->xmax();
+ drag()->target()->setX(x);
+ }
+ if (d->dragY) {
+ qreal y = (curLocalPos.y() - startLocalPos.y()) + d->startY;
+ if (y < drag()->ymin())
+ y = drag()->ymin();
+ else if (y > drag()->ymax())
+ y = drag()->ymax();
+ drag()->target()->setY(y);
+ }
+ }
+ d->moved = true;
+ QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
+ emit positionChanged(&me);
+}
+
+
+void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeMouseArea);
+ if (!d->absorb) {
+ QDeclarativeItem::mouseReleaseEvent(event);
+ } else {
+ d->saveEvent(event);
+ setPressed(false);
+ // If we don't accept hover, we need to reset containsMouse.
+ if (!acceptHoverEvents())
+ setHovered(false);
+ setKeepMouseGrab(false);
+ }
+}
+
+void QDeclarativeMouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeMouseArea);
+ if (!d->absorb) {
+ QDeclarativeItem::mouseDoubleClickEvent(event);
+ } else {
+ QDeclarativeItem::mouseDoubleClickEvent(event);
+ if (event->isAccepted()) {
+ // Only deliver the event if we have accepted the press.
+ d->saveEvent(event);
+ QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false);
+ emit this->doubleClicked(&me);
+ }
+ }
+}
+
+void QDeclarativeMouseArea::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_D(QDeclarativeMouseArea);
+ if (!d->absorb)
+ QDeclarativeItem::hoverEnterEvent(event);
+ else
+ setHovered(true);
+}
+
+void QDeclarativeMouseArea::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_D(QDeclarativeMouseArea);
+ if (!d->absorb) {
+ QDeclarativeItem::hoverEnterEvent(event);
+ } else {
+ d->lastPos = event->pos();
+ QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, d->lastButtons, d->lastModifiers, false, d->longPress);
+ emit positionChanged(&me);
+ }
+}
+
+void QDeclarativeMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_D(QDeclarativeMouseArea);
+ if (!d->absorb)
+ QDeclarativeItem::hoverLeaveEvent(event);
+ else
+ setHovered(false);
+}
+
+bool QDeclarativeMouseArea::sceneEvent(QEvent *event)
+{
+ bool rv = QDeclarativeItem::sceneEvent(event);
+ if (event->type() == QEvent::UngrabMouse) {
+ Q_D(QDeclarativeMouseArea);
+ if (d->pressed) {
+ // if our mouse grab has been removed (probably by Flickable), fix our
+ // state
+ d->pressed = false;
+ setKeepMouseGrab(false);
+ emit pressedChanged();
+ //emit hoveredChanged();
+ }
+ }
+ return rv;
+}
+
+void QDeclarativeMouseArea::timerEvent(QTimerEvent *event)
+{
+ Q_D(QDeclarativeMouseArea);
+ if (event->timerId() == d->pressAndHoldTimer.timerId()) {
+ d->pressAndHoldTimer.stop();
+ if (d->pressed && d->dragged == false && d->hovered == true) {
+ d->longPress = true;
+ QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
+ emit pressAndHold(&me);
+ }
+ }
+}
+
+/*!
+ \qmlproperty bool MouseArea::hoverEnabled
+ This property holds whether hover events are handled.
+
+ By default, mouse events are only handled in response to a button event, or when a button is
+ pressed. Hover enables handling of all mouse events even when no mouse button is
+ pressed.
+
+ This property affects the containsMouse property and the onEntered, onExited and onPositionChanged signals.
+*/
+
+/*!
+ \qmlproperty bool MouseArea::containsMouse
+ This property holds whether the mouse is currently inside the mouse region.
+
+ \warning This property is not updated if the region moves under the mouse: \e containsMouse will not change.
+ In addition, if hoverEnabled is false, containsMouse will only be valid when the mouse is pressed.
+*/
+bool QDeclarativeMouseArea::hovered() const
+{
+ Q_D(const QDeclarativeMouseArea);
+ return d->hovered;
+}
+
+/*!
+ \qmlproperty bool MouseArea::pressed
+ This property holds whether the mouse region is currently pressed.
+*/
+bool QDeclarativeMouseArea::pressed() const
+{
+ Q_D(const QDeclarativeMouseArea);
+ return d->pressed;
+}
+
+void QDeclarativeMouseArea::setHovered(bool h)
+{
+ Q_D(QDeclarativeMouseArea);
+ if (d->hovered != h) {
+ d->hovered = h;
+ emit hoveredChanged();
+ d->hovered ? emit entered() : emit exited();
+ }
+}
+
+/*!
+ \qmlproperty Qt::MouseButtons MouseArea::acceptedButtons
+ This property holds the mouse buttons that the mouse region reacts to.
+
+ The available buttons are:
+ \list
+ \o Qt.LeftButton
+ \o Qt.RightButton
+ \o Qt.MidButton
+ \endlist
+
+ To accept more than one button the flags can be combined with the
+ "|" (or) operator:
+
+ \code
+ MouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton }
+ \endcode
+
+ The default is to accept the Left button.
+*/
+Qt::MouseButtons QDeclarativeMouseArea::acceptedButtons() const
+{
+ return acceptedMouseButtons();
+}
+
+void QDeclarativeMouseArea::setAcceptedButtons(Qt::MouseButtons buttons)
+{
+ if (buttons != acceptedMouseButtons()) {
+ setAcceptedMouseButtons(buttons);
+ emit acceptedButtonsChanged();
+ }
+}
+
+bool QDeclarativeMouseArea::setPressed(bool p)
+{
+ Q_D(QDeclarativeMouseArea);
+ bool isclick = d->pressed == true && p == false && d->dragged == false && d->hovered == true;
+
+ if (d->pressed != p) {
+ d->pressed = p;
+ QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress);
+ if (d->pressed) {
+ emit positionChanged(&me);
+ emit pressed(&me);
+ } else {
+ emit released(&me);
+ if (isclick)
+ emit clicked(&me);
+ }
+
+ emit pressedChanged();
+ return me.isAccepted();
+ }
+ return false;
+}
+
+QDeclarativeDrag *QDeclarativeMouseArea::drag()
+{
+ Q_D(QDeclarativeMouseArea);
+ if (!d->drag)
+ d->drag = new QDeclarativeDrag;
+ return d->drag;
+}
+
+/*!
+ \qmlproperty Item MouseArea::drag.target
+ \qmlproperty Axis MouseArea::drag.axis
+ \qmlproperty real MouseArea::drag.minimumX
+ \qmlproperty real MouseArea::drag.maximumX
+ \qmlproperty real MouseArea::drag.minimumY
+ \qmlproperty real MouseArea::drag.maximumY
+
+ drag provides a convenient way to make an item draggable.
+
+ \list
+ \i \c target specifies the item to drag.
+ \i \c axis specifies whether dragging can be done horizontally (XAxis), vertically (YAxis), or both (XandYAxis)
+ \i the minimum and maximum properties limit how far the target can be dragged along the corresponding axes.
+ \endlist
+
+ The following example uses drag to reduce the opacity of an image as it moves to the right:
+ \snippet doc/src/snippets/declarative/drag.qml 0
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
new file mode 100644
index 0000000..33422e2
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEMOUSEAREA_H
+#define QDECLARATIVEMOUSEAREA_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDrag : public QObject
+{
+ Q_OBJECT
+
+ Q_ENUMS(Axis)
+ Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget NOTIFY targetChanged)
+ Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
+ Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
+ Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
+ Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
+ Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
+ //### consider drag and drop
+
+public:
+ QDeclarativeDrag(QObject *parent=0);
+ ~QDeclarativeDrag();
+
+ QDeclarativeItem *target() const;
+ void setTarget(QDeclarativeItem *);
+
+ enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
+ Axis axis() const;
+ void setAxis(Axis);
+
+ qreal xmin() const;
+ void setXmin(qreal);
+ qreal xmax() const;
+ void setXmax(qreal);
+ qreal ymin() const;
+ void setYmin(qreal);
+ qreal ymax() const;
+ void setYmax(qreal);
+
+Q_SIGNALS:
+ void targetChanged();
+ void axisChanged();
+ void minimumXChanged();
+ void maximumXChanged();
+ void minimumYChanged();
+ void maximumYChanged();
+
+private:
+ QDeclarativeItem *_target;
+ Axis _axis;
+ qreal _xmin;
+ qreal _xmax;
+ qreal _ymin;
+ qreal _ymax;
+ Q_DISABLE_COPY(QDeclarativeDrag)
+};
+
+class QDeclarativeMouseEvent;
+class QDeclarativeMouseAreaPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeMouseArea : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal mouseX READ mouseX NOTIFY positionChanged)
+ Q_PROPERTY(qreal mouseY READ mouseY NOTIFY positionChanged)
+ Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
+ Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
+ Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
+ Q_PROPERTY(bool hoverEnabled READ acceptHoverEvents WRITE setAcceptHoverEvents)
+ Q_PROPERTY(QDeclarativeDrag *drag READ drag CONSTANT) //### add flicking to QDeclarativeDrag or add a QDeclarativeFlick ???
+
+public:
+ QDeclarativeMouseArea(QDeclarativeItem *parent=0);
+ ~QDeclarativeMouseArea();
+
+ qreal mouseX() const;
+ qreal mouseY() const;
+
+ bool isEnabled() const;
+ void setEnabled(bool);
+
+ bool hovered() const;
+ bool pressed() const;
+
+ Qt::MouseButtons pressedButtons() const;
+
+ Qt::MouseButtons acceptedButtons() const;
+ void setAcceptedButtons(Qt::MouseButtons buttons);
+
+ QDeclarativeDrag *drag();
+
+Q_SIGNALS:
+ void hoveredChanged();
+ void pressedChanged();
+ void enabledChanged();
+ void acceptedButtonsChanged();
+ void positionChanged(QDeclarativeMouseEvent *mouse);
+
+ void pressed(QDeclarativeMouseEvent *mouse);
+ void pressAndHold(QDeclarativeMouseEvent *mouse);
+ void released(QDeclarativeMouseEvent *mouse);
+ void clicked(QDeclarativeMouseEvent *mouse);
+ void doubleClicked(QDeclarativeMouseEvent *mouse);
+ void entered();
+ void exited();
+
+protected:
+ void setHovered(bool);
+ bool setPressed(bool);
+
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
+ void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
+ void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+ bool sceneEvent(QEvent *);
+ void timerEvent(QTimerEvent *event);
+
+private:
+ void handlePress();
+ void handleRelease();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeMouseArea)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeMouseArea)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeDrag)
+QML_DECLARE_TYPE(QDeclarativeMouseArea)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEMOUSEAREA_H
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
new file mode 100644
index 0000000..d4871f2
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEMOUSEREGION_P_H
+#define QDECLARATIVEMOUSEREGION_P_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 "qdeclarativeitem_p.h"
+
+#include <qdatetime.h>
+#include <qbasictimer.h>
+#include <qgraphicssceneevent.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeMouseAreaPrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeMouseArea)
+
+public:
+ QDeclarativeMouseAreaPrivate()
+ : absorb(true), hovered(false), pressed(false), longPress(false), drag(0)
+ {
+ }
+
+ ~QDeclarativeMouseAreaPrivate();
+
+ void init()
+ {
+ Q_Q(QDeclarativeMouseArea);
+ q->setAcceptedMouseButtons(Qt::LeftButton);
+ }
+
+ void saveEvent(QGraphicsSceneMouseEvent *event) {
+ lastPos = event->pos();
+ lastButton = event->button();
+ lastButtons = event->buttons();
+ lastModifiers = event->modifiers();
+ }
+
+ bool isConnected(const char *signal) {
+ Q_Q(QDeclarativeMouseArea);
+ int idx = QObjectPrivate::get(q)->signalIndex(signal);
+ return QObjectPrivate::get(q)->isSignalConnected(idx);
+ }
+
+ bool absorb : 1;
+ bool hovered : 1;
+ bool pressed : 1;
+ bool longPress : 1;
+ bool moved : 1;
+ bool dragX : 1;
+ bool dragY : 1;
+ bool dragged : 1;
+ QDeclarativeDrag *drag;
+ QPointF start;
+ QPointF startScene;
+ qreal startX;
+ qreal startY;
+ QPointF lastPos;
+ Qt::MouseButton lastButton;
+ Qt::MouseButtons lastButtons;
+ Qt::KeyboardModifiers lastModifiers;
+ QBasicTimer pressAndHoldTimer;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEMOUSEREGION_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
new file mode 100644
index 0000000..ab6007a
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
@@ -0,0 +1,466 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativepainteditem_p.h"
+#include "qdeclarativepainteditem_p_p.h"
+
+#include <QDebug>
+#include <QPen>
+#include <QFile>
+#include <QEvent>
+#include <QApplication>
+#include <QGraphicsSceneMouseEvent>
+#include <QPainter>
+#include <QPaintEngine>
+#include <qmath.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QDeclarativePaintedItem
+ \brief The QDeclarativePaintedItem class is an abstract base class for QDeclarativeView items that want cached painting.
+ \internal
+
+ This is a convenience class for implementing items that paint their contents
+ using a QPainter. The contents of the item are cached behind the scenes.
+ The dirtyCache() function should be called if the contents change to
+ ensure the cache is refreshed the next time painting occurs.
+
+ To subclass QDeclarativePaintedItem, you must reimplement drawContents() to draw
+ the contents of the item.
+*/
+
+/*!
+ \fn void QDeclarativePaintedItem::drawContents(QPainter *painter, const QRect &rect)
+
+ This function is called when the cache needs to be refreshed. When
+ sub-classing QDeclarativePaintedItem this function should be implemented so as to
+ paint the contents of the item using the given \a painter for the
+ area of the contents specified by \a rect.
+*/
+
+/*!
+ \property QDeclarativePaintedItem::contentsSize
+ \brief The size of the contents
+
+ The contents size is the size of the item in regards to how it is painted
+ using the drawContents() function. This is distinct from the size of the
+ item in regards to height() and width().
+*/
+
+// XXX bug in WebKit - can call repaintRequested and other cache-changing functions from within render!
+static int inpaint=0;
+static int inpaint_clearcache=0;
+
+/*!
+ Marks areas of the cache that intersect with the given \a rect as dirty and
+ in need of being refreshed.
+
+ \sa clearCache()
+*/
+void QDeclarativePaintedItem::dirtyCache(const QRect& rect)
+{
+ Q_D(QDeclarativePaintedItem);
+ QRect srect(qCeil(rect.x()*d->contentsScale),
+ qCeil(rect.y()*d->contentsScale),
+ qCeil(rect.width()*d->contentsScale),
+ qCeil(rect.height()*d->contentsScale));
+ for (int i=0; i < d->imagecache.count(); ) {
+ QDeclarativePaintedItemPrivate::ImageCacheItem *c = d->imagecache[i];
+ QRect isect = (c->area & srect) | c->dirty;
+ if (isect == c->area && !inpaint) {
+ delete d->imagecache.takeAt(i);
+ } else {
+ c->dirty = isect;
+ ++i;
+ }
+ }
+}
+
+/*!
+ Marks the entirety of the contents cache as dirty.
+
+ \sa dirtyCache()
+*/
+void QDeclarativePaintedItem::clearCache()
+{
+ if (inpaint) {
+ inpaint_clearcache=1;
+ return;
+ }
+ Q_D(QDeclarativePaintedItem);
+ qDeleteAll(d->imagecache);
+ d->imagecache.clear();
+}
+
+/*!
+ Returns the size of the contents.
+
+ \sa setContentsSize()
+*/
+QSize QDeclarativePaintedItem::contentsSize() const
+{
+ Q_D(const QDeclarativePaintedItem);
+ return d->contentsSize;
+}
+
+/*!
+ Sets the size of the contents to the given \a size.
+
+ \sa contentsSize()
+*/
+void QDeclarativePaintedItem::setContentsSize(const QSize &size)
+{
+ Q_D(QDeclarativePaintedItem);
+ if (d->contentsSize == size) return;
+ d->contentsSize = size;
+ setImplicitWidth(size.width()*d->contentsScale);
+ setImplicitHeight(size.height()*d->contentsScale);
+ clearCache();
+ update();
+ emit contentsSizeChanged();
+}
+
+qreal QDeclarativePaintedItem::contentsScale() const
+{
+ Q_D(const QDeclarativePaintedItem);
+ return d->contentsScale;
+}
+
+void QDeclarativePaintedItem::setContentsScale(qreal scale)
+{
+ Q_D(QDeclarativePaintedItem);
+ if (d->contentsScale == scale) return;
+ d->contentsScale = scale;
+ setImplicitWidth(d->contentsSize.width()*scale);
+ setImplicitHeight(d->contentsSize.height()*scale);
+ clearCache();
+ update();
+ emit contentsScaleChanged();
+}
+
+
+/*!
+ Constructs a new QDeclarativePaintedItem with the given \a parent.
+*/
+QDeclarativePaintedItem::QDeclarativePaintedItem(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativePaintedItemPrivate), parent)
+{
+ init();
+}
+
+/*!
+ \internal
+ Constructs a new QDeclarativePaintedItem with the given \a parent and
+ initialized private data member \a dd.
+*/
+QDeclarativePaintedItem::QDeclarativePaintedItem(QDeclarativePaintedItemPrivate &dd, QDeclarativeItem *parent)
+ : QDeclarativeItem(dd, parent)
+{
+ init();
+}
+
+/*!
+ Destroys the image item.
+*/
+QDeclarativePaintedItem::~QDeclarativePaintedItem()
+{
+ clearCache();
+}
+
+/*!
+ \internal
+*/
+void QDeclarativePaintedItem::init()
+{
+ connect(this,SIGNAL(widthChanged()),this,SLOT(clearCache()));
+ connect(this,SIGNAL(heightChanged()),this,SLOT(clearCache()));
+ connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache()));
+}
+
+void QDeclarativePaintedItem::setCacheFrozen(bool frozen)
+{
+ Q_D(QDeclarativePaintedItem);
+ if (d->cachefrozen == frozen)
+ return;
+ d->cachefrozen = frozen;
+ // XXX clear cache?
+}
+
+/*!
+ \reimp
+*/
+void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ Q_D(QDeclarativePaintedItem);
+ const QRect content(0,0,qCeil(d->contentsSize.width()*d->contentsScale),
+ qCeil(d->contentsSize.height()*d->contentsScale));
+ if (content.width() <= 0 || content.height() <= 0)
+ return;
+
+ ++inpaint;
+
+ const QTransform &x = p->deviceTransform();
+ QTransform xinv = x.inverted();
+ QRegion effectiveClip;
+ QRegion sysClip = p->paintEngine()->systemClip();
+ if (xinv.type() <= QTransform::TxScale && sysClip.numRects() < 5) {
+ // simple transform, region gets no more complicated...
+ effectiveClip = xinv.map(sysClip);
+ } else {
+ // do not make complicated regions...
+ effectiveClip = xinv.mapRect(sysClip.boundingRect());
+ }
+
+ QRegion topaint = p->clipRegion();
+ if (topaint.isEmpty()) {
+ if (effectiveClip.isEmpty())
+ topaint = QRect(0,0,p->device()->width(),p->device()->height());
+ else
+ topaint = effectiveClip;
+ } else if (!effectiveClip.isEmpty()) {
+ topaint &= effectiveClip;
+ }
+
+ topaint &= content;
+ QRegion uncached(content);
+ p->setRenderHints(QPainter::SmoothPixmapTransform, d->smooth);
+
+ int cachesize=0;
+ for (int i=0; i<d->imagecache.count(); ++i) {
+ QRect area = d->imagecache[i]->area;
+ if (topaint.contains(area)) {
+ QRectF target(area.x(), area.y(), area.width(), area.height());
+ if (!d->cachefrozen) {
+ if (!d->imagecache[i]->dirty.isNull() && topaint.contains(d->imagecache[i]->dirty)) {
+ QPainter qp(&d->imagecache[i]->image);
+ qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache);
+ qp.translate(-area.x(), -area.y());
+ qp.scale(d->contentsScale,d->contentsScale);
+ QRect clip = d->imagecache[i]->dirty;
+ QRect sclip(qFloor(clip.x()/d->contentsScale),
+ qFloor(clip.y()/d->contentsScale),
+ qCeil(clip.width()/d->contentsScale+clip.x()/d->contentsScale-qFloor(clip.x()/d->contentsScale)),
+ qCeil(clip.height()/d->contentsScale+clip.y()/d->contentsScale-qFloor(clip.y()/d->contentsScale)));
+ qp.setClipRect(sclip);
+ if (d->fillColor.isValid()){
+ if(d->fillColor.alpha() < 255){
+ // ### Might not work outside of raster paintengine
+ QPainter::CompositionMode prev = qp.compositionMode();
+ qp.setCompositionMode(QPainter::CompositionMode_Source);
+ qp.fillRect(sclip,d->fillColor);
+ qp.setCompositionMode(prev);
+ }else{
+ qp.fillRect(sclip,d->fillColor);
+ }
+ }
+ drawContents(&qp, sclip);
+ d->imagecache[i]->dirty = QRect();
+ }
+ }
+ p->drawPixmap(target.toRect(), d->imagecache[i]->image);
+ topaint -= area;
+ d->imagecache[i]->age=0;
+ } else {
+ d->imagecache[i]->age++;
+ }
+ cachesize += area.width()*area.height();
+ uncached -= area;
+ }
+
+ if (!topaint.isEmpty()) {
+ if (!d->cachefrozen) {
+ // Find a sensible larger area, otherwise will paint lots of tiny images.
+ QRect biggerrect = topaint.boundingRect().adjusted(-64,-64,128,128);
+ cachesize += biggerrect.width() * biggerrect.height();
+ while (d->imagecache.count() && cachesize > d->max_imagecache_size) {
+ int oldest=-1;
+ int age=-1;
+ for (int i=0; i<d->imagecache.count(); ++i) {
+ int a = d->imagecache[i]->age;
+ if (a > age) {
+ oldest = i;
+ age = a;
+ }
+ }
+ cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
+ uncached += d->imagecache[oldest]->area;
+ delete d->imagecache.takeAt(oldest);
+ }
+ const QRegion bigger = QRegion(biggerrect) & uncached;
+ const QVector<QRect> rects = bigger.rects();
+ for (int i = 0; i < rects.count(); ++i) {
+ const QRect &r = rects.at(i);
+ QPixmap img(r.size());
+ if (d->fillColor.isValid())
+ img.fill(d->fillColor);
+ {
+ QPainter qp(&img);
+ qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache);
+
+ qp.translate(-r.x(),-r.y());
+ qp.scale(d->contentsScale,d->contentsScale);
+ QRect sclip(qFloor(r.x()/d->contentsScale),
+ qFloor(r.y()/d->contentsScale),
+ qCeil(r.width()/d->contentsScale+r.x()/d->contentsScale-qFloor(r.x()/d->contentsScale)),
+ qCeil(r.height()/d->contentsScale+r.y()/d->contentsScale-qFloor(r.y()/d->contentsScale)));
+ drawContents(&qp, sclip);
+ }
+ QDeclarativePaintedItemPrivate::ImageCacheItem *newitem = new QDeclarativePaintedItemPrivate::ImageCacheItem;
+ newitem->area = r;
+ newitem->image = img;
+ d->imagecache.append(newitem);
+ p->drawPixmap(r, newitem->image);
+ }
+ } else {
+ const QVector<QRect> rects = uncached.rects();
+ for (int i = 0; i < rects.count(); ++i)
+ p->fillRect(rects.at(i), Qt::lightGray);
+ }
+ }
+
+ if (inpaint_clearcache) {
+ clearCache();
+ inpaint_clearcache = 0;
+ }
+
+ --inpaint;
+}
+
+/*!
+ \qmlproperty int PaintedItem::pixelCacheSize
+
+ This property holds the maximum number of pixels of image cache to
+ allow. The default is 0.1 megapixels. The cache will not be larger
+ than the (unscaled) size of the WebView.
+*/
+/*!
+ \property QDeclarativePaintedItem::pixelCacheSize
+
+ The maximum number of pixels of image cache to allow. The default
+ is 0.1 megapixels. The cache will not be larger than the (unscaled)
+ size of the QDeclarativePaintedItem.
+*/
+int QDeclarativePaintedItem::pixelCacheSize() const
+{
+ Q_D(const QDeclarativePaintedItem);
+ return d->max_imagecache_size;
+}
+
+void QDeclarativePaintedItem::setPixelCacheSize(int pixels)
+{
+ Q_D(QDeclarativePaintedItem);
+ if (pixels < d->max_imagecache_size) {
+ int cachesize=0;
+ for (int i=0; i<d->imagecache.count(); ++i) {
+ QRect area = d->imagecache[i]->area;
+ cachesize += area.width()*area.height();
+ }
+ while (d->imagecache.count() && cachesize > pixels) {
+ int oldest=-1;
+ int age=-1;
+ for (int i=0; i<d->imagecache.count(); ++i) {
+ int a = d->imagecache[i]->age;
+ if (a > age) {
+ oldest = i;
+ age = a;
+ }
+ }
+ cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
+ delete d->imagecache.takeAt(oldest);
+ }
+ }
+ d->max_imagecache_size = pixels;
+}
+
+
+
+/*!
+ \property QDeclarativePaintedItem::fillColor
+
+ The color to be used to fill the item prior to calling drawContents().
+ By default, this is Qt::transparent.
+
+ Performance improvements can be achieved if subclasses call this with either an
+ invalid color (QColor()), or an appropriate solid color.
+*/
+void QDeclarativePaintedItem::setFillColor(const QColor& c)
+{
+ Q_D(QDeclarativePaintedItem);
+ if (d->fillColor == c)
+ return;
+ d->fillColor = c;
+ emit fillColorChanged();
+ update();
+}
+
+QColor QDeclarativePaintedItem::fillColor() const
+{
+ Q_D(const QDeclarativePaintedItem);
+ return d->fillColor;
+}
+
+/*!
+ \qmlproperty bool PaintedItem::smoothCache
+
+ Controls whether the cached tiles of which the item is composed are
+ rendered smoothly when they are generated.
+
+ This is in addition toe Item::smooth, which controls the smooth painting of
+ the already-painted cached tiles under transformation.
+*/
+bool QDeclarativePaintedItem::smoothCache() const
+{
+ Q_D(const QDeclarativePaintedItem);
+ return d->smoothCache;
+}
+
+void QDeclarativePaintedItem::setSmoothCache(bool on)
+{
+ Q_D(QDeclarativePaintedItem);
+ if (d->smoothCache != on) {
+ d->smoothCache = on;
+ clearCache();
+ }
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem_p.h b/src/declarative/graphicsitems/qdeclarativepainteditem_p.h
new file mode 100644
index 0000000..cc616af
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem_p.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEIMAGEITEM_H
+#define QDECLARATIVEIMAGEITEM_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativePaintedItemPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativePaintedItem : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize NOTIFY contentsSizeChanged)
+ Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
+ Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize)
+ Q_PROPERTY(bool smoothCache READ smoothCache WRITE setSmoothCache)
+ Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged)
+
+
+public:
+ QDeclarativePaintedItem(QDeclarativeItem *parent=0);
+ ~QDeclarativePaintedItem();
+
+ QSize contentsSize() const;
+ void setContentsSize(const QSize &);
+
+ qreal contentsScale() const;
+ void setContentsScale(qreal);
+
+ int pixelCacheSize() const;
+ void setPixelCacheSize(int pixels);
+
+ bool smoothCache() const;
+ void setSmoothCache(bool on);
+
+ QColor fillColor() const;
+ void setFillColor(const QColor&);
+
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+protected:
+ QDeclarativePaintedItem(QDeclarativePaintedItemPrivate &dd, QDeclarativeItem *parent);
+
+ virtual void drawContents(QPainter *p, const QRect &) = 0;
+
+ void setCacheFrozen(bool);
+
+Q_SIGNALS:
+ void fillColorChanged();
+ void contentsSizeChanged();
+ void contentsScaleChanged();
+
+protected Q_SLOTS:
+ void dirtyCache(const QRect &);
+ void clearCache();
+
+private:
+ void init();
+ Q_DISABLE_COPY(QDeclarativePaintedItem)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativePaintedItem)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativePaintedItem)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem_p_p.h b/src/declarative/graphicsitems/qdeclarativepainteditem_p_p.h
new file mode 100644
index 0000000..a15febb
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem_p_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEIMAGEITEM_P_H
+#define QDECLARATIVEIMAGEITEM_P_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 "qdeclarativeitem_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativePaintedItemPrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativePaintedItem)
+
+public:
+ QDeclarativePaintedItemPrivate()
+ : max_imagecache_size(100000), contentsScale(1.0), fillColor(Qt::transparent), cachefrozen(false), smoothCache(true)
+ {
+ }
+
+ struct ImageCacheItem {
+ ImageCacheItem() : age(0) {}
+ ~ImageCacheItem() { }
+ int age;
+ QRect area;
+ QRect dirty; // one dirty area (allows optimization of common cases)
+ QPixmap image;
+ };
+
+ QList<ImageCacheItem*> imagecache;
+
+ int max_imagecache_size;
+ QSize contentsSize;
+ qreal contentsScale;
+ QColor fillColor;
+ bool cachefrozen;
+ bool smoothCache;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeparticles.cpp b/src/declarative/graphicsitems/qdeclarativeparticles.cpp
new file mode 100644
index 0000000..3c07798
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeparticles.cpp
@@ -0,0 +1,1295 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeparticles_p.h"
+
+#include "qdeclarativeitem_p.h"
+
+#include <qdeclarativepixmapcache_p.h>
+#include <qfxperf_p_p.h>
+#include <qdeclarativeanimation_p_p.h>
+
+#include <QNetworkReply>
+#include <QPainter>
+#include <QtGui/qdrawutil.h>
+#include <QVarLengthArray>
+
+#include <stdlib.h>
+#include <math.h>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#define M_PI_2 (M_PI / 2.)
+#endif
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+
+QT_BEGIN_NAMESPACE
+#define PI_SQR 9.8696044
+// parabolic approximation
+inline qreal fastSin(qreal theta)
+{
+ const qreal b = 4 / M_PI;
+ const qreal c = -4 / PI_SQR;
+
+ qreal y = b * theta + c * theta * qAbs(theta);
+ return y;
+}
+
+inline qreal fastCos(qreal theta)
+{
+ theta += M_PI_2;
+ if (theta > M_PI)
+ theta -= 2 * M_PI;
+
+ return fastSin(theta);
+}
+
+class QDeclarativeParticle
+{
+public:
+ QDeclarativeParticle(int time) : lifeSpan(1000), fadeOutAge(800)
+ , opacity(0), birthTime(time), x_velocity(0), y_velocity(0)
+ , state(FadeIn), data(0)
+ {
+ }
+
+ int lifeSpan;
+ int fadeOutAge;
+ qreal x;
+ qreal y;
+ qreal opacity;
+ int birthTime;
+ qreal x_velocity;
+ qreal y_velocity;
+ enum State { FadeIn, Solid, FadeOut };
+ State state;
+ void *data;
+};
+
+//---------------------------------------------------------------------------
+
+/*!
+ \class QDeclarativeParticleMotion
+ \ingroup group_effects
+ \brief The QDeclarativeParticleMotion class is the base class for particle motion.
+ \internal
+
+ This class causes the particles to remain static.
+*/
+
+/*!
+ Constructs a QDeclarativeParticleMotion with parent object \a parent.
+*/
+QDeclarativeParticleMotion::QDeclarativeParticleMotion(QObject *parent) :
+ QObject(parent)
+{
+}
+
+/*!
+ Move the \a particle to its new position. \a interval is the number of
+ milliseconds elapsed since it was last moved.
+*/
+void QDeclarativeParticleMotion::advance(QDeclarativeParticle &particle, int interval)
+{
+ Q_UNUSED(particle);
+ Q_UNUSED(interval);
+}
+
+/*!
+ The \a particle has just been created. Some motion strategies require
+ additional state information. This can be allocated by this function.
+*/
+void QDeclarativeParticleMotion::created(QDeclarativeParticle &particle)
+{
+ Q_UNUSED(particle);
+}
+
+/*!
+ The \a particle is about to be destroyed. Any additional memory
+ that has been allocated for the particle should be freed.
+*/
+void QDeclarativeParticleMotion::destroy(QDeclarativeParticle &particle)
+{
+ Q_UNUSED(particle);
+}
+
+/*!
+ \qmlclass ParticleMotionLinear
+ \since 4.7
+ \brief The ParticleMotionLinear object moves particles linearly.
+
+ \sa Particles
+*/
+
+/*!
+ \internal
+ \class QDeclarativeParticleMotionLinear
+ \ingroup group_effects
+ \brief The QDeclarativeParticleMotionLinear class moves the particles linearly.
+*/
+
+void QDeclarativeParticleMotionLinear::advance(QDeclarativeParticle &p, int interval)
+{
+ p.x += interval * p.x_velocity;
+ p.y += interval * p.y_velocity;
+}
+
+/*!
+ \qmlclass ParticleMotionGravity
+ \since 4.7
+ \brief The ParticleMotionGravity object moves particles towards a point.
+
+ \sa Particles
+*/
+
+/*!
+ \internal
+ \class QDeclarativeParticleMotionGravity
+ \ingroup group_effects
+ \brief The QDeclarativeParticleMotionGravity class moves the particles towards a point.
+*/
+
+/*!
+ \qmlproperty qreal ParticleMotionGravity::xattractor
+ \qmlproperty qreal ParticleMotionGravity::yattractor
+ These properties hold the x and y coordinates of the point attracting the particles.
+*/
+
+/*!
+ \qmlproperty qreal ParticleMotionGravity::acceleration
+ This property holds the acceleration to apply to the particles.
+*/
+
+/*!
+ \property QDeclarativeParticleMotionGravity::xattractor
+ \brief the x coordinate of the point attracting the particles.
+*/
+
+/*!
+ \property QDeclarativeParticleMotionGravity::yattractor
+ \brief the y coordinate of the point attracting the particles.
+*/
+
+/*!
+ \property QDeclarativeParticleMotionGravity::acceleration
+ \brief the acceleration to apply to the particles.
+*/
+
+void QDeclarativeParticleMotionGravity::setXAttractor(qreal x)
+{
+ if (qFuzzyCompare(x, _xAttr))
+ return;
+ _xAttr = x;
+ emit xattractorChanged();
+}
+
+void QDeclarativeParticleMotionGravity::setYAttractor(qreal y)
+{
+ if (qFuzzyCompare(y, _yAttr))
+ return;
+ _yAttr = y;
+ emit yattractorChanged();
+}
+
+void QDeclarativeParticleMotionGravity::setAcceleration(qreal accel)
+{
+ qreal scaledAccel = accel/1000000.0;
+ if (qFuzzyCompare(scaledAccel, _accel))
+ return;
+ _accel = scaledAccel;
+ emit accelerationChanged();
+}
+
+void QDeclarativeParticleMotionGravity::advance(QDeclarativeParticle &p, int interval)
+{
+ qreal xdiff = p.x - _xAttr;
+ qreal ydiff = p.y - _yAttr;
+
+ qreal xcomp = xdiff / (xdiff + ydiff);
+ qreal ycomp = ydiff / (xdiff + ydiff);
+
+ p.x_velocity += xcomp * _accel * interval;
+ p.y_velocity += ycomp * _accel * interval;
+
+ p.x += interval * p.x_velocity;
+ p.y += interval * p.y_velocity;
+}
+
+/*!
+ \qmlclass ParticleMotionWander
+ \since 4.7
+ \brief The ParticleMotionWander object moves particles in a somewhat random fashion.
+
+ The particles will continue roughly in the original direction, however will randomly
+ drift to each side.
+
+ The code below produces an effect similar to falling snow.
+
+ \qml
+Rectangle {
+ width: 240
+ height: 320
+ color: "black"
+
+ Particles {
+ y: 0
+ width: parent.width
+ height: 30
+ source: "star.png"
+ lifeSpan: 5000
+ count: 50
+ angle: 70
+ angleDeviation: 36
+ velocity: 30
+ velocityDeviation: 10
+ ParticleMotionWander {
+ xvariance: 30
+ pace: 100
+ }
+ }
+}
+ \endqml
+
+ \sa Particles
+*/
+
+/*!
+ \internal
+ \class QDeclarativeParticleMotionWander
+ \ingroup group_effects
+ \brief The QDeclarativeParticleMotionWander class moves particles in a somewhat random fashion.
+
+ The particles will continue roughly in the original direction, however will randomly
+ drift to each side.
+*/
+
+/*!
+ \qmlproperty qreal QDeclarativeParticleMotionWander::xvariance
+ \qmlproperty qreal QDeclarativeParticleMotionWander::yvariance
+
+ These properties set the amount to wander in the x and y directions.
+*/
+
+/*!
+ \qmlproperty qreal QDeclarativeParticleMotionWander::pace
+ This property holds how quickly the paricles will move from side to side.
+*/
+
+void QDeclarativeParticleMotionWander::advance(QDeclarativeParticle &p, int interval)
+{
+ if (!particles)
+ particles = qobject_cast<QDeclarativeParticles*>(parent());
+ if (particles) {
+ Data *d = (Data*)p.data;
+ if (_xvariance != 0.) {
+ qreal xdiff = p.x_velocity - d->x_targetV;
+ if ((xdiff > d->x_peak && d->x_var > 0.0) || (xdiff < -d->x_peak && d->x_var < 0.0)) {
+ d->x_var = -d->x_var;
+ d->x_peak = _xvariance + _xvariance * qreal(qrand()) / RAND_MAX;
+ }
+ p.x_velocity += d->x_var * interval;
+ }
+ p.x += interval * p.x_velocity;
+
+ if (_yvariance != 0.) {
+ qreal ydiff = p.y_velocity - d->y_targetV;
+ if ((ydiff > d->y_peak && d->y_var > 0.0) || (ydiff < -d->y_peak && d->y_var < 0.0)) {
+ d->y_var = -d->y_var;
+ d->y_peak = _yvariance + _yvariance * qreal(qrand()) / RAND_MAX;
+ }
+ p.y_velocity += d->y_var * interval;
+ }
+ p.y += interval * p.y_velocity;
+ }
+}
+
+void QDeclarativeParticleMotionWander::created(QDeclarativeParticle &p)
+{
+ if (!p.data) {
+ Data *d = new Data;
+ p.data = (void*)d;
+ d->x_targetV = p.x_velocity;
+ d->y_targetV = p.y_velocity;
+ d->x_peak = _xvariance;
+ d->y_peak = _yvariance;
+ d->x_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0;
+ d->y_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0;
+ }
+}
+
+void QDeclarativeParticleMotionWander::destroy(QDeclarativeParticle &p)
+{
+ if (p.data)
+ delete (Data*)p.data;
+}
+
+void QDeclarativeParticleMotionWander::setXVariance(qreal var)
+{
+ qreal scaledVar = var / 1000.0;
+ if (qFuzzyCompare(scaledVar, _xvariance))
+ return;
+ _xvariance = scaledVar;
+ emit xvarianceChanged();
+}
+
+void QDeclarativeParticleMotionWander::setYVariance(qreal var)
+{
+ qreal scaledVar = var / 1000.0;
+ if (qFuzzyCompare(scaledVar, _yvariance))
+ return;
+ _yvariance = scaledVar;
+ emit yvarianceChanged();
+}
+
+void QDeclarativeParticleMotionWander::setPace(qreal pace)
+{
+ qreal scaledPace = pace / 1000.0;
+ if (qFuzzyCompare(scaledPace, _pace))
+ return;
+ _pace = scaledPace;
+ emit paceChanged();
+}
+
+//---------------------------------------------------------------------------
+class QDeclarativeParticlesPainter : public QDeclarativeItem
+{
+public:
+ QDeclarativeParticlesPainter(QDeclarativeParticlesPrivate *p, QDeclarativeItem* parent)
+ : QDeclarativeItem(parent), d(p)
+ {
+ setFlag(QGraphicsItem::ItemHasNoContents, false);
+ maxX = minX = maxY = minY = 0;
+ }
+
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+ void updateSize();
+
+ qreal maxX;
+ qreal minX;
+ qreal maxY;
+ qreal minY;
+ QDeclarativeParticlesPrivate* d;
+};
+
+//---------------------------------------------------------------------------
+class QDeclarativeParticlesPrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeParticles)
+public:
+ QDeclarativeParticlesPrivate()
+ : count(1), emissionRate(-1), emissionVariance(0.5), lifeSpan(1000)
+ , lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300)
+ , angle(0), angleDev(0), velocity(0), velocityDev(0), emissionCarry(0.)
+ , addParticleTime(0), addParticleCount(0), lastAdvTime(0)
+ , motion(0), pendingPixmapCache(false), clock(this)
+ {
+ }
+
+ ~QDeclarativeParticlesPrivate()
+ {
+ }
+
+ void init()
+ {
+ Q_Q(QDeclarativeParticles);
+ paintItem = new QDeclarativeParticlesPainter(this, q);
+ }
+
+ void tick(int time);
+ void createParticle(int time);
+ void updateOpacity(QDeclarativeParticle &p, int age);
+
+ QUrl url;
+ QPixmap image;
+ int count;
+ int emissionRate;
+ qreal emissionVariance;
+ int lifeSpan;
+ int lifeSpanDev;
+ int fadeInDur;
+ int fadeOutDur;
+ qreal angle;
+ qreal angleDev;
+ qreal velocity;
+ qreal velocityDev;
+ qreal emissionCarry;
+ int addParticleTime;
+ int addParticleCount;
+ int lastAdvTime;
+ QDeclarativeParticleMotion *motion;
+ QDeclarativeParticlesPainter *paintItem;
+
+ bool pendingPixmapCache;
+
+ QList<QPair<int, int> > bursts;//countLeft, emissionRate pairs
+ QList<QDeclarativeParticle> particles;
+ QTickAnimationProxy<QDeclarativeParticlesPrivate, &QDeclarativeParticlesPrivate::tick> clock;
+
+};
+
+void QDeclarativeParticlesPrivate::tick(int time)
+{
+ Q_Q(QDeclarativeParticles);
+ if (!motion)
+ motion = new QDeclarativeParticleMotionLinear(q);
+
+ int oldCount = particles.count();
+ int removed = 0;
+ int interval = time - lastAdvTime;
+ for (int i = 0; i < particles.count(); ) {
+ QDeclarativeParticle &particle = particles[i];
+ int age = time - particle.birthTime;
+ if (age >= particle.lifeSpan) {
+ QDeclarativeParticle part = particles.takeAt(i);
+ motion->destroy(part);
+ ++removed;
+ } else {
+ updateOpacity(particle, age);
+ motion->advance(particle, interval);
+ ++i;
+ }
+ }
+
+ if(emissionRate == -1)//Otherwise leave emission to the emission rate
+ while(removed-- && ((count == -1) || particles.count() < count))
+ createParticle(time);
+
+ if (!addParticleTime)
+ addParticleTime = time;
+
+ //Possibly emit new particles
+ if (((count == -1) || particles.count() < count) && emissionRate
+ && !(count==-1 && emissionRate==-1)) {
+ int emissionCount = -1;
+ if (emissionRate != -1){
+ qreal variance = 1.;
+ if (emissionVariance > 0.){
+ variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.);
+ }
+ qreal emission = emissionRate * (qreal(interval)/1000.);
+ emission = emission * variance + emissionCarry;
+ double tmpDbl;
+ emissionCarry = modf(emission, &tmpDbl);
+ emissionCount = (int)tmpDbl;
+ emissionCount = qMax(0,emissionCount);
+ }
+ while(((count == -1) || particles.count() < count) &&
+ (emissionRate==-1 || emissionCount--))
+ createParticle(time);
+ }
+
+ //Deal with emissions from requested bursts
+ for(int i=0; i<bursts.size(); i++){
+ int emission = 0;
+ if(bursts[i].second == -1){
+ emission = bursts[i].first;
+ }else{
+ qreal variance = 1.;
+ if (emissionVariance > 0.){
+ variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.);
+ }
+ qreal workingEmission = bursts[i].second * (qreal(interval)/1000.);
+ workingEmission *= variance;
+ emission = (int)workingEmission;
+ emission = qMax(emission, 0);
+ }
+ emission = qMin(emission, bursts[i].first);
+ bursts[i].first -= emission;
+ while(emission--)
+ createParticle(time);
+ }
+ for(int i=bursts.size()-1; i>=0; i--)
+ if(bursts[i].first <= 0)
+ bursts.removeAt(i);
+
+ lastAdvTime = time;
+ paintItem->updateSize();
+ paintItem->update();
+ if (!(oldCount || particles.count()) && (!count || !emissionRate) && bursts.isEmpty()) {
+ lastAdvTime = 0;
+ clock.stop();
+ }
+}
+
+void QDeclarativeParticlesPrivate::createParticle(int time)
+{
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::CreateParticle> x;
+#endif
+ Q_Q(QDeclarativeParticles);
+ QDeclarativeParticle p(time);
+ p.x = q->x() + q->width() * qreal(qrand()) / RAND_MAX - image.width()/2.0;
+ p.y = q->y() + q->height() * qreal(qrand()) / RAND_MAX - image.height()/2.0;
+ p.lifeSpan = lifeSpan;
+ if (lifeSpanDev)
+ p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(qrand()) / RAND_MAX);
+ p.fadeOutAge = p.lifeSpan - fadeOutDur;
+ if (fadeInDur == 0.) {
+ p.state= QDeclarativeParticle::Solid;
+ p.opacity = 1.0;
+ }
+ qreal a = angle;
+ if (angleDev)
+ a += angleDev/2 - angleDev * qreal(qrand()) / RAND_MAX;
+ if (a > M_PI)
+ a = a - 2 * M_PI;
+ qreal v = velocity;
+ if (velocityDev)
+ v += velocityDev/2 - velocityDev * qreal(qrand()) / RAND_MAX;
+ p.x_velocity = v * fastCos(a);
+ p.y_velocity = v * fastSin(a);
+ particles.append(p);
+ motion->created(particles.last());
+}
+
+void QDeclarativeParticlesPrivate::updateOpacity(QDeclarativeParticle &p, int age)
+{
+ switch (p.state) {
+ case QDeclarativeParticle::FadeIn:
+ if (age <= fadeInDur) {
+ p.opacity = qreal(age) / fadeInDur;
+ break;
+ } else {
+ p.opacity = 1.0;
+ p.state = QDeclarativeParticle::Solid;
+ // Fall through
+ }
+ case QDeclarativeParticle::Solid:
+ if (age <= p.fadeOutAge) {
+ break;
+ } else {
+ p.state = QDeclarativeParticle::FadeOut;
+ // Fall through
+ }
+ case QDeclarativeParticle::FadeOut:
+ p.opacity = qreal(p.lifeSpan - age) / fadeOutDur;
+ break;
+ }
+}
+
+/*!
+ \qmlclass Particles
+ \since 4.7
+ \brief The Particles object generates and moves particles.
+ \inherits Item
+
+ This element provides preliminary support for particles in QML,
+ and may be heavily changed or removed in later versions.
+
+ The particles created by this object cannot be dealt with
+ directly, they can only be controlled through the parameters of
+ the Particles object. The particles are all the same pixmap,
+ specified by the user.
+
+ The particles are painted relative to the parent of the Particles
+ object. Moving the Particles object will not move the particles
+ already emitted.
+
+ The below example creates two differently behaving particle
+ sources. The top one has particles falling from the top like
+ snow, the lower one has particles expelled up like a fountain.
+
+ \qml
+Rectangle {
+ width: 240
+ height: 320
+ color: "black"
+ Particles {
+ y: 0
+ width: parent.width
+ height: 30
+ source: "star.png"
+ lifeSpan: 5000
+ count: 50
+ angle: 70
+ angleDeviation: 36
+ velocity: 30
+ velocityDeviation: 10
+ ParticleMotionWander {
+ xvariance: 30
+ pace: 100
+ }
+ }
+ Particles {
+ y: 300
+ x: 120
+ width: 1
+ height: 1
+ source: "star.png"
+ lifeSpan: 5000
+ count: 200
+ angle: 270
+ angleDeviation: 45
+ velocity: 50
+ velocityDeviation: 30
+ ParticleMotionGravity {
+ yattractor: 1000
+ xattractor: 0
+ acceleration: 25
+ }
+ }
+}
+ \endqml
+ \image particles.gif
+*/
+
+/*!
+ \internal
+ \class QDeclarativeParticles
+ \ingroup group_effects
+ \brief The QDeclarativeParticles class generates and moves particles.
+*/
+
+QDeclarativeParticles::QDeclarativeParticles(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativeParticlesPrivate), parent)
+{
+ Q_D(QDeclarativeParticles);
+ d->init();
+}
+
+QDeclarativeParticles::~QDeclarativeParticles()
+{
+ Q_D(QDeclarativeParticles);
+ if (d->pendingPixmapCache)
+ QDeclarativePixmapCache::cancel(d->url, this);
+}
+
+/*!
+ \qmlproperty string Particles::source
+ This property holds the URL of the particle image.
+*/
+
+/*!
+ \property QDeclarativeParticles::source
+ \brief the URL of the particle image.
+*/
+QUrl QDeclarativeParticles::source() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->url;
+}
+
+void QDeclarativeParticles::imageLoaded()
+{
+ Q_D(QDeclarativeParticles);
+ d->pendingPixmapCache = false;
+ QDeclarativePixmapCache::get(d->url, &d->image);
+ d->paintItem->updateSize();
+ d->paintItem->update();
+}
+
+void QDeclarativeParticles::setSource(const QUrl &name)
+{
+ Q_D(QDeclarativeParticles);
+
+ if ((d->url.isEmpty() == name.isEmpty()) && name == d->url)
+ return;
+
+ if (d->pendingPixmapCache) {
+ QDeclarativePixmapCache::cancel(d->url, this);
+ d->pendingPixmapCache = false;
+ }
+ if (name.isEmpty()) {
+ d->url = name;
+ d->image = QPixmap();
+ d->paintItem->updateSize();
+ d->paintItem->update();
+ } else {
+ d->url = name;
+ Q_ASSERT(!name.isRelative());
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->image);
+ if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) {
+ QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url);
+ connect(reply, SIGNAL(finished()), this, SLOT(imageLoaded()));
+ d->pendingPixmapCache = true;
+ } else {
+ //### unify with imageLoaded
+ d->paintItem->updateSize();
+ d->paintItem->update();
+ }
+ }
+ emit sourceChanged();
+}
+
+/*!
+ \qmlproperty int Particles::count
+ This property holds the maximum number of particles
+
+ The particles element emits particles until it has count active
+ particles. When this number is reached, new particles are not emitted until
+ some of the current particles reach theend of their lifespan.
+
+ If count is -1 then there is no maximum number of active particles, and
+ particles will be constantly emitted at the rate specified by emissionRate.
+
+ If both count and emissionRate are set to -1, nothing will be emitted.
+
+*/
+
+/*!
+ \property QDeclarativeParticles::count
+ \brief the maximum number of particles
+*/
+int QDeclarativeParticles::count() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->count;
+}
+
+void QDeclarativeParticles::setCount(int cnt)
+{
+ Q_D(QDeclarativeParticles);
+ if (cnt == d->count)
+ return;
+
+ int oldCount = d->count;
+ d->count = cnt;
+ d->addParticleTime = 0;
+ d->addParticleCount = d->particles.count();
+ if (!oldCount && d->clock.state() != QAbstractAnimation::Running && d->count && d->emissionRate) {
+ d->clock.start();
+ }
+ d->paintItem->updateSize();
+ d->paintItem->update();
+ emit countChanged();
+}
+
+
+/*!
+ \qmlproperty int Particles::emissionRate
+ This property holds the target number of particles to emit every second.
+
+ The particles element will emit up to emissionRate particles every
+ second. Fewer particles may be emitted per second if the maximum number of
+ particles has been reached.
+
+ If emissionRate is set to -1 there is no limit to the number of
+ particles emitted per second, and particles will be instantly emitted to
+ reach the maximum number of particles specified by count.
+
+ The default value for emissionRate is -1.
+
+ If both count and emissionRate are set to -1, nothing will be emitted.
+*/
+
+/*!
+ \property QDeclarativeParticles::emissionRate
+ \brief the emission rate of particles
+*/
+int QDeclarativeParticles::emissionRate() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->emissionRate;
+}
+void QDeclarativeParticles::setEmissionRate(int er)
+{
+ Q_D(QDeclarativeParticles);
+ if(er == d->emissionRate)
+ return;
+ d->emissionRate = er;
+ if (d->clock.state() != QAbstractAnimation::Running && d->count && d->emissionRate) {
+ d->clock.start();
+ }
+ emit emissionRateChanged();
+}
+
+/*!
+ \qmlproperty qreal Particles::emissionVariance
+ This property holds how inconsistent the rate of particle emissions are.
+ It is a number between 0 (no variance) and 1 (some variance).
+
+ The expected number of particles emitted per second is emissionRate. If
+ emissionVariance is 0 then particles will be emitted consistently throughout
+ each second to reach that number. If emissionVariance is greater than 0 the
+ rate of particle emission will vary randomly throughout the second, with the
+ consequence that the actual number of particles emitted in one second will
+ vary randomly as well.
+
+ emissionVariance is the maximum deviation from emitting
+ emissionRate particles per second. An emissionVariance of 0 means you should
+ get exactly emissionRate particles emitted per second,
+ and an emissionVariance of 1 means you will get between zero and two times
+ emissionRate particles per second, but you should get emissionRate particles
+ per second on average.
+
+ Note that even with an emissionVariance of 0 there may be some variance due
+ to performance and hardware constraints.
+
+ The default value of emissionVariance is 0.5
+*/
+
+/*!
+ \property QDeclarativeParticles::emissionVariance
+ \brief how much the particle emission amounts vary per tick
+*/
+
+qreal QDeclarativeParticles::emissionVariance() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->emissionVariance;
+}
+
+void QDeclarativeParticles::setEmissionVariance(qreal ev)
+{
+ Q_D(QDeclarativeParticles);
+ if(d->emissionVariance == ev)
+ return;
+ d->emissionVariance = ev;
+ emit emissionVarianceChanged();
+}
+
+/*!
+ \qmlproperty int Particles::lifeSpan
+ \qmlproperty int Particles::lifeSpanDeviation
+
+ These properties describe the life span of each particle.
+
+ The default lifespan for a particle is 1000ms.
+
+ lifeSpanDeviation randomly varies the lifeSpan up to the specified variation. For
+ example, the following creates particles whose lifeSpan will vary
+ from 150ms to 250ms:
+
+ \qml
+Particles {
+ source: "star.png"
+ lifeSpan: 200
+ lifeSpanDeviation: 100
+}
+ \endqml
+*/
+
+/*!
+ \property QDeclarativeParticles::lifeSpan
+ \brief the life span of each particle.
+
+ Default value is 1000ms.
+
+ \sa QDeclarativeParticles::lifeSpanDeviation
+*/
+int QDeclarativeParticles::lifeSpan() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->lifeSpan;
+}
+
+void QDeclarativeParticles::setLifeSpan(int ls)
+{
+ Q_D(QDeclarativeParticles);
+ if(d->lifeSpan == ls)
+ return;
+ d->lifeSpan = ls;
+ emit lifeSpanChanged();
+}
+
+/*!
+ \property QDeclarativeParticles::lifeSpanDeviation
+ \brief the maximum possible deviation from the set lifeSpan.
+
+ Randomly varies the lifeSpan up to the specified variation. For
+ example, the following creates particles whose lifeSpan will vary
+ from 150ms to 250ms:
+
+\qml
+Particles {
+ source: "star.png"
+ lifeSpan: 200
+ lifeSpanDeviation: 100
+}
+\endqml
+
+ \sa QDeclarativeParticles::lifeSpan
+*/
+int QDeclarativeParticles::lifeSpanDeviation() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->lifeSpanDev;
+}
+
+void QDeclarativeParticles::setLifeSpanDeviation(int dev)
+{
+ Q_D(QDeclarativeParticles);
+ if(d->lifeSpanDev == dev)
+ return;
+ d->lifeSpanDev = dev;
+ emit lifeSpanDeviationChanged();
+}
+
+/*!
+ \qmlproperty int Particles::fadeInDuration
+ \qmlproperty int Particles::fadeOutDuration
+ These properties hold the time taken to fade the particles in and out.
+
+ By default fade in is 200ms and fade out is 300ms.
+*/
+
+/*!
+ \property QDeclarativeParticles::fadeInDuration
+ \brief the time taken to fade in the particles.
+
+ Default value is 200ms.
+*/
+int QDeclarativeParticles::fadeInDuration() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->fadeInDur;
+}
+
+void QDeclarativeParticles::setFadeInDuration(int dur)
+{
+ Q_D(QDeclarativeParticles);
+ if (dur < 0.0 || dur == d->fadeInDur)
+ return;
+ d->fadeInDur = dur;
+ emit fadeInDurationChanged();
+}
+
+/*!
+ \property QDeclarativeParticles::fadeOutDuration
+ \brief the time taken to fade out the particles.
+
+ Default value is 300ms.
+*/
+int QDeclarativeParticles::fadeOutDuration() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->fadeOutDur;
+}
+
+void QDeclarativeParticles::setFadeOutDuration(int dur)
+{
+ Q_D(QDeclarativeParticles);
+ if (dur < 0.0 || d->fadeOutDur == dur)
+ return;
+ d->fadeOutDur = dur;
+ emit fadeOutDurationChanged();
+}
+
+/*!
+ \qmlproperty real Particles::angle
+ \qmlproperty real Particles::angleDeviation
+
+ These properties control particle direction.
+
+ angleDeviation randomly varies the direction up to the specified variation. For
+ example, the following creates particles whose initial direction will
+ vary from 15 degrees to 105 degrees:
+
+ \qml
+Particles {
+ source: "star.png"
+ angle: 60
+ angleDeviation: 90
+}
+ \endqml
+*/
+
+/*!
+ \property QDeclarativeParticles::angle
+ \brief the initial angle of direction.
+
+ \sa QDeclarativeParticles::angleDeviation
+*/
+qreal QDeclarativeParticles::angle() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->angle * 180.0 / M_PI;
+}
+
+void QDeclarativeParticles::setAngle(qreal angle)
+{
+ Q_D(QDeclarativeParticles);
+ qreal radAngle = angle * M_PI / 180.0;
+ if(radAngle == d->angle)
+ return;
+ d->angle = radAngle;
+ emit angleChanged();
+}
+
+/*!
+ \property QDeclarativeParticles::angleDeviation
+ \brief the maximum possible deviation from the set angle.
+
+ Randomly varies the direction up to the specified variation. For
+ example, the following creates particles whose initial direction will
+ vary from 15 degrees to 105 degrees:
+
+\qml
+Particles {
+ source: "star.png"
+ angle: 60
+ angleDeviation: 90
+}
+\endqml
+
+ \sa QDeclarativeParticles::angle
+*/
+qreal QDeclarativeParticles::angleDeviation() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->angleDev * 180.0 / M_PI;
+}
+
+void QDeclarativeParticles::setAngleDeviation(qreal dev)
+{
+ Q_D(QDeclarativeParticles);
+ qreal radDev = dev * M_PI / 180.0;
+ if(radDev == d->angleDev)
+ return;
+ d->angleDev = radDev;
+ emit angleDeviationChanged();
+}
+
+/*!
+ \qmlproperty real Particles::velocity
+ \qmlproperty real Particles::velocityDeviation
+
+ These properties control the velocity of the particles.
+
+ velocityDeviation randomly varies the velocity up to the specified variation. For
+ example, the following creates particles whose initial velocity will
+ vary from 40 to 60.
+
+ \qml
+Particles {
+ source: "star.png"
+ velocity: 50
+ velocityDeviation: 20
+}
+ \endqml
+*/
+
+/*!
+ \property QDeclarativeParticles::velocity
+ \brief the initial velocity of the particles.
+
+ \sa QDeclarativeParticles::velocityDeviation
+*/
+qreal QDeclarativeParticles::velocity() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->velocity * 1000.0;
+}
+
+void QDeclarativeParticles::setVelocity(qreal velocity)
+{
+ Q_D(QDeclarativeParticles);
+ qreal realVel = velocity / 1000.0;
+ if(realVel == d->velocity)
+ return;
+ d->velocity = realVel;
+ emit velocityChanged();
+}
+
+/*!
+ \property QDeclarativeParticles::velocityDeviation
+ \brief the maximum possible deviation from the set velocity.
+
+ Randomly varies the velocity up to the specified variation. For
+ example, the following creates particles whose initial velocity will
+ vary from 40 to 60.
+
+\qml
+Particles {
+ source: "star.png"
+ velocity: 50
+ velocityDeviation: 20
+}
+\endqml
+
+ \sa QDeclarativeParticles::velocity
+*/
+qreal QDeclarativeParticles::velocityDeviation() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->velocityDev * 1000.0;
+}
+
+void QDeclarativeParticles::setVelocityDeviation(qreal velocity)
+{
+ Q_D(QDeclarativeParticles);
+ qreal realDev = velocity / 1000.0;
+ if(realDev == d->velocityDev)
+ return;
+ d->velocityDev = realDev;
+ emit velocityDeviationChanged();
+}
+
+/*!
+ \qmlproperty ParticleMotion Particles::motion
+ This property sets the type of motion to apply to the particles.
+
+ When a particle is created it will have an initial direction and velocity.
+ The motion of the particle during its lifeSpan is then influenced by the
+ motion property.
+
+ Default motion is ParticleMotionLinear.
+*/
+
+/*!
+ \property QDeclarativeParticles::motion
+ \brief sets the type of motion to apply to the particles.
+
+ When a particle is created it will have an initial direction and velocity.
+ The motion of the particle during its lifeSpan is then influenced by the
+ motion property.
+
+ Default motion is QDeclarativeParticleMotionLinear.
+*/
+QDeclarativeParticleMotion *QDeclarativeParticles::motion() const
+{
+ Q_D(const QDeclarativeParticles);
+ return d->motion;
+}
+
+void QDeclarativeParticles::setMotion(QDeclarativeParticleMotion *motion)
+{
+ Q_D(QDeclarativeParticles);
+ if (motion == d->motion)
+ return;
+ d->motion = motion;
+ emit motionChanged();
+}
+
+/*!
+ \qmlmethod Particles::burst(int count, int emissionRate)
+
+ Initiates a burst of particles.
+
+ This method takes two arguments. The first argument is the number
+ of particles to emit and the second argument is the emissionRate for the
+ burst. If the second argument is omitted, it is treated as -1. The burst
+ of particles has a separate emissionRate and count to the normal emission of
+ particles. The burst uses the same values as normal emission for all other
+ properties, including emissionVariance.
+
+ The normal emission of particles will continue during the burst, however
+ the particles created by the burst count towards the maximum number used by
+ normal emission. To avoid this behavior, use two Particles elements.
+
+*/
+void QDeclarativeParticles::burst(int count, int emissionRate)
+{
+ Q_D(QDeclarativeParticles);
+ d->bursts << qMakePair(count, emissionRate);
+ if (d->clock.state() != QAbstractAnimation::Running)
+ d->clock.start();
+}
+
+void QDeclarativeParticlesPainter::updateSize()
+{
+ if (!isComponentComplete())
+ return;
+
+ const int parentX = parentItem()->x();
+ const int parentY = parentItem()->y();
+ for (int i = 0; i < d->particles.count(); ++i) {
+ const QDeclarativeParticle &particle = d->particles.at(i);
+ if(particle.x > maxX)
+ maxX = particle.x;
+ if(particle.x < minX)
+ minX = particle.x;
+ if(particle.y > maxY)
+ maxY = particle.y;
+ if(particle.y < minY)
+ minY = particle.y;
+ }
+
+ int myWidth = (int)(maxX-minX+0.5)+d->image.width();
+ int myX = (int)(minX - parentX);
+ int myHeight = (int)(maxY-minY+0.5)+d->image.height();
+ int myY = (int)(minY - parentY);
+ setWidth(myWidth);
+ setHeight(myHeight);
+ setX(myX);
+ setY(myY);
+}
+
+void QDeclarativeParticles::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ Q_UNUSED(p);
+ //painting is done by the ParticlesPainter, so it can have the right size
+}
+
+void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ if (d->image.isNull() || d->particles.isEmpty())
+ return;
+
+ const int myX = x() + parentItem()->x();
+ const int myY = y() + parentItem()->y();
+
+ QVarLengthArray<QDrawPixmaps::Data, 256> pixmapData;
+ pixmapData.resize(d->particles.count());
+
+ const QRectF sourceRect = d->image.rect();
+ qreal halfPWidth = sourceRect.width()/2.;
+ qreal halfPHeight = sourceRect.height()/2.;
+ for (int i = 0; i < d->particles.count(); ++i) {
+ const QDeclarativeParticle &particle = d->particles.at(i);
+ pixmapData[i].point = QPointF(particle.x - myX + halfPWidth, particle.y - myY + halfPHeight);
+ pixmapData[i].opacity = particle.opacity;
+
+ //these never change
+ pixmapData[i].rotation = 0;
+ pixmapData[i].scaleX = 1;
+ pixmapData[i].scaleY = 1;
+ pixmapData[i].source = sourceRect;
+ }
+ qDrawPixmaps(p, pixmapData.data(), d->particles.count(), d->image);
+}
+
+void QDeclarativeParticles::componentComplete()
+{
+ Q_D(QDeclarativeParticles);
+ QDeclarativeItem::componentComplete();
+ if (d->count) {
+ d->paintItem->updateSize();
+ d->clock.start();
+ }
+ if (d->lifeSpanDev > d->lifeSpan)
+ d->lifeSpanDev = d->lifeSpan;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeparticles_p.h b/src/declarative/graphicsitems/qdeclarativeparticles_p.h
new file mode 100644
index 0000000..06acbb9
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeparticles_p.h
@@ -0,0 +1,258 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPARTICLES_H
+#define QDECLARATIVEPARTICLES_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeParticle;
+class QDeclarativeParticles;
+class Q_DECLARATIVE_EXPORT QDeclarativeParticleMotion : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeParticleMotion(QObject *parent=0);
+
+ virtual void advance(QDeclarativeParticle &, int interval);
+ virtual void created(QDeclarativeParticle &);
+ virtual void destroy(QDeclarativeParticle &);
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeParticleMotionLinear : public QDeclarativeParticleMotion
+{
+ Q_OBJECT
+public:
+ QDeclarativeParticleMotionLinear(QObject *parent=0)
+ : QDeclarativeParticleMotion(parent) {}
+
+ virtual void advance(QDeclarativeParticle &, int interval);
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeParticleMotionGravity : public QDeclarativeParticleMotion
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal xattractor READ xAttractor WRITE setXAttractor NOTIFY xattractorChanged)
+ Q_PROPERTY(qreal yattractor READ yAttractor WRITE setYAttractor NOTIFY yattractorChanged)
+ Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
+public:
+ QDeclarativeParticleMotionGravity(QObject *parent=0)
+ : QDeclarativeParticleMotion(parent), _xAttr(0.0), _yAttr(0.0), _accel(0.00005) {}
+
+ qreal xAttractor() const { return _xAttr; }
+ void setXAttractor(qreal x);
+
+ qreal yAttractor() const { return _yAttr; }
+ void setYAttractor(qreal y);
+
+ qreal acceleration() const { return _accel * 1000000; }
+ void setAcceleration(qreal accel);
+
+ virtual void advance(QDeclarativeParticle &, int interval);
+
+Q_SIGNALS:
+ void xattractorChanged();
+ void yattractorChanged();
+ void accelerationChanged();
+
+private:
+ qreal _xAttr;
+ qreal _yAttr;
+ qreal _accel;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeParticleMotionWander : public QDeclarativeParticleMotion
+{
+ Q_OBJECT
+public:
+ QDeclarativeParticleMotionWander()
+ : QDeclarativeParticleMotion(), particles(0), _xvariance(0), _yvariance(0) {}
+
+ virtual void advance(QDeclarativeParticle &, int interval);
+ virtual void created(QDeclarativeParticle &);
+ virtual void destroy(QDeclarativeParticle &);
+
+ struct Data {
+ qreal x_targetV;
+ qreal y_targetV;
+ qreal x_peak;
+ qreal y_peak;
+ qreal x_var;
+ qreal y_var;
+ };
+
+ Q_PROPERTY(qreal xvariance READ xVariance WRITE setXVariance NOTIFY xvarianceChanged)
+ qreal xVariance() const { return _xvariance * 1000.0; }
+ void setXVariance(qreal var);
+
+ Q_PROPERTY(qreal yvariance READ yVariance WRITE setYVariance NOTIFY yvarianceChanged)
+ qreal yVariance() const { return _yvariance * 1000.0; }
+ void setYVariance(qreal var);
+
+ Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged)
+ qreal pace() const { return _pace * 1000.0; }
+ void setPace(qreal pace);
+
+Q_SIGNALS:
+ void xvarianceChanged();
+ void yvarianceChanged();
+ void paceChanged();
+
+private:
+ QDeclarativeParticles *particles;
+ qreal _xvariance;
+ qreal _yvariance;
+ qreal _pace;
+};
+
+class QDeclarativeParticlesPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeParticles : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
+ Q_PROPERTY(int emissionRate READ emissionRate WRITE setEmissionRate NOTIFY emissionRateChanged)
+ Q_PROPERTY(qreal emissionVariance READ emissionVariance WRITE setEmissionVariance NOTIFY emissionVarianceChanged)
+ Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan NOTIFY lifeSpanChanged)
+ Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation NOTIFY lifeSpanDeviationChanged)
+ Q_PROPERTY(int fadeInDuration READ fadeInDuration WRITE setFadeInDuration NOTIFY fadeInDurationChanged)
+ Q_PROPERTY(int fadeOutDuration READ fadeOutDuration WRITE setFadeOutDuration NOTIFY fadeOutDurationChanged)
+ Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
+ Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation NOTIFY angleDeviationChanged)
+ Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
+ Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation NOTIFY velocityDeviationChanged)
+ Q_PROPERTY(QDeclarativeParticleMotion *motion READ motion WRITE setMotion NOTIFY motionChanged)
+ Q_CLASSINFO("DefaultProperty", "motion")
+
+public:
+ QDeclarativeParticles(QDeclarativeItem *parent=0);
+ ~QDeclarativeParticles();
+
+ QUrl source() const;
+ void setSource(const QUrl &);
+
+ int count() const;
+ void setCount(int cnt);
+
+ int emissionRate() const;
+ void setEmissionRate(int);
+
+ qreal emissionVariance() const;
+ void setEmissionVariance(qreal);
+
+ int lifeSpan() const;
+ void setLifeSpan(int);
+
+ int lifeSpanDeviation() const;
+ void setLifeSpanDeviation(int);
+
+ int fadeInDuration() const;
+ void setFadeInDuration(int);
+
+ int fadeOutDuration() const;
+ void setFadeOutDuration(int);
+
+ qreal angle() const;
+ void setAngle(qreal);
+
+ qreal angleDeviation() const;
+ void setAngleDeviation(qreal);
+
+ qreal velocity() const;
+ void setVelocity(qreal);
+
+ qreal velocityDeviation() const;
+ void setVelocityDeviation(qreal);
+
+ QDeclarativeParticleMotion *motion() const;
+ void setMotion(QDeclarativeParticleMotion *);
+
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+public Q_SLOTS:
+ void burst(int count, int emissionRate=-1);
+
+protected:
+ virtual void componentComplete();
+
+Q_SIGNALS:
+ void sourceChanged();
+ void countChanged();
+ void emissionRateChanged();
+ void emissionVarianceChanged();
+ void lifeSpanChanged();
+ void lifeSpanDeviationChanged();
+ void fadeInDurationChanged();
+ void fadeOutDurationChanged();
+ void angleChanged();
+ void angleDeviationChanged();
+ void velocityChanged();
+ void velocityDeviationChanged();
+ void emittingChanged();
+ void motionChanged();
+
+private Q_SLOTS:
+ void imageLoaded();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeParticles)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeParticles)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeParticleMotion)
+QML_DECLARE_TYPE(QDeclarativeParticleMotionLinear)
+QML_DECLARE_TYPE(QDeclarativeParticleMotionGravity)
+QML_DECLARE_TYPE(QDeclarativeParticleMotionWander)
+QML_DECLARE_TYPE(QDeclarativeParticles)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp
new file mode 100644
index 0000000..48f112a
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepath.cpp
@@ -0,0 +1,849 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativepath_p.h"
+#include "qdeclarativepath_p_p.h"
+
+#include <qfxperf_p_p.h>
+
+#include <QSet>
+
+#include <private/qbezier_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass PathElement QDeclarativePathElement
+ \since 4.7
+ \brief PathElement is the base path type.
+
+ This type is the base for all path types. It cannot
+ be instantiated.
+
+ \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic
+*/
+
+/*!
+ \internal
+ \class QDeclarativePathElement
+ \ingroup group_utility
+*/
+
+/*!
+ \qmlclass Path QDeclarativePath
+ \since 4.7
+ \brief A Path object defines a path for use by \l PathView.
+
+ A Path is composed of one or more path segments - PathLine, PathQuad,
+ PathCubic.
+
+ The spacing of the items along the Path can be adjusted via a
+ PathPercent object.
+
+ PathAttribute allows named attributes with values to be defined
+ along the path.
+
+ \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic
+*/
+
+/*!
+ \internal
+ \class QDeclarativePath
+ \ingroup group_utility
+ \brief The QDeclarativePath class defines a path.
+ \sa QDeclarativePathView
+*/
+QDeclarativePath::QDeclarativePath(QObject *parent)
+ : QObject(*(new QDeclarativePathPrivate), parent)
+{
+}
+
+QDeclarativePath::~QDeclarativePath()
+{
+}
+
+/*!
+ \qmlproperty real Path::startX
+ \qmlproperty real Path::startY
+ These properties hold the starting position of the path.
+*/
+qreal QDeclarativePath::startX() const
+{
+ Q_D(const QDeclarativePath);
+ return d->startX;
+}
+
+void QDeclarativePath::setStartX(qreal x)
+{
+ Q_D(QDeclarativePath);
+ d->startX = x;
+}
+
+qreal QDeclarativePath::startY() const
+{
+ Q_D(const QDeclarativePath);
+ return d->startY;
+}
+
+void QDeclarativePath::setStartY(qreal y)
+{
+ Q_D(QDeclarativePath);
+ d->startY = y;
+}
+
+/*!
+ \qmlproperty bool Path::closed
+ This property holds whether the start and end of the path are identical.
+*/
+bool QDeclarativePath::isClosed() const
+{
+ Q_D(const QDeclarativePath);
+ return d->closed;
+}
+
+/*!
+ \qmlproperty list<PathElement> Path::pathElements
+ This property holds the objects composing the path.
+
+ \default
+
+ A path can contain the following path objects:
+ \list
+ \i \l PathLine - a straight line to a given position.
+ \i \l PathQuad - a quadratic Bezier curve to a given position with a control point.
+ \i \l PathCubic - a cubic Bezier curve to a given position with two control points.
+ \i \l PathAttribute - an attribute at a given position in the path.
+ \i \l PathPercent - a way to spread out items along various segments of the path.
+ \endlist
+
+ \snippet doc/src/snippets/declarative/pathview/pathattributes.qml 2
+*/
+
+QDeclarativeListProperty<QDeclarativePathElement> QDeclarativePath::pathElements()
+{
+ Q_D(QDeclarativePath);
+ return QDeclarativeListProperty<QDeclarativePathElement>(this, d->_pathElements);
+}
+
+void QDeclarativePath::interpolate(int idx, const QString &name, qreal value)
+{
+ Q_D(QDeclarativePath);
+ if (!idx)
+ return;
+
+ qreal lastValue = 0;
+ qreal lastPercent = 0;
+ int search = idx - 1;
+ while(search >= 0) {
+ const AttributePoint &point = d->_attributePoints.at(search);
+ if (point.values.contains(name)) {
+ lastValue = point.values.value(name);
+ lastPercent = point.origpercent;
+ break;
+ }
+ --search;
+ }
+
+ ++search;
+
+ const AttributePoint &curPoint = d->_attributePoints.at(idx);
+
+ for (int ii = search; ii < idx; ++ii) {
+ AttributePoint &point = d->_attributePoints[ii];
+
+ qreal val = lastValue + (value - lastValue) * (point.origpercent - lastPercent) / (curPoint.origpercent - lastPercent);
+ point.values.insert(name, val);
+ }
+}
+
+void QDeclarativePath::endpoint(const QString &name)
+{
+ Q_D(QDeclarativePath);
+ const AttributePoint &first = d->_attributePoints.first();
+ qreal val = first.values.value(name);
+ for (int ii = d->_attributePoints.count() - 1; ii >= 0; ii--) {
+ const AttributePoint &point = d->_attributePoints.at(ii);
+ if (point.values.contains(name)) {
+ for (int jj = ii + 1; jj < d->_attributePoints.count(); ++jj) {
+ AttributePoint &setPoint = d->_attributePoints[jj];
+ setPoint.values.insert(name, val);
+ }
+ return;
+ }
+ }
+}
+
+void QDeclarativePath::processPath()
+{
+ Q_D(QDeclarativePath);
+
+ d->_pointCache.clear();
+ d->_attributePoints.clear();
+ d->_path = QPainterPath();
+
+ AttributePoint first;
+ for (int ii = 0; ii < d->_attributes.count(); ++ii)
+ first.values[d->_attributes.at(ii)] = 0;
+ d->_attributePoints << first;
+
+ d->_path.moveTo(d->startX, d->startY);
+
+ QDeclarativeCurve *lastCurve = 0;
+ foreach (QDeclarativePathElement *pathElement, d->_pathElements) {
+ if (QDeclarativeCurve *curve = qobject_cast<QDeclarativeCurve *>(pathElement)) {
+ curve->addToPath(d->_path);
+ AttributePoint p;
+ p.origpercent = d->_path.length();
+ d->_attributePoints << p;
+ lastCurve = curve;
+ } else if (QDeclarativePathAttribute *attribute = qobject_cast<QDeclarativePathAttribute *>(pathElement)) {
+ AttributePoint &point = d->_attributePoints.last();
+ point.values[attribute->name()] = attribute->value();
+ interpolate(d->_attributePoints.count() - 1, attribute->name(), attribute->value());
+ } else if (QDeclarativePathPercent *percent = qobject_cast<QDeclarativePathPercent *>(pathElement)) {
+ AttributePoint &point = d->_attributePoints.last();
+ point.values[QLatin1String("_qfx_percent")] = percent->value();
+ interpolate(d->_attributePoints.count() - 1, QLatin1String("_qfx_percent"), percent->value());
+ }
+ }
+
+ // Fixup end points
+ const AttributePoint &last = d->_attributePoints.last();
+ for (int ii = 0; ii < d->_attributes.count(); ++ii) {
+ if (!last.values.contains(d->_attributes.at(ii)))
+ endpoint(d->_attributes.at(ii));
+ }
+
+ // Adjust percent
+ qreal length = d->_path.length();
+ qreal prevpercent = 0;
+ qreal prevorigpercent = 0;
+ for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
+ const AttributePoint &point = d->_attributePoints.at(ii);
+ if (point.values.contains(QLatin1String("_qfx_percent"))) { //special string for QDeclarativePathPercent
+ if ( ii > 0) {
+ qreal scale = (d->_attributePoints[ii].origpercent/length - prevorigpercent) /
+ (point.values.value(QLatin1String("_qfx_percent"))-prevpercent);
+ d->_attributePoints[ii].scale = scale;
+ }
+ d->_attributePoints[ii].origpercent /= length;
+ d->_attributePoints[ii].percent = point.values.value(QLatin1String("_qfx_percent"));
+ prevorigpercent = d->_attributePoints[ii].origpercent;
+ prevpercent = d->_attributePoints[ii].percent;
+ } else {
+ d->_attributePoints[ii].origpercent /= length;
+ d->_attributePoints[ii].percent = d->_attributePoints[ii].origpercent;
+ }
+ }
+
+ d->closed = lastCurve && d->startX == lastCurve->x() && d->startY == lastCurve->y();
+
+ emit changed();
+}
+
+void QDeclarativePath::componentComplete()
+{
+ Q_D(QDeclarativePath);
+ QSet<QString> attrs;
+ // First gather up all the attributes
+ foreach (QDeclarativePathElement *pathElement, d->_pathElements) {
+ if (QDeclarativePathAttribute *attribute =
+ qobject_cast<QDeclarativePathAttribute *>(pathElement))
+ attrs.insert(attribute->name());
+ }
+ d->_attributes = attrs.toList();
+
+ processPath();
+
+ foreach (QDeclarativePathElement *pathElement, d->_pathElements)
+ connect(pathElement, SIGNAL(changed()), this, SLOT(processPath()));
+}
+
+QPainterPath QDeclarativePath::path() const
+{
+ Q_D(const QDeclarativePath);
+ return d->_path;
+}
+
+QStringList QDeclarativePath::attributes() const
+{
+ Q_D(const QDeclarativePath);
+ return d->_attributes;
+}
+#include <QTime>
+
+static inline QBezier nextBezier(const QPainterPath &path, int *from, qreal *bezLength)
+{
+ const int lastElement = path.elementCount() - 1;
+ for (int i=*from; i <= lastElement; ++i) {
+ const QPainterPath::Element &e = path.elementAt(i);
+
+ switch (e.type) {
+ case QPainterPath::MoveToElement:
+ break;
+ case QPainterPath::LineToElement:
+ {
+ QLineF line(path.elementAt(i-1), e);
+ *bezLength = line.length();
+ QPointF a = path.elementAt(i-1);
+ QPointF delta = e - a;
+ *from = i+1;
+ return QBezier::fromPoints(a, a + delta / 3, a + 2 * delta / 3, e);
+ }
+ case QPainterPath::CurveToElement:
+ {
+ QBezier b = QBezier::fromPoints(path.elementAt(i-1),
+ e,
+ path.elementAt(i+1),
+ path.elementAt(i+2));
+ *bezLength = b.length();
+ *from = i+3;
+ return b;
+ }
+ default:
+ break;
+ }
+ }
+ *from = lastElement;
+ *bezLength = 0;
+ return QBezier();
+}
+
+void QDeclarativePath::createPointCache() const
+{
+ Q_D(const QDeclarativePath);
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::QDeclarativePathViewPathCache> pc;
+#endif
+ qreal pathLength = d->_path.length();
+ const int points = int(pathLength*2);
+ const int lastElement = d->_path.elementCount() - 1;
+ d->_pointCache.resize(points+1);
+
+ int currElement = 0;
+ qreal bezLength = 0;
+ QBezier currBez = nextBezier(d->_path, &currElement, &bezLength);
+ qreal currLength = bezLength;
+ qreal epc = currLength / pathLength;
+
+ for (int i = 0; i < d->_pointCache.size(); i++) {
+ //find which set we are in
+ qreal prevPercent = 0;
+ qreal prevOrigPercent = 0;
+ for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
+ qreal percent = qreal(i)/points;
+ const AttributePoint &point = d->_attributePoints.at(ii);
+ if (percent < point.percent || ii == d->_attributePoints.count() - 1) { //### || is special case for very last item
+ qreal elementPercent = (percent - prevPercent);
+
+ qreal spc = prevOrigPercent + elementPercent * point.scale;
+
+ while (spc > epc) {
+ if (currElement > lastElement)
+ break;
+ currBez = nextBezier(d->_path, &currElement, &bezLength);
+ if (bezLength == 0.0) {
+ currLength = pathLength;
+ epc = 1.0;
+ break;
+ }
+ currLength += bezLength;
+ epc = currLength / pathLength;
+ }
+ qreal realT = (pathLength * spc - (currLength - bezLength)) / bezLength;
+ d->_pointCache[i] = currBez.pointAt(qBound(qreal(0), realT, qreal(1)));
+ break;
+ }
+ prevOrigPercent = point.origpercent;
+ prevPercent = point.percent;
+ }
+ }
+}
+
+QPointF QDeclarativePath::pointAt(qreal p) const
+{
+ Q_D(const QDeclarativePath);
+ if (d->_pointCache.isEmpty()) {
+ createPointCache();
+ }
+ int idx = qRound(p*d->_pointCache.size());
+ if (idx >= d->_pointCache.size())
+ idx = d->_pointCache.size() - 1;
+ else if (idx < 0)
+ idx = 0;
+ return d->_pointCache.at(idx);
+}
+
+qreal QDeclarativePath::attributeAt(const QString &name, qreal percent) const
+{
+ Q_D(const QDeclarativePath);
+ if (percent < 0 || percent > 1)
+ return 0;
+
+ for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
+ const AttributePoint &point = d->_attributePoints.at(ii);
+
+ if (point.percent == percent) {
+ return point.values.value(name);
+ } else if (point.percent > percent) {
+ qreal lastValue =
+ ii?(d->_attributePoints.at(ii - 1).values.value(name)):0;
+ qreal lastPercent =
+ ii?(d->_attributePoints.at(ii - 1).percent):0;
+ qreal curValue = point.values.value(name);
+ qreal curPercent = point.percent;
+
+ return lastValue + (curValue - lastValue) * (percent - lastPercent) / (curPercent - lastPercent);
+ }
+ }
+
+ return 0;
+}
+
+/****************************************************************************/
+
+qreal QDeclarativeCurve::x() const
+{
+ return _x;
+}
+
+void QDeclarativeCurve::setX(qreal x)
+{
+ if (_x != x) {
+ _x = x;
+ emit changed();
+ }
+}
+
+qreal QDeclarativeCurve::y() const
+{
+ return _y;
+}
+
+void QDeclarativeCurve::setY(qreal y)
+{
+ if (_y != y) {
+ _y = y;
+ emit changed();
+ }
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathAttribute QDeclarativePathAttribute
+ \since 4.7
+ \brief The PathAttribute allows setting an attribute at a given position in a Path.
+
+ The PathAttribute object allows attibutes consisting of a name and
+ a value to be specified for the endpoints of path segments. The
+ attributes are exposed to the delegate as
+ \l{qdeclarativeintroduction.html#attached-properties} {Attached Properties}.
+ The value of an attribute at any particular point is interpolated
+ from the PathAttributes bounding the point.
+
+ The example below shows a path with the items scaled to 30% with
+ opacity 50% at the top of the path and scaled 100% with opacity
+ 100% at the bottom. Note the use of the PathView.scale and
+ PathView.opacity attached properties to set the scale and opacity
+ of the delegate.
+
+ \table
+ \row
+ \o \image declarative-pathattribute.png
+ \o
+ \snippet doc/src/snippets/declarative/pathview/pathattributes.qml 0
+ \endtable
+
+ \sa Path
+*/
+
+/*!
+ \internal
+ \class QDeclarativePathAttribute
+ \ingroup group_utility
+ \brief The QDeclarativePathAttribute class allows to set the value of an attribute at a given position in the path.
+
+ \sa QDeclarativePath
+*/
+
+
+/*!
+ \qmlproperty string PathAttribute::name
+ the name of the attribute to change.
+*/
+
+/*!
+ the name of the attribute to change.
+*/
+
+QString QDeclarativePathAttribute::name() const
+{
+ return _name;
+}
+
+void QDeclarativePathAttribute::setName(const QString &name)
+{
+ _name = name;
+}
+
+/*!
+ \qmlproperty string PathAttribute::value
+ the new value of the attribute.
+*/
+
+/*!
+ the new value of the attribute.
+*/
+qreal QDeclarativePathAttribute::value() const
+{
+ return _value;
+}
+
+void QDeclarativePathAttribute::setValue(qreal value)
+{
+ if (_value != value) {
+ _value = value;
+ emit changed();
+ }
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathLine QDeclarativePathLine
+ \since 4.7
+ \brief The PathLine defines a straight line.
+
+ The example below creates a path consisting of a straight line from
+ 0,100 to 200,100:
+
+ \qml
+ Path {
+ startX: 0; startY: 100
+ PathLine { x: 200; y: 100 }
+ }
+ \endqml
+
+ \sa Path, PathQuad, PathCubic
+*/
+
+/*!
+ \internal
+ \class QDeclarativePathLine
+ \ingroup group_utility
+ \brief The QDeclarativePathLine class defines a straight line.
+
+ \sa QDeclarativePath
+*/
+
+/*!
+ \qmlproperty real PathLine::x
+ \qmlproperty real PathLine::y
+
+ Defines the end point of the line.
+*/
+
+void QDeclarativePathLine::addToPath(QPainterPath &path)
+{
+ path.lineTo(x(), y());
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathQuad QDeclarativePathQuad
+ \since 4.7
+ \brief The PathQuad defines a quadratic Bezier curve with a control point.
+
+ The following QML produces the path shown below:
+ \table
+ \row
+ \o \image declarative-pathquad.png
+ \o
+ \qml
+ Path {
+ startX: 0; startY: 0
+ PathQuad x: 200; y: 0; controlX: 100; controlY: 150 }
+ }
+ \endqml
+ \endtable
+
+ \sa Path, PathCubic, PathLine
+*/
+
+/*!
+ \internal
+ \class QDeclarativePathQuad
+ \ingroup group_utility
+ \brief The QDeclarativePathQuad class defines a quadratic Bezier curve with a control point.
+
+ \sa QDeclarativePath
+*/
+
+
+/*!
+ \qmlproperty real PathQuad::x
+ \qmlproperty real PathQuad::y
+
+ Defines the end point of the curve.
+*/
+
+/*!
+ \qmlproperty real PathQuad::controlX
+ \qmlproperty real PathQuad::controlY
+
+ Defines the position of the control point.
+*/
+
+/*!
+ the x position of the control point.
+*/
+qreal QDeclarativePathQuad::controlX() const
+{
+ return _controlX;
+}
+
+void QDeclarativePathQuad::setControlX(qreal x)
+{
+ if (_controlX != x) {
+ _controlX = x;
+ emit changed();
+ }
+}
+
+
+/*!
+ the y position of the control point.
+*/
+qreal QDeclarativePathQuad::controlY() const
+{
+ return _controlY;
+}
+
+void QDeclarativePathQuad::setControlY(qreal y)
+{
+ if (_controlY != y) {
+ _controlY = y;
+ emit changed();
+ }
+}
+
+void QDeclarativePathQuad::addToPath(QPainterPath &path)
+{
+ path.quadTo(controlX(), controlY(), x(), y());
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathCubic QDeclarativePathCubic
+ \since 4.7
+ \brief The PathCubic defines a cubic Bezier curve with two control points.
+
+ The following QML produces the path shown below:
+ \table
+ \row
+ \o \image declarative-pathcubic.png
+ \o
+ \qml
+ Path {
+ startX: 20; startY: 0
+ PathCubic {
+ x: 180; y: 0; control1X: -10; control1Y: 90
+ control2X: 210; control2Y: 90
+ }
+ }
+ \endqml
+ \endtable
+
+ \sa Path, PathQuad, PathLine
+*/
+
+/*!
+ \internal
+ \class QDeclarativePathCubic
+ \ingroup group_utility
+ \brief The QDeclarativePathCubic class defines a cubic Bezier curve with two control points.
+
+ \sa QDeclarativePath
+*/
+
+/*!
+ \qmlproperty real PathCubic::x
+ \qmlproperty real PathCubic::y
+
+ Defines the end point of the curve.
+*/
+
+/*!
+ \qmlproperty real PathCubic::control1X
+ \qmlproperty real PathCubic::control1Y
+
+ Defines the position of the first control point.
+*/
+qreal QDeclarativePathCubic::control1X() const
+{
+ return _control1X;
+}
+
+void QDeclarativePathCubic::setControl1X(qreal x)
+{
+ if (_control1X != x) {
+ _control1X = x;
+ emit changed();
+ }
+}
+
+qreal QDeclarativePathCubic::control1Y() const
+{
+ return _control1Y;
+}
+
+void QDeclarativePathCubic::setControl1Y(qreal y)
+{
+ if (_control1Y != y) {
+ _control1Y = y;
+ emit changed();
+ }
+}
+
+/*!
+ \qmlproperty real PathCubic::control2X
+ \qmlproperty real PathCubic::control2Y
+
+ Defines the position of the second control point.
+*/
+qreal QDeclarativePathCubic::control2X() const
+{
+ return _control2X;
+}
+
+void QDeclarativePathCubic::setControl2X(qreal x)
+{
+ if (_control2X != x) {
+ _control2X = x;
+ emit changed();
+ }
+}
+
+qreal QDeclarativePathCubic::control2Y() const
+{
+ return _control2Y;
+}
+
+void QDeclarativePathCubic::setControl2Y(qreal y)
+{
+ if (_control2Y != y) {
+ _control2Y = y;
+ emit changed();
+ }
+}
+
+void QDeclarativePathCubic::addToPath(QPainterPath &path)
+{
+ path.cubicTo(control1X(), control1Y(), control2X(), control2Y(), x(), y());
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathPercent QDeclarativePathPercent
+ \since 4.7
+ \brief The PathPercent manipulates the way a path is interpreted.
+
+ The examples below show the normal distrubution of items along a path
+ compared to a distribution which places 50% of the items along the
+ PathLine section of the path.
+ \table
+ \row
+ \o \image declarative-nopercent.png
+ \o
+ \qml
+ Path {
+ startX: 20; startY: 0
+ PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 }
+ PathLine { x: 150; y: 80 }
+ PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 }
+ }
+ \endqml
+ \row
+ \o \image declarative-percent.png
+ \o
+ \qml
+ Path {
+ startX: 20; startY: 0
+ PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 }
+ PathPercent { value: 0.25 }
+ PathLine { x: 150; y: 80 }
+ PathPercent { value: 0.75 }
+ PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 }
+ PathPercent { value: 1 }
+ }
+ \endqml
+ \endtable
+
+ \sa Path
+*/
+
+/*!
+ \internal
+ \class QDeclarativePathPercent
+ \ingroup group_utility
+ \brief The QDeclarativePathPercent class manipulates the way a path is interpreted.
+
+ QDeclarativePathPercent allows you to bunch up items (or spread out items) along various
+ segments of a QDeclarativePathView's path.
+
+ \sa QDeclarativePath
+
+*/
+
+qreal QDeclarativePathPercent::value() const
+{
+ return _value;
+}
+
+void QDeclarativePathPercent::setValue(qreal value)
+{
+ _value = value;
+}
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativepath_p.h b/src/declarative/graphicsitems/qdeclarativepath_p.h
new file mode 100644
index 0000000..b3139f8
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepath_p.h
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPATH_H
+#define QDECLARATIVEPATH_H
+
+#include "qdeclarativeitem.h"
+
+#include <qdeclarative.h>
+
+#include <QtCore/QObject>
+#include <QtGui/QPainterPath>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+class Q_DECLARATIVE_EXPORT QDeclarativePathElement : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativePathElement(QObject *parent=0) : QObject(parent) {}
+Q_SIGNALS:
+ void changed();
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativePathAttribute : public QDeclarativePathElement
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY changed)
+public:
+ QDeclarativePathAttribute(QObject *parent=0) : QDeclarativePathElement(parent), _value(0) {}
+
+
+ QString name() const;
+ void setName(const QString &name);
+
+ qreal value() const;
+ void setValue(qreal value);
+
+private:
+ QString _name;
+ qreal _value;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeCurve : public QDeclarativePathElement
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal x READ x WRITE setX NOTIFY changed)
+ Q_PROPERTY(qreal y READ y WRITE setY NOTIFY changed)
+public:
+ QDeclarativeCurve(QObject *parent=0) : QDeclarativePathElement(parent), _x(0), _y(0) {}
+
+ qreal x() const;
+ void setX(qreal x);
+
+ qreal y() const;
+ void setY(qreal y);
+
+ virtual void addToPath(QPainterPath &) {}
+
+private:
+ qreal _x;
+ qreal _y;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativePathLine : public QDeclarativeCurve
+{
+ Q_OBJECT
+public:
+ QDeclarativePathLine(QObject *parent=0) : QDeclarativeCurve(parent) {}
+
+ void addToPath(QPainterPath &path);
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativePathQuad : public QDeclarativeCurve
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal controlX READ controlX WRITE setControlX NOTIFY changed)
+ Q_PROPERTY(qreal controlY READ controlY WRITE setControlY NOTIFY changed)
+public:
+ QDeclarativePathQuad(QObject *parent=0) : QDeclarativeCurve(parent), _controlX(0), _controlY(0) {}
+
+ qreal controlX() const;
+ void setControlX(qreal x);
+
+ qreal controlY() const;
+ void setControlY(qreal y);
+
+ void addToPath(QPainterPath &path);
+
+private:
+ qreal _controlX;
+ qreal _controlY;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativePathCubic : public QDeclarativeCurve
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal control1X READ control1X WRITE setControl1X NOTIFY changed)
+ Q_PROPERTY(qreal control1Y READ control1Y WRITE setControl1Y NOTIFY changed)
+ Q_PROPERTY(qreal control2X READ control2X WRITE setControl2X NOTIFY changed)
+ Q_PROPERTY(qreal control2Y READ control2Y WRITE setControl2Y NOTIFY changed)
+public:
+ QDeclarativePathCubic(QObject *parent=0) : QDeclarativeCurve(parent), _control1X(0), _control1Y(0), _control2X(0), _control2Y(0) {}
+
+ qreal control1X() const;
+ void setControl1X(qreal x);
+
+ qreal control1Y() const;
+ void setControl1Y(qreal y);
+
+ qreal control2X() const;
+ void setControl2X(qreal x);
+
+ qreal control2Y() const;
+ void setControl2Y(qreal y);
+
+ void addToPath(QPainterPath &path);
+
+private:
+ int _control1X;
+ int _control1Y;
+ int _control2X;
+ int _control2Y;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativePathPercent : public QDeclarativePathElement
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal value READ value WRITE setValue)
+public:
+ QDeclarativePathPercent(QObject *parent=0) : QDeclarativePathElement(parent) {}
+
+ qreal value() const;
+ void setValue(qreal value);
+
+private:
+ qreal _value;
+};
+
+class QDeclarativePathPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativePath : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+
+ Q_INTERFACES(QDeclarativeParserStatus)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativePathElement> pathElements READ pathElements)
+ Q_PROPERTY(qreal startX READ startX WRITE setStartX)
+ Q_PROPERTY(qreal startY READ startY WRITE setStartY)
+ Q_PROPERTY(bool closed READ isClosed NOTIFY changed)
+ Q_CLASSINFO("DefaultProperty", "pathElements")
+ Q_INTERFACES(QDeclarativeParserStatus)
+public:
+ QDeclarativePath(QObject *parent=0);
+ ~QDeclarativePath();
+
+ QDeclarativeListProperty<QDeclarativePathElement> pathElements();
+
+ qreal startX() const;
+ void setStartX(qreal x);
+
+ qreal startY() const;
+ void setStartY(qreal y);
+
+ bool isClosed() const;
+
+ QPainterPath path() const;
+ QStringList attributes() const;
+ qreal attributeAt(const QString &, qreal) const;
+ QPointF pointAt(qreal) const;
+
+Q_SIGNALS:
+ void changed();
+
+protected:
+ virtual void componentComplete();
+
+private Q_SLOTS:
+ void processPath();
+
+private:
+ struct AttributePoint {
+ AttributePoint() : percent(0), scale(1), origpercent(0) {}
+ AttributePoint(const AttributePoint &other)
+ : percent(other.percent), scale(other.scale), origpercent(other.origpercent), values(other.values) {}
+ AttributePoint &operator=(const AttributePoint &other) {
+ percent = other.percent; scale = other.scale; origpercent = other.origpercent; values = other.values; return *this;
+ }
+ qreal percent; //massaged percent along the painter path
+ qreal scale;
+ qreal origpercent; //'real' percent along the painter path
+ QHash<QString, qreal> values;
+ };
+
+ void interpolate(int idx, const QString &name, qreal value);
+ void endpoint(const QString &name);
+ void createPointCache() const;
+
+private:
+ Q_DISABLE_COPY(QDeclarativePath)
+ Q_DECLARE_PRIVATE(QDeclarativePath)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativePathElement)
+QML_DECLARE_TYPE(QDeclarativePathAttribute)
+QML_DECLARE_TYPE(QDeclarativeCurve)
+QML_DECLARE_TYPE(QDeclarativePathLine)
+QML_DECLARE_TYPE(QDeclarativePathQuad)
+QML_DECLARE_TYPE(QDeclarativePathCubic)
+QML_DECLARE_TYPE(QDeclarativePathPercent)
+QML_DECLARE_TYPE(QDeclarativePath)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPATH_H
diff --git a/src/declarative/graphicsitems/qdeclarativepath_p_p.h b/src/declarative/graphicsitems/qdeclarativepath_p_p.h
new file mode 100644
index 0000000..fb63867
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepath_p_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPATH_P_H
+#define QDECLARATIVEPATH_P_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 "qdeclarativepath_p.h"
+
+#include <qdeclarative.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+class QDeclarativePathPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativePath)
+
+public:
+ QDeclarativePathPrivate() : startX(0), startY(0), closed(false) { }
+
+ QPainterPath _path;
+ QList<QDeclarativePathElement*> _pathElements;
+ mutable QVector<QPointF> _pointCache;
+ QList<QDeclarativePath::AttributePoint> _attributePoints;
+ QStringList _attributes;
+ int startX;
+ int startY;
+ bool closed;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
new file mode 100644
index 0000000..b9e38ef
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -0,0 +1,979 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativepathview_p.h"
+#include "qdeclarativepathview_p_p.h"
+
+#include <qdeclarativestate_p.h>
+#include <qdeclarativeopenmetaobject_p.h>
+
+#include <QDebug>
+#include <QEvent>
+#include <qlistmodelinterface_p.h>
+#include <QGraphicsSceneEvent>
+
+#include <math.h>
+
+QT_BEGIN_NAMESPACE
+
+inline qreal qmlMod(qreal x, qreal y)
+{
+#ifdef QT_USE_MATH_H_FLOATS
+ if(sizeof(qreal) == sizeof(float))
+ return fmodf(float(x), float(y));
+ else
+#endif
+ return fmod(x, y);
+}
+
+
+class QDeclarativePathViewAttached : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool onPath READ isOnPath NOTIFY onPathChanged)
+public:
+ QDeclarativePathViewAttached(QObject *parent)
+ : QObject(parent), mo(new QDeclarativeOpenMetaObject(this)), onPath(false)
+ {
+ }
+
+ ~QDeclarativePathViewAttached()
+ {
+ QDeclarativePathView::attachedProperties.remove(parent());
+ }
+
+ QVariant value(const QByteArray &name) const
+ {
+ return mo->value(name);
+ }
+ void setValue(const QByteArray &name, const QVariant &val)
+ {
+ mo->setValue(name, val);
+ }
+
+ bool isOnPath() const { return onPath; }
+ void setOnPath(bool on) {
+ if (on != onPath) {
+ onPath = on;
+ emit onPathChanged();
+ }
+ }
+
+Q_SIGNALS:
+ void onPathChanged();
+
+private:
+ QDeclarativeOpenMetaObject *mo;
+ bool onPath;
+};
+
+
+QDeclarativeItem *QDeclarativePathViewPrivate::getItem(int modelIndex)
+{
+ Q_Q(QDeclarativePathView);
+ requestedIndex = modelIndex;
+ QDeclarativeItem *item = model->item(modelIndex);
+ if (item) {
+ if (QObject *obj = QDeclarativePathView::qmlAttachedProperties(item))
+ static_cast<QDeclarativePathViewAttached *>(obj)->setOnPath(true);
+ item->setParentItem(q);
+ }
+ requestedIndex = -1;
+ return item;
+}
+
+void QDeclarativePathViewPrivate::releaseItem(QDeclarativeItem *item)
+{
+ if (!item || !model)
+ return;
+ if (QObject *obj = QDeclarativePathView::qmlAttachedProperties(item))
+ static_cast<QDeclarativePathViewAttached *>(obj)->setOnPath(false);
+ if (model->release(item) == 0) {
+ if (QObject *obj = QDeclarativePathView::qmlAttachedProperties(item))
+ static_cast<QDeclarativePathViewAttached *>(obj)->setOnPath(false);
+ }
+}
+
+/*!
+ \qmlclass PathView QDeclarativePathView
+ \since 4.7
+ \brief The PathView element lays out model-provided items on a path.
+ \inherits Item
+
+ The model is typically provided by a QAbstractListModel "C++ model object", but can also be created directly in QML.
+
+ The items are laid out along a path defined by a \l Path and may be flicked to scroll.
+
+ \snippet doc/src/snippets/declarative/pathview/pathview.qml 0
+
+ \image pathview.gif
+
+ \sa Path
+*/
+
+QDeclarativePathView::QDeclarativePathView(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativePathViewPrivate), parent)
+{
+ Q_D(QDeclarativePathView);
+ d->init();
+}
+
+QDeclarativePathView::~QDeclarativePathView()
+{
+ Q_D(QDeclarativePathView);
+ if (d->ownModel)
+ delete d->model;
+}
+
+/*!
+ \qmlattachedproperty bool PathView::onPath
+ This attached property holds whether the item is currently on the path.
+
+ If a pathItemCount has been set, it is possible that some items may
+ be instantiated, but not considered to be currently on the path.
+ Usually, these items would be set invisible, for example:
+
+ \code
+ Component {
+ Rectangle {
+ visible: PathView.onPath
+ ...
+ }
+ }
+ \endcode
+
+ It is attached to each instance of the delegate.
+*/
+
+/*!
+ \qmlproperty model PathView::model
+ This property holds the model providing data for the view.
+
+ The model provides a set of data that is used to create the items for the view.
+ For large or dynamic datasets the model is usually provided by a C++ model object.
+ Models can also be created directly in XML, using the ListModel element.
+
+ \sa {qmlmodels}{Data Models}
+*/
+QVariant QDeclarativePathView::model() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->modelVariant;
+}
+
+void QDeclarativePathView::setModel(const QVariant &model)
+{
+ Q_D(QDeclarativePathView);
+ if (d->model) {
+ disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
+ disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
+ for (int i=0; i<d->items.count(); i++){
+ QDeclarativeItem *p = d->items[i];
+ d->model->release(p);
+ }
+ d->items.clear();
+ }
+
+ d->modelVariant = model;
+ QObject *object = qvariant_cast<QObject*>(model);
+ QDeclarativeVisualModel *vim = 0;
+ if (object && (vim = qobject_cast<QDeclarativeVisualModel *>(object))) {
+ if (d->ownModel) {
+ delete d->model;
+ d->ownModel = false;
+ }
+ d->model = vim;
+ } else {
+ if (!d->ownModel) {
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->ownModel = true;
+ }
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
+ dataModel->setModel(model);
+ }
+ if (d->model) {
+ connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
+ connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
+ }
+ d->firstIndex = 0;
+ d->pathOffset = 0;
+ d->regenerate();
+ d->fixOffset();
+}
+
+/*!
+ \qmlproperty int PathView::count
+ This property holds the number of items in the model.
+*/
+int QDeclarativePathView::count() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->model ? d->model->count() : 0;
+}
+
+/*!
+ \qmlproperty Path PathView::path
+ \default
+ This property holds the path used to lay out the items.
+ For more information see the \l Path documentation.
+*/
+QDeclarativePath *QDeclarativePathView::path() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->path;
+}
+
+void QDeclarativePathView::setPath(QDeclarativePath *path)
+{
+ Q_D(QDeclarativePathView);
+ d->path = path;
+ connect(d->path, SIGNAL(changed()), this, SLOT(refill()));
+ d->regenerate();
+}
+
+/*!
+ \qmlproperty int PathView::currentIndex
+ This property holds the index of the current item.
+*/
+int QDeclarativePathView::currentIndex() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->currentIndex;
+}
+
+void QDeclarativePathView::setCurrentIndex(int idx)
+{
+ Q_D(QDeclarativePathView);
+ if (d->model && d->model->count())
+ idx = qAbs(idx % d->model->count());
+ if (d->model && idx != d->currentIndex) {
+ d->currentIndex = idx;
+ if (d->model->count()) {
+ d->snapToCurrent();
+ int itemIndex = (idx - d->firstIndex + d->model->count()) % d->model->count();
+ if (itemIndex < d->items.count())
+ d->items.at(itemIndex)->setFocus(true);
+ }
+ emit currentIndexChanged();
+ }
+}
+
+/*!
+ \qmlproperty real PathView::offset
+
+ The offset specifies how far along the path the items are from their initial positions.
+*/
+qreal QDeclarativePathView::offset() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->_offset;
+}
+
+void QDeclarativePathView::setOffset(qreal offset)
+{
+ Q_D(QDeclarativePathView);
+ d->setOffset(offset);
+ d->updateCurrent();
+}
+
+void QDeclarativePathViewPrivate::setOffset(qreal o)
+{
+ Q_Q(QDeclarativePathView);
+ if (_offset != o) {
+ _offset = qmlMod(o, qreal(100.0));
+ if (_offset < 0)
+ _offset = 100.0 + _offset;
+ q->refill();
+ }
+}
+
+/*!
+ \qmlproperty real PathView::snapPosition
+
+ This property determines the position (0-100) the nearest item will snap to.
+*/
+qreal QDeclarativePathView::snapPosition() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->snapPos;
+}
+
+void QDeclarativePathView::setSnapPosition(qreal pos)
+{
+ Q_D(QDeclarativePathView);
+ d->snapPos = pos/100;
+ d->fixOffset();
+}
+
+/*!
+ \qmlproperty real PathView::dragMargin
+ This property holds the maximum distance from the path that initiate mouse dragging.
+
+ By default the path can only be dragged by clicking on an item. If
+ dragMargin is greater than zero, a drag can be initiated by clicking
+ within dragMargin pixels of the path.
+*/
+qreal QDeclarativePathView::dragMargin() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->dragMargin;
+}
+
+void QDeclarativePathView::setDragMargin(qreal dragMargin)
+{
+ Q_D(QDeclarativePathView);
+ d->dragMargin = dragMargin;
+}
+
+/*!
+ \qmlproperty component PathView::delegate
+
+ The delegate provides a template defining each item instantiated by the view.
+ The index is exposed as an accessible \c index property. Properties of the
+ model are also available depending upon the type of \l {qmlmodels}{Data Model}.
+
+ Note that the PathView will layout the items based on the size of the root
+ item in the delegate.
+
+ Here is an example delegate:
+ \snippet doc/src/snippets/declarative/pathview/pathview.qml 1
+*/
+QDeclarativeComponent *QDeclarativePathView::delegate() const
+{
+ Q_D(const QDeclarativePathView);
+ if (d->model) {
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
+ return dataModel->delegate();
+ }
+
+ return 0;
+}
+
+void QDeclarativePathView::setDelegate(QDeclarativeComponent *c)
+{
+ Q_D(QDeclarativePathView);
+ if (!d->ownModel) {
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->ownModel = true;
+ }
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) {
+ dataModel->setDelegate(c);
+ d->regenerate();
+ }
+}
+
+/*!
+ \qmlproperty int PathView::pathItemCount
+ This property holds the number of items visible on the path at any one time
+*/
+int QDeclarativePathView::pathItemCount() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->pathItems;
+}
+
+void QDeclarativePathView::setPathItemCount(int i)
+{
+ Q_D(QDeclarativePathView);
+ if (i == d->pathItems)
+ return;
+ d->pathItems = i;
+ d->regenerate();
+}
+
+QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
+{
+ //XXX maybe do recursively at increasing resolution.
+ qreal mindist = 1e10; // big number
+ QPointF nearPoint = path->pointAt(0);
+ qreal nearPc = 0;
+ for (qreal i=1; i < 1000; i++) {
+ QPointF pt = path->pointAt(i/1000.0);
+ QPointF diff = pt - point;
+ qreal dist = diff.x()*diff.x() + diff.y()*diff.y();
+ if (dist < mindist) {
+ nearPoint = pt;
+ nearPc = i;
+ mindist = dist;
+ }
+ }
+
+ if (nearPercent)
+ *nearPercent = nearPc / 10.0;
+
+ return nearPoint;
+}
+
+
+void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativePathView);
+ if (!d->items.count())
+ return;
+ QPointF scenePoint = mapToScene(event->pos());
+ int idx = 0;
+ for (; idx < d->items.count(); ++idx) {
+ QRectF rect = d->items.at(idx)->boundingRect();
+ rect = d->items.at(idx)->mapToScene(rect).boundingRect();
+ if (rect.contains(scenePoint))
+ break;
+ }
+ if (idx == d->items.count() && d->dragMargin == 0.) // didn't click on an item
+ return;
+
+ d->startPoint = d->pointNear(event->pos(), &d->startPc);
+ if (idx == d->items.count()) {
+ qreal distance = qAbs(event->pos().x() - d->startPoint.x()) + qAbs(event->pos().y() - d->startPoint.y());
+ if (distance > d->dragMargin)
+ return;
+ }
+
+ d->stealMouse = false;
+ d->lastElapsed = 0;
+ d->lastDist = 0;
+ QDeclarativeItemPrivate::start(d->lastPosTime);
+ d->tl.clear();
+}
+
+void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativePathView);
+ if (d->lastPosTime.isNull())
+ return;
+
+ if (!d->stealMouse) {
+ QPointF delta = event->pos() - d->startPoint;
+ if (qAbs(delta.x()) > QApplication::startDragDistance() && qAbs(delta.y()) > QApplication::startDragDistance())
+ d->stealMouse = true;
+ }
+
+ if (d->stealMouse) {
+ d->moveReason = QDeclarativePathViewPrivate::Mouse;
+ qreal newPc;
+ d->pointNear(event->pos(), &newPc);
+ qreal diff = newPc - d->startPc;
+ if (diff) {
+ setOffset(d->_offset + diff);
+
+ if (diff > 50)
+ diff -= 100;
+ else if (diff < -50)
+ diff += 100;
+
+ d->lastElapsed = QDeclarativeItemPrivate::restart(d->lastPosTime);
+ d->lastDist = diff;
+ d->startPc = newPc;
+ }
+ }
+}
+
+void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
+{
+ Q_D(QDeclarativePathView);
+ if (d->lastPosTime.isNull())
+ return;
+
+ qreal elapsed = qreal(d->lastElapsed + QDeclarativeItemPrivate::elapsed(d->lastPosTime)) / 1000.;
+ qreal velocity = elapsed > 0. ? d->lastDist / elapsed : 0;
+ if (d->model && d->model->count() && qAbs(velocity) > 5) {
+ if (velocity > 100)
+ velocity = 100;
+ else if (velocity < -100)
+ velocity = -100;
+ qreal inc = qmlMod(d->_offset - d->snapPos, qreal(100.0 / d->model->count()));
+ qreal dist = qAbs(velocity/2 - qmlMod(velocity/2, qreal(100.0 / d->model->count()) - inc));
+ d->moveOffset.setValue(d->_offset);
+ d->tl.accel(d->moveOffset, velocity, 10, dist);
+ d->tl.callback(QDeclarativeTimeLineCallback(&d->moveOffset, d->fixOffsetCallback, d));
+ } else {
+ d->fixOffset();
+ }
+
+ d->lastPosTime = QTime();
+ d->stealMouse = false;
+ ungrabMouse();
+}
+
+bool QDeclarativePathView::sendMouseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativePathView);
+ QGraphicsSceneMouseEvent mouseEvent(event->type());
+ QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect();
+ QGraphicsScene *s = scene();
+ QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0;
+ if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
+ mouseEvent.setAccepted(false);
+ for (int i = 0x1; i <= 0x10; i <<= 1) {
+ if (event->buttons() & i) {
+ Qt::MouseButton button = Qt::MouseButton(i);
+ mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button)));
+ }
+ }
+ mouseEvent.setScenePos(event->scenePos());
+ mouseEvent.setLastScenePos(event->lastScenePos());
+ mouseEvent.setPos(mapFromScene(event->scenePos()));
+ mouseEvent.setLastPos(mapFromScene(event->lastScenePos()));
+
+ switch(mouseEvent.type()) {
+ case QEvent::GraphicsSceneMouseMove:
+ mouseMoveEvent(&mouseEvent);
+ break;
+ case QEvent::GraphicsSceneMousePress:
+ mousePressEvent(&mouseEvent);
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ mouseReleaseEvent(&mouseEvent);
+ break;
+ default:
+ break;
+ }
+ grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem());
+ if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this)
+ grabMouse();
+
+ return d->stealMouse;
+ } else if (!d->lastPosTime.isNull()) {
+ d->lastPosTime = QTime();
+ }
+ return false;
+}
+
+bool QDeclarativePathView::sceneEventFilter(QGraphicsItem *i, QEvent *e)
+{
+ if (!isVisible())
+ return QDeclarativeItem::sceneEventFilter(i, e);
+
+ switch (e->type()) {
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMouseRelease:
+ {
+ bool ret = sendMouseEvent(static_cast<QGraphicsSceneMouseEvent *>(e));
+ if (e->type() == QEvent::GraphicsSceneMouseRelease)
+ return ret;
+ break;
+ }
+ default:
+ break;
+ }
+
+ return QDeclarativeItem::sceneEventFilter(i, e);
+}
+
+void QDeclarativePathView::componentComplete()
+{
+ Q_D(QDeclarativePathView);
+ QDeclarativeItem::componentComplete();
+ d->regenerate();
+
+ // move to correct offset
+ if (d->items.count()) {
+ int itemIndex = (d->currentIndex - d->firstIndex + d->model->count()) % d->model->count();
+
+ itemIndex += d->pathOffset;
+ itemIndex %= d->items.count();
+ qreal targetOffset = qmlMod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0));
+
+ if (targetOffset < 0)
+ targetOffset = 100.0 + targetOffset;
+ if (targetOffset != d->_offset) {
+ d->moveOffset.setValue(targetOffset);
+ }
+ }
+}
+
+void QDeclarativePathViewPrivate::regenerate()
+{
+ Q_Q(QDeclarativePathView);
+ if (!q->isComponentComplete())
+ return;
+
+ for (int i=0; i<items.count(); i++){
+ QDeclarativeItem *p = items[i];
+ releaseItem(p);
+ }
+ items.clear();
+
+ if (!isValid())
+ return;
+
+ if (firstIndex >= model->count())
+ firstIndex = model->count()-1;
+ if (pathOffset >= model->count())
+ pathOffset = model->count()-1;
+
+ int numItems = pathItems >= 0 ? pathItems : model->count();
+ for (int i=0; i < numItems && i < model->count(); ++i){
+ int index = (i + firstIndex) % model->count();
+ QDeclarativeItem *item = getItem(index);
+ if (!item) {
+ qWarning() << "PathView: Cannot create item, index" << (i + firstIndex) % model->count();
+ return;
+ }
+ items.append(item);
+ item->setZValue(i);
+ if (currentIndex == index)
+ item->setFocus(true);
+ }
+ q->refill();
+}
+
+void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent)
+{
+ if (QObject *obj = QDeclarativePathView::qmlAttachedProperties(item)) {
+ foreach(const QString &attr, path->attributes())
+ static_cast<QDeclarativePathViewAttached *>(obj)->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
+ }
+ QPointF pf = path->pointAt(percent);
+ item->setX(pf.x() - item->width()*item->scale()/2);
+ item->setY(pf.y() - item->height()*item->scale()/2);
+}
+
+void QDeclarativePathView::refill()
+{
+ Q_D(QDeclarativePathView);
+ if (!d->isValid() || !isComponentComplete())
+ return;
+
+ QList<qreal> positions;
+ for (int i=0; i<d->items.count(); i++){
+ qreal percent = i * (100. / d->items.count());
+ percent = percent + d->_offset;
+ percent = qmlMod(percent, qreal(100.0));
+ positions << qAbs(percent/100.0);
+ }
+
+ if (d->pathItems==-1) {
+ for (int i=0; i<positions.count(); i++)
+ d->updateItem(d->items.at(i), positions[i]);
+ return;
+ }
+
+ QList<qreal> rotatedPositions;
+ for (int i=0; i<d->items.count(); i++)
+ rotatedPositions << positions[(i + d->pathOffset + d->items.count()) % d->items.count()];
+
+ int wrapIndex= -1;
+ for (int i=0; i<d->items.count()-1; i++) {
+ if (rotatedPositions[i] > rotatedPositions[i+1]){
+ wrapIndex = i;
+ break;
+ }
+ }
+ if (wrapIndex != -1 ){
+ //A wraparound has occured
+ if (wrapIndex < d->items.count()/2){
+ while(wrapIndex-- >= 0){
+ QDeclarativeItem* p = d->items.takeFirst();
+ d->updateItem(p, 0.0);
+ d->releaseItem(p);
+ d->firstIndex++;
+ d->firstIndex %= d->model->count();
+ int index = (d->firstIndex + d->items.count())%d->model->count();
+ QDeclarativeItem *item = d->getItem(index);
+ item->setZValue(wrapIndex);
+ if (d->currentIndex == index)
+ item->setFocus(true);
+ d->items << item;
+ d->pathOffset++;
+ d->pathOffset=d->pathOffset % d->items.count();
+ }
+ } else {
+ while(wrapIndex++ < d->items.count()-1){
+ QDeclarativeItem* p = d->items.takeLast();
+ d->updateItem(p, 1.0);
+ d->releaseItem(p);
+ d->firstIndex--;
+ if (d->firstIndex < 0)
+ d->firstIndex = d->model->count() - 1;
+ QDeclarativeItem *item = d->getItem(d->firstIndex);
+ item->setZValue(d->firstIndex);
+ if (d->currentIndex == d->firstIndex)
+ item->setFocus(true);
+ d->items.prepend(item);
+ d->pathOffset--;
+ if (d->pathOffset < 0)
+ d->pathOffset = d->items.count() - 1;
+ }
+ }
+ for (int i=0; i<d->items.count(); i++)
+ rotatedPositions[i] = positions[(i + d->pathOffset + d->items.count())
+ % d->items.count()];
+ }
+ for (int i=0; i<d->items.count(); i++)
+ d->updateItem(d->items.at(i), rotatedPositions[i]);
+}
+
+void QDeclarativePathView::itemsInserted(int modelIndex, int count)
+{
+ //XXX support animated insertion
+ Q_D(QDeclarativePathView);
+ if (!d->isValid() || !isComponentComplete())
+ return;
+ if (d->pathItems == -1) {
+ for (int i = 0; i < count; ++i) {
+ QDeclarativeItem *item = d->getItem(modelIndex + i);
+ item->setZValue(modelIndex + i);
+ d->items.insert(modelIndex + i, item);
+ }
+ refill();
+ } else {
+ //XXX This is pretty heavy handed until we reference count items.
+ d->regenerate();
+ }
+
+ // make sure the current item is still at the snap position
+ int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count();
+ itemIndex += d->pathOffset;
+ itemIndex %= d->items.count();
+ qreal targetOffset = qmlMod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0));
+
+ if (targetOffset < 0)
+ targetOffset = 100.0 + targetOffset;
+ if (targetOffset != d->_offset)
+ d->moveOffset.setValue(targetOffset);
+}
+
+void QDeclarativePathView::itemsRemoved(int modelIndex, int count)
+{
+ //XXX support animated removal
+ Q_D(QDeclarativePathView);
+ if (!d->isValid() || !isComponentComplete())
+ return;
+ if (d->pathItems == -1) {
+ for (int i = 0; i < count; ++i) {
+ QDeclarativeItem* p = d->items.takeAt(modelIndex);
+ d->model->release(p);
+ }
+ d->snapToCurrent();
+ refill();
+ } else {
+ d->regenerate();
+ }
+
+ if (d->model->count() == 0) {
+ d->currentIndex = -1;
+ d->moveOffset.setValue(0);
+ return;
+ }
+
+ // make sure the current item is still at the snap position
+ if (d->currentIndex >= d->model->count())
+ d->currentIndex = d->model->count() - 1;
+ int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count();
+ itemIndex += d->pathOffset;
+ itemIndex %= d->items.count();
+ qreal targetOffset = qmlMod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0));
+
+ if (targetOffset < 0)
+ targetOffset = 100.0 + targetOffset;
+ if (targetOffset != d->_offset)
+ d->moveOffset.setValue(targetOffset);
+}
+
+void QDeclarativePathView::createdItem(int index, QDeclarativeItem *item)
+{
+ Q_D(QDeclarativePathView);
+ if (d->requestedIndex != index) {
+ item->setParentItem(this);
+ d->updateItem(item, index < d->firstIndex ? 0.0 : 1.0);
+ }
+}
+
+void QDeclarativePathView::destroyingItem(QDeclarativeItem *item)
+{
+ Q_UNUSED(item);
+}
+
+void QDeclarativePathView::ticked()
+{
+ Q_D(QDeclarativePathView);
+ d->updateCurrent();
+}
+
+// find the item closest to the snap position
+int QDeclarativePathViewPrivate::calcCurrentIndex()
+{
+ int current = -1;
+ if (model && items.count()) {
+ _offset = qmlMod(_offset, qreal(100.0));
+ if (_offset < 0)
+ _offset += 100.0;
+
+ if (pathItems == -1) {
+ qreal delta = qmlMod(_offset - snapPos, qreal(100.0));
+ if (delta < 0)
+ delta = 100.0 + delta;
+ int ii = model->count() - qRound(delta * model->count() / 100);
+ if (ii < 0)
+ ii = 0;
+ current = ii;
+ } else {
+ qreal bestDiff=1e9;
+ int bestI=-1;
+ for (int i=0; i<items.count(); i++){
+ qreal percent = i * (100. / items.count());
+ percent = percent + _offset;
+ percent = qmlMod(percent, qreal(100.0));
+ qreal diff = qAbs(snapPos - (percent/100.0));
+ if (diff < bestDiff){
+ bestDiff = diff;
+ bestI = i;
+ }
+ }
+ int modelIndex = (bestI - pathOffset + items.count())%items.count();
+ modelIndex += firstIndex;
+ current = modelIndex;
+ }
+ current = qAbs(current % model->count());
+ }
+
+ return current;
+}
+
+void QDeclarativePathViewPrivate::updateCurrent()
+{
+ Q_Q(QDeclarativePathView);
+ if (moveReason != Mouse)
+ return;
+ int idx = calcCurrentIndex();
+ if (model && idx != currentIndex) {
+ currentIndex = idx;
+ int itemIndex = (idx - firstIndex + model->count()) % model->count();
+ if (itemIndex < items.count())
+ items.at(itemIndex)->setFocus(true);
+ emit q->currentIndexChanged();
+ }
+}
+
+void QDeclarativePathViewPrivate::fixOffsetCallback(void *d)
+{
+ ((QDeclarativePathViewPrivate *)d)->fixOffset();
+}
+
+void QDeclarativePathViewPrivate::fixOffset()
+{
+ Q_Q(QDeclarativePathView);
+ if (model && items.count()) {
+ int curr = calcCurrentIndex();
+ if (curr != currentIndex)
+ q->setCurrentIndex(curr);
+ else
+ snapToCurrent();
+ }
+}
+
+void QDeclarativePathViewPrivate::snapToCurrent()
+{
+ if (!model || model->count() <= 0)
+ return;
+
+ int itemIndex = (currentIndex - firstIndex + model->count()) % model->count();
+
+ //Rounds is the number of times round to make the current item visible
+ int rounds = itemIndex / items.count();
+ int otherWayRounds = (model->count() - (itemIndex)) / items.count();
+ if (otherWayRounds < rounds)
+ rounds = -otherWayRounds;
+
+ itemIndex += pathOffset;
+ if(model->count() % items.count() && itemIndex - model->count() + items.count() > 0){
+ //When model.count() is not a multiple of pathItemCount we need to manually
+ //fix the index so that going backwards one step works correctly.
+ itemIndex = itemIndex - model->count() + items.count();
+ }
+ itemIndex %= items.count();
+ qreal targetOffset = qmlMod(100 + (snapPos*100) - 100.0 * itemIndex / items.count(), qreal(100.0));
+
+ if (targetOffset < 0)
+ targetOffset = 100.0 + targetOffset;
+ if (targetOffset == _offset && rounds == 0)
+ return;
+
+ moveReason = Other;
+ tl.clear();
+ moveOffset.setValue(_offset);
+
+ if (rounds!=0){
+ //Compensate if the targetOffset would bring the target in from off the screen
+ qreal distance = targetOffset - _offset;
+ if (distance <= -50)
+ rounds--;
+ if (distance > 50)
+ rounds++;
+ tl.move(moveOffset, targetOffset + 100.0*(-rounds), QEasingCurve(QEasingCurve::InOutQuad),
+ int(100*items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds))));
+ tl.callback(QDeclarativeTimeLineCallback(&moveOffset, fixOffsetCallback, this));
+ return;
+ }
+
+ if (targetOffset - _offset > 50.0) {
+ qreal distance = 100 - targetOffset + _offset;
+ tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * _offset / distance));
+ tl.set(moveOffset, 100.0);
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * (100-targetOffset) / distance));
+ } else if (targetOffset - _offset <= -50.0) {
+ qreal distance = 100 - _offset + targetOffset;
+ tl.move(moveOffset, 100.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * (100-_offset) / distance));
+ tl.set(moveOffset, 0.0);
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * targetOffset / distance));
+ } else {
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), 200);
+ }
+}
+
+QHash<QObject*, QObject*> QDeclarativePathView::attachedProperties;
+QObject *QDeclarativePathView::qmlAttachedProperties(QObject *obj)
+{
+ QObject *rv = attachedProperties.value(obj);
+ if (!rv) {
+ rv = new QDeclarativePathViewAttached(obj);
+ attachedProperties.insert(obj, rv);
+ }
+ return rv;
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativepathview.moc>
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h
new file mode 100644
index 0000000..d351a4e
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPATHVIEW_H
+#define QDECLARATIVEPATHVIEW_H
+
+#include "qdeclarativeitem.h"
+#include "qdeclarativepath_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativePathViewPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QVariant model READ model WRITE setModel)
+ Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath)
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
+ Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
+ Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition)
+ Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin)
+ Q_PROPERTY(int count READ count)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount)
+
+public:
+ QDeclarativePathView(QDeclarativeItem *parent=0);
+ virtual ~QDeclarativePathView();
+
+ QVariant model() const;
+ void setModel(const QVariant &);
+
+ QDeclarativePath *path() const;
+ void setPath(QDeclarativePath *);
+
+ int currentIndex() const;
+ void setCurrentIndex(int idx);
+
+ qreal offset() const;
+ void setOffset(qreal offset);
+
+ qreal snapPosition() const;
+ void setSnapPosition(qreal pos);
+
+ qreal dragMargin() const;
+ void setDragMargin(qreal margin);
+
+ int count() const;
+
+ QDeclarativeComponent *delegate() const;
+ void setDelegate(QDeclarativeComponent *);
+
+ int pathItemCount() const;
+ void setPathItemCount(int);
+
+ static QObject *qmlAttachedProperties(QObject *);
+
+Q_SIGNALS:
+ void currentIndexChanged();
+ void offsetChanged();
+
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
+ bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
+ bool sceneEventFilter(QGraphicsItem *, QEvent *);
+ void componentComplete();
+
+private Q_SLOTS:
+ void refill();
+ void ticked();
+ void itemsInserted(int index, int count);
+ void itemsRemoved(int index, int count);
+ void createdItem(int index, QDeclarativeItem *item);
+ void destroyingItem(QDeclarativeItem *item);
+
+private:
+ friend class QDeclarativePathViewAttached;
+ static QHash<QObject*, QObject*> attachedProperties;
+ Q_DISABLE_COPY(QDeclarativePathView)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativePathView)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativePathView)
+QML_DECLARE_TYPEINFO(QDeclarativePathView, QML_HAS_ATTACHED_PROPERTIES)
+QT_END_HEADER
+
+#endif // QDECLARATIVEPATHVIEW_H
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
new file mode 100644
index 0000000..ca50910
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPATHVIEW_P_H
+#define QDECLARATIVEPATHVIEW_P_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 "qdeclarativepathview_p.h"
+
+#include "qdeclarativeitem_p.h"
+#include "qdeclarativevisualitemmodel_p.h"
+
+#include <qdeclarative.h>
+#include <qdeclarativeanimation_p_p.h>
+
+#include <qdatetime.h>
+
+QT_BEGIN_NAMESPACE
+
+typedef struct PathViewItem{
+ int index;
+ QDeclarativeItem* item;
+}PathViewItem;
+
+class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativePathView)
+
+public:
+ QDeclarativePathViewPrivate()
+ : path(0), currentIndex(0), startPc(0), lastDist(0)
+ , lastElapsed(0), stealMouse(false), ownModel(false), activeItem(0)
+ , snapPos(0), dragMargin(0), moveOffset(this, &QDeclarativePathViewPrivate::setOffset)
+ , firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1)
+ , moveReason(Other)
+ {
+ }
+
+ void init()
+ {
+ Q_Q(QDeclarativePathView);
+ _offset = 0;
+ q->setAcceptedMouseButtons(Qt::LeftButton);
+ q->setFlag(QGraphicsItem::ItemIsFocusScope);
+ q->setFiltersChildEvents(true);
+ q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked()));
+ }
+
+ QDeclarativeItem *getItem(int modelIndex);
+ void releaseItem(QDeclarativeItem *item);
+
+ bool isValid() const {
+ return model && model->count() > 0 && model->isValid() && path;
+ }
+
+ int calcCurrentIndex();
+ void updateCurrent();
+ static void fixOffsetCallback(void*);
+ void fixOffset();
+ void setOffset(qreal offset);
+ void regenerate();
+ void updateItem(QDeclarativeItem *, qreal);
+ void snapToCurrent();
+ QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const;
+
+ QDeclarativePath *path;
+ int currentIndex;
+ qreal startPc;
+ QPointF startPoint;
+ qreal lastDist;
+ int lastElapsed;
+ qreal _offset;
+ bool stealMouse : 1;
+ bool ownModel : 1;
+ QTime lastPosTime;
+ QPointF lastPos;
+ QDeclarativeItem *activeItem;
+ qreal snapPos;
+ qreal dragMargin;
+ QDeclarativeTimeLine tl;
+ QDeclarativeTimeLineValueProxy<QDeclarativePathViewPrivate> moveOffset;
+ int firstIndex;
+ int pathItems;
+ int pathOffset;
+ int requestedIndex;
+ QList<QDeclarativeItem *> items;
+ QGuard<QDeclarativeVisualModel> model;
+ QVariant modelVariant;
+ enum MovementReason { Other, Key, Mouse };
+ MovementReason moveReason;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
new file mode 100644
index 0000000..1212e89
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -0,0 +1,891 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativepositioners_p.h"
+#include "qdeclarativepositioners_p_p.h"
+
+#include <qdeclarative.h>
+#include <qdeclarativestate_p.h>
+#include <qdeclarativestategroup_p.h>
+#include <qdeclarativestateoperations_p.h>
+#include <qfxperf_p_p.h>
+#include <QtCore/qmath.h>
+
+#include <QDebug>
+#include <QCoreApplication>
+
+QT_BEGIN_NAMESPACE
+
+static const QDeclarativeItemPrivate::ChangeTypes watchedChanges
+ = QDeclarativeItemPrivate::Geometry
+ | QDeclarativeItemPrivate::SiblingOrder
+ | QDeclarativeItemPrivate::Visibility
+ | QDeclarativeItemPrivate::Opacity
+ | QDeclarativeItemPrivate::Destroyed;
+
+void QDeclarativeBasePositionerPrivate::watchChanges(QDeclarativeItem *other)
+{
+ QDeclarativeItemPrivate *otherPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(other));
+ otherPrivate->addItemChangeListener(this, watchedChanges);
+}
+
+void QDeclarativeBasePositionerPrivate::unwatchChanges(QDeclarativeItem* other)
+{
+ QDeclarativeItemPrivate *otherPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(other));
+ otherPrivate->removeItemChangeListener(this, watchedChanges);
+}
+
+/*!
+ \internal
+ \class QDeclarativeBasePositioner
+ \ingroup group_layouts
+ \brief The QDeclarativeBasePositioner class provides a base for QDeclarativeGraphics layouts.
+
+ To create a QDeclarativeGraphics Positioner, simply subclass QDeclarativeBasePositioner and implement
+ doLayout(), which is automatically called when the layout might need
+ updating. In doLayout() use the setX and setY functions from QDeclarativeBasePositioner, and the
+ base class will apply the positions along with the appropriate transitions. The items to
+ position are provided in order as the protected member positionedItems.
+
+ You also need to set a PositionerType, to declare whether you are positioning the x, y or both
+ for the child items. Depending on the chosen type, only x or y changes will be applied.
+
+ Note that the subclass is responsible for adding the
+ spacing in between items.
+*/
+QDeclarativeBasePositioner::QDeclarativeBasePositioner(PositionerType at, QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativeBasePositionerPrivate), parent)
+{
+ Q_D(QDeclarativeBasePositioner);
+ d->init(at);
+}
+
+QDeclarativeBasePositioner::QDeclarativeBasePositioner(QDeclarativeBasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent)
+ : QDeclarativeItem(dd, parent)
+{
+ Q_D(QDeclarativeBasePositioner);
+ d->init(at);
+}
+
+QDeclarativeBasePositioner::~QDeclarativeBasePositioner()
+{
+ Q_D(QDeclarativeBasePositioner);
+ for (int i = 0; i < positionedItems.count(); ++i)
+ d->unwatchChanges(positionedItems.at(i).item);
+ positionedItems.clear();
+}
+
+int QDeclarativeBasePositioner::spacing() const
+{
+ Q_D(const QDeclarativeBasePositioner);
+ return d->spacing;
+}
+
+void QDeclarativeBasePositioner::setSpacing(int s)
+{
+ Q_D(QDeclarativeBasePositioner);
+ if (s==d->spacing)
+ return;
+ d->spacing = s;
+ prePositioning();
+ emit spacingChanged();
+}
+
+QDeclarativeTransition *QDeclarativeBasePositioner::move() const
+{
+ Q_D(const QDeclarativeBasePositioner);
+ return d->moveTransition;
+}
+
+void QDeclarativeBasePositioner::setMove(QDeclarativeTransition *mt)
+{
+ Q_D(QDeclarativeBasePositioner);
+ if (mt == d->moveTransition)
+ return;
+ d->moveTransition = mt;
+ emit moveChanged();
+}
+
+QDeclarativeTransition *QDeclarativeBasePositioner::add() const
+{
+ Q_D(const QDeclarativeBasePositioner);
+ return d->addTransition;
+}
+
+void QDeclarativeBasePositioner::setAdd(QDeclarativeTransition *add)
+{
+ Q_D(QDeclarativeBasePositioner);
+ if (add == d->addTransition)
+ return;
+
+ d->addTransition = add;
+ emit addChanged();
+}
+
+void QDeclarativeBasePositioner::componentComplete()
+{
+ Q_D(QDeclarativeBasePositioner);
+ QDeclarativeItem::componentComplete();
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::BasepositionerComponentComplete> cc;
+#endif
+ positionedItems.reserve(d->QGraphicsItemPrivate::children.count());
+ prePositioning();
+}
+
+QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change,
+ const QVariant &value)
+{
+ Q_D(QDeclarativeBasePositioner);
+ if (change == ItemChildAddedChange){
+ QGraphicsItem* item = value.value<QGraphicsItem*>();
+ QDeclarativeItem* child = 0;
+ if(item)
+ child = qobject_cast<QDeclarativeItem*>(item->toGraphicsObject());
+ if (child)
+ prePositioning();
+ } else if (change == ItemChildRemovedChange) {
+ QGraphicsItem* item = value.value<QGraphicsItem*>();
+ QDeclarativeItem* child = 0;
+ if(item)
+ child = qobject_cast<QDeclarativeItem*>(item->toGraphicsObject());
+ if (child) {
+ QDeclarativeBasePositioner::PositionedItem posItem(child);
+ int idx = positionedItems.find(posItem);
+ if (idx >= 0) {
+ d->unwatchChanges(child);
+ positionedItems.remove(idx);
+ }
+ prePositioning();
+ }
+ }
+
+ return QDeclarativeItem::itemChange(change, value);
+}
+
+void QDeclarativeBasePositioner::prePositioning()
+{
+ Q_D(QDeclarativeBasePositioner);
+ if (!isComponentComplete())
+ return;
+
+ d->queuedPositioning = false;
+ //Need to order children by creation order modified by stacking order
+ QList<QGraphicsItem *> children = d->QGraphicsItemPrivate::children;
+ qSort(children.begin(), children.end(), d->insertionOrder);
+
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(ii));
+ if (!child)
+ continue;
+ PositionedItem *item = 0;
+ PositionedItem posItem(child);
+ int wIdx = positionedItems.find(posItem);
+ if (wIdx < 0) {
+ d->watchChanges(child);
+ positionedItems.append(posItem);
+ item = &positionedItems[positionedItems.count()-1];
+ } else {
+ item = &positionedItems[wIdx];
+ }
+ if (child->opacity() <= 0.0 || !child->isVisible()) {
+ item->isVisible = false;
+ continue;
+ }
+ if (!item->isVisible) {
+ item->isVisible = true;
+ item->isNew = true;
+ } else {
+ item->isNew = false;
+ }
+ }
+ doPositioning();
+ if(d->addTransition || d->moveTransition)
+ finishApplyTransitions();
+ //Set implicit size to the size of its children
+ qreal h = 0.0f;
+ qreal w = 0.0f;
+ for (int i = 0; i < positionedItems.count(); ++i) {
+ const PositionedItem &posItem = positionedItems.at(i);
+ if (posItem.isVisible) {
+ h = qMax(h, posItem.item->y() + posItem.item->height());
+ w = qMax(w, posItem.item->x() + posItem.item->width());
+ }
+ }
+ setImplicitHeight(h);
+ setImplicitWidth(w);
+}
+
+void QDeclarativeBasePositioner::positionX(int x, const PositionedItem &target)
+{
+ Q_D(QDeclarativeBasePositioner);
+ if(d->type == Horizontal || d->type == Both){
+ if(!d->addTransition && !d->moveTransition){
+ target.item->setX(x);
+ }else{
+ if(target.isNew)
+ d->addActions << QDeclarativeAction(target.item, QLatin1String("x"), QVariant(x));
+ else
+ d->moveActions << QDeclarativeAction(target.item, QLatin1String("x"), QVariant(x));
+ }
+ }
+}
+
+void QDeclarativeBasePositioner::positionY(int y, const PositionedItem &target)
+{
+ Q_D(QDeclarativeBasePositioner);
+ if(d->type == Vertical || d->type == Both){
+ if(!d->addTransition && !d->moveTransition){
+ target.item->setY(y);
+ }else{
+ if(target.isNew)
+ d->addActions << QDeclarativeAction(target.item, QLatin1String("y"), QVariant(y));
+ else
+ d->moveActions << QDeclarativeAction(target.item, QLatin1String("y"), QVariant(y));
+ }
+ }
+}
+
+void QDeclarativeBasePositioner::finishApplyTransitions()
+{
+ Q_D(QDeclarativeBasePositioner);
+ // Note that if a transition is not set the transition manager will
+ // apply the changes directly, in the case add/move aren't set
+ d->addTransitionManager.transition(d->addActions, d->addTransition);
+ d->moveTransitionManager.transition(d->moveActions, d->moveTransition);
+ d->addActions.clear();
+ d->moveActions.clear();
+}
+
+/*!
+ \qmlclass Column QDeclarativeColumn
+ \since 4.7
+ \brief The Column item lines up its children vertically.
+ \inherits Item
+
+ The Column item positions its child items so that they are vertically
+ aligned and not overlapping. Spacing between items can be added.
+
+ The below example positions differently shaped rectangles using a Column.
+ \table
+ \row
+ \o \image verticalpositioner_example.png
+ \o
+ \qml
+Column {
+ spacing: 2
+ Rectangle { color: "red"; width: 50; height: 50 }
+ Rectangle { color: "green"; width: 20; height: 50 }
+ Rectangle { color: "blue"; width: 50; height: 20 }
+}
+ \endqml
+ \endtable
+
+ Column also provides for transitions to be set when items are added, moved,
+ or removed in the positioner. Adding and removing apply both to items which are deleted
+ or have their position in the document changed so as to no longer be children of the positioner,
+ as well as to items which have their opacity set to or from zero so as to appear or disappear.
+
+ \table
+ \row
+ \o \image verticalpositioner_transition.gif
+ \o
+ \qml
+Column {
+ spacing: 2
+ remove: ...
+ add: ...
+ move: ...
+ ...
+}
+ \endqml
+ \endtable
+
+ Note that the positioner assumes that the x and y positions of its children
+ will not change. If you manually change the x or y properties in script, bind
+ the x or y properties, or use anchors on a child of a positioner, then the
+ positioner may exhibit strange behaviour.
+
+*/
+/*!
+ \qmlproperty Transition Column::add
+
+ This property holds the transition to be applied when adding an
+ item to the positioner. The transition will only be applied to the
+ added item(s). Positioner transitions will only affect the
+ position (x,y) of items.
+
+ Added can mean that either the object has been created or
+ reparented, and thus is now a child or the positioner, or that the
+ object has had its opacity increased from zero, and thus is now
+ visible.
+
+
+*/
+/*!
+ \qmlproperty Transition Column::move
+
+ This property holds the transition to apply when moving an item
+ within the positioner. Positioner transitions will only affect
+ the position (x,y) of items.
+
+ This can happen when other items are added or removed from the
+ positioner, or when items resize themselves.
+
+ \table
+ \row
+ \o \image positioner-move.gif
+ \o
+ \qml
+Column {
+ move: Transition {
+ NumberAnimation {
+ properties: "y"
+ easing: "easeOutBounce"
+ }
+ }
+}
+ \endqml
+ \endtable
+*/
+/*!
+ \qmlproperty int Column::spacing
+
+ spacing is the amount in pixels left empty between each adjacent
+ item, and defaults to 0.
+
+ The below example places a Grid containing a red, a blue and a
+ green rectangle on a gray background. The area the grid positioner
+ occupies is colored white. The top positioner has the default of no spacing,
+ and the bottom positioner has its spacing set to 2.
+
+ \image spacing_a.png
+ \image spacing_b.png
+
+*/
+/*!
+ \internal
+ \class QDeclarativeColumn
+ \brief The QDeclarativeColumn class lines up items vertically.
+ \ingroup group_positioners
+*/
+QDeclarativeColumn::QDeclarativeColumn(QDeclarativeItem *parent)
+: QDeclarativeBasePositioner(Vertical, parent)
+{
+}
+
+static inline bool isInvisible(QDeclarativeItem *child)
+{
+ return child->opacity() == 0.0 || !child->isVisible() || !child->width() || !child->height();
+}
+
+void QDeclarativeColumn::doPositioning()
+{
+ int voffset = 0;
+
+ for (int ii = 0; ii < positionedItems.count(); ++ii) {
+ const PositionedItem &child = positionedItems.at(ii);
+ if (!child.item || isInvisible(child.item))
+ continue;
+
+ if(child.item->y() != voffset)
+ positionY(voffset, child);
+
+ voffset += child.item->height();
+ voffset += spacing();
+ }
+}
+
+/*!
+ \qmlclass Row QDeclarativeRow
+ \since 4.7
+ \brief The Row item lines up its children horizontally.
+ \inherits Item
+
+ The Row item positions its child items so that they are
+ horizontally aligned and not overlapping. Spacing can be added between the
+ items, and a margin around all items can also be added. It also provides for
+ transitions to be set when items are added, moved, or removed in the
+ positioner. Adding and removing apply both to items which are deleted or have
+ their position in the document changed so as to no longer be children of the
+ positioner, as well as to items which have their opacity set to or from zero
+ so as to appear or disappear.
+
+ The below example lays out differently shaped rectangles using a Row.
+ \qml
+Row {
+ spacing: 2
+ Rectangle { color: "red"; width: 50; height: 50 }
+ Rectangle { color: "green"; width: 20; height: 50 }
+ Rectangle { color: "blue"; width: 50; height: 20 }
+}
+ \endqml
+ \image horizontalpositioner_example.png
+
+ Note that the positioner assumes that the x and y positions of its children
+ will not change. If you manually change the x or y properties in script, bind
+ the x or y properties, or use anchors on a child of a positioner, then the
+ positioner may exhibit strange behaviour.
+
+*/
+/*!
+ \qmlproperty Transition Row::add
+ This property holds the transition to apply when adding an item to the positioner.
+ The transition will only be applied to the added item(s).
+ Positioner transitions will only affect the position (x,y) of items.
+
+ Added can mean that either the object has been created or
+ reparented, and thus is now a child or the positioner, or that the
+ object has had its opacity increased from zero, and thus is now
+ visible.
+
+
+*/
+/*!
+ \qmlproperty Transition Row::move
+
+ This property holds the transition to apply when moving an item
+ within the positioner. Positioner transitions will only affect
+ the position (x,y) of items.
+
+ This can happen when other items are added or removed from the
+ positioner, or when items resize themselves.
+
+ \qml
+Row {
+ id: positioner
+ move: Transition {
+ NumberAnimation {
+ properties: "x"
+ ease: "easeOutBounce"
+ }
+ }
+}
+ \endqml
+
+*/
+/*!
+ \qmlproperty int Row::spacing
+
+ spacing is the amount in pixels left empty between each adjacent
+ item, and defaults to 0.
+
+ The below example places a Grid containing a red, a blue and a
+ green rectangle on a gray background. The area the grid positioner
+ occupies is colored white. The top positioner has the default of no spacing,
+ and the bottom positioner has its spacing set to 2.
+
+ \image spacing_a.png
+ \image spacing_b.png
+
+*/
+/*!
+ \internal
+ \class QDeclarativeRow
+ \brief The QDeclarativeRow class lines up items horizontally.
+ \ingroup group_positioners
+*/
+QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent)
+: QDeclarativeBasePositioner(Horizontal, parent)
+{
+}
+
+void QDeclarativeRow::doPositioning()
+{
+ int hoffset = 0;
+
+ for (int ii = 0; ii < positionedItems.count(); ++ii) {
+ const PositionedItem &child = positionedItems.at(ii);
+ if (!child.item || isInvisible(child.item))
+ continue;
+
+ if(child.item->x() != hoffset)
+ positionX(hoffset, child);
+
+ hoffset += child.item->width();
+ hoffset += spacing();
+ }
+}
+
+
+/*!
+ \qmlclass Grid QDeclarativeGrid
+ \since 4.7
+ \brief The Grid item positions its children in a grid.
+ \inherits Item
+
+ The Grid item positions its child items so that they are
+ aligned in a grid and are not overlapping. Spacing can be added
+ between the items. It also provides for transitions to be set when items are
+ added, moved, or removed in the positioner. Adding and removing apply
+ both to items which are deleted or have their position in the
+ document changed so as to no longer be children of the positioner, as
+ well as to items which have their opacity set to or from zero so
+ as to appear or disappear.
+
+ The Grid defaults to using four columns, and as many rows as
+ are necessary to fit all the child items. The number of rows
+ and/or the number of columns can be constrained by setting the rows
+ or columns properties. The grid positioner calculates a grid with
+ rectangular cells of sufficient size to hold all items, and then
+ places the items in the cells, going across then down, and
+ positioning each item at the (0,0) corner of the cell. The below
+ example demonstrates this.
+
+ \table
+ \row
+ \o \image gridLayout_example.png
+ \o
+ \qml
+Grid {
+ columns: 3
+ spacing: 2
+ Rectangle { color: "red"; width: 50; height: 50 }
+ Rectangle { color: "green"; width: 20; height: 50 }
+ Rectangle { color: "blue"; width: 50; height: 20 }
+ Rectangle { color: "cyan"; width: 50; height: 50 }
+ Rectangle { color: "magenta"; width: 10; height: 10 }
+}
+ \endqml
+ \endtable
+
+ Note that the positioner assumes that the x and y positions of its children
+ will not change. If you manually change the x or y properties in script, bind
+ the x or y properties, or use anchors on a child of a positioner, then the
+ positioner may exhibit strange behaviour.
+*/
+/*!
+ \qmlproperty Transition Grid::add
+ This property holds the transition to apply when adding an item to the positioner.
+ The transition is only applied to the added item(s).
+ Positioner transitions will only affect the position (x,y) of items.
+
+ Added can mean that either the object has been created or
+ reparented, and thus is now a child or the positioner, or that the
+ object has had its opacity increased from zero, and thus is now
+ visible.
+
+
+*/
+/*!
+ \qmlproperty Transition Grid::move
+ This property holds the transition to apply when moving an item within the positioner.
+ Positioner transitions will only affect the position (x,y) of items.
+
+ This can happen when other items are added or removed from the positioner, or
+ when items resize themselves.
+
+ \qml
+Grid {
+ move: Transition {
+ NumberAnimation {
+ properties: "x,y"
+ ease: "easeOutBounce"
+ }
+ }
+}
+ \endqml
+
+*/
+/*!
+ \qmlproperty int Grid::spacing
+
+ spacing is the amount in pixels left empty between each adjacent
+ item, and defaults to 0.
+
+ The below example places a Grid containing a red, a blue and a
+ green rectangle on a gray background. The area the grid positioner
+ occupies is colored white. The top positioner has the default of no spacing,
+ and the bottom positioner has its spacing set to 2.
+
+ \image spacing_a.png
+ \image spacing_b.png
+
+*/
+/*!
+ \internal
+ \class QDeclarativeGrid
+ \brief The QDeclarativeGrid class lays out items in a grid.
+ \ingroup group_layouts
+
+*/
+QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) :
+ QDeclarativeBasePositioner(Both, parent)
+{
+ _columns=-1;
+ _rows=-1;
+}
+
+/*!
+ \qmlproperty int Grid::columns
+ This property holds the number of columns in the grid.
+
+ When the columns property is set the Grid will always have
+ that many columns. Note that if you do not have enough items to
+ fill this many columns some columns will be of zero width.
+*/
+
+/*!
+ \qmlproperty int Grid::rows
+ This property holds the number of rows in the grid.
+
+ When the rows property is set the Grid will always have that
+ many rows. Note that if you do not have enough items to fill this
+ many rows some rows will be of zero width.
+*/
+
+void QDeclarativeGrid::setColumns(const int columns)
+{
+ if (columns == _columns)
+ return;
+ _columns = columns;
+ prePositioning();
+ emit columnsChanged();
+}
+
+void QDeclarativeGrid::setRows(const int rows)
+{
+ if (rows == _rows)
+ return;
+ _rows = rows;
+ prePositioning();
+ emit rowsChanged();
+}
+
+void QDeclarativeGrid::doPositioning()
+{
+ int c=_columns,r=_rows;//Actual number of rows/columns
+ int numVisible = positionedItems.count();
+ if (_columns==-1 && _rows==-1){
+ c = 4;
+ r = (numVisible+3)/4;
+ }else if (_rows==-1){
+ r = (numVisible+(_columns-1))/_columns;
+ }else if (_columns==-1){
+ c = (numVisible+(_rows-1))/_rows;
+ }
+
+ QList<int> maxColWidth;
+ QList<int> maxRowHeight;
+ int childIndex =0;
+ for (int i=0; i<r; i++){
+ for (int j=0; j<c; j++){
+ if (j==0)
+ maxRowHeight << 0;
+ if (i==0)
+ maxColWidth << 0;
+
+ if (childIndex == positionedItems.count())
+ continue;
+ const PositionedItem &child = positionedItems.at(childIndex++);
+ if (!child.item || isInvisible(child.item))
+ continue;
+ if (child.item->width() > maxColWidth[j])
+ maxColWidth[j] = child.item->width();
+ if (child.item->height() > maxRowHeight[i])
+ maxRowHeight[i] = child.item->height();
+ }
+ }
+
+ int xoffset=0;
+ int yoffset=0;
+ int curRow =0;
+ int curCol =0;
+ for (int i = 0; i < positionedItems.count(); ++i) {
+ const PositionedItem &child = positionedItems.at(i);
+ if (!child.item || isInvisible(child.item))
+ continue;
+ if((child.item->x()!=xoffset)||(child.item->y()!=yoffset)){
+ positionX(xoffset, child);
+ positionY(yoffset, child);
+ }
+ xoffset+=maxColWidth[curCol]+spacing();
+ curCol++;
+ curCol%=c;
+ if (!curCol){
+ yoffset+=maxRowHeight[curRow]+spacing();
+ xoffset=0;
+ curRow++;
+ if (curRow>=r)
+ break;
+ }
+ }
+}
+
+
+/*!
+ \qmlclass Flow QDeclarativeFlow
+ \since 4.7
+ \brief The Flow item lines up its children side by side, wrapping as necessary.
+ \inherits Item
+
+
+*/
+/*!
+ \qmlproperty Transition Flow::add
+ This property holds the transition to apply when adding an item to the positioner.
+ The transition will only be applied to the added item(s).
+ Positioner transitions will only affect the position (x,y) of items.
+
+ Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible.
+
+
+*/
+/*!
+ \qmlproperty Transition Flow::move
+ This property holds the transition to apply when moving an item within the positioner.
+ Positioner transitions will only affect the position (x,y) of items.
+
+ This can happen when other items are added or removed from the positioner, or when items resize themselves.
+
+ \qml
+Flow {
+ id: positioner
+ move: Transition {
+ NumberAnimation {
+ properties: "x,y"
+ ease: "easeOutBounce"
+ }
+ }
+}
+ \endqml
+
+*/
+/*!
+ \qmlproperty int Flow::spacing
+
+ spacing is the amount in pixels left empty between each adjacent
+ item, and defaults to 0.
+
+*/
+
+class QDeclarativeFlowPrivate : public QDeclarativeBasePositionerPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeFlow)
+
+public:
+ QDeclarativeFlowPrivate()
+ : QDeclarativeBasePositionerPrivate(), flow(QDeclarativeFlow::LeftToRight)
+ {}
+
+ QDeclarativeFlow::Flow flow;
+};
+
+QDeclarativeFlow::QDeclarativeFlow(QDeclarativeItem *parent)
+: QDeclarativeBasePositioner(*(new QDeclarativeFlowPrivate), Both, parent)
+{
+}
+
+/*!
+ \qmlproperty enumeration Flow::flow
+ This property holds the flow of the layout.
+
+ Possible values are \c LeftToRight (default) and \c TopToBottom.
+
+ If \a flow is \c LeftToRight, the items are positioned next to
+ to each other from left to right until the width of the Flow
+ is exceeded, then wrapped to the next line.
+ If \a flow is \c TopToBottom, the items are positioned next to each
+ other from top to bottom until the height of the Flow is exceeded,
+ then wrapped to the next column.
+*/
+QDeclarativeFlow::Flow QDeclarativeFlow::flow() const
+{
+ Q_D(const QDeclarativeFlow);
+ return d->flow;
+}
+
+void QDeclarativeFlow::setFlow(Flow flow)
+{
+ Q_D(QDeclarativeFlow);
+ if (d->flow != flow) {
+ d->flow = flow;
+ prePositioning();
+ emit flowChanged();
+ }
+}
+
+void QDeclarativeFlow::doPositioning()
+{
+ Q_D(QDeclarativeFlow);
+
+ int hoffset = 0;
+ int voffset = 0;
+ int linemax = 0;
+
+ for (int i = 0; i < positionedItems.count(); ++i) {
+ const PositionedItem &child = positionedItems.at(i);
+ if (!child.item || isInvisible(child.item))
+ continue;
+
+ if (d->flow == LeftToRight) {
+ if (hoffset && hoffset + child.item->width() > width()) {
+ hoffset = 0;
+ voffset += linemax + spacing();
+ linemax = 0;
+ }
+ } else {
+ if (voffset && voffset + child.item->height() > height()) {
+ voffset = 0;
+ hoffset += linemax + spacing();
+ linemax = 0;
+ }
+ }
+
+ if(child.item->x() != hoffset || child.item->y() != voffset){
+ positionX(hoffset, child);
+ positionY(voffset, child);
+ }
+
+ if (d->flow == LeftToRight) {
+ hoffset += child.item->width();
+ hoffset += spacing();
+ linemax = qMax(linemax, qCeil(child.item->height()));
+ } else {
+ voffset += child.item->height();
+ voffset += spacing();
+ linemax = qMax(linemax, qCeil(child.item->width()));
+ }
+ }
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
new file mode 100644
index 0000000..ff6fc4b
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVELAYOUTS_H
+#define QDECLARATIVELAYOUTS_H
+
+#include "qdeclarativeitem.h"
+
+#include "../util/qdeclarativestate_p.h"
+#include <private/qpodvector_p.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QString>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+class QDeclarativeBasePositionerPrivate;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeBasePositioner : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
+ Q_PROPERTY(QDeclarativeTransition *move READ move WRITE setMove NOTIFY moveChanged)
+ Q_PROPERTY(QDeclarativeTransition *add READ add WRITE setAdd NOTIFY addChanged)
+public:
+ enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
+ QDeclarativeBasePositioner(PositionerType, QDeclarativeItem *parent);
+ ~QDeclarativeBasePositioner();
+
+ int spacing() const;
+ void setSpacing(int);
+
+ QDeclarativeTransition *move() const;
+ void setMove(QDeclarativeTransition *);
+
+ QDeclarativeTransition *add() const;
+ void setAdd(QDeclarativeTransition *);
+
+protected:
+ QDeclarativeBasePositioner(QDeclarativeBasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent);
+ virtual void componentComplete();
+ virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
+ void finishApplyTransitions();
+
+Q_SIGNALS:
+ void spacingChanged();
+ void moveChanged();
+ void addChanged();
+
+protected Q_SLOTS:
+ virtual void doPositioning()=0;
+ void prePositioning();
+
+protected:
+ struct PositionedItem {
+ PositionedItem(QDeclarativeItem *i) : item(i), isNew(false), isVisible(true) {}
+ bool operator==(const PositionedItem &other) const { return other.item == item; }
+ QDeclarativeItem *item;
+ bool isNew;
+ bool isVisible;
+ };
+
+ QPODVector<PositionedItem,8> positionedItems;
+ void positionX(int,const PositionedItem &target);
+ void positionY(int,const PositionedItem &target);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeBasePositioner)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeBasePositioner)
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeColumn : public QDeclarativeBasePositioner
+{
+ Q_OBJECT
+public:
+ QDeclarativeColumn(QDeclarativeItem *parent=0);
+protected Q_SLOTS:
+ virtual void doPositioning();
+private:
+ Q_DISABLE_COPY(QDeclarativeColumn)
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeRow: public QDeclarativeBasePositioner
+{
+ Q_OBJECT
+public:
+ QDeclarativeRow(QDeclarativeItem *parent=0);
+protected Q_SLOTS:
+ virtual void doPositioning();
+private:
+ Q_DISABLE_COPY(QDeclarativeRow)
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeGrid : public QDeclarativeBasePositioner
+{
+ Q_OBJECT
+ Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowChanged)
+ Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
+public:
+ QDeclarativeGrid(QDeclarativeItem *parent=0);
+
+ int rows() const {return _rows;}
+ void setRows(const int rows);
+
+ int columns() const {return _columns;}
+ void setColumns(const int columns);
+
+Q_SIGNALS:
+ void rowsChanged();
+ void columnsChanged();
+
+protected Q_SLOTS:
+ virtual void doPositioning();
+
+private:
+ int _rows;
+ int _columns;
+ Q_DISABLE_COPY(QDeclarativeGrid)
+};
+
+class QDeclarativeFlowPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeFlow: public QDeclarativeBasePositioner
+{
+ Q_OBJECT
+ Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
+public:
+ QDeclarativeFlow(QDeclarativeItem *parent=0);
+
+ Q_ENUMS(Flow)
+ enum Flow { LeftToRight, TopToBottom };
+ Flow flow() const;
+ void setFlow(Flow);
+
+Q_SIGNALS:
+ void flowChanged();
+
+protected Q_SLOTS:
+ virtual void doPositioning();
+
+protected:
+ QDeclarativeFlow(QDeclarativeFlowPrivate &dd, QDeclarativeItem *parent);
+private:
+ Q_DISABLE_COPY(QDeclarativeFlow)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeFlow)
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeColumn)
+QML_DECLARE_TYPE(QDeclarativeRow)
+QML_DECLARE_TYPE(QDeclarativeGrid)
+QML_DECLARE_TYPE(QDeclarativeFlow)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
new file mode 100644
index 0000000..3a1edee
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVELAYOUTS_P_H
+#define QDECLARATIVELAYOUTS_P_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 "qdeclarativepositioners_p.h"
+
+#include "qdeclarativeitem_p.h"
+
+#include <qdeclarativestate_p.h>
+#include <qdeclarativetransitionmanager_p_p.h>
+#include <qdeclarativestateoperations_p.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtCore/QTimer>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+class QDeclarativeBasePositionerPrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener
+{
+ Q_DECLARE_PUBLIC(QDeclarativeBasePositioner)
+
+public:
+ QDeclarativeBasePositionerPrivate()
+ : spacing(0), type(QDeclarativeBasePositioner::None), moveTransition(0), addTransition(0),
+ queuedPositioning(false)
+ {
+ }
+
+ void init(QDeclarativeBasePositioner::PositionerType at)
+ {
+ type = at;
+ }
+
+ int spacing;
+ QDeclarativeBasePositioner::PositionerType type;
+ QDeclarativeTransition *moveTransition;
+ QDeclarativeTransition *addTransition;
+ QDeclarativeStateOperation::ActionList addActions;
+ QDeclarativeStateOperation::ActionList moveActions;
+ QDeclarativeTransitionManager addTransitionManager;
+ QDeclarativeTransitionManager moveTransitionManager;
+
+ void watchChanges(QDeclarativeItem *other);
+ void unwatchChanges(QDeclarativeItem* other);
+ bool queuedPositioning;
+
+ virtual void itemSiblingOrderChanged(QDeclarativeItem* other)
+ {
+ Q_Q(QDeclarativeBasePositioner);
+ Q_UNUSED(other);
+ if(!queuedPositioning){
+ //Delay is due to many children often being reordered at once
+ //And we only want to reposition them all once
+ QTimer::singleShot(0,q,SLOT(prePositioning()));
+ queuedPositioning = true;
+ }
+ }
+
+ void itemGeometryChanged(QDeclarativeItem *, const QRectF &newGeometry, const QRectF &oldGeometry)
+ {
+ Q_Q(QDeclarativeBasePositioner);
+ if (newGeometry.size() != oldGeometry.size())
+ q->prePositioning();
+ }
+ virtual void itemVisibilityChanged(QDeclarativeItem *)
+ {
+ Q_Q(QDeclarativeBasePositioner);
+ q->prePositioning();
+ }
+ virtual void itemOpacityChanged(QDeclarativeItem *)
+ {
+ Q_Q(QDeclarativeBasePositioner);
+ q->prePositioning();
+ }
+
+ void itemDestroyed(QDeclarativeItem *item)
+ {
+ Q_Q(QDeclarativeBasePositioner);
+ q->positionedItems.removeOne(QDeclarativeBasePositioner::PositionedItem(item));
+ }
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
new file mode 100644
index 0000000..d534f21
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -0,0 +1,466 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativerectangle_p.h"
+#include "qdeclarativerectangle_p_p.h"
+
+#include <QPainter>
+#include <QtCore/qmath.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+ \class QDeclarativePen
+ \brief The QDeclarativePen class provides a pen used for drawing rectangle borders on a QDeclarativeView.
+
+ By default, the pen is invalid and nothing is drawn. You must either set a color (then the default
+ width is 1) or a width (then the default color is black).
+
+ A width of 1 indicates is a single-pixel line on the border of the item being painted.
+
+ Example:
+ \qml
+ Rectangle { border.width: 2; border.color: "red" ... }
+ \endqml
+*/
+
+void QDeclarativePen::setColor(const QColor &c)
+{
+ _color = c;
+ _valid = _color.alpha() ? true : false;
+ emit penChanged();
+}
+
+void QDeclarativePen::setWidth(int w)
+{
+ if (_width == w && _valid)
+ return;
+
+ _width = w;
+ _valid = (_width < 1) ? false : true;
+ emit penChanged();
+}
+
+
+/*!
+ \qmlclass GradientStop QDeclarativeGradientStop
+ \since 4.7
+ \brief The GradientStop item defines the color at a position in a Gradient
+
+ \sa Gradient
+*/
+
+/*!
+ \qmlproperty real GradientStop::position
+ \qmlproperty color GradientStop::color
+
+ Sets a \e color at a \e position in a gradient.
+*/
+
+void QDeclarativeGradientStop::updateGradient()
+{
+ if (QDeclarativeGradient *grad = qobject_cast<QDeclarativeGradient*>(parent()))
+ grad->doUpdate();
+}
+
+/*!
+ \qmlclass Gradient QDeclarativeGradient
+ \since 4.7
+ \brief The Gradient item defines a gradient fill.
+
+ A gradient is defined by two or more colors, which will be blended seemlessly. The
+ colors are specified at their position in the range 0.0 - 1.0 via
+ the GradientStop item. For example, the following code paints a
+ rectangle with a gradient starting with red, blending to yellow at 1/3 of the
+ size of the rectangle, and ending with Green:
+
+ \table
+ \row
+ \o \image gradient.png
+ \o \quotefile doc/src/snippets/declarative/gradient.qml
+ \endtable
+
+ \sa GradientStop
+*/
+
+/*!
+ \qmlproperty list<GradientStop> Gradient::stops
+ This property holds the gradient stops describing the gradient.
+*/
+
+const QGradient *QDeclarativeGradient::gradient() const
+{
+ if (!m_gradient && !m_stops.isEmpty()) {
+ m_gradient = new QLinearGradient(0,0,0,1.0);
+ for (int i = 0; i < m_stops.count(); ++i) {
+ const QDeclarativeGradientStop *stop = m_stops.at(i);
+ m_gradient->setCoordinateMode(QGradient::ObjectBoundingMode);
+ m_gradient->setColorAt(stop->position(), stop->color());
+ }
+ }
+
+ return m_gradient;
+}
+
+void QDeclarativeGradient::doUpdate()
+{
+ delete m_gradient;
+ m_gradient = 0;
+ emit updated();
+}
+
+
+/*!
+ \qmlclass Rectangle QDeclarativeRectangle
+ \since 4.7
+ \brief The Rectangle item allows you to add rectangles to a scene.
+ \inherits Item
+
+ A Rectangle is painted having a solid fill (color) and an optional border.
+ You can also create rounded rectangles using the radius property.
+
+ \qml
+ Rectangle {
+ width: 100
+ height: 100
+ color: "red"
+ border.color: "black"
+ border.width: 5
+ radius: 10
+ }
+ \endqml
+
+ \image declarative-rect.png
+*/
+
+/*!
+ \internal
+ \class QDeclarativeRectangle
+ \brief The QDeclarativeRectangle class provides a rectangle item that you can add to a QDeclarativeView.
+*/
+QDeclarativeRectangle::QDeclarativeRectangle(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativeRectanglePrivate), parent)
+{
+ Q_D(QDeclarativeRectangle);
+ d->init();
+ setFlag(QGraphicsItem::ItemHasNoContents, false);
+}
+
+void QDeclarativeRectangle::doUpdate()
+{
+ Q_D(QDeclarativeRectangle);
+ d->rectImage = QPixmap();
+ const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
+ d->setPaintMargin((pw+1)/2);
+ update();
+}
+
+/*!
+ \qmlproperty int Rectangle::border.width
+ \qmlproperty color Rectangle::border.color
+
+ The width and color used to draw the border of the rectangle.
+
+ A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color.
+
+ To keep the border smooth (rather than blurry), odd widths cause the rectangle to be painted at
+ a half-pixel offset;
+*/
+QDeclarativePen *QDeclarativeRectangle::border()
+{
+ Q_D(QDeclarativeRectangle);
+ return d->getPen();
+}
+
+/*!
+ \qmlproperty Gradient Rectangle::gradient
+
+ The gradient to use to fill the rectangle.
+
+ This property allows for the construction of simple vertical gradients.
+ Other gradients may by formed by adding rotation to the rectangle.
+
+ \table
+ \row
+ \o \image declarative-rect_gradient.png
+ \o
+ \qml
+ Rectangle { y: 0; width: 80; height: 80; color: "lightsteelblue" }
+ Rectangle { y: 100; width: 80; height: 80
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightsteelblue" }
+ GradientStop { position: 1.0; color: "blue" }
+ }
+ }
+ Rectangle { rotation: 90; x: 80; y: 200; width: 80; height: 80
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightsteelblue" }
+ GradientStop { position: 1.0; color: "blue" }
+ }
+ }
+ // The x offset is needed because the rotation is from the top left corner
+ \endqml
+ \endtable
+
+ If both a gradient and a color are specified, the gradient will be used.
+
+ \sa Gradient, color
+*/
+QDeclarativeGradient *QDeclarativeRectangle::gradient() const
+{
+ Q_D(const QDeclarativeRectangle);
+ return d->gradient;
+}
+
+void QDeclarativeRectangle::setGradient(QDeclarativeGradient *gradient)
+{
+ Q_D(QDeclarativeRectangle);
+ if (d->gradient == gradient)
+ return;
+ if (d->gradient)
+ disconnect(d->gradient, SIGNAL(updated()), this, SLOT(doUpdate()));
+ d->gradient = gradient;
+ if (d->gradient)
+ connect(d->gradient, SIGNAL(updated()), this, SLOT(doUpdate()));
+ update();
+}
+
+
+/*!
+ \qmlproperty real Rectangle::radius
+ This property holds the corner radius used to draw a rounded rectangle.
+
+ If radius is non-zero, the rectangle will be painted as a rounded rectangle, otherwise it will be
+ painted as a normal rectangle. The same radius is used by all 4 corners; there is currently
+ no way to specify different radii for different corners.
+*/
+qreal QDeclarativeRectangle::radius() const
+{
+ Q_D(const QDeclarativeRectangle);
+ return d->radius;
+}
+
+void QDeclarativeRectangle::setRadius(qreal radius)
+{
+ Q_D(QDeclarativeRectangle);
+ if (d->radius == radius)
+ return;
+
+ d->radius = radius;
+ d->rectImage = QPixmap();
+ update();
+ emit radiusChanged();
+}
+
+/*!
+ \qmlproperty color Rectangle::color
+ This property holds the color used to fill the rectangle.
+
+ \qml
+ // green rectangle using hexidecimal notation
+ Rectangle { color: "#00FF00" }
+
+ // steelblue rectangle using SVG color name
+ Rectangle { color: "steelblue" }
+ \endqml
+
+ The default color is white.
+
+ If both a gradient and a color are specified, the gradient will be used.
+*/
+QColor QDeclarativeRectangle::color() const
+{
+ Q_D(const QDeclarativeRectangle);
+ return d->color;
+}
+
+void QDeclarativeRectangle::setColor(const QColor &c)
+{
+ Q_D(QDeclarativeRectangle);
+ if (d->color == c)
+ return;
+
+ d->color = c;
+ d->rectImage = QPixmap();
+ update();
+ emit colorChanged();
+}
+
+void QDeclarativeRectangle::generateRoundedRect()
+{
+ Q_D(QDeclarativeRectangle);
+ if (d->rectImage.isNull()) {
+ const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
+ const int radius = qCeil(d->radius); //ensure odd numbered width/height so we get 1-pixel center
+ d->rectImage = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2);
+ d->rectImage.fill(Qt::transparent);
+ QPainter p(&(d->rectImage));
+ p.setRenderHint(QPainter::Antialiasing);
+ if (d->pen && d->pen->isValid()) {
+ QPen pn(QColor(d->pen->color()), d->pen->width());
+ p.setPen(pn);
+ } else {
+ p.setPen(Qt::NoPen);
+ }
+ p.setBrush(d->color);
+ if (pw%2)
+ p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)), d->radius, d->radius);
+ else
+ p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw), d->radius, d->radius);
+ }
+}
+
+void QDeclarativeRectangle::generateBorderedRect()
+{
+ Q_D(QDeclarativeRectangle);
+ if (d->rectImage.isNull()) {
+ const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
+ d->rectImage = QPixmap(pw*2 + 3, pw*2 + 3);
+ d->rectImage.fill(Qt::transparent);
+ QPainter p(&(d->rectImage));
+ p.setRenderHint(QPainter::Antialiasing);
+ if (d->pen && d->pen->isValid()) {
+ QPen pn(QColor(d->pen->color()), d->pen->width());
+ pn.setJoinStyle(Qt::MiterJoin);
+ p.setPen(pn);
+ } else {
+ p.setPen(Qt::NoPen);
+ }
+ p.setBrush(d->color);
+ if (pw%2)
+ p.drawRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)));
+ else
+ p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw));
+ }
+}
+
+void QDeclarativeRectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ Q_D(QDeclarativeRectangle);
+ if (d->radius > 0 || (d->pen && d->pen->isValid())
+ || (d->gradient && d->gradient->gradient()) ) {
+ drawRect(*p);
+ }
+ else {
+ bool oldAA = p->testRenderHint(QPainter::Antialiasing);
+ if (d->smooth)
+ p->setRenderHints(QPainter::Antialiasing, true);
+ p->fillRect(QRectF(0, 0, width(), height()), d->color);
+ if (d->smooth)
+ p->setRenderHint(QPainter::Antialiasing, oldAA);
+ }
+}
+
+void QDeclarativeRectangle::drawRect(QPainter &p)
+{
+ Q_D(QDeclarativeRectangle);
+ if (d->gradient && d->gradient->gradient()) {
+ // XXX This path is still slower than the image path
+ // Image path won't work for gradients though
+ bool oldAA = p.testRenderHint(QPainter::Antialiasing);
+ if (d->smooth)
+ p.setRenderHint(QPainter::Antialiasing);
+ if (d->pen && d->pen->isValid()) {
+ QPen pn(QColor(d->pen->color()), d->pen->width());
+ p.setPen(pn);
+ } else {
+ p.setPen(Qt::NoPen);
+ }
+ p.setBrush(*d->gradient->gradient());
+ if (d->radius > 0.)
+ p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius);
+ else
+ p.drawRect(0, 0, width(), height());
+ if (d->smooth)
+ p.setRenderHint(QPainter::Antialiasing, oldAA);
+ } else {
+ bool oldAA = p.testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform);
+ if (d->smooth)
+ p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+
+ const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0;
+
+ if (d->radius > 0)
+ generateRoundedRect();
+ else
+ generateBorderedRect();
+
+ int xOffset = (d->rectImage.width()-1)/2;
+ int yOffset = (d->rectImage.height()-1)/2;
+ Q_ASSERT(d->rectImage.width() == 2*xOffset + 1);
+ Q_ASSERT(d->rectImage.height() == 2*yOffset + 1);
+
+ QMargins margins(xOffset, yOffset, xOffset, yOffset);
+ QTileRules rules(Qt::StretchTile, Qt::StretchTile);
+ //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects
+ qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width()+pw, height()+pw), margins, d->rectImage, d->rectImage.rect(), margins, rules);
+
+ if (d->smooth) {
+ p.setRenderHint(QPainter::Antialiasing, oldAA);
+ p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
+ }
+ }
+}
+
+/*!
+ \qmlproperty bool Rectangle::smooth
+
+ Set this property if you want the item to be smoothly scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the item is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the item is stationary on
+ the screen. A common pattern when animating an item is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+
+ \image rect-smooth.png
+*/
+
+QRectF QDeclarativeRectangle::boundingRect() const
+{
+ Q_D(const QDeclarativeRectangle);
+ return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle_p.h b/src/declarative/graphicsitems/qdeclarativerectangle_p.h
new file mode 100644
index 0000000..7272962
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativerectangle_p.h
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVERECT_H
+#define QDECLARATIVERECT_H
+
+#include "qdeclarativeitem.h"
+
+#include <QtGui/qbrush.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+class Q_DECLARATIVE_EXPORT QDeclarativePen : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int width READ width WRITE setWidth NOTIFY penChanged)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged)
+public:
+ QDeclarativePen(QObject *parent=0)
+ : QObject(parent), _width(1), _color("#000000"), _valid(false)
+ {}
+
+ int width() const { return _width; }
+ void setWidth(int w);
+
+ QColor color() const { return _color; }
+ void setColor(const QColor &c);
+
+ bool isValid() { return _valid; };
+
+Q_SIGNALS:
+ void penChanged();
+
+private:
+ int _width;
+ QColor _color;
+ bool _valid;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeGradientStop : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal position READ position WRITE setPosition)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+public:
+ QDeclarativeGradientStop(QObject *parent=0) : QObject(parent) {}
+
+ qreal position() const { return m_position; }
+ void setPosition(qreal position) { m_position = position; updateGradient(); }
+
+ QColor color() const { return m_color; }
+ void setColor(const QColor &color) { m_color = color; updateGradient(); }
+
+private:
+ void updateGradient();
+
+private:
+ qreal m_position;
+ QColor m_color;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeGradient : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeGradientStop> stops READ stops)
+ Q_CLASSINFO("DefaultProperty", "stops")
+
+public:
+ QDeclarativeGradient(QObject *parent=0) : QObject(parent), m_gradient(0) {}
+ ~QDeclarativeGradient() { delete m_gradient; }
+
+ QDeclarativeListProperty<QDeclarativeGradientStop> stops() { return QDeclarativeListProperty<QDeclarativeGradientStop>(this, m_stops); }
+
+ const QGradient *gradient() const;
+
+Q_SIGNALS:
+ void updated();
+
+private:
+ void doUpdate();
+
+private:
+ QList<QDeclarativeGradientStop *> m_stops;
+ mutable QGradient *m_gradient;
+ friend class QDeclarativeGradientStop;
+};
+
+class QDeclarativeRectanglePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeRectangle : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(QDeclarativeGradient *gradient READ gradient WRITE setGradient)
+ Q_PROPERTY(QDeclarativePen * border READ border CONSTANT)
+ Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
+public:
+ QDeclarativeRectangle(QDeclarativeItem *parent=0);
+
+ QColor color() const;
+ void setColor(const QColor &);
+
+ QDeclarativePen *border();
+
+ QDeclarativeGradient *gradient() const;
+ void setGradient(QDeclarativeGradient *gradient);
+
+ qreal radius() const;
+ void setRadius(qreal radius);
+
+ QRectF boundingRect() const;
+
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+Q_SIGNALS:
+ void colorChanged();
+ void radiusChanged();
+
+private Q_SLOTS:
+ void doUpdate();
+
+private:
+ void generateRoundedRect();
+ void generateBorderedRect();
+ void drawRect(QPainter &painter);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeRectangle)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeRectangle)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativePen)
+QML_DECLARE_TYPE(QDeclarativeGradientStop)
+QML_DECLARE_TYPE(QDeclarativeGradient)
+QML_DECLARE_TYPE(QDeclarativeRectangle)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVERECT_H
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h b/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h
new file mode 100644
index 0000000..b87c57f
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVERECT_P_H
+#define QDECLARATIVERECT_P_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 "qdeclarativeitem_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeGradient;
+class QDeclarativeRectangle;
+class QDeclarativeRectanglePrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeRectangle)
+
+public:
+ QDeclarativeRectanglePrivate() :
+ color(Qt::white), gradient(0), pen(0), radius(0), paintmargin(0)
+ {
+ }
+
+ ~QDeclarativeRectanglePrivate()
+ {
+ delete pen;
+ }
+
+ void init()
+ {
+ }
+
+ QColor getColor();
+ QColor color;
+ QDeclarativeGradient *gradient;
+ QDeclarativePen *getPen() {
+ if (!pen) {
+ Q_Q(QDeclarativeRectangle);
+ pen = new QDeclarativePen;
+ QObject::connect(pen, SIGNAL(penChanged()), q, SLOT(doUpdate()));
+ }
+ return pen;
+ }
+ QDeclarativePen *pen;
+ qreal radius;
+ qreal paintmargin;
+ QPixmap rectImage;
+
+ void setPaintMargin(qreal margin)
+ {
+ Q_Q(QDeclarativeRectangle);
+ if (margin == paintmargin)
+ return;
+ q->prepareGeometryChange();
+ paintmargin = margin;
+ }
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVERECT_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
new file mode 100644
index 0000000..ca57d3c
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -0,0 +1,328 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativerepeater_p.h"
+#include "qdeclarativerepeater_p_p.h"
+
+#include "qdeclarativevisualitemmodel_p.h"
+
+#include <qdeclarativelistaccessor_p.h>
+
+#include <qlistmodelinterface_p.h>
+
+QT_BEGIN_NAMESPACE
+QDeclarativeRepeaterPrivate::QDeclarativeRepeaterPrivate()
+: model(0), ownModel(false)
+{
+}
+
+QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate()
+{
+ if (ownModel)
+ delete model;
+}
+
+/*!
+ \qmlclass Repeater QDeclarativeRepeater
+ \since 4.7
+ \inherits Item
+
+ \brief The Repeater item allows you to repeat a component based on a model.
+
+ The Repeater item is used when you want to create a large number of
+ similar items. For each entry in the model, an item is instantiated
+ in a context seeded with data from the model. If the repeater will
+ be instantiating a large number of instances, it may be more efficient to
+ use one of Qt Declarative's \l {xmlViews}{view items}.
+
+ The model may be either an object list, a string list, a number or a Qt model.
+ In each case, the data element and the index is exposed to each instantiated
+ component.
+
+ The index is always exposed as an accessible \c index property.
+ In the case of an object or string list, the data element (of type string
+ or object) is available as the \c modelData property. In the case of a Qt model,
+ all roles are available as named properties just like in the view classes. The
+ following example shows how to use the index property inside the instantiated
+ items.
+
+ \snippet doc/src/snippets/declarative/repeater-index.qml 0
+
+ \image repeater-index.png
+
+ Items instantiated by the Repeater are inserted, in order, as
+ children of the Repeater's parent. The insertion starts immediately after
+ the repeater's position in its parent stacking list. This is to allow
+ you to use a Repeater inside a layout. The following QML example shows how
+ the instantiated items would visually appear stacked between the red and
+ blue rectangles.
+
+ \snippet doc/src/snippets/declarative/repeater.qml 0
+
+ \image repeater.png
+
+ The repeater instance continues to own all items it instantiates, even
+ if they are otherwise manipulated. It is illegal to manually remove an item
+ created by the Repeater.
+ */
+
+/*!
+ \internal
+ \class QDeclarativeRepeater
+ \qmlclass Repeater
+
+ XXX Repeater is very conservative in how it instatiates/deletes items. Also
+ new model entries will not be created and old ones will not be removed.
+ */
+
+/*!
+ Create a new QDeclarativeRepeater instance.
+ */
+QDeclarativeRepeater::QDeclarativeRepeater(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativeRepeaterPrivate), parent)
+{
+}
+
+/*!
+ Destroy the repeater instance. All items it instantiated are also
+ destroyed.
+ */
+QDeclarativeRepeater::~QDeclarativeRepeater()
+{
+}
+
+/*!
+ \qmlproperty any Repeater::model
+
+ The model providing data for the repeater.
+
+ The model may be either an object list, a string list, a number or a Qt model.
+ In each case, the data element and the index is exposed to each instantiated
+ component. The index is always exposed as an accessible \c index property.
+ In the case of an object or string list, the data element (of type string
+ or object) is available as the \c modelData property. In the case of a Qt model,
+ all roles are available as named properties just like in the view classes.
+
+ As a special case the model can also be merely a number. In this case it will
+ create that many instances of the component. They will also be assigned an index
+ based on the order they are created.
+
+ Models can also be created directly in QML, using a \l{ListModel} or \l{XmlListModel}.
+
+ \sa {qmlmodels}{Data Models}
+*/
+QVariant QDeclarativeRepeater::model() const
+{
+ Q_D(const QDeclarativeRepeater);
+ return d->dataSource;
+}
+
+void QDeclarativeRepeater::setModel(const QVariant &model)
+{
+ Q_D(QDeclarativeRepeater);
+ if (d->dataSource == model)
+ return;
+
+ clear();
+ if (d->model) {
+ disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
+ disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
+ /*
+ disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
+ disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
+ */
+ }
+ d->dataSource = model;
+ emit modelChanged();
+ QObject *object = qvariant_cast<QObject*>(model);
+ QDeclarativeVisualModel *vim = 0;
+ if (object && (vim = qobject_cast<QDeclarativeVisualModel *>(object))) {
+ if (d->ownModel) {
+ delete d->model;
+ d->ownModel = false;
+ }
+ d->model = vim;
+ } else {
+ if (!d->ownModel) {
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->ownModel = true;
+ }
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
+ dataModel->setModel(model);
+ }
+ if (d->model) {
+ connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
+ connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
+ /*
+ connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
+ connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
+ */
+ regenerate();
+ emit countChanged();
+ }
+}
+
+/*!
+ \qmlproperty Component Repeater::delegate
+ \default
+
+ The delegate provides a template defining each item instantiated by the repeater.
+ The index is exposed as an accessible \c index property. Properties of the
+ model are also available depending upon the type of \l {qmlmodels}{Data Model}.
+ */
+QDeclarativeComponent *QDeclarativeRepeater::delegate() const
+{
+ Q_D(const QDeclarativeRepeater);
+ if (d->model) {
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
+ return dataModel->delegate();
+ }
+
+ return 0;
+}
+
+void QDeclarativeRepeater::setDelegate(QDeclarativeComponent *delegate)
+{
+ Q_D(QDeclarativeRepeater);
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
+ if (delegate == dataModel->delegate())
+ return;
+
+ if (!d->ownModel) {
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->ownModel = true;
+ }
+ if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) {
+ dataModel->setDelegate(delegate);
+ regenerate();
+ emit delegateChanged();
+ }
+}
+
+/*!
+ \qmlproperty int Repeater::count
+
+ This property holds the number of items in the repeater.
+*/
+int QDeclarativeRepeater::count() const
+{
+ Q_D(const QDeclarativeRepeater);
+ if (d->model)
+ return d->model->count();
+ return 0;
+}
+
+
+/*!
+ \internal
+ */
+void QDeclarativeRepeater::componentComplete()
+{
+ QDeclarativeItem::componentComplete();
+ regenerate();
+}
+
+/*!
+ \internal
+ */
+QVariant QDeclarativeRepeater::itemChange(GraphicsItemChange change,
+ const QVariant &value)
+{
+ QVariant rv = QDeclarativeItem::itemChange(change, value);
+ if (change == ItemParentHasChanged) {
+ regenerate();
+ }
+
+ return rv;
+}
+
+void QDeclarativeRepeater::clear()
+{
+ Q_D(QDeclarativeRepeater);
+ if (d->model) {
+ foreach (QDeclarativeItem *item, d->deletables) {
+ item->setParentItem(this);
+ d->model->release(item);
+ }
+ }
+ d->deletables.clear();
+}
+
+/*!
+ \internal
+ */
+void QDeclarativeRepeater::regenerate()
+{
+ Q_D(QDeclarativeRepeater);
+
+ clear();
+
+ if (!d->model || !d->model->count() || !d->model->isValid() || !parentItem() || !isComponentComplete())
+ return;
+
+ for (int ii = 0; ii < count(); ++ii) {
+ QDeclarativeItem *item = d->model->item(ii);
+ if (item) {
+ item->setParent(parentItem());
+ item->stackBefore(this);
+ d->deletables << item;
+ }
+ }
+}
+
+void QDeclarativeRepeater::itemsInserted(int, int)
+{
+ regenerate();
+}
+
+void QDeclarativeRepeater::itemsRemoved(int, int)
+{
+ regenerate();
+}
+
+void QDeclarativeRepeater::itemsMoved(int,int,int)
+{
+ regenerate();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater_p.h b/src/declarative/graphicsitems/qdeclarativerepeater_p.h
new file mode 100644
index 0000000..f58d1b6
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativerepeater_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEREPEATER_H
+#define QDECLARATIVEREPEATER_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeRepeaterPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeRepeater : public QDeclarativeItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+ Q_CLASSINFO("DefaultProperty", "delegate")
+
+public:
+ QDeclarativeRepeater(QDeclarativeItem *parent=0);
+ virtual ~QDeclarativeRepeater();
+
+ QVariant model() const;
+ void setModel(const QVariant &);
+
+ QDeclarativeComponent *delegate() const;
+ void setDelegate(QDeclarativeComponent *);
+
+ int count() const;
+
+Q_SIGNALS:
+ void modelChanged();
+ void delegateChanged();
+ void countChanged();
+private:
+ void clear();
+ void regenerate();
+
+protected:
+ virtual void componentComplete();
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+
+private Q_SLOTS:
+ void itemsInserted(int,int);
+ void itemsRemoved(int,int);
+ void itemsMoved(int,int,int);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeRepeater)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeRepeater)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeRepeater)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEREPEATER_H
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater_p_p.h b/src/declarative/graphicsitems/qdeclarativerepeater_p_p.h
new file mode 100644
index 0000000..11773ff
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativerepeater_p_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEREPEATER_P_H
+#define QDECLARATIVEREPEATER_P_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 "qdeclarativerepeater_p.h"
+
+#include "qdeclarativeitem_p.h"
+
+#include <QPointer>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeContext;
+class QDeclarativeVisualModel;
+class QDeclarativeRepeaterPrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeRepeater)
+
+public:
+ QDeclarativeRepeaterPrivate();
+ ~QDeclarativeRepeaterPrivate();
+
+ QDeclarativeVisualModel *model;
+ QVariant dataSource;
+ bool ownModel;
+
+ QList<QPointer<QDeclarativeItem> > deletables;
+};
+
+QT_END_NAMESPACE
+#endif // QDECLARATIVEREPEATER_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid.cpp b/src/declarative/graphicsitems/qdeclarativescalegrid.cpp
new file mode 100644
index 0000000..dbc7568
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativescalegrid.cpp
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativescalegrid_p_p.h"
+
+#include <qdeclarative.h>
+
+#include <QBuffer>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+/*!
+ \internal
+ \class QDeclarativeScaleGrid
+ \brief The QDeclarativeScaleGrid class allows you to specify a 3x3 grid to use in scaling an image.
+*/
+
+QDeclarativeScaleGrid::QDeclarativeScaleGrid(QObject *parent) : QObject(parent), _left(0), _top(0), _right(0), _bottom(0)
+{
+}
+
+QDeclarativeScaleGrid::~QDeclarativeScaleGrid()
+{
+}
+
+bool QDeclarativeScaleGrid::isNull() const
+{
+ return !_left && !_top && !_right && !_bottom;
+}
+
+void QDeclarativeScaleGrid::setLeft(int pos)
+{
+ if (_left != pos) {
+ _left = pos;
+ emit borderChanged();
+ }
+}
+
+void QDeclarativeScaleGrid::setTop(int pos)
+{
+ if (_top != pos) {
+ _top = pos;
+ emit borderChanged();
+ }
+}
+
+void QDeclarativeScaleGrid::setRight(int pos)
+{
+ if (_right != pos) {
+ _right = pos;
+ emit borderChanged();
+ }
+}
+
+void QDeclarativeScaleGrid::setBottom(int pos)
+{
+ if (_bottom != pos) {
+ _bottom = pos;
+ emit borderChanged();
+ }
+}
+
+QDeclarativeGridScaledImage::QDeclarativeGridScaledImage()
+: _l(-1), _r(-1), _t(-1), _b(-1),
+ _h(QDeclarativeBorderImage::Stretch), _v(QDeclarativeBorderImage::Stretch)
+{
+}
+
+QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(const QDeclarativeGridScaledImage &o)
+: _l(o._l), _r(o._r), _t(o._t), _b(o._b), _h(o._h), _v(o._v), _pix(o._pix)
+{
+}
+
+QDeclarativeGridScaledImage &QDeclarativeGridScaledImage::operator=(const QDeclarativeGridScaledImage &o)
+{
+ _l = o._l;
+ _r = o._r;
+ _t = o._t;
+ _b = o._b;
+ _h = o._h;
+ _v = o._v;
+ _pix = o._pix;
+ return *this;
+}
+
+QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(QIODevice *data)
+: _l(-1), _r(-1), _t(-1), _b(-1), _h(QDeclarativeBorderImage::Stretch), _v(QDeclarativeBorderImage::Stretch)
+{
+ int l = -1;
+ int r = -1;
+ int t = -1;
+ int b = -1;
+ QString imgFile;
+
+ while(!data->atEnd()) {
+ QString line = QString::fromUtf8(data->readLine().trimmed());
+ if (line.isEmpty() || line.startsWith(QLatin1Char('#')))
+ continue;
+
+ QStringList list = line.split(QLatin1Char(':'));
+ if (list.count() != 2)
+ return;
+
+ list[0] = list[0].trimmed();
+ list[1] = list[1].trimmed();
+
+ if (list[0] == QLatin1String("border.left"))
+ l = list[1].toInt();
+ else if (list[0] == QLatin1String("border.right"))
+ r = list[1].toInt();
+ else if (list[0] == QLatin1String("border.top"))
+ t = list[1].toInt();
+ else if (list[0] == QLatin1String("border.bottom"))
+ b = list[1].toInt();
+ else if (list[0] == QLatin1String("source"))
+ imgFile = list[1];
+ else if (list[0] == QLatin1String("horizontalTileRule"))
+ _h = stringToRule(list[1]);
+ else if (list[0] == QLatin1String("verticalTileRule"))
+ _v = stringToRule(list[1]);
+ }
+
+ if (l < 0 || r < 0 || t < 0 || b < 0 || imgFile.isEmpty())
+ return;
+
+ _l = l; _r = r; _t = t; _b = b;
+
+ _pix = imgFile;
+}
+
+QDeclarativeBorderImage::TileMode QDeclarativeGridScaledImage::stringToRule(const QString &s)
+{
+ if (s == QLatin1String("Stretch"))
+ return QDeclarativeBorderImage::Stretch;
+ if (s == QLatin1String("Repeat"))
+ return QDeclarativeBorderImage::Repeat;
+ if (s == QLatin1String("Round"))
+ return QDeclarativeBorderImage::Round;
+
+ qWarning() << "Unknown tile rule specified. Using Stretch";
+ return QDeclarativeBorderImage::Stretch;
+}
+
+bool QDeclarativeGridScaledImage::isValid() const
+{
+ return _l >= 0;
+}
+
+int QDeclarativeGridScaledImage::gridLeft() const
+{
+ return _l;
+}
+
+int QDeclarativeGridScaledImage::gridRight() const
+{
+ return _r;
+}
+
+int QDeclarativeGridScaledImage::gridTop() const
+{
+ return _t;
+}
+
+int QDeclarativeGridScaledImage::gridBottom() const
+{
+ return _b;
+}
+
+QString QDeclarativeGridScaledImage::pixmapUrl() const
+{
+ return _pix;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h
new file mode 100644
index 0000000..92b3f91
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVESCALEGRID_H
+#define QDECLARATIVESCALEGRID_H
+
+#include "qdeclarativeborderimage_p.h"
+
+#include "../util/qdeclarativepixmapcache_p.h"
+#include <qdeclarative.h>
+
+#include <QtCore/QString>
+#include <QtCore/QObject>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QDeclarativeScaleGrid : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(TileRule)
+
+ Q_PROPERTY(int left READ left WRITE setLeft NOTIFY borderChanged)
+ Q_PROPERTY(int top READ top WRITE setTop NOTIFY borderChanged)
+ Q_PROPERTY(int right READ right WRITE setRight NOTIFY borderChanged)
+ Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY borderChanged)
+
+public:
+ QDeclarativeScaleGrid(QObject *parent=0);
+ ~QDeclarativeScaleGrid();
+
+ bool isNull() const;
+
+ int left() const { return _left; }
+ void setLeft(int);
+
+ int top() const { return _top; }
+ void setTop(int);
+
+ int right() const { return _right; }
+ void setRight(int);
+
+ int bottom() const { return _bottom; }
+ void setBottom(int);
+
+Q_SIGNALS:
+ void borderChanged();
+
+private:
+ int _left;
+ int _top;
+ int _right;
+ int _bottom;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeGridScaledImage
+{
+public:
+ QDeclarativeGridScaledImage();
+ QDeclarativeGridScaledImage(const QDeclarativeGridScaledImage &);
+ QDeclarativeGridScaledImage(QIODevice*);
+ QDeclarativeGridScaledImage &operator=(const QDeclarativeGridScaledImage &);
+ bool isValid() const;
+ int gridLeft() const;
+ int gridRight() const;
+ int gridTop() const;
+ int gridBottom() const;
+ QDeclarativeBorderImage::TileMode horizontalTileRule() const { return _h; }
+ QDeclarativeBorderImage::TileMode verticalTileRule() const { return _v; }
+
+ QString pixmapUrl() const;
+
+private:
+ static QDeclarativeBorderImage::TileMode stringToRule(const QString &);
+
+private:
+ int _l;
+ int _r;
+ int _t;
+ int _b;
+ QDeclarativeBorderImage::TileMode _h;
+ QDeclarativeBorderImage::TileMode _v;
+ QString _pix;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeScaleGrid)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVESCALEGRID_H
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
new file mode 100644
index 0000000..307b674
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -0,0 +1,936 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativetext_p.h"
+#include "qdeclarativetext_p_p.h"
+#include <qdeclarativestyledtext_p.h>
+
+#include <qfxperf_p_p.h>
+
+#include <QTextLayout>
+#include <QTextLine>
+#include <QTextDocument>
+#include <QTextCursor>
+#include <QGraphicsSceneMouseEvent>
+#include <QPainter>
+#include <QAbstractTextDocumentLayout>
+#include <qmath.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass Text QDeclarativeText
+ \since 4.7
+ \brief The Text item allows you to add formatted text to a scene.
+ \inherits Item
+
+ It can display both plain and rich text. For example:
+
+ \qml
+ Text { text: "Hello World!"; font.family: "Helvetica"; font.pointSize: 24; color: "red" }
+ Text { text: "<b>Hello</b> <i>World!</i>" }
+ \endqml
+
+ \image declarative-text.png
+
+ If height and width are not explicitly set, Text will attempt to determine how
+ much room is needed and set it accordingly. Unless \c wrap is set, it will always
+ prefer width to height (all text will be placed on a single line).
+
+ The \c elide property can alternatively be used to fit a single line of
+ plain text to a set width.
+
+ Text provides read-only text. For editable text, see \l TextEdit.
+*/
+
+/*!
+ \internal
+ \class QDeclarativeText
+ \qmlclass Text
+ \ingroup group_coreitems
+
+ \brief The QDeclarativeText class provides a formatted text item that you can add to a QDeclarativeView.
+
+ Text was designed for read-only text; it does not allow for any text editing.
+ It can display both plain and rich text. For example:
+
+ \qml
+ Text { text: "Hello World!"; font.family: "Helvetica"; font.pointSize: 24; color: "red" }
+ Text { text: "<b>Hello</b> <i>World!</i>" }
+ \endqml
+
+ \image text.png
+
+ If height and width are not explicitly set, Text will attempt to determine how
+ much room is needed and set it accordingly. Unless \c wrap is set, it will always
+ prefer width to height (all text will be placed on a single line).
+
+ The \c elide property can alternatively be used to fit a line of plain text to a set width.
+
+ A QDeclarativeText object can be instantiated in Qml using the tag \c Text.
+*/
+QDeclarativeText::QDeclarativeText(QDeclarativeItem *parent)
+ : QDeclarativeItem(*(new QDeclarativeTextPrivate), parent)
+{
+ setAcceptedMouseButtons(Qt::LeftButton);
+ setFlag(QGraphicsItem::ItemHasNoContents, false);
+}
+
+QDeclarativeText::~QDeclarativeText()
+{
+}
+
+
+QDeclarativeTextPrivate::~QDeclarativeTextPrivate()
+{
+}
+
+/*!
+ \qmlproperty string Text::font.family
+ \qmlproperty bool Text::font.bold
+ \qmlproperty bool Text::font.italic
+ \qmlproperty bool Text::font.underline
+ \qmlproperty real Text::font.pointSize
+ \qmlproperty int Text::font.pixelSize
+
+ Set the Text's font attributes.
+*/
+QFont QDeclarativeText::font() const
+{
+ Q_D(const QDeclarativeText);
+ return d->font;
+}
+
+void QDeclarativeText::setFont(const QFont &font)
+{
+ Q_D(QDeclarativeText);
+ if (d->font == font)
+ return;
+
+ d->font = font;
+
+ d->updateLayout();
+ d->markImgDirty();
+ emit fontChanged(d->font);
+}
+
+void QDeclarativeText::setText(const QString &n)
+{
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::QDeclarativeText_setText> st;
+#endif
+ Q_D(QDeclarativeText);
+ if (d->text == n)
+ return;
+
+ d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(n));
+ if (d->richText) {
+ if (!d->doc) {
+ d->doc = new QTextDocument(this);
+ d->doc->setDocumentMargin(0);
+ }
+ d->doc->setHtml(n);
+ }
+
+ d->text = n;
+ d->updateLayout();
+ d->markImgDirty();
+ emit textChanged(d->text);
+}
+
+/*!
+ \qmlproperty string Text::text
+
+ The text to display. Text supports both plain and rich text strings.
+
+ The item will try to automatically determine whether the text should
+ be treated as rich text. This determination is made using Qt::mightBeRichText().
+*/
+QString QDeclarativeText::text() const
+{
+ Q_D(const QDeclarativeText);
+ return d->text;
+}
+
+void QDeclarativeText::setColor(const QColor &color)
+{
+ Q_D(QDeclarativeText);
+ if (d->color == color)
+ return;
+
+ d->color = color;
+ d->markImgDirty();
+ emit colorChanged(d->color);
+}
+
+/*!
+ \qmlproperty color Text::color
+
+ The text color.
+
+ \qml
+ //green text using hexadecimal notation
+ Text { color: "#00FF00"; ... }
+
+ //steelblue text using SVG color name
+ Text { color: "steelblue"; ... }
+ \endqml
+*/
+
+QColor QDeclarativeText::color() const
+{
+ Q_D(const QDeclarativeText);
+ return d->color;
+}
+
+/*!
+ \qmlproperty enumeration Text::style
+
+ Set an additional text style.
+
+ Supported text styles are \c Normal, \c Outline, \c Raised and \c Sunken.
+
+ \qml
+ Row {
+ Text { font.pointSize: 24; text: "Normal" }
+ Text { font.pointSize: 24; text: "Raised"; style: Text.Raised; styleColor: "#AAAAAA" }
+ Text { font.pointSize: 24; text: "Outline"; style: Text.Outline; styleColor: "red" }
+ Text { font.pointSize: 24; text: "Sunken"; style: Text.Sunken; styleColor: "#AAAAAA" }
+ }
+ \endqml
+
+ \image declarative-textstyle.png
+*/
+QDeclarativeText::TextStyle QDeclarativeText::style() const
+{
+ Q_D(const QDeclarativeText);
+ return d->style;
+}
+
+void QDeclarativeText::setStyle(QDeclarativeText::TextStyle style)
+{
+ Q_D(QDeclarativeText);
+ if (d->style == style)
+ return;
+
+ d->style = style;
+ d->markImgDirty();
+ emit styleChanged(d->style);
+}
+
+void QDeclarativeText::setStyleColor(const QColor &color)
+{
+ Q_D(QDeclarativeText);
+ if (d->styleColor == color)
+ return;
+
+ d->styleColor = color;
+ d->markImgDirty();
+ emit styleColorChanged(d->styleColor);
+}
+
+/*!
+ \qmlproperty color Text::styleColor
+
+ Defines the secondary color used by text styles.
+
+ \c styleColor is used as the outline color for outlined text, and as the
+ shadow color for raised or sunken text. If no style has been set, it is not
+ used at all.
+ */
+QColor QDeclarativeText::styleColor() const
+{
+ Q_D(const QDeclarativeText);
+ return d->styleColor;
+}
+
+/*!
+ \qmlproperty enumeration Text::horizontalAlignment
+ \qmlproperty enumeration Text::verticalAlignment
+
+ Sets the horizontal and vertical alignment of the text within the Text items
+ width and height. By default, the text is top-left aligned.
+
+ The valid values for \c horizontalAlignment are \c AlignLeft, \c AlignRight and
+ \c AlignHCenter. The valid values for \c verticalAlignment are \c AlignTop, \c AlignBottom
+ and \c AlignVCenter.
+*/
+QDeclarativeText::HAlignment QDeclarativeText::hAlign() const
+{
+ Q_D(const QDeclarativeText);
+ return d->hAlign;
+}
+
+void QDeclarativeText::setHAlign(HAlignment align)
+{
+ Q_D(QDeclarativeText);
+ if (d->hAlign == align)
+ return;
+
+ d->hAlign = align;
+ emit horizontalAlignmentChanged(align);
+}
+
+QDeclarativeText::VAlignment QDeclarativeText::vAlign() const
+{
+ Q_D(const QDeclarativeText);
+ return d->vAlign;
+}
+
+void QDeclarativeText::setVAlign(VAlignment align)
+{
+ Q_D(QDeclarativeText);
+ if (d->vAlign == align)
+ return;
+
+ d->vAlign = align;
+ emit verticalAlignmentChanged(align);
+}
+
+/*!
+ \qmlproperty bool Text::wrap
+
+ Set this property to wrap the text to the Text item's width. The text will only
+ wrap if an explicit width has been set.
+
+ Wrapping is done on word boundaries (i.e. it is a "word-wrap"). If the text cannot be
+ word-wrapped to the specified width it will be partially drawn outside of the item's bounds.
+ If this is undesirable then enable clipping on the item (Item::clip).
+
+ Wrapping is off by default.
+*/
+//### Future may provide choice of wrap modes, such as QTextOption::WrapAtWordBoundaryOrAnywhere
+bool QDeclarativeText::wrap() const
+{
+ Q_D(const QDeclarativeText);
+ return d->wrap;
+}
+
+void QDeclarativeText::setWrap(bool w)
+{
+ Q_D(QDeclarativeText);
+ if (w == d->wrap)
+ return;
+
+ d->wrap = w;
+
+ d->updateLayout();
+ d->markImgDirty();
+ emit wrapChanged(d->wrap);
+}
+
+/*!
+ \qmlproperty enumeration Text::textFormat
+
+ The way the text property should be displayed.
+
+ Supported text formats are \c AutoText, \c PlainText, \c RichText and \c StyledText
+
+ The default is AutoText. If the text format is AutoText the text element
+ will automatically determine whether the text should be treated as
+ rich text. This determination is made using Qt::mightBeRichText().
+
+ StyledText is an optimized format supporting some basic text
+ styling markup, in the style of html 3.2:
+
+ \code
+ <font size="4" color="#ff0000">font size and color</font>
+ <b>bold</b>
+ <i>italic</i>
+ <br>
+ &gt; &lt; &amp;
+ \endcode
+
+ \c StyledText parser is strict, requiring tags to be correctly nested.
+
+ \table
+ \row
+ \o
+ \qml
+Column {
+ TextEdit {
+ font.pointSize: 24
+ text: "<b>Hello</b> <i>World!</i>"
+ }
+ TextEdit {
+ font.pointSize: 24
+ textFormat: "RichText"
+ text: "<b>Hello</b> <i>World!</i>"
+ }
+ TextEdit {
+ font.pointSize: 24
+ textFormat: "PlainText"
+ text: "<b>Hello</b> <i>World!</i>"
+ }
+}
+ \endqml
+ \o \image declarative-textformat.png
+ \endtable
+*/
+
+QDeclarativeText::TextFormat QDeclarativeText::textFormat() const
+{
+ Q_D(const QDeclarativeText);
+ return d->format;
+}
+
+void QDeclarativeText::setTextFormat(TextFormat format)
+{
+ Q_D(QDeclarativeText);
+ if (format == d->format)
+ return;
+ d->format = format;
+ bool wasRich = d->richText;
+ d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text));
+
+ if (wasRich && !d->richText) {
+ //### delete control? (and vice-versa below)
+ d->updateLayout();
+ d->markImgDirty();
+ } else if (!wasRich && d->richText) {
+ if (!d->doc) {
+ d->doc = new QTextDocument(this);
+ d->doc->setDocumentMargin(0);
+ }
+ d->doc->setHtml(d->text);
+ d->updateLayout();
+ d->markImgDirty();
+ }
+
+ emit textFormatChanged(d->format);
+}
+
+/*!
+ \qmlproperty enumeration Text::elide
+
+ Set this property to elide parts of the text fit to the Text item's width.
+ The text will only elide if an explicit width has been set.
+
+ This property cannot be used with wrap enabled or with rich text.
+
+ Eliding can be \c ElideNone (the default), \c ElideLeft, \c ElideMiddle, or \c ElideRight.
+
+ If the text is a multi-length string, and the mode is not \c ElideNone,
+ the first string that fits will be used, otherwise the last will be elided.
+
+ Multi-length strings are ordered from longest to shortest, separated by the
+ Unicode "String Terminator" character \c U009C (write this in QML with \c{"\u009C"} or \c{"\x9C"}).
+*/
+QDeclarativeText::TextElideMode QDeclarativeText::elideMode() const
+{
+ Q_D(const QDeclarativeText);
+ return d->elideMode;
+}
+
+void QDeclarativeText::setElideMode(QDeclarativeText::TextElideMode mode)
+{
+ Q_D(QDeclarativeText);
+ if (mode == d->elideMode)
+ return;
+
+ d->elideMode = mode;
+
+ d->updateLayout();
+ d->markImgDirty();
+ emit elideModeChanged(d->elideMode);
+}
+
+void QDeclarativeText::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
+{
+ Q_D(QDeclarativeText);
+ if (newGeometry.width() != oldGeometry.width()) {
+ if (d->wrap || d->elideMode != QDeclarativeText::ElideNone) {
+ //re-elide if needed
+ if (d->singleline && d->elideMode != QDeclarativeText::ElideNone &&
+ isComponentComplete() && widthValid()) {
+
+ QFontMetrics fm(d->font);
+ QString tmp = fm.elidedText(d->text,(Qt::TextElideMode)d->elideMode,width()); // XXX still worth layout...?
+ d->layout.setText(tmp);
+ }
+
+ d->imgDirty = true;
+ d->updateSize();
+ }
+ }
+ QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+void QDeclarativeTextPrivate::updateLayout()
+{
+ Q_Q(QDeclarativeText);
+ if (q->isComponentComplete()) {
+ //setup instance of QTextLayout for all cases other than richtext
+ if (!richText) {
+ layout.clearLayout();
+ layout.setFont(font);
+ if (format != QDeclarativeText::StyledText) {
+ QString tmp = text;
+ tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
+ singleline = !tmp.contains(QChar::LineSeparator);
+ if (singleline && elideMode != QDeclarativeText::ElideNone && q->widthValid()) {
+ QFontMetrics fm(font);
+ tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); // XXX still worth layout...?
+ }
+ layout.setText(tmp);
+ } else {
+ singleline = false;
+ QDeclarativeStyledText::parse(text, layout);
+ }
+ }
+ updateSize();
+ } else {
+ dirty = true;
+ }
+}
+
+void QDeclarativeTextPrivate::updateSize()
+{
+ Q_Q(QDeclarativeText);
+ if (q->isComponentComplete()) {
+ QFontMetrics fm(font);
+ if (text.isEmpty()) {
+ q->setImplicitHeight(fm.height());
+ return;
+ }
+
+ int dy = q->height();
+ QSize size(0, 0);
+
+ //setup instance of QTextLayout for all cases other than richtext
+ if (!richText) {
+ size = setupTextLayout(&layout);
+ cachedLayoutSize = size;
+ dy -= size.height();
+ } else {
+ singleline = false; // richtext can't elide or be optimized for single-line case
+ doc->setDefaultFont(font);
+ QTextOption option((Qt::Alignment)int(hAlign | vAlign));
+ if (wrap)
+ option.setWrapMode(QTextOption::WordWrap);
+ else
+ option.setWrapMode(QTextOption::NoWrap);
+ doc->setDefaultTextOption(option);
+ if (wrap && !q->heightValid() && q->widthValid())
+ doc->setTextWidth(q->width());
+ else
+ doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
+ dy -= (int)doc->size().height();
+ cachedLayoutSize = doc->size().toSize();
+ }
+ int yoff = 0;
+
+ if (q->heightValid()) {
+ if (vAlign == QDeclarativeText::AlignBottom)
+ yoff = dy;
+ else if (vAlign == QDeclarativeText::AlignVCenter)
+ yoff = dy/2;
+ }
+ q->setBaselineOffset(fm.ascent() + yoff);
+
+ //### need to comfirm cost of always setting these for richText
+ q->setImplicitWidth(richText ? (int)doc->idealWidth() : size.width());
+ q->setImplicitHeight(richText ? (int)doc->size().height() : size.height());
+ } else {
+ dirty = true;
+ }
+}
+
+// ### text layout handling should be profiled and optimized as needed
+// what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine);
+
+void QDeclarativeTextPrivate::drawOutline()
+{
+ QPixmap img = QPixmap(imgStyleCache.width()+2,imgStyleCache.height()+2);
+ img.fill(Qt::transparent);
+
+ QPainter ppm(&img);
+
+ QPoint pos(imgCache.rect().topLeft());
+ pos += QPoint(-1, 0);
+ ppm.drawPixmap(pos, imgStyleCache);
+ pos += QPoint(2, 0);
+ ppm.drawPixmap(pos, imgStyleCache);
+ pos += QPoint(-1, -1);
+ ppm.drawPixmap(pos, imgStyleCache);
+ pos += QPoint(0, 2);
+ ppm.drawPixmap(pos, imgStyleCache);
+
+ pos += QPoint(0, -1);
+ ppm.drawPixmap(pos, imgCache);
+ ppm.end();
+
+ imgCache = img;
+}
+
+void QDeclarativeTextPrivate::drawOutline(int yOffset)
+{
+ QPixmap img = QPixmap(imgStyleCache.width()+2,imgStyleCache.height()+2);
+ img.fill(Qt::transparent);
+
+ QPainter ppm(&img);
+
+ QPoint pos(imgCache.rect().topLeft());
+ pos += QPoint(0, yOffset);
+ ppm.drawPixmap(pos, imgStyleCache);
+
+ pos += QPoint(0, -yOffset);
+ ppm.drawPixmap(pos, imgCache);
+ ppm.end();
+
+ imgCache = img;
+}
+
+QSize QDeclarativeTextPrivate::setupTextLayout(QTextLayout *layout)
+{
+ Q_Q(QDeclarativeText);
+ layout->setCacheEnabled(true);
+
+ int height = 0;
+ qreal widthUsed = 0;
+ qreal lineWidth = 0;
+
+ //set manual width
+ if ((wrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid())
+ lineWidth = q->width();
+
+ layout->beginLayout();
+
+ while (1) {
+ QTextLine line = layout->createLine();
+ if (!line.isValid())
+ break;
+
+ if ((wrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid())
+ line.setLineWidth(lineWidth);
+ }
+ layout->endLayout();
+
+ int x = 0;
+ for (int i = 0; i < layout->lineCount(); ++i) {
+ QTextLine line = layout->lineAt(i);
+ widthUsed = qMax(widthUsed, line.naturalTextWidth());
+ line.setPosition(QPointF(0, height));
+ height += int(line.height());
+
+ if (!cache) {
+ if (hAlign == QDeclarativeText::AlignLeft) {
+ x = 0;
+ } else if (hAlign == QDeclarativeText::AlignRight) {
+ x = q->width() - (int)line.naturalTextWidth();
+ } else if (hAlign == QDeclarativeText::AlignHCenter) {
+ x = (q->width() - (int)line.naturalTextWidth()) / 2;
+ }
+ line.setPosition(QPoint(x, (int)line.y()));
+ }
+ }
+
+ return QSize(qCeil(widthUsed), height);
+}
+
+QPixmap QDeclarativeTextPrivate::wrappedTextImage(bool drawStyle)
+{
+ //do layout
+ QSize size = cachedLayoutSize;
+
+ int x = 0;
+ for (int i = 0; i < layout.lineCount(); ++i) {
+ QTextLine line = layout.lineAt(i);
+ if (hAlign == QDeclarativeText::AlignLeft) {
+ x = 0;
+ } else if (hAlign == QDeclarativeText::AlignRight) {
+ x = size.width() - (int)line.naturalTextWidth();
+ } else if (hAlign == QDeclarativeText::AlignHCenter) {
+ x = (size.width() - (int)line.naturalTextWidth()) / 2;
+ }
+ line.setPosition(QPoint(x, (int)line.y()));
+ }
+
+ //paint text
+ QPixmap img(size);
+ if (!size.isEmpty()) {
+ img.fill(Qt::transparent);
+ QPainter p(&img);
+ drawWrappedText(&p, QPointF(0,0), drawStyle);
+ }
+ return img;
+}
+
+void QDeclarativeTextPrivate::drawWrappedText(QPainter *p, const QPointF &pos, bool drawStyle)
+{
+ if (drawStyle)
+ p->setPen(styleColor);
+ else
+ p->setPen(color);
+ p->setFont(font);
+ layout.draw(p, pos);
+}
+
+QPixmap QDeclarativeTextPrivate::richTextImage(bool drawStyle)
+{
+ QSize size = doc->size().toSize();
+
+ //paint text
+ QPixmap img(size);
+ img.fill(Qt::transparent);
+ QPainter p(&img);
+
+ QAbstractTextDocumentLayout::PaintContext context;
+
+ if (drawStyle) {
+ context.palette.setColor(QPalette::Text, styleColor);
+ // ### Do we really want this?
+ QTextOption colorOption;
+ colorOption.setFlags(QTextOption::SuppressColors);
+ doc->setDefaultTextOption(colorOption);
+ } else {
+ context.palette.setColor(QPalette::Text, color);
+ }
+ doc->documentLayout()->draw(&p, context);
+ if (drawStyle)
+ doc->setDefaultTextOption(QTextOption());
+ return img;
+}
+
+void QDeclarativeTextPrivate::checkImgCache()
+{
+ if (!imgDirty)
+ return;
+
+ bool empty = text.isEmpty();
+ if (empty) {
+ imgCache = QPixmap();
+ imgStyleCache = QPixmap();
+ } else if (richText) {
+ imgCache = richTextImage(false);
+ if (style != QDeclarativeText::Normal)
+ imgStyleCache = richTextImage(true); //### should use styleColor
+ } else {
+ imgCache = wrappedTextImage(false);
+ if (style != QDeclarativeText::Normal)
+ imgStyleCache = wrappedTextImage(true); //### should use styleColor
+ }
+ if (!empty)
+ switch (style) {
+ case QDeclarativeText::Outline:
+ drawOutline();
+ break;
+ case QDeclarativeText::Sunken:
+ drawOutline(-1);
+ break;
+ case QDeclarativeText::Raised:
+ drawOutline(1);
+ break;
+ default:
+ break;
+ }
+
+ imgDirty = false;
+}
+
+void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ Q_D(QDeclarativeText);
+
+ if (d->cache || d->style != Normal) {
+ d->checkImgCache();
+ if (d->imgCache.isNull())
+ return;
+
+ bool oldAA = p->testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
+ if (d->smooth)
+ p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+
+ int w = width();
+ int h = height();
+
+ int x = 0;
+ int y = 0;
+
+ switch (d->hAlign) {
+ case AlignLeft:
+ x = 0;
+ break;
+ case AlignRight:
+ x = w - d->imgCache.width();
+ break;
+ case AlignHCenter:
+ x = (w - d->imgCache.width()) / 2;
+ break;
+ }
+
+ switch (d->vAlign) {
+ case AlignTop:
+ y = 0;
+ break;
+ case AlignBottom:
+ y = h - d->imgCache.height();
+ break;
+ case AlignVCenter:
+ y = (h - d->imgCache.height()) / 2;
+ break;
+ }
+
+ bool needClip = !clip() && (d->imgCache.width() > width() ||
+ d->imgCache.height() > height());
+
+ if (needClip) {
+ p->save();
+ p->setClipRect(boundingRect(), Qt::IntersectClip);
+ }
+ p->drawPixmap(x, y, d->imgCache);
+ if (needClip)
+ p->restore();
+
+ if (d->smooth) {
+ p->setRenderHint(QPainter::Antialiasing, oldAA);
+ p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
+ }
+ } else {
+ int h = height();
+ int y = 0;
+
+ switch (d->vAlign) {
+ case AlignTop:
+ y = 0;
+ break;
+ case AlignBottom:
+ y = h - d->cachedLayoutSize.height();
+ break;
+ case AlignVCenter:
+ y = (h - d->cachedLayoutSize.height()) / 2;
+ break;
+ }
+ bool needClip = !clip() && (d->cachedLayoutSize.width() > width() ||
+ d->cachedLayoutSize.height() > height());
+
+ if (needClip) {
+ p->save();
+ p->setClipRect(boundingRect(), Qt::IntersectClip);
+ }
+ if (d->richText) {
+ QAbstractTextDocumentLayout::PaintContext context;
+ context.palette.setColor(QPalette::Text, d->color);
+ p->translate(0, y);
+ d->doc->documentLayout()->draw(p, context);
+ p->translate(0, -y);
+ } else {
+ d->drawWrappedText(p, QPointF(0,y), false);
+ }
+ if (needClip)
+ p->restore();
+ }
+}
+
+/*!
+ \qmlproperty bool Text::smooth
+
+ Set this property if you want the text to be smoothly scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the item is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the item is stationary on
+ the screen. A common pattern when animating an item is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+*/
+
+void QDeclarativeText::componentComplete()
+{
+ Q_D(QDeclarativeText);
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::TextComponentComplete> cc;
+#endif
+ QDeclarativeItem::componentComplete();
+ if (d->dirty) {
+ d->updateLayout();
+ d->dirty = false;
+ }
+}
+
+/*!
+ \overload
+ Handles the given mouse \a event.
+ */
+void QDeclarativeText::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeText);
+
+ if (!d->richText || !d->doc || d->doc->documentLayout()->anchorAt(event->pos()).isEmpty()) {
+ event->setAccepted(false);
+ d->activeLink = QString();
+ } else {
+ d->activeLink = d->doc->documentLayout()->anchorAt(event->pos());
+ }
+
+ // ### may malfunction if two of the same links are clicked & dragged onto each other)
+
+ if (!event->isAccepted())
+ QDeclarativeItem::mousePressEvent(event);
+
+}
+
+/*!
+ \qmlsignal Text::linkActivated(link)
+
+ This handler is called when the user clicks on a link embedded in the text.
+*/
+
+/*!
+ \overload
+ Handles the given mouse \a event.
+ */
+void QDeclarativeText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeText);
+
+ // ### confirm the link, and send a signal out
+ if (d->richText && d->doc && d->activeLink == d->doc->documentLayout()->anchorAt(event->pos()))
+ emit linkActivated(d->activeLink);
+ else
+ event->setAccepted(false);
+
+ if (!event->isAccepted())
+ QDeclarativeItem::mouseReleaseEvent(event);
+}
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h
new file mode 100644
index 0000000..cbea8f3
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetext_p.h
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVETEXT_H
+#define QDECLARATIVETEXT_H
+
+#include "qdeclarativeitem.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+class QDeclarativeTextPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeText : public QDeclarativeItem
+{
+ Q_OBJECT
+ Q_ENUMS(HAlignment)
+ Q_ENUMS(VAlignment)
+ Q_ENUMS(TextStyle)
+ Q_ENUMS(TextFormat)
+ Q_ENUMS(TextElideMode)
+
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(TextStyle style READ style WRITE setStyle NOTIFY styleChanged)
+ Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor NOTIFY styleColorChanged)
+ Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
+ Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
+ Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged) //### there are several wrap modes in Qt
+ Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
+ Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode?
+
+public:
+ QDeclarativeText(QDeclarativeItem *parent=0);
+ ~QDeclarativeText();
+
+ enum HAlignment { AlignLeft = Qt::AlignLeft,
+ AlignRight = Qt::AlignRight,
+ AlignHCenter = Qt::AlignHCenter };
+ enum VAlignment { AlignTop = Qt::AlignTop,
+ AlignBottom = Qt::AlignBottom,
+ AlignVCenter = Qt::AlignVCenter };
+ enum TextStyle { Normal,
+ Outline,
+ Raised,
+ Sunken };
+ enum TextFormat { PlainText = Qt::PlainText,
+ RichText = Qt::RichText,
+ AutoText = Qt::AutoText,
+ StyledText = 4 };
+ enum TextElideMode { ElideLeft = Qt::ElideLeft,
+ ElideRight = Qt::ElideRight,
+ ElideMiddle = Qt::ElideMiddle,
+ ElideNone = Qt::ElideNone };
+
+ QString text() const;
+ void setText(const QString &);
+
+ QFont font() const;
+ void setFont(const QFont &font);
+
+ QColor color() const;
+ void setColor(const QColor &c);
+
+ TextStyle style() const;
+ void setStyle(TextStyle style);
+
+ QColor styleColor() const;
+ void setStyleColor(const QColor &c);
+
+ HAlignment hAlign() const;
+ void setHAlign(HAlignment align);
+
+ VAlignment vAlign() const;
+ void setVAlign(VAlignment align);
+
+ bool wrap() const;
+ void setWrap(bool w);
+
+ TextFormat textFormat() const;
+ void setTextFormat(TextFormat format);
+
+ TextElideMode elideMode() const;
+ void setElideMode(TextElideMode);
+
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+ virtual void componentComplete();
+
+Q_SIGNALS:
+ void textChanged(const QString &text);
+ void linkActivated(const QString &link);
+ void fontChanged(const QFont &font);
+ void colorChanged(const QColor &color);
+ void styleChanged(TextStyle style);
+ void styleColorChanged(const QColor &color);
+ void horizontalAlignmentChanged(HAlignment alignment);
+ void verticalAlignmentChanged(VAlignment alignment);
+ void wrapChanged(bool wrap);
+ void textFormatChanged(TextFormat textFormat);
+ void elideModeChanged(TextElideMode mode);
+
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeText)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeText)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeText)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
new file mode 100644
index 0000000..a0c8abe
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVETEXT_P_H
+#define QDECLARATIVETEXT_P_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 "qdeclarativeitem.h"
+#include "qdeclarativeitem_p.h"
+
+#include <qdeclarative.h>
+
+#include <QtGui/qtextlayout.h>
+
+QT_BEGIN_NAMESPACE
+
+class QTextLayout;
+class QTextDocument;
+
+class QDeclarativeTextPrivate : public QDeclarativeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeText)
+public:
+ QDeclarativeTextPrivate()
+ : color((QRgb)0), style(QDeclarativeText::Normal), imgDirty(true),
+ hAlign(QDeclarativeText::AlignLeft), vAlign(QDeclarativeText::AlignTop), elideMode(QDeclarativeText::ElideNone),
+ dirty(true), wrap(false), richText(false), singleline(false), cache(true), doc(0),
+ format(QDeclarativeText::AutoText)
+ {
+#if defined(QML_NO_TEXT_CACHE)
+ cache = false;
+#endif
+ }
+
+ ~QDeclarativeTextPrivate();
+
+ void updateSize();
+ void updateLayout();
+ void markImgDirty() {
+ Q_Q(QDeclarativeText);
+ imgDirty = true;
+ if (q->isComponentComplete())
+ q->update();
+ }
+ void checkImgCache();
+
+ void drawOutline();
+ void drawOutline(int yOffset);
+
+ QPixmap wrappedTextImage(bool drawStyle);
+ void drawWrappedText(QPainter *p, const QPointF &pos, bool drawStyle);
+ QPixmap richTextImage(bool drawStyle);
+ QSize setupTextLayout(QTextLayout *layout);
+
+ QString text;
+ QFont font;
+ QColor color;
+ QDeclarativeText::TextStyle style;
+ QColor styleColor;
+ QString activeLink;
+ bool imgDirty;
+ QPixmap imgCache;
+ QPixmap imgStyleCache;
+ QDeclarativeText::HAlignment hAlign;
+ QDeclarativeText::VAlignment vAlign;
+ QDeclarativeText::TextElideMode elideMode;
+ bool dirty:1;
+ bool wrap:1;
+ bool richText:1;
+ bool singleline:1;
+ bool cache:1;
+ QTextDocument *doc;
+ QTextLayout layout;
+ QSize cachedLayoutSize;
+ QDeclarativeText::TextFormat format;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
new file mode 100644
index 0000000..8e44b26
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -0,0 +1,1035 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativetextedit_p.h"
+#include "qdeclarativetextedit_p_p.h"
+
+#include "qdeclarativeevents_p_p.h"
+
+#include <qfxperf_p_p.h>
+
+#include <QTextLayout>
+#include <QTextLine>
+#include <QTextDocument>
+#include <QGraphicsSceneMouseEvent>
+#include <QDebug>
+#include <QPainter>
+
+#include <private/qtextcontrol_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass TextEdit QDeclarativeTextEdit
+ \since 4.7
+ \brief The TextEdit item allows you to add editable formatted text to a scene.
+
+ It can display both plain and rich text. For example:
+
+ \qml
+TextEdit {
+ id: edit
+ text: "<b>Hello</b> <i>World!</i>"
+ focus: true
+ font.family: "Helvetica"
+ font.pointSize: 20
+ color: "blue"
+ width: 240
+}
+ \endqml
+
+ \image declarative-textedit.gif
+
+ \sa Text
+*/
+
+/*!
+ \internal
+ \class QDeclarativeTextEdit
+ \qmlclass TextEdit
+ \ingroup group_coreitems
+
+ \brief The QDeclarativeTextEdit class provides an editable formatted text item that you can add to a QDeclarativeView.
+
+ It can display both plain and rich text.
+
+ \image declarative-textedit.png
+
+ A QDeclarativeTextEdit object can be instantiated in Qml using the tag \c &lt;TextEdit&gt;.
+*/
+
+/*!
+ Constructs a new QDeclarativeTextEdit.
+*/
+QDeclarativeTextEdit::QDeclarativeTextEdit(QDeclarativeItem *parent)
+: QDeclarativePaintedItem(*(new QDeclarativeTextEditPrivate), parent)
+{
+ Q_D(QDeclarativeTextEdit);
+ d->init();
+}
+
+QString QDeclarativeTextEdit::text() const
+{
+ Q_D(const QDeclarativeTextEdit);
+
+ if (d->richText)
+ return d->document->toHtml();
+ else
+ return d->document->toPlainText();
+}
+
+/*!
+ \qmlproperty string TextEdit::font.family
+ \qmlproperty bool TextEdit::font.bold
+ \qmlproperty bool TextEdit::font.italic
+ \qmlproperty bool TextEdit::font.underline
+ \qmlproperty real TextEdit::font.pointSize
+ \qmlproperty int TextEdit::font.pixelSize
+
+ Set the TextEdit's font attributes.
+*/
+
+/*!
+ \qmlproperty string TextEdit::text
+
+ The text to display. If the text format is AutoText the text edit will
+ automatically determine whether the text should be treated as
+ rich text. This determination is made using Qt::mightBeRichText().
+*/
+void QDeclarativeTextEdit::setText(const QString &text)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (QDeclarativeTextEdit::text() == text)
+ return;
+ d->text = text;
+ d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text));
+ if (d->richText) {
+ d->control->setHtml(text);
+ } else {
+ d->control->setPlainText(text);
+ }
+ q_textChanged();
+}
+
+/*!
+ \qmlproperty enumeration TextEdit::textFormat
+
+ The way the text property should be displayed.
+
+ Supported text formats are \c AutoText, \c PlainText and \c RichText.
+
+ The default is AutoText. If the text format is AutoText the text edit
+ will automatically determine whether the text should be treated as
+ rich text. This determination is made using Qt::mightBeRichText().
+
+ \table
+ \row
+ \o
+ \qml
+Column {
+ TextEdit {
+ font.pointSize: 24
+ text: "<b>Hello</b> <i>World!</i>"
+ }
+ TextEdit {
+ font.pointSize: 24
+ textFormat: "RichText"
+ text: "<b>Hello</b> <i>World!</i>"
+ }
+ TextEdit {
+ font.pointSize: 24
+ textFormat: "PlainText"
+ text: "<b>Hello</b> <i>World!</i>"
+ }
+}
+ \endqml
+ \o \image declarative-textformat.png
+ \endtable
+*/
+QDeclarativeTextEdit::TextFormat QDeclarativeTextEdit::textFormat() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->format;
+}
+
+void QDeclarativeTextEdit::setTextFormat(TextFormat format)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (format == d->format)
+ return;
+ bool wasRich = d->richText;
+ d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text));
+
+ if (wasRich && !d->richText) {
+ d->control->setPlainText(d->text);
+ updateSize();
+ } else if (!wasRich && d->richText) {
+ d->control->setHtml(d->text);
+ updateSize();
+ }
+ d->format = format;
+ emit textFormatChanged(d->format);
+}
+
+QFont QDeclarativeTextEdit::font() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->font;
+}
+
+void QDeclarativeTextEdit::setFont(const QFont &font)
+{
+ Q_D(QDeclarativeTextEdit);
+ d->font = font;
+
+ clearCache();
+ d->document->setDefaultFont(d->font);
+ if(d->cursor){
+ d->cursor->setHeight(QFontMetrics(d->font).height());
+ moveCursorDelegate();
+ }
+ updateSize();
+ update();
+}
+
+/*!
+ \qmlproperty color TextEdit::color
+
+ The text color.
+
+ \qml
+// green text using hexadecimal notation
+TextEdit { color: "#00FF00"; ... }
+
+// steelblue text using SVG color name
+TextEdit { color: "steelblue"; ... }
+ \endqml
+*/
+QColor QDeclarativeTextEdit::color() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->color;
+}
+
+void QDeclarativeTextEdit::setColor(const QColor &color)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->color == color)
+ return;
+
+ clearCache();
+ d->color = color;
+ QPalette pal = d->control->palette();
+ pal.setColor(QPalette::Text, color);
+ d->control->setPalette(pal);
+ update();
+ emit colorChanged(d->color);
+}
+
+/*!
+ \qmlproperty color TextEdit::selectionColor
+
+ The text highlight color, used behind selections.
+*/
+QColor QDeclarativeTextEdit::selectionColor() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->selectionColor;
+}
+
+void QDeclarativeTextEdit::setSelectionColor(const QColor &color)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->selectionColor == color)
+ return;
+
+ clearCache();
+ d->selectionColor = color;
+ QPalette pal = d->control->palette();
+ pal.setColor(QPalette::Highlight, color);
+ d->control->setPalette(pal);
+ update();
+ emit selectionColorChanged(d->selectionColor);
+}
+
+/*!
+ \qmlproperty color TextEdit::selectedTextColor
+
+ The selected text color, used in selections.
+*/
+QColor QDeclarativeTextEdit::selectedTextColor() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->selectedTextColor;
+}
+
+void QDeclarativeTextEdit::setSelectedTextColor(const QColor &color)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->selectedTextColor == color)
+ return;
+
+ clearCache();
+ d->selectedTextColor = color;
+ QPalette pal = d->control->palette();
+ pal.setColor(QPalette::HighlightedText, color);
+ d->control->setPalette(pal);
+ update();
+ emit selectedTextColorChanged(d->selectedTextColor);
+}
+
+/*!
+ \qmlproperty enumeration TextEdit::horizontalAlignment
+ \qmlproperty enumeration TextEdit::verticalAlignment
+
+ Sets the horizontal and vertical alignment of the text within the TextEdit items
+ width and height. By default, the text is top-left aligned.
+
+ The valid values for \c horizontalAlignment are \c AlignLeft, \c AlignRight and
+ \c AlignHCenter. The valid values for \c verticalAlignment are \c AlignTop, \c AlignBottom
+ and \c AlignVCenter.
+*/
+QDeclarativeTextEdit::HAlignment QDeclarativeTextEdit::hAlign() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->hAlign;
+}
+
+void QDeclarativeTextEdit::setHAlign(QDeclarativeTextEdit::HAlignment alignment)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (alignment == d->hAlign)
+ return;
+ d->hAlign = alignment;
+ d->updateDefaultTextOption();
+ updateSize();
+ emit horizontalAlignmentChanged(d->hAlign);
+}
+
+QDeclarativeTextEdit::VAlignment QDeclarativeTextEdit::vAlign() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->vAlign;
+}
+
+void QDeclarativeTextEdit::setVAlign(QDeclarativeTextEdit::VAlignment alignment)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (alignment == d->vAlign)
+ return;
+ d->vAlign = alignment;
+ d->updateDefaultTextOption();
+ updateSize();
+ emit verticalAlignmentChanged(d->vAlign);
+}
+
+bool QDeclarativeTextEdit::wrap() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->wrap;
+}
+
+/*!
+ \qmlproperty bool TextEdit::wrap
+
+ Set this property to wrap the text to the TextEdit item's width.
+ The text will only wrap if an explicit width has been set.
+
+ Wrapping is done on word boundaries (i.e. it is a "word-wrap"). Wrapping is off by default.
+*/
+void QDeclarativeTextEdit::setWrap(bool w)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (w == d->wrap)
+ return;
+ d->wrap = w;
+ d->updateDefaultTextOption();
+ updateSize();
+ emit wrapChanged(d->wrap);
+}
+
+/*!
+ \qmlproperty bool TextEdit::cursorVisible
+ If true the text edit shows a cursor.
+
+ This property is set and unset when the text edit gets focus, but it can also
+ be set directly (useful, for example, if a KeyProxy might forward keys to it).
+*/
+bool QDeclarativeTextEdit::isCursorVisible() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->cursorVisible;
+}
+
+void QDeclarativeTextEdit::setCursorVisible(bool on)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->cursorVisible == on)
+ return;
+ d->cursorVisible = on;
+ QFocusEvent focusEvent(on ? QEvent::FocusIn : QEvent::FocusOut);
+ if (!on && !d->persistentSelection)
+ d->control->setCursorIsFocusIndicator(true);
+ d->control->processEvent(&focusEvent, QPointF(0, 0));
+ emit cursorVisibleChanged(d->cursorVisible);
+}
+
+/*!
+ \qmlproperty int TextEdit::cursorPosition
+ The position of the cursor in the TextEdit.
+*/
+int QDeclarativeTextEdit::cursorPosition() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->control->textCursor().position();
+}
+
+void QDeclarativeTextEdit::setCursorPosition(int pos)
+{
+ Q_D(QDeclarativeTextEdit);
+ QTextCursor cursor = d->control->textCursor();
+ if (cursor.position() == pos)
+ return;
+ cursor.setPosition(pos);
+ d->control->setTextCursor(cursor);
+}
+
+/*!
+ \qmlproperty Component TextEdit::cursorDelegate
+ The delegate for the cursor in the TextEdit.
+
+ If you set a cursorDelegate for a TextEdit, this delegate will be used for
+ drawing the cursor instead of the standard cursor. An instance of the
+ delegate will be created and managed by the text edit when a cursor is
+ needed, and the x and y properties of delegate instance will be set so as
+ to be one pixel before the top left of the current character.
+
+ Note that the root item of the delegate component must be a QDeclarativeItem or
+ QDeclarativeItem derived item.
+*/
+QDeclarativeComponent* QDeclarativeTextEdit::cursorDelegate() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->cursorComponent;
+}
+
+void QDeclarativeTextEdit::setCursorDelegate(QDeclarativeComponent* c)
+{
+ Q_D(QDeclarativeTextEdit);
+ if(d->cursorComponent){
+ if(d->cursor){
+ disconnect(d->control, SIGNAL(cursorPositionChanged()),
+ this, SLOT(moveCursorDelegate()));
+ d->control->setCursorWidth(-1);
+ dirtyCache(cursorRect());
+ delete d->cursor;
+ d->cursor = 0;
+ }
+ }
+ d->cursorComponent = c;
+ if(c && c->isReady()){
+ loadCursorDelegate();
+ }else{
+ if(c)
+ connect(c, SIGNAL(statusChanged()),
+ this, SLOT(loadCursorDelegate()));
+ }
+
+ emit cursorDelegateChanged();
+}
+
+void QDeclarativeTextEdit::loadCursorDelegate()
+{
+ Q_D(QDeclarativeTextEdit);
+ if(d->cursorComponent->isLoading())
+ return;
+ d->cursor = qobject_cast<QDeclarativeItem*>(d->cursorComponent->create(qmlContext(this)));
+ if(d->cursor){
+ connect(d->control, SIGNAL(cursorPositionChanged()),
+ this, SLOT(moveCursorDelegate()));
+ d->control->setCursorWidth(0);
+ dirtyCache(cursorRect());
+ d->cursor->setParentItem(this);
+ d->cursor->setHeight(QFontMetrics(d->font).height());
+ moveCursorDelegate();
+ }else{
+ qWarning() << QLatin1String("Error loading cursor delegate for TextEdit:") + objectName();
+ }
+}
+
+/*!
+ \qmlproperty int TextEdit::selectionStart
+
+ The cursor position before the first character in the current selection.
+ Setting this and selectionEnd allows you to specify a selection in the
+ text edit.
+
+ Note that if selectionStart == selectionEnd then there is no current
+ selection. If you attempt to set selectionStart to a value outside of
+ the current text, selectionStart will not be changed.
+
+ \sa selectionEnd, cursorPosition, selectedText
+*/
+int QDeclarativeTextEdit::selectionStart() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->control->textCursor().selectionStart();
+}
+
+void QDeclarativeTextEdit::setSelectionStart(int s)
+{
+ Q_D(QDeclarativeTextEdit);
+ if(d->lastSelectionStart == s || s < 0 || s > text().length())
+ return;
+ d->lastSelectionStart = s;
+ d->updateSelection();// Will emit the relevant signals
+}
+
+/*!
+ \qmlproperty int TextEdit::selectionEnd
+
+ The cursor position after the last character in the current selection.
+ Setting this and selectionStart allows you to specify a selection in the
+ text edit.
+
+ Note that if selectionStart == selectionEnd then there is no current
+ selection. If you attempt to set selectionEnd to a value outside of
+ the current text, selectionEnd will not be changed.
+
+ \sa selectionStart, cursorPosition, selectedText
+*/
+int QDeclarativeTextEdit::selectionEnd() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->control->textCursor().selectionEnd();
+}
+
+void QDeclarativeTextEdit::setSelectionEnd(int s)
+{
+ Q_D(QDeclarativeTextEdit);
+ if(d->lastSelectionEnd == s || s < 0 || s > text().length())
+ return;
+ d->lastSelectionEnd = s;
+ d->updateSelection();// Will emit the relevant signals
+}
+
+/*!
+ \qmlproperty string TextEdit::selectedText
+
+ This read-only property provides the text currently selected in the
+ text edit.
+
+ It is equivalent to the following snippet, but is faster and easier
+ to use.
+ \code
+ //myTextEdit is the id of the TextEdit
+ myTextEdit.text.toString().substring(myTextEdit.selectionStart,
+ myTextEdit.selectionEnd);
+ \endcode
+*/
+QString QDeclarativeTextEdit::selectedText() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->control->textCursor().selectedText();
+}
+
+/*!
+ \qmlproperty bool TextEdit::focusOnPress
+
+ Whether the TextEdit should gain focus on a mouse press. By default this is
+ set to true.
+*/
+bool QDeclarativeTextEdit::focusOnPress() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->focusOnPress;
+}
+
+void QDeclarativeTextEdit::setFocusOnPress(bool on)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->focusOnPress == on)
+ return;
+ d->focusOnPress = on;
+ emit focusOnPressChanged(d->focusOnPress);
+}
+
+/*!
+ \qmlproperty bool TextEdit::persistentSelection
+
+ Whether the TextEdit should keep the selection visible when it loses focus to another
+ item in the scene. By default this is set to true;
+*/
+bool QDeclarativeTextEdit::persistentSelection() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->persistentSelection;
+}
+
+void QDeclarativeTextEdit::setPersistentSelection(bool on)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->persistentSelection == on)
+ return;
+ d->persistentSelection = on;
+ emit persistentSelectionChanged(d->persistentSelection);
+}
+
+qreal QDeclarativeTextEdit::textMargin() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->textMargin;
+}
+
+void QDeclarativeTextEdit::setTextMargin(qreal margin)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->textMargin == margin)
+ return;
+ d->textMargin = margin;
+ d->document->setDocumentMargin(d->textMargin);
+ emit textMarginChanged(d->textMargin);
+}
+
+void QDeclarativeTextEdit::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
+{
+ if (newGeometry.width() != oldGeometry.width())
+ updateSize();
+ QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+/*!
+ Ensures any delayed caching or data loading the class
+ needs to performed is complete.
+*/
+void QDeclarativeTextEdit::componentComplete()
+{
+ Q_D(QDeclarativeTextEdit);
+ QDeclarativePaintedItem::componentComplete();
+ if (d->dirty) {
+ updateSize();
+ d->dirty = false;
+ }
+}
+
+/*!
+ \qmlproperty bool TextEdit::readOnly
+
+ Whether the user an interact with the TextEdit item. If this
+ property is set to true the text cannot be edited by user interaction.
+
+ By default this property is false.
+*/
+void QDeclarativeTextEdit::setReadOnly(bool r)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (r == isReadOnly())
+ return;
+
+
+ Qt::TextInteractionFlags flags = Qt::NoTextInteraction;
+ if (r) {
+ flags = Qt::TextSelectableByMouse;
+ } else {
+ flags = Qt::TextEditorInteraction;
+ }
+ d->control->setTextInteractionFlags(flags);
+ if (!r)
+ d->control->moveCursor(QTextCursor::End);
+
+ emit readOnlyChanged(r);
+}
+
+bool QDeclarativeTextEdit::isReadOnly() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return !(d->control->textInteractionFlags() & Qt::TextEditable);
+}
+
+/*!
+ Sets how the text edit should interact with user input to the given
+ \a flags.
+*/
+void QDeclarativeTextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags)
+{
+ Q_D(QDeclarativeTextEdit);
+ d->control->setTextInteractionFlags(flags);
+}
+
+/*!
+ Returns the flags specifying how the text edit should interact
+ with user input.
+*/
+Qt::TextInteractionFlags QDeclarativeTextEdit::textInteractionFlags() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->control->textInteractionFlags();
+}
+
+/*!
+ Returns the rectangle where the text cursor is rendered
+ within the text edit.
+*/
+QRect QDeclarativeTextEdit::cursorRect() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->control->cursorRect().toRect();
+}
+
+
+/*!
+\overload
+Handles the given \a event.
+*/
+bool QDeclarativeTextEdit::event(QEvent *event)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (event->type() == QEvent::ShortcutOverride) {
+ d->control->processEvent(event, QPointF(0, 0));
+ return event->isAccepted();
+ }
+ return QDeclarativePaintedItem::event(event);
+}
+
+/*!
+\overload
+Handles the given key \a event.
+*/
+void QDeclarativeTextEdit::keyPressEvent(QKeyEvent *event)
+{
+ Q_D(QDeclarativeTextEdit);
+ d->control->processEvent(event, QPointF(0, 0));
+
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::keyPressEvent(event);
+}
+
+/*!
+\overload
+Handles the given key \a event.
+*/
+void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event)
+{
+ Q_D(QDeclarativeTextEdit);
+ d->control->processEvent(event, QPointF(0, 0));
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::keyReleaseEvent(event);
+}
+
+/*!
+ \overload
+ Handles changing of the focus property. Focus is applied to the control
+ even if the edit does not have active focus. This is because things
+ like KeyProxy can give the behavior of focus even when hasFocus() isn't
+ true.
+*/
+void QDeclarativeTextEdit::focusChanged(bool hasFocus)
+{
+ setCursorVisible(hasFocus);
+ QDeclarativeItem::focusChanged(hasFocus);
+}
+
+/*!
+ Causes all text to be selected.
+*/
+void QDeclarativeTextEdit::selectAll()
+{
+ Q_D(QDeclarativeTextEdit);
+ d->control->selectAll();
+}
+
+/*!
+\overload
+Handles the given mouse \a event.
+*/
+void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->focusOnPress){
+ QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope?
+ while(p) {
+ if(p->flags() & QGraphicsItem::ItemIsFocusScope){
+ p->setFocus();
+ break;
+ }
+ p = p->parentItem();
+ }
+ setFocus(true);
+ }
+ d->control->processEvent(event, QPointF(0, 0));
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::mousePressEvent(event);
+}
+
+/*!
+\overload
+Handles the given mouse \a event.
+*/
+void QDeclarativeTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeTextEdit);
+ QWidget *widget = event->widget();
+ if (widget && (d->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos()))
+ qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress);
+
+ d->control->processEvent(event, QPointF(0, 0));
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::mousePressEvent(event);
+}
+
+/*!
+\overload
+Handles the given mouse \a event.
+*/
+void QDeclarativeTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeTextEdit);
+ d->control->processEvent(event, QPointF(0, 0));
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::mouseDoubleClickEvent(event);
+}
+
+/*!
+\overload
+Handles the given mouse \a event.
+*/
+void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeTextEdit);
+ d->control->processEvent(event, QPointF(0, 0));
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::mousePressEvent(event);
+}
+
+/*!
+\overload
+Handles the given input method \a event.
+*/
+void QDeclarativeTextEdit::inputMethodEvent(QInputMethodEvent *event)
+{
+ Q_D(QDeclarativeTextEdit);
+ d->control->processEvent(event, QPointF(0, 0));
+}
+
+/*!
+\overload
+Returns the value of the given \a property.
+*/
+QVariant QDeclarativeTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->control->inputMethodQuery(property);
+}
+
+/*!
+Draws the contents of the text edit using the given \a painter within
+the given \a bounds.
+*/
+void QDeclarativeTextEdit::drawContents(QPainter *painter, const QRect &bounds)
+{
+ Q_D(QDeclarativeTextEdit);
+
+ painter->setRenderHint(QPainter::TextAntialiasing, true);
+
+ d->control->drawContents(painter, bounds);
+}
+
+void QDeclarativeTextEdit::updateImgCache(const QRectF &r)
+{
+ dirtyCache(r.toRect());
+ emit update();
+}
+
+/*!
+ \qmlproperty bool TextEdit::smooth
+
+ Set this property if you want the text to be smoothly scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the item is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the item is stationary on
+ the screen. A common pattern when animating an item is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+*/
+
+void QDeclarativeTextEditPrivate::init()
+{
+ Q_Q(QDeclarativeTextEdit);
+
+ q->setSmooth(smooth);
+ q->setAcceptedMouseButtons(Qt::LeftButton);
+ q->setFlag(QGraphicsItem::ItemHasNoContents, false);
+ q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
+
+ control = new QTextControl(q);
+ control->setIgnoreUnusedNavigationEvents(true);
+
+ QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF)));
+
+ QObject::connect(control, SIGNAL(textChanged()), q, SLOT(q_textChanged()));
+ QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
+ QObject::connect(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers()));
+ QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers()));
+ QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
+
+ document = control->document();
+ document->setDefaultFont(font);
+ document->setDocumentMargin(textMargin);
+ document->setUndoRedoEnabled(false); // flush undo buffer.
+ document->setUndoRedoEnabled(true);
+ updateDefaultTextOption();
+}
+
+void QDeclarativeTextEdit::q_textChanged()
+{
+ updateSize();
+ emit textChanged(text());
+}
+
+void QDeclarativeTextEdit::moveCursorDelegate()
+{
+ Q_D(QDeclarativeTextEdit);
+ if(!d->cursor)
+ return;
+ QRectF cursorRect = d->control->cursorRect();
+ d->cursor->setX(cursorRect.x());
+ d->cursor->setY(cursorRect.y());
+}
+
+void QDeclarativeTextEditPrivate::updateSelection()
+{
+ Q_Q(QDeclarativeTextEdit);
+ QTextCursor cursor = control->textCursor();
+ bool startChange = (lastSelectionStart != cursor.selectionStart());
+ bool endChange = (lastSelectionEnd != cursor.selectionEnd());
+ //### Is it worth calculating a more minimal set of movements?
+ cursor.beginEditBlock();
+ cursor.setPosition(lastSelectionStart, QTextCursor::MoveAnchor);
+ cursor.setPosition(lastSelectionEnd, QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+ control->setTextCursor(cursor);
+ if(startChange)
+ q->selectionStartChanged();
+ if(endChange)
+ q->selectionEndChanged();
+ startChange = (lastSelectionStart != control->textCursor().selectionStart());
+ endChange = (lastSelectionEnd != control->textCursor().selectionEnd());
+ if(startChange || endChange)
+ qWarning() << "QDeclarativeTextEditPrivate::updateSelection() has failed you.";
+}
+
+void QDeclarativeTextEdit::updateSelectionMarkers()
+{
+ Q_D(QDeclarativeTextEdit);
+ if(d->lastSelectionStart != d->control->textCursor().selectionStart()){
+ d->lastSelectionStart = d->control->textCursor().selectionStart();
+ emit selectionStartChanged();
+ }
+ if(d->lastSelectionEnd != d->control->textCursor().selectionEnd()){
+ d->lastSelectionEnd = d->control->textCursor().selectionEnd();
+ emit selectionEndChanged();
+ }
+}
+
+//### we should perhaps be a bit smarter here -- depending on what has changed, we shouldn't
+// need to do all the calculations each time
+void QDeclarativeTextEdit::updateSize()
+{
+ Q_D(QDeclarativeTextEdit);
+ if (isComponentComplete()) {
+ QFontMetrics fm = QFontMetrics(d->font);
+ int dy = height();
+ // ### assumes that if the width is set, the text will fill to edges
+ // ### (unless wrap is false, then clipping will occur)
+ if (widthValid())
+ d->document->setTextWidth(width());
+ dy -= (int)d->document->size().height();
+
+ int yoff = 0;
+ if (heightValid()) {
+ if (d->vAlign == AlignBottom)
+ yoff = dy;
+ else if (d->vAlign == AlignVCenter)
+ yoff = dy/2;
+ }
+ setBaselineOffset(fm.ascent() + yoff + d->textMargin);
+
+ //### need to comfirm cost of always setting these
+ int newWidth = (int)d->document->idealWidth();
+ d->document->setTextWidth(newWidth); // ### QTextDoc> Alignment will not work unless textWidth is set. Does Text need this line as well?
+ int cursorWidth = 1;
+ if(d->cursor)
+ cursorWidth = d->cursor->width();
+ newWidth += cursorWidth;
+ if(!d->document->isEmpty())
+ newWidth += 3;// ### Need a better way of accounting for space between char and cursor
+ // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed.
+ setImplicitWidth(newWidth);
+ setImplicitHeight(d->text.isEmpty() ? fm.height() : (int)d->document->size().height());
+
+ setContentsSize(QSize(width(), height()));
+ } else {
+ d->dirty = true;
+ }
+ emit update();
+}
+
+void QDeclarativeTextEditPrivate::updateDefaultTextOption()
+{
+ QTextOption opt = document->defaultTextOption();
+ int oldAlignment = opt.alignment();
+ opt.setAlignment((Qt::Alignment)(int)(hAlign | vAlign));
+
+ QTextOption::WrapMode oldWrapMode = opt.wrapMode();
+
+ if (wrap)
+ opt.setWrapMode(QTextOption::WordWrap);
+ else
+ opt.setWrapMode(QTextOption::NoWrap);
+
+ if (oldWrapMode == opt.wrapMode() && oldAlignment == opt.alignment())
+ return;
+ document->setDefaultTextOption(opt);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
new file mode 100644
index 0000000..6183b1d
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVETEXTEDIT_H
+#define QDECLARATIVETEXTEDIT_H
+
+#include "qdeclarativetext_p.h"
+#include "qdeclarativepainteditem_p.h"
+
+#include <QtGui/qtextdocument.h>
+#include <QtGui/qtextoption.h>
+#include <QtGui/qtextcursor.h>
+#include <QtGui/qtextformat.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+
+class QDeclarativeTextEditPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
+{
+ Q_OBJECT
+ Q_ENUMS(VAlignment)
+ Q_ENUMS(HAlignment)
+ Q_ENUMS(TextFormat)
+
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
+ Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
+ Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
+ Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
+ Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged) //### other wrap modes
+ Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
+ Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
+ Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
+ Q_PROPERTY(QDeclarativeComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
+ Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
+ Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
+ Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged)
+ Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged)
+ Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
+ Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
+ Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
+
+public:
+ QDeclarativeTextEdit(QDeclarativeItem *parent=0);
+
+ enum HAlignment {
+ AlignLeft = Qt::AlignLeft,
+ AlignRight = Qt::AlignRight,
+ AlignHCenter = Qt::AlignHCenter
+ };
+
+ enum VAlignment {
+ AlignTop = Qt::AlignTop,
+ AlignBottom = Qt::AlignBottom,
+ AlignVCenter = Qt::AlignVCenter
+ };
+
+ enum TextFormat {
+ PlainText = Qt::PlainText,
+ RichText = Qt::RichText,
+ AutoText = Qt::AutoText
+ };
+
+ QString text() const;
+ void setText(const QString &);
+
+ TextFormat textFormat() const;
+ void setTextFormat(TextFormat format);
+
+ QFont font() const;
+ void setFont(const QFont &font);
+
+ QColor color() const;
+ void setColor(const QColor &c);
+
+ QColor selectionColor() const;
+ void setSelectionColor(const QColor &c);
+
+ QColor selectedTextColor() const;
+ void setSelectedTextColor(const QColor &c);
+
+ HAlignment hAlign() const;
+ void setHAlign(HAlignment align);
+
+ VAlignment vAlign() const;
+ void setVAlign(VAlignment align);
+
+ bool wrap() const;
+ void setWrap(bool w);
+
+ bool isCursorVisible() const;
+ void setCursorVisible(bool on);
+
+ int cursorPosition() const;
+ void setCursorPosition(int pos);
+
+ QDeclarativeComponent* cursorDelegate() const;
+ void setCursorDelegate(QDeclarativeComponent*);
+
+ int selectionStart() const;
+ void setSelectionStart(int);
+
+ int selectionEnd() const;
+ void setSelectionEnd(int);
+
+ QString selectedText() const;
+
+ bool focusOnPress() const;
+ void setFocusOnPress(bool on);
+
+ bool persistentSelection() const;
+ void setPersistentSelection(bool on);
+
+ qreal textMargin() const;
+ void setTextMargin(qreal margin);
+
+ virtual void componentComplete();
+
+ /* FROM EDIT */
+ void setReadOnly(bool);
+ bool isReadOnly() const;
+
+ void setTextInteractionFlags(Qt::TextInteractionFlags flags);
+ Qt::TextInteractionFlags textInteractionFlags() const;
+
+ QRect cursorRect() const;
+
+ QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+
+Q_SIGNALS:
+ void textChanged(const QString &);
+ void cursorPositionChanged();
+ void selectionStartChanged();
+ void selectionEndChanged();
+ void selectionChanged();
+ void colorChanged(const QColor &color);
+ void selectionColorChanged(const QColor &color);
+ void selectedTextColorChanged(const QColor &color);
+ void fontChanged(const QFont &font);
+ void horizontalAlignmentChanged(HAlignment alignment);
+ void verticalAlignmentChanged(VAlignment alignment);
+ void wrapChanged(bool isWrapped);
+ void textFormatChanged(TextFormat textFormat);
+ void readOnlyChanged(bool isReadOnly);
+ void cursorVisibleChanged(bool isCursorVisible);
+ void cursorDelegateChanged();
+ void focusOnPressChanged(bool focusIsPressed);
+ void persistentSelectionChanged(bool isPersistentSelection);
+ void textMarginChanged(qreal textMargin);
+
+public Q_SLOTS:
+ void selectAll();
+
+private Q_SLOTS:
+ void updateImgCache(const QRectF &rect);
+ void q_textChanged();
+ void updateSelectionMarkers();
+ void moveCursorDelegate();
+ void loadCursorDelegate();
+
+private:
+ void updateSize();
+
+protected:
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
+
+ bool event(QEvent *);
+ void keyPressEvent(QKeyEvent *);
+ void keyReleaseEvent(QKeyEvent *);
+
+ void focusChanged(bool);
+
+ // mouse filter?
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+
+ void inputMethodEvent(QInputMethodEvent *e);
+
+ void drawContents(QPainter *, const QRect &);
+private:
+ Q_DISABLE_COPY(QDeclarativeTextEdit)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeTextEdit)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeTextEdit)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
new file mode 100644
index 0000000..002fac4
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVETEXTEDIT_P_H
+#define QDECLARATIVETEXTEDIT_P_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 "qdeclarativeitem.h"
+#include "qdeclarativepainteditem_p_p.h"
+
+#include <qdeclarative.h>
+
+QT_BEGIN_NAMESPACE
+class QTextLayout;
+class QTextDocument;
+class QTextControl;
+class QDeclarativeTextEditPrivate : public QDeclarativePaintedItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeTextEdit)
+
+public:
+ QDeclarativeTextEditPrivate()
+ : color("black"), imgDirty(true), hAlign(QDeclarativeTextEdit::AlignLeft), vAlign(QDeclarativeTextEdit::AlignTop),
+ dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(true),
+ persistentSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
+ cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0)
+ {
+ }
+
+ void init();
+
+ void updateDefaultTextOption();
+ void relayoutDocument();
+ void updateSelection();
+
+ QString text;
+ QFont font;
+ QColor color;
+ QColor selectionColor;
+ QColor selectedTextColor;
+ QString style;
+ QColor styleColor;
+ bool imgDirty;
+ QPixmap imgCache;
+ QPixmap imgStyleCache;
+ QDeclarativeTextEdit::HAlignment hAlign;
+ QDeclarativeTextEdit::VAlignment vAlign;
+ bool dirty;
+ bool wrap;
+ bool richText;
+ bool cursorVisible;
+ bool focusOnPress;
+ bool persistentSelection;
+ qreal textMargin;
+ int lastSelectionStart;
+ int lastSelectionEnd;
+ QDeclarativeComponent* cursorComponent;
+ QDeclarativeItem* cursor;
+ QDeclarativeTextEdit::TextFormat format;
+ QTextDocument *document;
+ QTextControl *control;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
new file mode 100644
index 0000000..9919904
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -0,0 +1,913 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativetextinput_p.h"
+#include "qdeclarativetextinput_p_p.h"
+
+#include <qdeclarativeinfo.h>
+
+#include <QValidator>
+#include <QApplication>
+#include <QFontMetrics>
+#include <QPainter>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass TextInput QDeclarativeTextInput
+ \since 4.7
+ The TextInput item allows you to add an editable line of text to a scene.
+
+ TextInput can only display a single line of text, and can only display
+ plain text. However it can provide addition input constraints on the text.
+
+ Input constraints include setting a QValidator, an input mask, or a
+ maximum input length.
+*/
+QDeclarativeTextInput::QDeclarativeTextInput(QDeclarativeItem* parent)
+ : QDeclarativePaintedItem(*(new QDeclarativeTextInputPrivate), parent)
+{
+ Q_D(QDeclarativeTextInput);
+ d->init();
+}
+
+QDeclarativeTextInput::~QDeclarativeTextInput()
+{
+}
+
+/*!
+ \qmlproperty string TextInput::text
+
+ The text in the TextInput.
+*/
+
+QString QDeclarativeTextInput::text() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->control->text();
+}
+
+void QDeclarativeTextInput::setText(const QString &s)
+{
+ Q_D(QDeclarativeTextInput);
+ if(s == text())
+ return;
+ d->control->setText(s);
+ //emit textChanged();
+}
+
+/*!
+ \qmlproperty string TextInput::font.family
+ \qmlproperty bool TextInput::font.bold
+ \qmlproperty bool TextInput::font.italic
+ \qmlproperty bool TextInput::font.underline
+ \qmlproperty real TextInput::font.pointSize
+ \qmlproperty int TextInput::font.pixelSize
+
+ Set the TextInput's font attributes.
+*/
+QFont QDeclarativeTextInput::font() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->font;
+}
+
+void QDeclarativeTextInput::setFont(const QFont &font)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->font == font)
+ return;
+
+ d->font = font;
+
+ d->control->setFont(d->font);
+ if(d->cursorItem){
+ d->cursorItem->setHeight(QFontMetrics(d->font).height());
+ moveCursor();
+ }
+ updateSize();
+ emit fontChanged(d->font);
+}
+
+/*!
+ \qmlproperty color TextInput::color
+
+ The text color.
+*/
+QColor QDeclarativeTextInput::color() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->color;
+}
+
+void QDeclarativeTextInput::setColor(const QColor &c)
+{
+ Q_D(QDeclarativeTextInput);
+ d->color = c;
+}
+
+
+/*!
+ \qmlproperty color TextInput::selectionColor
+
+ The text highlight color, used behind selections.
+*/
+QColor QDeclarativeTextInput::selectionColor() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->selectionColor;
+}
+
+void QDeclarativeTextInput::setSelectionColor(const QColor &color)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->selectionColor == color)
+ return;
+
+ d->selectionColor = color;
+ QPalette p = d->control->palette();
+ p.setColor(QPalette::Highlight, d->selectionColor);
+ d->control->setPalette(p);
+ emit selectionColorChanged(color);
+}
+
+/*!
+ \qmlproperty color TextInput::selectedTextColor
+
+ The highlighted text color, used in selections.
+*/
+QColor QDeclarativeTextInput::selectedTextColor() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->selectedTextColor;
+}
+
+void QDeclarativeTextInput::setSelectedTextColor(const QColor &color)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->selectedTextColor == color)
+ return;
+
+ d->selectedTextColor = color;
+ QPalette p = d->control->palette();
+ p.setColor(QPalette::HighlightedText, d->selectedTextColor);
+ d->control->setPalette(p);
+ emit selectedTextColorChanged(color);
+}
+
+/*!
+ \qmlproperty enumeration TextInput::horizontalAlignment
+
+ Sets the horizontal alignment of the text within the TextInput item's
+ width and height. By default, the text is left aligned.
+
+ TextInput does not have vertical alignment, as the natural height is
+ exactly the height of the single line of text. If you set the height
+ manually to something larger, TextInput will always be top aligned
+ vertically. You can use anchors to align it however you want within
+ another item.
+
+ The valid values for \c horizontalAlignment are \c AlignLeft, \c AlignRight and
+ \c AlignHCenter.
+*/
+QDeclarativeTextInput::HAlignment QDeclarativeTextInput::hAlign() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->hAlign;
+}
+
+void QDeclarativeTextInput::setHAlign(HAlignment align)
+{
+ Q_D(QDeclarativeTextInput);
+ if(align == d->hAlign)
+ return;
+ d->hAlign = align;
+ emit horizontalAlignmentChanged(d->hAlign);
+}
+
+bool QDeclarativeTextInput::isReadOnly() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->control->isReadOnly();
+}
+
+void QDeclarativeTextInput::setReadOnly(bool ro)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->control->isReadOnly() == ro)
+ return;
+
+ d->control->setReadOnly(ro);
+
+ emit readOnlyChanged(ro);
+}
+
+int QDeclarativeTextInput::maxLength() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->control->maxLength();
+}
+
+void QDeclarativeTextInput::setMaxLength(int ml)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->control->maxLength() == ml)
+ return;
+
+ d->control->setMaxLength(ml);
+
+ emit maximumLengthChanged(ml);
+}
+
+/*!
+ \qmlproperty bool TextInput::cursorVisible
+ Set to true when the TextInput shows a cursor.
+
+ This property is set and unset when the TextInput gets focus, so that other
+ properties can be bound to whether the cursor is currently showing. As it
+ gets set and unset automatically, when you set the value yourself you must
+ keep in mind that your value may be overwritten.
+
+ It can be set directly in script, for example if a KeyProxy might
+ forward keys to it and you desire it to look active when this happens
+ (but without actually giving it the focus).
+
+ It should not be set directly on the element, like in the below QML,
+ as the specified value will be overridden an lost on focus changes.
+
+ \code
+ TextInput {
+ text: "Text"
+ cursorVisible: false
+ }
+ \endcode
+
+ In the above snippet the cursor will still become visible when the
+ TextInput gains focus.
+*/
+bool QDeclarativeTextInput::isCursorVisible() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->cursorVisible;
+}
+
+void QDeclarativeTextInput::setCursorVisible(bool on)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->cursorVisible == on)
+ return;
+ d->cursorVisible = on;
+ d->control->setCursorBlinkPeriod(on?QApplication::cursorFlashTime():0);
+ //d->control should emit the cursor update regions
+ emit cursorVisibleChanged(d->cursorVisible);
+}
+
+/*!
+ \qmlproperty int TextInput::cursorPosition
+ The position of the cursor in the TextInput.
+*/
+int QDeclarativeTextInput::cursorPosition() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->control->cursor();
+}
+void QDeclarativeTextInput::setCursorPosition(int cp)
+{
+ Q_D(QDeclarativeTextInput);
+ d->control->moveCursor(cp);
+}
+
+/*!
+ \internal
+
+ Returns a Rect which encompasses the cursor, but which may be larger than is
+ required. Ignores custom cursor delegates.
+*/
+QRect QDeclarativeTextInput::cursorRect() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->control->cursorRect();
+}
+
+/*!
+ \qmlproperty int TextInput::selectionStart
+
+ The cursor position before the first character in the current selection.
+ Setting this and selectionEnd allows you to specify a selection in the
+ text edit.
+
+ Note that if selectionStart == selectionEnd then there is no current
+ selection. If you attempt to set selectionStart to a value outside of
+ the current text, selectionStart will not be changed.
+
+ \sa selectionEnd, cursorPosition, selectedText
+*/
+int QDeclarativeTextInput::selectionStart() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->lastSelectionStart;
+}
+
+void QDeclarativeTextInput::setSelectionStart(int s)
+{
+ Q_D(QDeclarativeTextInput);
+ if(d->lastSelectionStart == s || s < 0 || s > text().length())
+ return;
+ d->lastSelectionStart = s;
+ d->control->setSelection(s, d->lastSelectionEnd - s);
+}
+
+/*!
+ \qmlproperty int TextInput::selectionEnd
+
+ The cursor position after the last character in the current selection.
+ Setting this and selectionStart allows you to specify a selection in the
+ text edit.
+
+ Note that if selectionStart == selectionEnd then there is no current
+ selection. If you attempt to set selectionEnd to a value outside of
+ the current text, selectionEnd will not be changed.
+
+ \sa selectionStart, cursorPosition, selectedText
+*/
+int QDeclarativeTextInput::selectionEnd() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->lastSelectionEnd;
+}
+
+void QDeclarativeTextInput::setSelectionEnd(int s)
+{
+ Q_D(QDeclarativeTextInput);
+ if(d->lastSelectionEnd == s || s < 0 || s > text().length())
+ return;
+ d->lastSelectionEnd = s;
+ d->control->setSelection(d->lastSelectionStart, s - d->lastSelectionStart);
+}
+
+/*!
+ \qmlproperty string TextInput::selectedText
+
+ This read-only property provides the text currently selected in the
+ text input.
+
+ It is equivalent to the following snippet, but is faster and easier
+ to use.
+
+ \qml
+ myTextInput.text.toString().substring(myTextInput.selectionStart,
+ myTextInput.selectionEnd);
+ \endqml
+*/
+QString QDeclarativeTextInput::selectedText() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->control->selectedText();
+}
+
+/*!
+ \qmlproperty bool TextInput::focusOnPress
+
+ Whether the TextInput should gain focus on a mouse press. By default this is
+ set to true.
+*/
+bool QDeclarativeTextInput::focusOnPress() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->focusOnPress;
+}
+
+void QDeclarativeTextInput::setFocusOnPress(bool b)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->focusOnPress == b)
+ return;
+
+ d->focusOnPress = b;
+
+ emit focusOnPressChanged(d->focusOnPress);
+}
+
+/*!
+ \qmlproperty QValidator* TextInput::validator
+
+ Allows you to set a QValidator on the TextInput. When a validator is set
+ the TextInput will only accept input which leaves the text property in
+ an acceptable or intermediate state. The accepted signal will only be sent
+ if the text is in an acceptable state when enter is pressed.
+
+ Currently supported validators are QIntValidator, QDoubleValidator and
+ QRegExpValidator. For details, refer to their C++ documentation and remember
+ that all Q_PROPERTIES are accessible from Qml. A brief usage guide follows:
+
+ QIntValidator and QDoubleValidator both are controllable through two properties,
+ top and bottom. The difference is that for QIntValidator the top and bottom properties
+ should be integers, and for QDoubleValidator they should be doubles. QRegExpValidator
+ has a single string property, regExp, which should be set to the regular expression to
+ be used for validation. An example of using validators is shown below, which allows
+ input of integers between 11 and 31 into the text input:
+
+ \code
+ import Qt 4.6
+ TextInput{
+ validator: QIntValidator{bottom: 11; top: 31;}
+ focus: true
+ }
+ \endcode
+
+ \sa acceptableInput, inputMask
+*/
+QValidator* QDeclarativeTextInput::validator() const
+{
+ Q_D(const QDeclarativeTextInput);
+ //###const cast isn't good, but needed for property system?
+ return const_cast<QValidator*>(d->control->validator());
+}
+
+void QDeclarativeTextInput::setValidator(QValidator* v)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->control->validator() == v)
+ return;
+
+ d->control->setValidator(v);
+ if(!d->control->hasAcceptableInput()){
+ d->oldValidity = false;
+ emit acceptableInputChanged();
+ }
+
+ emit validatorChanged();
+}
+
+/*!
+ \qmlproperty string TextInput::inputMask
+
+ Allows you to set an input mask on the TextInput, restricting the allowable
+ text inputs. See QLineEdit::inputMask for further details, as the exact
+ same mask strings are used by TextInput.
+
+ \sa acceptableInput, validator
+*/
+QString QDeclarativeTextInput::inputMask() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->control->inputMask();
+}
+
+void QDeclarativeTextInput::setInputMask(const QString &im)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->control->inputMask() == im)
+ return;
+
+ d->control->setInputMask(im);
+ emit inputMaskChanged(d->control->inputMask());
+}
+
+/*!
+ \qmlproperty bool TextInput::acceptableInput
+
+ This property is always true unless a validator or input mask has been set.
+ If a validator or input mask has been set, this property will only be true
+ if the current text is acceptable to the validator or input mask as a final
+ string (not as an intermediate string).
+*/
+bool QDeclarativeTextInput::hasAcceptableInput() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->control->hasAcceptableInput();
+}
+
+/*!
+ \qmlproperty TextInput.EchoMode TextInput::echoMode
+
+ Specifies how the text should be displayed in the TextInput.
+ The default is Normal, which displays the text as it is. Other values
+ are Password, which displays asterixes instead of characters, NoEcho,
+ which displays nothing, and PasswordEchoOnEdit, which displays all but the
+ current character as asterixes.
+
+*/
+QDeclarativeTextInput::EchoMode QDeclarativeTextInput::echoMode() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return (QDeclarativeTextInput::EchoMode)d->control->echoMode();
+}
+
+void QDeclarativeTextInput::setEchoMode(QDeclarativeTextInput::EchoMode echo)
+{
+ Q_D(QDeclarativeTextInput);
+ if (echoMode() == echo)
+ return;
+
+ d->control->setEchoMode((uint)echo);
+ emit echoModeChanged(echoMode());
+}
+
+/*!
+ \qmlproperty Component TextInput::cursorDelegate
+ The delegate for the cursor in the TextInput.
+
+ If you set a cursorDelegate for a TextInput, this delegate will be used for
+ drawing the cursor instead of the standard cursor. An instance of the
+ delegate will be created and managed by the TextInput when a cursor is
+ needed, and the x property of delegate instance will be set so as
+ to be one pixel before the top left of the current character.
+
+ Note that the root item of the delegate component must be a QDeclarativeItem or
+ QDeclarativeItem derived item.
+*/
+QDeclarativeComponent* QDeclarativeTextInput::cursorDelegate() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->cursorComponent;
+}
+
+void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->cursorComponent == c)
+ return;
+
+ d->cursorComponent = c;
+ if(!c){
+ //note that the components are owned by something else
+ disconnect(d->control, SIGNAL(cursorPositionChanged(int, int)),
+ this, SLOT(moveCursor()));
+ delete d->cursorItem;
+ }else{
+ d->startCreatingCursor();
+ }
+
+ emit cursorDelegateChanged();
+}
+
+void QDeclarativeTextInputPrivate::startCreatingCursor()
+{
+ Q_Q(QDeclarativeTextInput);
+ q->connect(control, SIGNAL(cursorPositionChanged(int, int)),
+ q, SLOT(moveCursor()));
+ if(cursorComponent->isReady()){
+ q->createCursor();
+ }else if(cursorComponent->isLoading()){
+ q->connect(cursorComponent, SIGNAL(statusChanged(int)),
+ q, SLOT(createCursor()));
+ }else{//isError
+ qmlInfo(q) << QDeclarativeTextInput::tr("Could not load cursor delegate");
+ qWarning() << cursorComponent->errors();
+ }
+}
+
+void QDeclarativeTextInput::createCursor()
+{
+ Q_D(QDeclarativeTextInput);
+ if(d->cursorComponent->isError()){
+ qmlInfo(this) << tr("Could not load cursor delegate");
+ qWarning() << d->cursorComponent->errors();
+ return;
+ }
+
+ if(!d->cursorComponent->isReady())
+ return;
+
+ if(d->cursorItem)
+ delete d->cursorItem;
+ d->cursorItem = qobject_cast<QDeclarativeItem*>(d->cursorComponent->create());
+ if(!d->cursorItem){
+ qmlInfo(this) << tr("Could not instantiate cursor delegate");
+ //The failed instantiation should print its own error messages
+ return;
+ }
+
+ d->cursorItem->setParentItem(this);
+ d->cursorItem->setX(d->control->cursorToX());
+ d->cursorItem->setHeight(d->control->height());
+}
+
+void QDeclarativeTextInput::moveCursor()
+{
+ Q_D(QDeclarativeTextInput);
+ if(!d->cursorItem)
+ return;
+ d->cursorItem->setX(d->control->cursorToX() - d->hscroll);
+}
+
+int QDeclarativeTextInput::xToPos(int x)
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->control->xToPos(x - d->hscroll);
+}
+
+void QDeclarativeTextInput::focusChanged(bool hasFocus)
+{
+ Q_D(QDeclarativeTextInput);
+ d->focused = hasFocus;
+ setCursorVisible(hasFocus);
+ QDeclarativeItem::focusChanged(hasFocus);
+}
+
+void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev)
+{
+ Q_D(QDeclarativeTextInput);
+ if(((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
+ || (d->control->cursor() == d->control->text().length()
+ && ev->key() == Qt::Key_Right))
+ && (d->lastSelectionStart == d->lastSelectionEnd)){
+ //ignore when moving off the end
+ //unless there is a selection, because then moving will do something (deselect)
+ ev->ignore();
+ }else{
+ d->control->processKeyEvent(ev);
+ }
+ if (!ev->isAccepted())
+ QDeclarativePaintedItem::keyPressEvent(ev);
+}
+
+void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeTextInput);
+ if(d->focusOnPress){
+ QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope?
+ while(p) {
+ if(p->flags() & QGraphicsItem::ItemIsFocusScope){
+ p->setFocus();
+ break;
+ }
+ p = p->parentItem();
+ }
+ setFocus(true);
+ }
+ d->control->processEvent(event);
+}
+
+/*!
+\overload
+Handles the given mouse \a event.
+*/
+void QDeclarativeTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeTextInput);
+ QWidget *widget = event->widget();
+ if (widget && !d->control->isReadOnly() && boundingRect().contains(event->pos()))
+ qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress);
+ d->control->processEvent(event);
+}
+
+bool QDeclarativeTextInput::event(QEvent* ev)
+{
+ Q_D(QDeclarativeTextInput);
+ //Anything we don't deal with ourselves, pass to the control
+ bool handled = false;
+ switch(ev->type()){
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease://###Should the control be doing anything with release?
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseRelease:
+ break;
+ default:
+ handled = d->control->processEvent(ev);
+ }
+ if(!handled)
+ return QDeclarativePaintedItem::event(ev);
+ return true;
+}
+
+void QDeclarativeTextInput::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
+{
+ if (newGeometry.width() != oldGeometry.width())
+ updateSize();
+ QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+void QDeclarativeTextInput::drawContents(QPainter *p, const QRect &r)
+{
+ Q_D(QDeclarativeTextInput);
+ p->setRenderHint(QPainter::TextAntialiasing, true);
+ p->save();
+ p->setPen(QPen(d->color));
+ int flags = QLineControl::DrawText;
+ if(!isReadOnly() && d->cursorVisible && !d->cursorItem)
+ flags |= QLineControl::DrawCursor;
+ if (d->control->hasSelectedText()){
+ flags |= QLineControl::DrawSelections;
+ }
+
+ QPoint offset = QPoint(0,0);
+ if(d->hAlign != AlignLeft){
+ QFontMetrics fm = QFontMetrics(d->font);
+ //###Is this using bearing appropriately?
+ int minLB = qMax(0, -fm.minLeftBearing());
+ int minRB = qMax(0, -fm.minRightBearing());
+ int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB;
+ int hOffset = 0;
+ if(d->hAlign == AlignRight){
+ hOffset = width() - widthUsed;
+ }else if(d->hAlign == AlignHCenter){
+ hOffset = (width() - widthUsed) / 2;
+ }
+ hOffset -= minLB;
+ offset = QPoint(hOffset, 0);
+ }
+ QRect clipRect = r;
+ d->control->draw(p, offset, clipRect, flags);
+
+ p->restore();
+}
+
+/*!
+\overload
+Returns the value of the given \a property.
+*/
+QVariant QDeclarativeTextInput::inputMethodQuery(Qt::InputMethodQuery property) const
+{
+ Q_D(const QDeclarativeTextInput);
+ switch(property) {
+ case Qt::ImFont:
+ return font();
+ case Qt::ImCursorPosition:
+ return QVariant(d->control->cursor());
+ case Qt::ImSurroundingText:
+ return QVariant(text());
+ case Qt::ImCurrentSelection:
+ return QVariant(selectedText());
+ case Qt::ImMaximumTextLength:
+ return QVariant(maxLength());
+ case Qt::ImAnchorPosition:
+ if (d->control->selectionStart() == d->control->selectionEnd())
+ return QVariant(d->control->cursor());
+ else if (d->control->selectionStart() == d->control->cursor())
+ return QVariant(d->control->selectionEnd());
+ else
+ return QVariant(d->control->selectionStart());
+ default:
+ return QVariant();
+ }
+}
+
+void QDeclarativeTextInput::selectAll()
+{
+ Q_D(QDeclarativeTextInput);
+ d->control->setSelection(0, d->control->text().length());
+}
+
+
+/*!
+ \qmlproperty bool TextInput::smooth
+
+ Set this property if you want the text to be smoothly scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the item is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the item is stationary on
+ the screen. A common pattern when animating an item is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+*/
+
+void QDeclarativeTextInputPrivate::init()
+{
+ Q_Q(QDeclarativeTextInput);
+ control->setCursorWidth(1);
+ control->setPasswordCharacter(QLatin1Char('*'));
+ control->setLayoutDirection(Qt::LeftToRight);
+ q->setSmooth(smooth);
+ q->setAcceptedMouseButtons(Qt::LeftButton);
+ q->setFlag(QGraphicsItem::ItemHasNoContents, false);
+ q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
+ q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
+ q, SLOT(cursorPosChanged()));
+ q->connect(control, SIGNAL(selectionChanged()),
+ q, SLOT(selectionChanged()));
+ q->connect(control, SIGNAL(textChanged(const QString &)),
+ q, SLOT(q_textChanged()));
+ q->connect(control, SIGNAL(accepted()),
+ q, SIGNAL(accepted()));
+ q->connect(control, SIGNAL(updateNeeded(QRect)),
+ q, SLOT(updateRect(QRect)));
+ q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
+ q, SLOT(updateRect()));//TODO: Only update rect between pos's
+ q->connect(control, SIGNAL(selectionChanged()),
+ q, SLOT(updateRect()));//TODO: Only update rect in selection
+ //Note that above TODOs probably aren't that big a savings
+ q->updateSize();
+ oldValidity = control->hasAcceptableInput();
+ lastSelectionStart = 0;
+ lastSelectionEnd = 0;
+}
+
+void QDeclarativeTextInput::cursorPosChanged()
+{
+ Q_D(QDeclarativeTextInput);
+ emit cursorPositionChanged();
+
+ if(!d->control->hasSelectedText()){
+ if(d->lastSelectionStart != d->control->cursor()){
+ d->lastSelectionStart = d->control->cursor();
+ emit selectionStartChanged();
+ }
+ if(d->lastSelectionEnd != d->control->cursor()){
+ d->lastSelectionEnd = d->control->cursor();
+ emit selectionEndChanged();
+ }
+ }
+}
+
+void QDeclarativeTextInput::selectionChanged()
+{
+ Q_D(QDeclarativeTextInput);
+ emit selectedTextChanged();
+
+ if(d->lastSelectionStart != d->control->selectionStart()){
+ d->lastSelectionStart = d->control->selectionStart();
+ if(d->lastSelectionStart == -1)
+ d->lastSelectionStart = d->control->cursor();
+ emit selectionStartChanged();
+ }
+ if(d->lastSelectionEnd != d->control->selectionEnd()){
+ d->lastSelectionEnd = d->control->selectionEnd();
+ if(d->lastSelectionEnd == -1)
+ d->lastSelectionEnd = d->control->cursor();
+ emit selectionEndChanged();
+ }
+}
+
+void QDeclarativeTextInput::q_textChanged()
+{
+ Q_D(QDeclarativeTextInput);
+ updateSize();
+ emit textChanged();
+ if(hasAcceptableInput() != d->oldValidity){
+ d->oldValidity = hasAcceptableInput();
+ emit acceptableInputChanged();
+ }
+}
+
+void QDeclarativeTextInput::updateRect(const QRect &r)
+{
+ if(r == QRect())
+ clearCache();
+ else
+ dirtyCache(r);
+ update();
+}
+
+void QDeclarativeTextInput::updateSize(bool needsRedraw)
+{
+ Q_D(QDeclarativeTextInput);
+ int w = width();
+ int h = height();
+ setImplicitHeight(d->control->height());
+ int cursorWidth = d->control->cursorWidth();
+ if(d->cursorItem)
+ cursorWidth = d->cursorItem->width();
+ //### Is QFontMetrics too slow?
+ QFontMetricsF fm(d->font);
+ setImplicitWidth(fm.width(d->control->displayText())+cursorWidth);
+ setContentsSize(QSize(width(), height()));//Repaints if changed
+ if(w==width() && h==height() && needsRedraw){
+ clearCache();
+ update();
+ }
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
new file mode 100644
index 0000000..f690ae2
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -0,0 +1,232 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVETEXTINPUT_H
+#define QDECLARATIVETEXTINPUT_H
+
+#include "qdeclarativetext_p.h"
+#include "qdeclarativepainteditem_p.h"
+
+#include <QGraphicsSceneMouseEvent>
+#include <QIntValidator>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeTextInputPrivate;
+class QValidator;
+class Q_DECLARATIVE_EXPORT QDeclarativeTextInput : public QDeclarativePaintedItem
+{
+ Q_OBJECT
+ Q_ENUMS(HAlignment)
+ Q_ENUMS(EchoMode)
+
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
+ Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
+ Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
+
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
+ Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
+ Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
+ Q_PROPERTY(QRect cursorRect READ cursorRect NOTIFY cursorPositionChanged)
+ Q_PROPERTY(QDeclarativeComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
+ Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
+ Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
+ Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged)
+
+ Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged)
+ Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged)
+ Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged)
+ Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
+
+ Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
+ Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged)
+ Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged)
+
+public:
+ QDeclarativeTextInput(QDeclarativeItem* parent=0);
+ ~QDeclarativeTextInput();
+
+ enum EchoMode {//To match QLineEdit::EchoMode
+ Normal,
+ NoEcho,
+ Password,
+ PasswordEchoOnEdit
+ };
+
+ enum HAlignment {
+ AlignLeft = Qt::AlignLeft,
+ AlignRight = Qt::AlignRight,
+ AlignHCenter = Qt::AlignHCenter
+ };
+
+ //### Should we have this function, x based properties,
+ //### or copy TextEdit with x instead of QTextCursor?
+ Q_INVOKABLE int xToPos(int x);
+
+ QString text() const;
+ void setText(const QString &);
+
+ QFont font() const;
+ void setFont(const QFont &font);
+
+ QColor color() const;
+ void setColor(const QColor &c);
+
+ QColor selectionColor() const;
+ void setSelectionColor(const QColor &c);
+
+ QColor selectedTextColor() const;
+ void setSelectedTextColor(const QColor &c);
+
+ HAlignment hAlign() const;
+ void setHAlign(HAlignment align);
+
+ bool isReadOnly() const;
+ void setReadOnly(bool);
+
+ bool isCursorVisible() const;
+ void setCursorVisible(bool on);
+
+ int cursorPosition() const;
+ void setCursorPosition(int cp);
+
+ QRect cursorRect() const;
+
+ int selectionStart() const;
+ void setSelectionStart(int);
+
+ int selectionEnd() const;
+ void setSelectionEnd(int);
+
+ QString selectedText() const;
+
+ int maxLength() const;
+ void setMaxLength(int ml);
+
+ QValidator * validator() const;
+ void setValidator(QValidator* v);
+
+ QString inputMask() const;
+ void setInputMask(const QString &im);
+
+ EchoMode echoMode() const;
+ void setEchoMode(EchoMode echo);
+
+ QDeclarativeComponent* cursorDelegate() const;
+ void setCursorDelegate(QDeclarativeComponent*);
+
+ bool focusOnPress() const;
+ void setFocusOnPress(bool);
+
+ bool hasAcceptableInput() const;
+
+ void drawContents(QPainter *p,const QRect &r);
+ QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+
+Q_SIGNALS:
+ void textChanged();
+ void cursorPositionChanged();
+ void selectionStartChanged();
+ void selectionEndChanged();
+ void selectedTextChanged();
+ void accepted();
+ void acceptableInputChanged();
+ void colorChanged(const QColor &color);
+ void selectionColorChanged(const QColor &color);
+ void selectedTextColorChanged(const QColor &color);
+ void fontChanged(const QFont &font);
+ void horizontalAlignmentChanged(HAlignment alignment);
+ void readOnlyChanged(bool isReadOnly);
+ void cursorVisibleChanged(bool isCursorVisible);
+ void cursorDelegateChanged();
+ void maximumLengthChanged(int maximumLength);
+ void validatorChanged();
+ void inputMaskChanged(const QString &inputMask);
+ void echoModeChanged(EchoMode echoMode);
+ void focusOnPressChanged(bool focusOnPress);
+
+protected:
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
+
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void keyPressEvent(QKeyEvent* ev);
+ bool event(QEvent *e);
+
+ void focusChanged(bool hasFocus);
+
+public Q_SLOTS:
+ void selectAll();
+
+private Q_SLOTS:
+ void updateSize(bool needsRedraw = true);
+ void q_textChanged();
+ void selectionChanged();
+ void createCursor();
+ void moveCursor();
+ void cursorPosChanged();
+ void updateRect(const QRect &r = QRect());
+
+private:
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeTextInput)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeTextInput)
+QML_DECLARE_TYPE(QValidator)
+QML_DECLARE_TYPE(QIntValidator)
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
+QML_DECLARE_TYPE(QDoubleValidator)
+QML_DECLARE_TYPE(QRegExpValidator)
+#endif
+
+QT_END_HEADER
+
+#endif // QDECLARATIVETEXTINPUT_H
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
new file mode 100644
index 0000000..3d28f40
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVETEXTINPUT_P_H
+#define QDECLARATIVETEXTINPUT_P_H
+
+#include "qdeclarativetextinput_p.h"
+
+#include "qdeclarativepainteditem_p_p.h"
+
+#include <qdeclarative.h>
+
+#include <QPointer>
+
+#include <private/qlinecontrol_p.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.
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeTextInputPrivate : public QDeclarativePaintedItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeTextInput)
+public:
+ QDeclarativeTextInputPrivate() : control(new QLineControl(QString())),
+ color((QRgb)0), style(QDeclarativeText::Normal),
+ styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft),
+ hscroll(0), oldScroll(0), focused(false), focusOnPress(true),
+ cursorVisible(false)
+ {
+ }
+
+ ~QDeclarativeTextInputPrivate()
+ {
+ delete control;
+ }
+
+ void init();
+ void startCreatingCursor();
+
+ QLineControl* control;
+
+ QFont font;
+ QColor color;
+ QColor selectionColor;
+ QColor selectedTextColor;
+ QDeclarativeText::TextStyle style;
+ QColor styleColor;
+ QDeclarativeTextInput::HAlignment hAlign;
+ QPointer<QDeclarativeComponent> cursorComponent;
+ QPointer<QDeclarativeItem> cursorItem;
+
+ int lastSelectionStart;
+ int lastSelectionEnd;
+ int oldHeight;
+ int oldWidth;
+ bool oldValidity;
+ int hscroll;
+ int oldScroll;
+ bool focused;
+ bool focusOnPress;
+ bool cursorVisible;
+};
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
new file mode 100644
index 0000000..bfe8db9
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -0,0 +1,1256 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativevisualitemmodel_p.h"
+
+#include "qdeclarativeitem.h"
+
+#include <qdeclarativecontext.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativeexpression.h>
+#include <qdeclarativepackage_p.h>
+#include <qdeclarativeopenmetaobject_p.h>
+#include <qdeclarativelistaccessor_p.h>
+#include <qdeclarativeinfo.h>
+#include <qdeclarativedeclarativedata_p.h>
+#include <qdeclarativepropertycache_p.h>
+#include <qdeclarativeguard_p.h>
+
+#include <qlistmodelinterface_p.h>
+#include <qhash.h>
+#include <qlist.h>
+#include <qmetaobjectbuilder_p.h>
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QHash<QObject*, QDeclarativeVisualItemModelAttached*> QDeclarativeVisualItemModelAttached::attachedProperties;
+
+
+class QDeclarativeVisualItemModelPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeVisualItemModel)
+public:
+ QDeclarativeVisualItemModelPrivate() : QObjectPrivate() {}
+
+ static void children_append(QDeclarativeListProperty<QDeclarativeItem> *prop, QDeclarativeItem *item) {
+ item->QObject::setParent(prop->object);
+ static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.append(item);
+ static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->itemAppended();
+ static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->emitChildrenChanged();
+ }
+
+ void itemAppended() {
+ Q_Q(QDeclarativeVisualItemModel);
+ QDeclarativeVisualItemModelAttached *attached = QDeclarativeVisualItemModelAttached::properties(children.last());
+ attached->setIndex(children.count()-1);
+ emit q->itemsInserted(children.count()-1, 1);
+ emit q->countChanged();
+ }
+
+ void emitChildrenChanged() {
+ Q_Q(QDeclarativeVisualItemModel);
+ emit q->childrenChanged();
+ }
+
+ QList<QDeclarativeItem *> children;
+};
+
+
+/*!
+ \qmlclass VisualItemModel QDeclarativeVisualItemModel
+ \since 4.7
+ \brief The VisualItemModel allows items to be provided to a view.
+
+ The children of the VisualItemModel are provided in a model which
+ can be used in a view. Note that no delegate should be
+ provided to a view since the VisualItemModel contains the
+ visual delegate (items).
+
+ An item can determine its index within the
+ model via the VisualItemModel.index attached property.
+
+ The example below places three colored rectangles in a ListView.
+ \code
+ Item {
+ VisualItemModel {
+ id: itemModel
+ Rectangle { height: 30; width: 80; color: "red" }
+ Rectangle { height: 30; width: 80; color: "green" }
+ Rectangle { height: 30; width: 80; color: "blue" }
+ }
+
+ ListView {
+ anchors.fill: parent
+ model: itemModel
+ }
+ }
+ \endcode
+*/
+QDeclarativeVisualItemModel::QDeclarativeVisualItemModel()
+ : QDeclarativeVisualModel(*(new QDeclarativeVisualItemModelPrivate))
+{
+}
+
+QDeclarativeListProperty<QDeclarativeItem> QDeclarativeVisualItemModel::children()
+{
+ Q_D(QDeclarativeVisualItemModel);
+ return QDeclarativeListProperty<QDeclarativeItem>(this, d, QDeclarativeVisualItemModelPrivate::children_append);
+}
+
+/*!
+ \qmlproperty int VisualItemModel::count
+
+ The number of items in the model. This property is readonly.
+*/
+int QDeclarativeVisualItemModel::count() const
+{
+ Q_D(const QDeclarativeVisualItemModel);
+ return d->children.count();
+}
+
+bool QDeclarativeVisualItemModel::isValid() const
+{
+ return true;
+}
+
+QDeclarativeItem *QDeclarativeVisualItemModel::item(int index, bool)
+{
+ Q_D(QDeclarativeVisualItemModel);
+ return d->children.at(index);
+}
+
+QDeclarativeVisualModel::ReleaseFlags QDeclarativeVisualItemModel::release(QDeclarativeItem *)
+{
+ // Nothing to do
+ return 0;
+}
+
+void QDeclarativeVisualItemModel::completeItem()
+{
+ // Nothing to do
+}
+
+QString QDeclarativeVisualItemModel::stringValue(int index, const QString &name)
+{
+ Q_D(QDeclarativeVisualItemModel);
+ if (index < 0 || index >= d->children.count())
+ return QString();
+ return QDeclarativeEngine::contextForObject(d->children.at(index))->contextProperty(name).toString();
+}
+
+QVariant QDeclarativeVisualItemModel::evaluate(int index, const QString &expression, QObject *objectContext)
+{
+ Q_D(QDeclarativeVisualItemModel);
+ if (index < 0 || index >= d->children.count())
+ return QVariant();
+ QDeclarativeContext *ccontext = qmlContext(this);
+ QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext);
+ ctxt->addDefaultObject(d->children.at(index));
+ QDeclarativeExpression e(ctxt, expression, objectContext);
+ QVariant value = e.value();
+ delete ctxt;
+ return value;
+}
+
+int QDeclarativeVisualItemModel::indexOf(QDeclarativeItem *item, QObject *) const
+{
+ Q_D(const QDeclarativeVisualItemModel);
+ return d->children.indexOf(item);
+}
+
+QDeclarativeVisualItemModelAttached *QDeclarativeVisualItemModel::qmlAttachedProperties(QObject *obj)
+{
+ return QDeclarativeVisualItemModelAttached::properties(obj);
+}
+
+//============================================================================
+
+class VDMDelegateDataType : public QDeclarativeOpenMetaObjectType
+{
+public:
+ VDMDelegateDataType(const QMetaObject *base, QDeclarativeEngine *engine) : QDeclarativeOpenMetaObjectType(base, engine) {}
+
+ void propertyCreated(int, QMetaPropertyBuilder &prop) {
+ prop.setWritable(false);
+ }
+};
+
+class QDeclarativeVisualDataModelParts;
+class QDeclarativeVisualDataModelData;
+class QDeclarativeVisualDataModelPrivate : public QObjectPrivate
+{
+public:
+ QDeclarativeVisualDataModelPrivate(QDeclarativeContext *);
+
+ static QDeclarativeVisualDataModelPrivate *get(QDeclarativeVisualDataModel *m) {
+ return static_cast<QDeclarativeVisualDataModelPrivate *>(QObjectPrivate::get(m));
+ }
+
+ QDeclarativeGuard<QListModelInterface> m_listModelInterface;
+ QDeclarativeGuard<QAbstractItemModel> m_abstractItemModel;
+ QDeclarativeGuard<QDeclarativeVisualDataModel> m_visualItemModel;
+ QString m_part;
+
+ QDeclarativeComponent *m_delegate;
+ QDeclarativeContext *m_context;
+ QList<int> m_roles;
+ QHash<QByteArray,int> m_roleNames;
+ void ensureRoles() {
+ if (m_roleNames.isEmpty()) {
+ if (m_listModelInterface) {
+ m_roles = m_listModelInterface->roles();
+ for (int ii = 0; ii < m_roles.count(); ++ii)
+ m_roleNames.insert(m_listModelInterface->toString(m_roles.at(ii)).toUtf8(), m_roles.at(ii));
+ if (m_roles.count() == 1)
+ m_roleNames.insert("modelData", m_roles.at(0));
+ } else if (m_abstractItemModel) {
+ for (QHash<int,QByteArray>::const_iterator it = m_abstractItemModel->roleNames().begin();
+ it != m_abstractItemModel->roleNames().end(); ++it) {
+ m_roles.append(it.key());
+ m_roleNames.insert(*it, it.key());
+ }
+ if (m_roles.count() == 1)
+ m_roleNames.insert("modelData", m_roles.at(0));
+ } else if (m_listAccessor) {
+ m_roleNames.insert("modelData", 0);
+ if (m_listAccessor->type() == QDeclarativeListAccessor::Instance) {
+ if (QObject *object = m_listAccessor->at(0).value<QObject*>()) {
+ int count = object->metaObject()->propertyCount();
+ for (int ii = 1; ii < count; ++ii) {
+ const QMetaProperty &prop = object->metaObject()->property(ii);
+ m_roleNames.insert(prop.name(), 0);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ void createMetaData() {
+ if (!m_metaDataCreated) {
+ ensureRoles();
+ QHash<QByteArray, int>::const_iterator it = m_roleNames.begin();
+ while (it != m_roleNames.end()) {
+ m_delegateDataType->createProperty(it.key());
+ ++it;
+ }
+ m_metaDataCreated = true;
+ }
+ }
+
+ struct ObjectRef {
+ ObjectRef(QObject *object=0) : obj(object), ref(1) {}
+ QObject *obj;
+ int ref;
+ };
+ class Cache : public QHash<int, ObjectRef> {
+ public:
+ QObject *getItem(int index) {
+ QObject *item = 0;
+ QHash<int,ObjectRef>::iterator it = find(index);
+ if (it != end()) {
+ (*it).ref++;
+ item = (*it).obj;
+ }
+ return item;
+ }
+ QObject *item(int index) {
+ QObject *item = 0;
+ QHash<int, ObjectRef>::const_iterator it = find(index);
+ if (it != end())
+ item = (*it).obj;
+ return item;
+ }
+ void insertItem(int index, QObject *obj) {
+ insert(index, ObjectRef(obj));
+ }
+ bool releaseItem(QObject *obj) {
+ QHash<int, ObjectRef>::iterator it = begin();
+ for (; it != end(); ++it) {
+ ObjectRef &objRef = *it;
+ if (objRef.obj == obj) {
+ if (--objRef.ref == 0) {
+ erase(it);
+ return true;
+ }
+ break;
+ }
+ }
+ return false;
+ }
+ };
+
+ int modelCount() const {
+ if (m_visualItemModel)
+ return m_visualItemModel->count();
+ if (m_listModelInterface)
+ return m_listModelInterface->count();
+ if (m_abstractItemModel)
+ return m_abstractItemModel->rowCount(m_root);
+ if (m_listAccessor)
+ return m_listAccessor->count();
+ return 0;
+ }
+
+ Cache m_cache;
+ QHash<QObject *, QDeclarativePackage*> m_packaged;
+
+ QDeclarativeVisualDataModelParts *m_parts;
+ friend class QDeclarativeVisualItemParts;
+
+ VDMDelegateDataType *m_delegateDataType;
+ friend class QDeclarativeVisualDataModelData;
+ bool m_metaDataCreated;
+ bool m_metaDataCacheable;
+
+ QDeclarativeVisualDataModelData *data(QObject *item);
+
+ QVariant m_modelVariant;
+ QDeclarativeListAccessor *m_listAccessor;
+
+ QModelIndex m_root;
+};
+
+class QDeclarativeVisualDataModelDataMetaObject : public QDeclarativeOpenMetaObject
+{
+public:
+ QDeclarativeVisualDataModelDataMetaObject(QObject *parent, QDeclarativeOpenMetaObjectType *type)
+ : QDeclarativeOpenMetaObject(parent, type) {}
+
+ virtual QVariant initialValue(int);
+ virtual int createProperty(const char *, const char *);
+
+private:
+ friend class QDeclarativeVisualDataModelData;
+ QHash<int,int> roleToProp;
+};
+
+class QDeclarativeVisualDataModelData : public QObject
+{
+Q_OBJECT
+public:
+ QDeclarativeVisualDataModelData(int index, QDeclarativeVisualDataModel *model);
+ ~QDeclarativeVisualDataModelData();
+
+ Q_PROPERTY(int index READ index NOTIFY indexChanged)
+ int index() const;
+ void setIndex(int index);
+
+ int propForRole(int) const;
+ void setValue(int, const QVariant &);
+
+Q_SIGNALS:
+ void indexChanged();
+
+private:
+ friend class QDeclarativeVisualDataModelDataMetaObject;
+ int m_index;
+ QDeclarativeGuard<QDeclarativeVisualDataModel> m_model;
+ QDeclarativeVisualDataModelDataMetaObject *m_meta;
+};
+
+int QDeclarativeVisualDataModelData::propForRole(int id) const
+{
+ QHash<int,int>::const_iterator it = m_meta->roleToProp.find(id);
+ if (it != m_meta->roleToProp.end())
+ return m_meta->roleToProp[id];
+ return -1;
+}
+
+void QDeclarativeVisualDataModelData::setValue(int id, const QVariant &val)
+{
+ m_meta->setValue(id, val);
+}
+
+int QDeclarativeVisualDataModelDataMetaObject::createProperty(const char *name, const char *type)
+{
+ QDeclarativeVisualDataModelData *data =
+ static_cast<QDeclarativeVisualDataModelData *>(object());
+
+ if (!data->m_model)
+ return -1;
+
+ QDeclarativeVisualDataModelPrivate *model = QDeclarativeVisualDataModelPrivate::get(data->m_model);
+
+ if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) {
+ if (model->m_listAccessor->type() == QDeclarativeListAccessor::ListProperty) {
+ model->ensureRoles();
+ QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>();
+ if (object && (object->property(name).isValid() || qstrcmp(name,"modelData")==0))
+ return QDeclarativeOpenMetaObject::createProperty(name, type);
+ }
+ }
+ return -1;
+}
+
+QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId)
+{
+ QDeclarativeVisualDataModelData *data =
+ static_cast<QDeclarativeVisualDataModelData *>(object());
+
+ Q_ASSERT(data->m_model);
+ QDeclarativeVisualDataModelPrivate *model = QDeclarativeVisualDataModelPrivate::get(data->m_model);
+
+ QByteArray propName = name(propId);
+ if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) {
+ if (propName == "modelData") {
+ if (model->m_listAccessor->type() == QDeclarativeListAccessor::Instance) {
+ QObject *object = model->m_listAccessor->at(0).value<QObject*>();
+ return object->metaObject()->property(1).read(object); // the first property after objectName
+ }
+ return model->m_listAccessor->at(data->m_index);
+ } else {
+ // return any property of a single object instance.
+ QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>();
+ return object->property(propName);
+ }
+ } else if (model->m_listModelInterface) {
+ model->ensureRoles();
+ QHash<QByteArray,int>::const_iterator it = model->m_roleNames.find(propName);
+ if (it != model->m_roleNames.end()) {
+ roleToProp.insert(*it, propId);
+ QVariant value = model->m_listModelInterface->data(data->m_index, *it);
+ return value;
+ } else if (model->m_roles.count() == 1 && propName == "modelData") {
+ //for compatability with other lists, assign modelData if there is only a single role
+ roleToProp.insert(model->m_roles.first(), propId);
+ QVariant value = model->m_listModelInterface->data(data->m_index, model->m_roles.first());
+ return value;
+ }
+ } else if (model->m_abstractItemModel) {
+ model->ensureRoles();
+ QHash<QByteArray,int>::const_iterator it = model->m_roleNames.find(propName);
+ if (it != model->m_roleNames.end()) {
+ roleToProp.insert(*it, propId);
+ QModelIndex index = model->m_abstractItemModel->index(data->m_index, 0, model->m_root);
+ return model->m_abstractItemModel->data(index, *it);
+ }
+ }
+ Q_ASSERT(!"Can never be reached");
+ return QVariant();
+}
+
+QDeclarativeVisualDataModelData::QDeclarativeVisualDataModelData(int index,
+ QDeclarativeVisualDataModel *model)
+: m_index(index), m_model(model),
+m_meta(new QDeclarativeVisualDataModelDataMetaObject(this, QDeclarativeVisualDataModelPrivate::get(model)->m_delegateDataType))
+{
+ QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(model);
+ if (modelPriv->m_metaDataCacheable) {
+ if (!modelPriv->m_metaDataCreated)
+ modelPriv->createMetaData();
+ m_meta->setCached(true);
+ }
+}
+
+QDeclarativeVisualDataModelData::~QDeclarativeVisualDataModelData()
+{
+}
+
+int QDeclarativeVisualDataModelData::index() const
+{
+ return m_index;
+}
+
+// This is internal only - it should not be set from qml
+void QDeclarativeVisualDataModelData::setIndex(int index)
+{
+ m_index = index;
+ emit indexChanged();
+}
+
+//---------------------------------------------------------------------------
+
+class QDeclarativeVisualDataModelPartsMetaObject : public QDeclarativeOpenMetaObject
+{
+public:
+ QDeclarativeVisualDataModelPartsMetaObject(QObject *parent)
+ : QDeclarativeOpenMetaObject(parent) {}
+
+ virtual void propertyCreated(int, QMetaPropertyBuilder &);
+ virtual QVariant initialValue(int);
+};
+
+class QDeclarativeVisualDataModelParts : public QObject
+{
+Q_OBJECT
+public:
+ QDeclarativeVisualDataModelParts(QDeclarativeVisualDataModel *parent);
+
+private:
+ friend class QDeclarativeVisualDataModelPartsMetaObject;
+ QDeclarativeVisualDataModel *model;
+};
+
+void QDeclarativeVisualDataModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop)
+{
+ prop.setWritable(false);
+}
+
+QVariant QDeclarativeVisualDataModelPartsMetaObject::initialValue(int id)
+{
+ QDeclarativeVisualDataModel *m = new QDeclarativeVisualDataModel;
+ m->setParent(object());
+ m->setPart(QString::fromUtf8(name(id)));
+ m->setModel(QVariant::fromValue(static_cast<QDeclarativeVisualDataModelParts *>(object())->model));
+
+ QVariant var = QVariant::fromValue((QObject *)m);
+ return var;
+}
+
+QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeVisualDataModel *parent)
+: QObject(parent), model(parent)
+{
+ new QDeclarativeVisualDataModelPartsMetaObject(this);
+}
+
+QDeclarativeVisualDataModelPrivate::QDeclarativeVisualDataModelPrivate(QDeclarativeContext *ctxt)
+: m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0)
+, m_context(ctxt), m_parts(0), m_delegateDataType(0), m_metaDataCreated(false)
+, m_metaDataCacheable(false), m_listAccessor(0)
+{
+}
+
+QDeclarativeVisualDataModelData *QDeclarativeVisualDataModelPrivate::data(QObject *item)
+{
+ QDeclarativeVisualDataModelData *dataItem =
+ item->findChild<QDeclarativeVisualDataModelData *>();
+ Q_ASSERT(dataItem);
+ return dataItem;
+}
+
+//---------------------------------------------------------------------------
+
+/*!
+ \qmlclass VisualDataModel QDeclarativeVisualDataModel
+ \brief The VisualDataModel encapsulates a model and delegate
+
+ A VisualDataModel encapsulates a model and the delegate that will
+ be instantiated for items in the model.
+
+ It is usually not necessary to create a VisualDataModel directly,
+ since the QML views will create one internally.
+
+ The example below illustrates using a VisualDataModel with a ListView.
+
+ \code
+ VisualDataModel {
+ id: visualModel
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ Text { text: "Name:" + name}
+ }
+ }
+ }
+ ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: visualModel
+ }
+ \endcode
+*/
+
+QDeclarativeVisualDataModel::QDeclarativeVisualDataModel()
+: QDeclarativeVisualModel(*(new QDeclarativeVisualDataModelPrivate(0)))
+{
+}
+
+QDeclarativeVisualDataModel::QDeclarativeVisualDataModel(QDeclarativeContext *ctxt)
+: QDeclarativeVisualModel(*(new QDeclarativeVisualDataModelPrivate(ctxt)))
+{
+}
+
+QDeclarativeVisualDataModel::~QDeclarativeVisualDataModel()
+{
+ Q_D(QDeclarativeVisualDataModel);
+ if (d->m_listAccessor)
+ delete d->m_listAccessor;
+ if (d->m_delegateDataType)
+ d->m_delegateDataType->release();
+}
+
+/*!
+ \qmlproperty model VisualDataModel::model
+ This property holds the model providing data for the VisualDataModel.
+
+ The model provides a set of data that is used to create the items
+ for a view. For large or dynamic datasets the model is usually
+ provided by a C++ model object. The C++ model object must be a \l
+ {QAbstractItemModel} subclass or a simple list.
+
+ Models can also be created directly in QML, using a \l{ListModel} or
+ \l{XmlListModel}.
+
+ \sa {qmlmodels}{Data Models}
+*/
+QVariant QDeclarativeVisualDataModel::model() const
+{
+ Q_D(const QDeclarativeVisualDataModel);
+ return d->m_modelVariant;
+}
+
+void QDeclarativeVisualDataModel::setModel(const QVariant &model)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ delete d->m_listAccessor;
+ d->m_listAccessor = 0;
+ d->m_modelVariant = model;
+ if (d->m_listModelInterface) {
+ // Assume caller has released all items.
+ QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsChanged(int,int,QList<int>)),
+ this, SLOT(_q_itemsChanged(int,int,QList<int>)));
+ QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsInserted(int,int)),
+ this, SLOT(_q_itemsInserted(int,int)));
+ QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsRemoved(int,int)),
+ this, SLOT(_q_itemsRemoved(int,int)));
+ QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)),
+ this, SLOT(_q_itemsMoved(int,int,int)));
+ d->m_listModelInterface = 0;
+ } else if (d->m_abstractItemModel) {
+ QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsInserted(const QModelIndex &,int,int)),
+ this, SLOT(_q_rowsInserted(const QModelIndex &,int,int)));
+ QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsRemoved(const QModelIndex &,int,int)),
+ this, SLOT(_q_rowsRemoved(const QModelIndex &,int,int)));
+ QObject::disconnect(d->m_abstractItemModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)),
+ this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&)));
+ QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)),
+ this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)));
+ } else if (d->m_visualItemModel) {
+ QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)),
+ this, SIGNAL(itemsInserted(int,int)));
+ QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)),
+ this, SIGNAL(itemsRemoved(int,int)));
+ QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsMoved(int,int,int)),
+ this, SIGNAL(itemsMoved(int,int,int)));
+ QObject::disconnect(d->m_visualItemModel, SIGNAL(createdPackage(int,QDeclarativePackage*)),
+ this, SLOT(_q_createdPackage(int,QDeclarativePackage*)));
+ QObject::disconnect(d->m_visualItemModel, SIGNAL(destroyingPackage(QDeclarativePackage*)),
+ this, SLOT(_q_destroyingPackage(QDeclarativePackage*)));
+ d->m_visualItemModel = 0;
+ }
+
+ d->m_roles.clear();
+ d->m_roleNames.clear();
+ if (d->m_delegateDataType)
+ d->m_delegateDataType->release();
+ d->m_metaDataCreated = 0;
+ d->m_metaDataCacheable = false;
+ d->m_delegateDataType = new VDMDelegateDataType(&QDeclarativeVisualDataModelData::staticMetaObject, d->m_context?d->m_context->engine():qmlEngine(this));
+
+ QObject *object = qvariant_cast<QObject *>(model);
+ if (object && (d->m_listModelInterface = qobject_cast<QListModelInterface *>(object))) {
+ QObject::connect(d->m_listModelInterface, SIGNAL(itemsChanged(int,int,QList<int>)),
+ this, SLOT(_q_itemsChanged(int,int,QList<int>)));
+ QObject::connect(d->m_listModelInterface, SIGNAL(itemsInserted(int,int)),
+ this, SLOT(_q_itemsInserted(int,int)));
+ QObject::connect(d->m_listModelInterface, SIGNAL(itemsRemoved(int,int)),
+ this, SLOT(_q_itemsRemoved(int,int)));
+ QObject::connect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)),
+ this, SLOT(_q_itemsMoved(int,int,int)));
+ d->m_metaDataCacheable = true;
+ if (d->m_delegate && d->m_listModelInterface->count())
+ emit itemsInserted(0, d->m_listModelInterface->count());
+ return;
+ } else if (object && (d->m_abstractItemModel = qobject_cast<QAbstractItemModel *>(object))) {
+ QObject::connect(d->m_abstractItemModel, SIGNAL(rowsInserted(const QModelIndex &,int,int)),
+ this, SLOT(_q_rowsInserted(const QModelIndex &,int,int)));
+ QObject::connect(d->m_abstractItemModel, SIGNAL(rowsRemoved(const QModelIndex &,int,int)),
+ this, SLOT(_q_rowsRemoved(const QModelIndex &,int,int)));
+ QObject::connect(d->m_abstractItemModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)),
+ this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&)));
+ QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)),
+ this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)));
+ d->m_metaDataCacheable = true;
+ return;
+ }
+ if ((d->m_visualItemModel = qvariant_cast<QDeclarativeVisualDataModel *>(model))) {
+ QObject::connect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)),
+ this, SIGNAL(itemsInserted(int,int)));
+ QObject::connect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)),
+ this, SIGNAL(itemsRemoved(int,int)));
+ QObject::connect(d->m_visualItemModel, SIGNAL(itemsMoved(int,int,int)),
+ this, SIGNAL(itemsMoved(int,int,int)));
+ QObject::connect(d->m_visualItemModel, SIGNAL(createdPackage(int,QDeclarativePackage*)),
+ this, SLOT(_q_createdPackage(int,QDeclarativePackage*)));
+ QObject::connect(d->m_visualItemModel, SIGNAL(destroyingPackage(QDeclarativePackage*)),
+ this, SLOT(_q_destroyingPackage(QDeclarativePackage*)));
+ return;
+ }
+ d->m_listAccessor = new QDeclarativeListAccessor;
+ d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this));
+ if (d->m_listAccessor->type() != QDeclarativeListAccessor::ListProperty)
+ d->m_metaDataCacheable = true;
+ if (d->m_delegate && d->modelCount()) {
+ emit itemsInserted(0, d->modelCount());
+ emit countChanged();
+ }
+}
+
+/*!
+ \qmlproperty component VisualDataModel::delegate
+
+ The delegate provides a template defining each item instantiated by a view.
+ The index is exposed as an accessible \c index property. Properties of the
+ model are also available depending upon the type of \l {qmlmodels}{Data Model}.
+
+ Here is an example delegate:
+ \snippet doc/src/snippets/declarative/listview/listview.qml 0
+*/
+QDeclarativeComponent *QDeclarativeVisualDataModel::delegate() const
+{
+ Q_D(const QDeclarativeVisualDataModel);
+ if (d->m_visualItemModel)
+ return d->m_visualItemModel->delegate();
+ return d->m_delegate;
+}
+
+void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ bool wasValid = d->m_delegate != 0;
+ d->m_delegate = delegate;
+ if (!wasValid && d->modelCount() && d->m_delegate) {
+ emit itemsInserted(0, d->modelCount());
+ emit countChanged();
+ }
+ if (wasValid && !d->m_delegate && d->modelCount()) {
+ emit itemsRemoved(0, d->modelCount());
+ emit countChanged();
+ }
+}
+
+/*!
+ \qmlproperty QModelIndex VisualDataModel::rootIndex
+
+ QAbstractItemModel provides a heirachical tree of data, whereas
+ QML only operates on list data. rootIndex allows the children of
+ any node in a QAbstractItemModel to be provided by this model.
+
+ This property only affects models of type QAbstractItemModel.
+
+ \code
+ // main.cpp
+ Q_DECLARE_METATYPE(QModelIndex)
+
+ class MyModel : public QDirModel
+ {
+ Q_OBJECT
+ public:
+ MyModel(QDeclarativeContext *ctxt) : QDirModel(), context(ctxt) {
+ QHash<int,QByteArray> roles = roleNames();
+ roles.insert(FilePathRole, "path");
+ setRoleNames(roles);
+ context->setContextProperty("myModel", this);
+ context->setContextProperty("myRoot", QVariant::fromValue(index(0,0,QModelIndex())));
+ }
+
+ Q_INVOKABLE void setRoot(const QString &path) {
+ QModelIndex root = index(path);
+ context->setContextProperty("myRoot", QVariant::fromValue(root));
+ }
+
+ QDeclarativeContext *context;
+ };
+
+ int main(int argc, char ** argv)
+ {
+ QApplication app(argc, argv);
+
+ QDeclarativeView view;
+
+ MyModel model(view.rootContext());
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+ }
+
+ #include "main.moc"
+ \endcode
+
+ \code
+ // view.qml
+ import Qt 4.6
+
+ ListView {
+ width: 200
+ height: 200
+ model: VisualDataModel {
+ model: myModel
+ rootIndex: myRoot
+ delegate: Component {
+ Rectangle {
+ height: 25; width: 100
+ Text { text: path }
+ MouseRegion {
+ anchors.fill: parent;
+ onClicked: myModel.setRoot(path)
+ }
+ }
+ }
+ }
+ }
+ \endcode
+
+*/
+QModelIndex QDeclarativeVisualDataModel::rootIndex() const
+{
+ Q_D(const QDeclarativeVisualDataModel);
+ return d->m_root;
+}
+
+void QDeclarativeVisualDataModel::setRootIndex(const QModelIndex &root)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ if (d->m_root != root) {
+ int oldCount = d->modelCount();
+ d->m_root = root;
+ int newCount = d->modelCount();
+ if (d->m_delegate && oldCount)
+ emit itemsRemoved(0, oldCount);
+ if (d->m_delegate && newCount)
+ emit itemsInserted(0, newCount);
+ if (newCount != oldCount)
+ emit countChanged();
+ emit rootIndexChanged();
+ }
+}
+
+QString QDeclarativeVisualDataModel::part() const
+{
+ Q_D(const QDeclarativeVisualDataModel);
+ return d->m_part;
+}
+
+void QDeclarativeVisualDataModel::setPart(const QString &part)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ d->m_part = part;
+}
+
+int QDeclarativeVisualDataModel::count() const
+{
+ Q_D(const QDeclarativeVisualDataModel);
+ return d->modelCount();
+}
+
+QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, bool complete)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ if (d->m_visualItemModel)
+ return d->m_visualItemModel->item(index, d->m_part.toUtf8(), complete);
+ return item(index, QByteArray(), complete);
+}
+
+/*
+ Returns ReleaseStatus flags.
+*/
+QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(QDeclarativeItem *item)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ if (d->m_visualItemModel)
+ return d->m_visualItemModel->release(item);
+
+ ReleaseFlags stat = 0;
+ QObject *obj = item;
+ bool inPackage = false;
+
+ QHash<QObject*,QDeclarativePackage*>::iterator it = d->m_packaged.find(item);
+ if (it != d->m_packaged.end()) {
+ QDeclarativePackage *package = *it;
+ d->m_packaged.erase(it);
+ if (d->m_packaged.contains(item))
+ stat |= Referenced;
+ inPackage = true;
+ obj = package; // fall through and delete
+ }
+
+ if (d->m_cache.releaseItem(obj)) {
+ if (inPackage) {
+ emit destroyingPackage(qobject_cast<QDeclarativePackage*>(obj));
+ } else {
+ item->setVisible(false);
+ static_cast<QGraphicsItem*>(item)->setParentItem(0);
+ }
+ stat |= Destroyed;
+ obj->deleteLater();
+ } else if (!inPackage) {
+ stat |= Referenced;
+ }
+
+ return stat;
+}
+
+QObject *QDeclarativeVisualDataModel::parts()
+{
+ Q_D(QDeclarativeVisualDataModel);
+ if (!d->m_parts)
+ d->m_parts = new QDeclarativeVisualDataModelParts(this);
+ return d->m_parts;
+}
+
+QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray &viewId, bool complete)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ if (d->m_visualItemModel)
+ return d->m_visualItemModel->item(index, viewId, complete);
+
+ if (d->modelCount() <= 0 || !d->m_delegate)
+ return 0;
+ QObject *nobj = d->m_cache.getItem(index);
+ if (!nobj) {
+ QDeclarativeContext *ccontext = d->m_context;
+ if (!ccontext) ccontext = qmlContext(this);
+ QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext);
+ QDeclarativeVisualDataModelData *data = new QDeclarativeVisualDataModelData(index, this);
+ ctxt->setContextProperty(QLatin1String("model"), data);
+ ctxt->addDefaultObject(data);
+ nobj = d->m_delegate->beginCreate(ctxt);
+ if (complete)
+ d->m_delegate->completeCreate();
+ if (nobj) {
+ ctxt->setParent(nobj);
+ data->setParent(nobj);
+ d->m_cache.insertItem(index, nobj);
+ if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(nobj))
+ emit createdPackage(index, package);
+ } else {
+ delete data;
+ delete ctxt;
+ qWarning() << d->m_delegate->errors();
+ }
+ }
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(nobj);
+ if (!item) {
+ QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(nobj);
+ if (package) {
+ QObject *o = package->part(QString::fromUtf8(viewId));
+ item = qobject_cast<QDeclarativeItem *>(o);
+ if (item)
+ d->m_packaged.insertMulti(item, package);
+ }
+ }
+ if (!item) {
+ d->m_cache.releaseItem(nobj);
+ qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type.");
+ }
+
+ return item;
+}
+
+void QDeclarativeVisualDataModel::completeItem()
+{
+ Q_D(QDeclarativeVisualDataModel);
+ if (d->m_visualItemModel) {
+ d->m_visualItemModel->completeItem();
+ return;
+ }
+
+ d->m_delegate->completeCreate();
+}
+
+QString QDeclarativeVisualDataModel::stringValue(int index, const QString &name)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ if (d->m_visualItemModel)
+ return d->m_visualItemModel->stringValue(index, name);
+
+ if ((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate)
+ return QString();
+
+ QString val;
+ QObject *data = 0;
+ bool tempData = false;
+
+ if (QObject *nobj = d->m_cache.item(index))
+ data = d->data(nobj);
+ if (!data) {
+ data = new QDeclarativeVisualDataModelData(index, this);
+ tempData = true;
+ }
+
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(data);
+ if (ddata && ddata->propertyCache) {
+ QDeclarativePropertyCache::Data *prop = ddata->propertyCache->property(name);
+ if (prop) {
+ if (prop->propType == QVariant::String) {
+ void *args[] = { &val, 0 };
+ QMetaObject::metacall(data, QMetaObject::ReadProperty, prop->coreIndex, args);
+ } else if (prop->propType == qMetaTypeId<QVariant>()) {
+ QVariant v;
+ void *args[] = { &v, 0 };
+ QMetaObject::metacall(data, QMetaObject::ReadProperty, prop->coreIndex, args);
+ val = v.toString();
+ }
+ } else {
+ val = data->property(name.toUtf8()).toString();
+ }
+ } else {
+ val = data->property(name.toUtf8()).toString();
+ }
+
+ if (tempData)
+ delete data;
+
+ return val;
+}
+
+QVariant QDeclarativeVisualDataModel::evaluate(int index, const QString &expression, QObject *objectContext)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ if (d->m_visualItemModel)
+ return d->m_visualItemModel->evaluate(index, expression, objectContext);
+
+ if ((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate)
+ return QVariant();
+
+ QVariant value;
+ QObject *nobj = d->m_cache.item(index);
+ if (nobj) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(nobj);
+ if (item) {
+ QDeclarativeExpression e(qmlContext(item), expression, objectContext);
+ value = e.value();
+ }
+ } else {
+ QDeclarativeContext *ccontext = d->m_context;
+ if (!ccontext) ccontext = qmlContext(this);
+ QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext);
+ QDeclarativeVisualDataModelData *data = new QDeclarativeVisualDataModelData(index, this);
+ ctxt->addDefaultObject(data);
+ QDeclarativeExpression e(ctxt, expression, objectContext);
+ value = e.value();
+ delete data;
+ delete ctxt;
+ }
+
+ return value;
+}
+
+int QDeclarativeVisualDataModel::indexOf(QDeclarativeItem *item, QObject *) const
+{
+ QVariant val = QDeclarativeEngine::contextForObject(item)->contextProperty(QLatin1String("index"));
+ return val.toInt();
+ return -1;
+}
+
+void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count,
+ const QList<int> &roles)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ // XXX - highly inefficient
+ for (int ii = index; ii < index + count; ++ii) {
+
+ if (QObject *item = d->m_cache.item(ii)) {
+ QDeclarativeVisualDataModelData *data = d->data(item);
+
+ for (int roleIdx = 0; roleIdx < roles.count(); ++roleIdx) {
+ int role = roles.at(roleIdx);
+ int propId = data->propForRole(role);
+ if (propId != -1) {
+ if (d->m_listModelInterface) {
+ data->setValue(propId, d->m_listModelInterface->data(ii, QList<int>() << role).value(role));
+ } else if (d->m_abstractItemModel) {
+ QModelIndex index = d->m_abstractItemModel->index(ii, 0, d->m_root);
+ data->setValue(propId, d->m_abstractItemModel->data(index, role));
+ }
+ }
+ }
+ }
+ }
+}
+
+void QDeclarativeVisualDataModel::_q_itemsInserted(int index, int count)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ // XXX - highly inefficient
+ QHash<int,QDeclarativeVisualDataModelPrivate::ObjectRef> items;
+ for (QHash<int,QDeclarativeVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin();
+ iter != d->m_cache.end(); ) {
+
+ if (iter.key() >= index) {
+ QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter;
+ int index = iter.key() + count;
+ iter = d->m_cache.erase(iter);
+
+ items.insert(index, objRef);
+
+ QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
+ data->setIndex(index);
+ } else {
+ ++iter;
+ }
+ }
+ d->m_cache.unite(items);
+
+ emit itemsInserted(index, count);
+ emit countChanged();
+}
+
+void QDeclarativeVisualDataModel::_q_itemsRemoved(int index, int count)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ // XXX - highly inefficient
+ QHash<int, QDeclarativeVisualDataModelPrivate::ObjectRef> items;
+ for (QHash<int, QDeclarativeVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin();
+ iter != d->m_cache.end(); ) {
+ if (iter.key() >= index && iter.key() < index + count) {
+ QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter;
+ iter = d->m_cache.erase(iter);
+ items.insertMulti(-1, objRef); //XXX perhaps better to maintain separately
+ QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
+ data->setIndex(-1);
+ } else if (iter.key() >= index + count) {
+ QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter;
+ int index = iter.key() - count;
+ iter = d->m_cache.erase(iter);
+ items.insert(index, objRef);
+ QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
+ data->setIndex(index);
+ } else {
+ ++iter;
+ }
+ }
+
+ d->m_cache.unite(items);
+ emit itemsRemoved(index, count);
+ emit countChanged();
+}
+
+void QDeclarativeVisualDataModel::_q_itemsMoved(int from, int to, int count)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ // XXX - highly inefficient
+ QHash<int,QDeclarativeVisualDataModelPrivate::ObjectRef> items;
+ for (QHash<int,QDeclarativeVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin();
+ iter != d->m_cache.end(); ) {
+
+ if (iter.key() >= from && iter.key() < from + count) {
+ QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter;
+ int index = iter.key() - from + to;
+ iter = d->m_cache.erase(iter);
+
+ items.insert(index, objRef);
+
+ QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
+ data->setIndex(index);
+ } else {
+ ++iter;
+ }
+ }
+ for (QHash<int,QDeclarativeVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin();
+ iter != d->m_cache.end(); ) {
+
+ int diff = from > to ? count : -count;
+ if (iter.key() >= qMin(from,to) && iter.key() < qMax(from+count,to+count)) {
+ QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter;
+ int index = iter.key() + diff;
+ iter = d->m_cache.erase(iter);
+
+ items.insert(index, objRef);
+
+ QDeclarativeVisualDataModelData *data = d->data(objRef.obj);
+ data->setIndex(index);
+ } else {
+ ++iter;
+ }
+ }
+ d->m_cache.unite(items);
+
+ emit itemsMoved(from, to, count);
+}
+
+void QDeclarativeVisualDataModel::_q_rowsInserted(const QModelIndex &parent, int begin, int end)
+{
+ if (!parent.isValid())
+ _q_itemsInserted(begin, end - begin + 1);
+}
+
+void QDeclarativeVisualDataModel::_q_rowsRemoved(const QModelIndex &parent, int begin, int end)
+{
+ if (!parent.isValid())
+ _q_itemsRemoved(begin, end - begin + 1);
+}
+
+void QDeclarativeVisualDataModel::_q_rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
+{
+ const int count = sourceEnd - sourceStart + 1;
+ if (!destinationParent.isValid() && !sourceParent.isValid()) {
+ _q_itemsMoved(sourceStart, destinationRow, count);
+ } else if (!sourceParent.isValid()) {
+ _q_itemsRemoved(sourceStart, count);
+ } else if (!destinationParent.isValid()) {
+ _q_itemsInserted(destinationRow, count);
+ }
+}
+
+void QDeclarativeVisualDataModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ if (!begin.parent().isValid())
+ _q_itemsChanged(begin.row(), end.row() - begin.row() + 1, d->m_roles);
+}
+
+void QDeclarativeVisualDataModel::_q_createdPackage(int index, QDeclarativePackage *package)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ emit createdItem(index, qobject_cast<QDeclarativeItem*>(package->part(d->m_part)));
+}
+
+void QDeclarativeVisualDataModel::_q_destroyingPackage(QDeclarativePackage *package)
+{
+ Q_D(QDeclarativeVisualDataModel);
+ emit destroyingItem(qobject_cast<QDeclarativeItem*>(package->part(d->m_part)));
+}
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QListModelInterface)
+
+#include <qdeclarativevisualitemmodel.moc>
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
new file mode 100644
index 0000000..76c8994
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
@@ -0,0 +1,253 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEVISUALDATAMODEL_H
+#define QDECLARATIVEVISUALDATAMODEL_H
+
+#include <qdeclarative.h>
+
+#include <QtCore/qobject.h>
+#include <QtCore/qabstractitemmodel.h>
+
+QT_BEGIN_HEADER
+
+Q_DECLARE_METATYPE(QModelIndex)
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+/*****************************************************************************
+ *****************************************************************************
+ XXX Experimental
+ *****************************************************************************
+*****************************************************************************/
+
+class QDeclarativeItem;
+class QDeclarativeComponent;
+class QDeclarativePackage;
+class QDeclarativeVisualDataModelPrivate;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeVisualModel : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+
+public:
+ QDeclarativeVisualModel() {}
+ virtual ~QDeclarativeVisualModel() {}
+
+ enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 };
+ Q_DECLARE_FLAGS(ReleaseFlags, ReleaseFlag)
+
+ virtual int count() const = 0;
+ virtual bool isValid() const = 0;
+ virtual QDeclarativeItem *item(int index, bool complete=true) = 0;
+ virtual ReleaseFlags release(QDeclarativeItem *item) = 0;
+ virtual void completeItem() = 0;
+ virtual QVariant evaluate(int index, const QString &expression, QObject *objectContext) = 0;
+ virtual QString stringValue(int, const QString &) { return QString(); }
+
+ virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const = 0;
+
+Q_SIGNALS:
+ void countChanged();
+ void itemsInserted(int index, int count);
+ void itemsRemoved(int index, int count);
+ void itemsMoved(int from, int to, int count);
+ void createdItem(int index, QDeclarativeItem *item);
+ void destroyingItem(QDeclarativeItem *item);
+
+protected:
+ QDeclarativeVisualModel(QObjectPrivate &dd, QObject *parent = 0)
+ : QObject(dd, parent) {}
+
+private:
+ Q_DISABLE_COPY(QDeclarativeVisualModel)
+};
+
+class QDeclarativeVisualItemModelAttached;
+class QDeclarativeVisualItemModelPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeVisualItemModel : public QDeclarativeVisualModel
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeVisualItemModel)
+
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> children READ children NOTIFY childrenChanged DESIGNABLE false)
+ Q_CLASSINFO("DefaultProperty", "children")
+
+public:
+ QDeclarativeVisualItemModel();
+ virtual ~QDeclarativeVisualItemModel() {}
+
+ virtual int count() const;
+ virtual bool isValid() const;
+ virtual QDeclarativeItem *item(int index, bool complete=true);
+ virtual ReleaseFlags release(QDeclarativeItem *item);
+ virtual void completeItem();
+ virtual QString stringValue(int index, const QString &role);
+ virtual QVariant evaluate(int index, const QString &expression, QObject *objectContext);
+
+ virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const;
+
+ QDeclarativeListProperty<QDeclarativeItem> children();
+
+ static QDeclarativeVisualItemModelAttached *qmlAttachedProperties(QObject *obj);
+
+Q_SIGNALS:
+ void childrenChanged();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeVisualItemModel)
+};
+
+
+class Q_DECLARATIVE_EXPORT QDeclarativeVisualDataModel : public QDeclarativeVisualModel
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeVisualDataModel)
+
+ Q_PROPERTY(QVariant model READ model WRITE setModel)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(QString part READ part WRITE setPart)
+ Q_PROPERTY(QObject *parts READ parts CONSTANT)
+ Q_PROPERTY(QModelIndex rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged)
+ Q_CLASSINFO("DefaultProperty", "delegate")
+public:
+ QDeclarativeVisualDataModel();
+ QDeclarativeVisualDataModel(QDeclarativeContext *);
+ virtual ~QDeclarativeVisualDataModel();
+
+ QVariant model() const;
+ void setModel(const QVariant &);
+
+ QDeclarativeComponent *delegate() const;
+ void setDelegate(QDeclarativeComponent *);
+
+ QModelIndex rootIndex() const;
+ void setRootIndex(const QModelIndex &root);
+
+ QString part() const;
+ void setPart(const QString &);
+
+ int count() const;
+ bool isValid() const { return delegate() != 0; }
+ QDeclarativeItem *item(int index, bool complete=true);
+ QDeclarativeItem *item(int index, const QByteArray &, bool complete=true);
+ ReleaseFlags release(QDeclarativeItem *item);
+ void completeItem();
+ virtual QString stringValue(int index, const QString &role);
+ QVariant evaluate(int index, const QString &expression, QObject *objectContext);
+
+ int indexOf(QDeclarativeItem *item, QObject *objectContext) const;
+
+ QObject *parts();
+
+Q_SIGNALS:
+ void createdPackage(int index, QDeclarativePackage *package);
+ void destroyingPackage(QDeclarativePackage *package);
+ void rootIndexChanged();
+
+private Q_SLOTS:
+ void _q_itemsChanged(int, int, const QList<int> &);
+ void _q_itemsInserted(int index, int count);
+ void _q_itemsRemoved(int index, int count);
+ void _q_itemsMoved(int from, int to, int count);
+ void _q_rowsInserted(const QModelIndex &,int,int);
+ void _q_rowsRemoved(const QModelIndex &,int,int);
+ void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+ void _q_dataChanged(const QModelIndex&,const QModelIndex&);
+ void _q_createdPackage(int index, QDeclarativePackage *package);
+ void _q_destroyingPackage(QDeclarativePackage *package);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeVisualDataModel)
+};
+
+class QDeclarativeVisualItemModelAttached : public QObject
+{
+ Q_OBJECT
+
+public:
+ QDeclarativeVisualItemModelAttached(QObject *parent)
+ : QObject(parent), m_index(0) {}
+ ~QDeclarativeVisualItemModelAttached() {
+ attachedProperties.remove(parent());
+ }
+
+ Q_PROPERTY(int index READ index NOTIFY indexChanged)
+ int index() const { return m_index; }
+ void setIndex(int idx) {
+ if (m_index != idx) {
+ m_index = idx;
+ emit indexChanged();
+ }
+ }
+
+ static QDeclarativeVisualItemModelAttached *properties(QObject *obj) {
+ QDeclarativeVisualItemModelAttached *rv = attachedProperties.value(obj);
+ if (!rv) {
+ rv = new QDeclarativeVisualItemModelAttached(obj);
+ attachedProperties.insert(obj, rv);
+ }
+ return rv;
+ }
+
+Q_SIGNALS:
+ void indexChanged();
+
+public:
+ int m_index;
+
+ static QHash<QObject*, QDeclarativeVisualItemModelAttached*> attachedProperties;
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeVisualModel)
+QML_DECLARE_TYPE(QDeclarativeVisualItemModel)
+QML_DECLARE_TYPEINFO(QDeclarativeVisualItemModel, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(QDeclarativeVisualDataModel)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEVISUALDATAMODEL_H
diff --git a/src/declarative/graphicsitems/qdeclarativewebview.cpp b/src/declarative/graphicsitems/qdeclarativewebview.cpp
new file mode 100644
index 0000000..61b5b56
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativewebview.cpp
@@ -0,0 +1,1335 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativewebview_p.h"
+#include "qdeclarativewebview_p_p.h"
+
+#include "qdeclarativepainteditem_p_p.h"
+
+#include <qdeclarative.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativestate_p.h>
+
+#include <QDebug>
+#include <QPen>
+#include <QFile>
+#include <QEvent>
+#include <QMouseEvent>
+#include <QKeyEvent>
+#include <QBasicTimer>
+#include <QApplication>
+#include <QGraphicsSceneMouseEvent>
+#include <QtWebKit/QWebPage>
+#include <QtWebKit/QWebFrame>
+#include <QtWebKit/QWebElement>
+#include <QtWebKit/QWebSettings>
+#include <qlistmodelinterface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system
+
+class QDeclarativeWebViewPrivate : public QDeclarativePaintedItemPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeWebView)
+
+public:
+ QDeclarativeWebViewPrivate()
+ : QDeclarativePaintedItemPrivate(), page(0), preferredwidth(0), preferredheight(0),
+ progress(1.0), status(QDeclarativeWebView::Null), pending(PendingNone),
+ newWindowComponent(0), newWindowParent(0),
+ pressTime(400),
+ rendering(true)
+ {
+ }
+
+ QUrl url; // page url might be different if it has not loaded yet
+ QWebPage *page;
+
+ int preferredwidth, preferredheight;
+ qreal progress;
+ QDeclarativeWebView::Status status;
+ QString statusText;
+ enum { PendingNone, PendingUrl, PendingHtml, PendingContent } pending;
+ QUrl pending_url;
+ QString pending_string;
+ QByteArray pending_data;
+ mutable QDeclarativeWebSettings settings;
+ QDeclarativeComponent *newWindowComponent;
+ QDeclarativeItem *newWindowParent;
+
+ QBasicTimer pressTimer;
+ QPoint pressPoint;
+ int pressTime; // milliseconds before it's a "hold"
+
+
+ static void windowObjects_append(QDeclarativeListProperty<QObject> *prop, QObject *o) {
+ static_cast<QDeclarativeWebViewPrivate *>(prop->data)->windowObjects.append(o);
+ static_cast<QDeclarativeWebViewPrivate *>(prop->data)->updateWindowObjects();
+ }
+
+ void updateWindowObjects();
+ QObjectList windowObjects;
+
+ bool rendering;
+};
+
+/*!
+ \qmlclass WebView QDeclarativeWebView
+ \since 4.7
+ \brief The WebView item allows you to add web content to a canvas.
+ \inherits Item
+
+ A WebView renders web content based on a URL.
+
+ If the width and height of the item is not set, they will
+ dynamically adjust to a size appropriate for the content.
+ This width may be large for typical online web pages.
+
+ If the preferredWidth is set, the width will be this amount or larger,
+ usually laying out the web content to fit the preferredWidth.
+
+ \qml
+ WebView {
+ url: "http://www.nokia.com"
+ width: 490
+ height: 400
+ scale: 0.5
+ smooth: false
+ smoothCache: true
+ }
+ \endqml
+
+ \image webview.png
+
+ The item includes no scrolling, scaling,
+ toolbars, etc., those must be implemented around WebView. See the WebBrowser example
+ for a demonstration of this.
+*/
+
+/*!
+ \internal
+ \class QDeclarativeWebView
+ \brief The QDeclarativeWebView class allows you to add web content to a QDeclarativeView.
+
+ A WebView renders web content base on a URL.
+
+ \image webview.png
+
+ The item includes no scrolling, scaling,
+ toolbars, etc., those must be implemented around WebView. See the WebBrowser example
+ for a demonstration of this.
+
+ A QDeclarativeWebView object can be instantiated in Qml using the tag \l WebView.
+*/
+
+QDeclarativeWebView::QDeclarativeWebView(QDeclarativeItem *parent)
+ : QDeclarativePaintedItem(*(new QDeclarativeWebViewPrivate), parent)
+{
+ init();
+}
+
+QDeclarativeWebView::~QDeclarativeWebView()
+{
+ Q_D(QDeclarativeWebView);
+ delete d->page;
+}
+
+void QDeclarativeWebView::init()
+{
+ Q_D(QDeclarativeWebView);
+
+ setAcceptHoverEvents(true);
+ setAcceptedMouseButtons(Qt::LeftButton);
+ setFlag(QGraphicsItem::ItemHasNoContents, false);
+
+ d->page = 0;
+}
+
+void QDeclarativeWebView::componentComplete()
+{
+ QDeclarativePaintedItem::componentComplete();
+ Q_D(QDeclarativeWebView);
+ switch (d->pending) {
+ case QDeclarativeWebViewPrivate::PendingUrl:
+ setUrl(d->pending_url);
+ break;
+ case QDeclarativeWebViewPrivate::PendingHtml:
+ setHtml(d->pending_string, d->pending_url);
+ break;
+ case QDeclarativeWebViewPrivate::PendingContent:
+ setContent(d->pending_data, d->pending_string, d->pending_url);
+ break;
+ default:
+ break;
+ }
+ d->pending = QDeclarativeWebViewPrivate::PendingNone;
+ d->updateWindowObjects();
+}
+
+QDeclarativeWebView::Status QDeclarativeWebView::status() const
+{
+ Q_D(const QDeclarativeWebView);
+ return d->status;
+}
+
+
+/*!
+ \qmlproperty real WebView::progress
+ This property holds the progress of loading the current URL, from 0 to 1.
+
+ If you just want to know when progress gets to 1, use
+ WebView::onLoadFinished() or WebView::onLoadFailed() instead.
+*/
+qreal QDeclarativeWebView::progress() const
+{
+ Q_D(const QDeclarativeWebView);
+ return d->progress;
+}
+
+void QDeclarativeWebView::doLoadStarted()
+{
+ Q_D(QDeclarativeWebView);
+
+ if (!d->url.isEmpty()) {
+ d->status = Loading;
+ emit statusChanged(d->status);
+ }
+ emit loadStarted();
+}
+
+void QDeclarativeWebView::doLoadProgress(int p)
+{
+ Q_D(QDeclarativeWebView);
+ if (d->progress == p/100.0)
+ return;
+ d->progress = p/100.0;
+ emit progressChanged();
+}
+
+void QDeclarativeWebView::pageUrlChanged()
+{
+ Q_D(QDeclarativeWebView);
+
+ page()->setViewportSize(QSize(
+ d->preferredwidth>0 ? d->preferredwidth : width(),
+ d->preferredheight>0 ? d->preferredheight : height()));
+ expandToWebPage();
+
+ if ((d->url.isEmpty() && page()->mainFrame()->url() != QUrl(QLatin1String("about:blank")))
+ || (d->url != page()->mainFrame()->url() && !page()->mainFrame()->url().isEmpty()))
+ {
+ d->url = page()->mainFrame()->url();
+ if (d->url == QUrl(QLatin1String("about:blank")))
+ d->url = QUrl();
+ emit urlChanged();
+ }
+}
+
+void QDeclarativeWebView::doLoadFinished(bool ok)
+{
+ Q_D(QDeclarativeWebView);
+
+ if (title().isEmpty())
+ pageUrlChanged(); // XXX bug 232556 - pages with no title never get urlChanged()
+
+ if (ok) {
+ d->status = d->url.isEmpty() ? Null : Ready;
+ emit loadFinished();
+ } else {
+ d->status = Error;
+ emit loadFailed();
+ }
+ emit statusChanged(d->status);
+}
+
+/*!
+ \qmlproperty url WebView::url
+ This property holds the URL to the page displayed in this item. It can be set,
+ but also can change spontaneously (eg. because of network redirection).
+
+ If the url is empty, the page is blank.
+
+ The url is always absolute (QML will resolve relative URL strings in the context
+ of the containing QML document).
+*/
+QUrl QDeclarativeWebView::url() const
+{
+ Q_D(const QDeclarativeWebView);
+ return d->url;
+}
+
+void QDeclarativeWebView::setUrl(const QUrl &url)
+{
+ Q_D(QDeclarativeWebView);
+ if (url == d->url)
+ return;
+
+ if (isComponentComplete()) {
+ d->url = url;
+ page()->setViewportSize(QSize(
+ d->preferredwidth>0 ? d->preferredwidth : width(),
+ d->preferredheight>0 ? d->preferredheight : height()));
+ QUrl seturl = url;
+ if (seturl.isEmpty())
+ seturl = QUrl(QLatin1String("about:blank"));
+
+ Q_ASSERT(!seturl.isRelative());
+
+ page()->mainFrame()->load(seturl);
+
+ emit urlChanged();
+ } else {
+ d->pending = d->PendingUrl;
+ d->pending_url = url;
+ }
+}
+
+/*!
+ \qmlproperty int WebView::preferredWidth
+ This property holds the ideal width for displaying the current URL.
+*/
+int QDeclarativeWebView::preferredWidth() const
+{
+ Q_D(const QDeclarativeWebView);
+ return d->preferredwidth;
+}
+
+void QDeclarativeWebView::setPreferredWidth(int iw)
+{
+ Q_D(QDeclarativeWebView);
+ if (d->preferredwidth == iw) return;
+ d->preferredwidth = iw;
+ //expandToWebPage();
+ emit preferredWidthChanged();
+}
+
+/*!
+ \qmlproperty int WebView::preferredHeight
+ This property holds the ideal height for displaying the current URL.
+ This only affects the area zoomed by heuristicZoom().
+*/
+int QDeclarativeWebView::preferredHeight() const
+{
+ Q_D(const QDeclarativeWebView);
+ return d->preferredheight;
+}
+void QDeclarativeWebView::setPreferredHeight(int ih)
+{
+ Q_D(QDeclarativeWebView);
+ if (d->preferredheight == ih) return;
+ d->preferredheight = ih;
+ emit preferredHeightChanged();
+}
+
+/*!
+ \qmlmethod bool WebView::evaluateJavaScript(string)
+
+ Evaluates the \a scriptSource JavaScript inside the context of the
+ main web frame, and returns the result of the last executed statement.
+
+ Note that this JavaScript does \e not have any access to QML objects
+ except as made available as windowObjects.
+*/
+QVariant QDeclarativeWebView::evaluateJavaScript(const QString &scriptSource)
+{
+ return this->page()->mainFrame()->evaluateJavaScript(scriptSource);
+}
+
+void QDeclarativeWebView::focusChanged(bool hasFocus)
+{
+ QFocusEvent e(hasFocus ? QEvent::FocusIn : QEvent::FocusOut);
+ page()->event(&e);
+ QDeclarativeItem::focusChanged(hasFocus);
+}
+
+void QDeclarativeWebView::initialLayout()
+{
+ // nothing useful to do at this point
+}
+
+void QDeclarativeWebView::noteContentsSizeChanged(const QSize&)
+{
+ expandToWebPage();
+}
+
+void QDeclarativeWebView::expandToWebPage()
+{
+ Q_D(QDeclarativeWebView);
+ QSize cs = page()->mainFrame()->contentsSize();
+ if (cs.width() < d->preferredwidth)
+ cs.setWidth(d->preferredwidth);
+ if (cs.height() < d->preferredheight)
+ cs.setHeight(d->preferredheight);
+ if (widthValid())
+ cs.setWidth(width());
+ if (heightValid())
+ cs.setHeight(height());
+ if (cs != page()->viewportSize()) {
+ page()->setViewportSize(cs);
+ }
+ if (cs != contentsSize())
+ setContentsSize(cs);
+}
+
+void QDeclarativeWebView::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
+{
+ if (newGeometry.size() != oldGeometry.size())
+ expandToWebPage();
+ QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+void QDeclarativeWebView::paintPage(const QRect& r)
+{
+ dirtyCache(r);
+ update();
+}
+
+/*!
+ \qmlproperty list<object> WebView::javaScriptWindowObjects
+
+ This property is a list of object that are available from within
+ the webview's JavaScript context.
+
+ The \a object will be inserted as a child of the frame's window
+ object, under the name given by the attached property \c WebView.windowObjectName.
+
+ \qml
+ WebView {
+ javaScriptWindowObjects: Object {
+ WebView.windowObjectName: "coordinates"
+ }
+ }
+ \endqml
+
+ Properties of the object will be exposed as JavaScript properties and slots as
+ JavaScript methods.
+
+ If Javascript is not enabled for this page, then this property does nothing.
+*/
+QDeclarativeListProperty<QObject> QDeclarativeWebView::javaScriptWindowObjects()
+{
+ Q_D(QDeclarativeWebView);
+ return QDeclarativeListProperty<QObject>(this, d, &QDeclarativeWebViewPrivate::windowObjects_append);
+}
+
+QDeclarativeWebViewAttached *QDeclarativeWebView::qmlAttachedProperties(QObject *o)
+{
+ return new QDeclarativeWebViewAttached(o);
+}
+
+void QDeclarativeWebViewPrivate::updateWindowObjects()
+{
+ Q_Q(QDeclarativeWebView);
+ if (!q->isComponentComplete() || !page)
+ return;
+
+ for (int ii = 0; ii < windowObjects.count(); ++ii) {
+ QObject *object = windowObjects.at(ii);
+ QDeclarativeWebViewAttached *attached = static_cast<QDeclarativeWebViewAttached *>(qmlAttachedPropertiesObject<QDeclarativeWebView>(object));
+ if (attached && !attached->windowObjectName().isEmpty()) {
+ page->mainFrame()->addToJavaScriptWindowObject(attached->windowObjectName(), object);
+ }
+ }
+}
+
+bool QDeclarativeWebView::renderingEnabled() const
+{
+ Q_D(const QDeclarativeWebView);
+ return d->rendering;
+}
+
+void QDeclarativeWebView::setRenderingEnabled(bool enabled)
+{
+ Q_D(QDeclarativeWebView);
+ if (d->rendering == enabled)
+ return;
+ d->rendering = enabled;
+ emit renderingEnabledChanged();
+
+ setCacheFrozen(!enabled);
+ if (enabled)
+ clearCache();
+}
+
+
+void QDeclarativeWebView::drawContents(QPainter *p, const QRect &r)
+{
+ Q_D(QDeclarativeWebView);
+ if (d->rendering)
+ page()->mainFrame()->render(p,r);
+}
+
+QMouseEvent *QDeclarativeWebView::sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e)
+{
+ QEvent::Type t;
+ switch(e->type()) {
+ default:
+ case QEvent::GraphicsSceneMousePress:
+ t = QEvent::MouseButtonPress;
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ t = QEvent::MouseButtonRelease;
+ break;
+ case QEvent::GraphicsSceneMouseMove:
+ t = QEvent::MouseMove;
+ break;
+ case QGraphicsSceneEvent::GraphicsSceneMouseDoubleClick:
+ t = QEvent::MouseButtonDblClick;
+ break;
+ }
+
+ QMouseEvent *me = new QMouseEvent(t, (e->pos()/contentsScale()).toPoint(), e->button(), e->buttons(), 0);
+ return me;
+}
+
+QMouseEvent *QDeclarativeWebView::sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *e)
+{
+ QEvent::Type t = QEvent::MouseMove;
+
+ QMouseEvent *me = new QMouseEvent(t, (e->pos()/contentsScale()).toPoint(), Qt::NoButton, Qt::NoButton, 0);
+
+ return me;
+}
+
+
+/*!
+ \qmlsignal WebView::onDoubleClick(clickx,clicky)
+
+ The WebView does not pass double-click events to the web engine, but rather
+ emits this signals.
+*/
+
+void QDeclarativeWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ QMouseEvent *me = sceneMouseEventToMouseEvent(event);
+ emit doubleClick(me->x(),me->y());
+ delete me;
+}
+
+/*!
+ \qmlmethod bool WebView::heuristicZoom(clickX,clickY,maxzoom)
+
+ Finds a zoom that:
+ \list
+ \i shows a whole item
+ \i includes (\a clickX, \a clickY)
+ \i fits into the preferredWidth and preferredHeight
+ \i zooms by no more than \a maxzoom
+ \i is more than 10% above the current zoom
+ \endlist
+
+ If such a zoom exists, emits zoomTo(zoom,centerX,centerY) and returns true; otherwise,
+ no signal is emitted and returns false.
+*/
+bool QDeclarativeWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom)
+{
+ Q_D(QDeclarativeWebView);
+ if (contentsScale() >= maxzoom/zoomFactor())
+ return false;
+ qreal ozf = contentsScale();
+ QRect showarea = elementAreaAt(clickX, clickY, d->preferredwidth/maxzoom, d->preferredheight/maxzoom);
+ qreal z = qMin(qreal(d->preferredwidth)/showarea.width(),qreal(d->preferredheight)/showarea.height());
+ if (z > maxzoom/zoomFactor())
+ z = maxzoom/zoomFactor();
+ if (z/ozf > 1.2) {
+ QRectF r(showarea.left()*z, showarea.top()*z, showarea.width()*z, showarea.height()*z);
+ emit zoomTo(z,r.x()+r.width()/2, r.y()+r.height()/2);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/*!
+ \qmlproperty int WebView::pressGrabTime
+
+ The number of milliseconds the user must press before the WebView
+ starts passing move events through to the web engine (rather than
+ letting other QML elements such as a Flickable take them).
+
+ Defaults to 400ms. Set to 0 to always grab and pass move events to
+ the web engine.
+*/
+int QDeclarativeWebView::pressGrabTime() const
+{
+ Q_D(const QDeclarativeWebView);
+ return d->pressTime;
+}
+
+void QDeclarativeWebView::setPressGrabTime(int ms)
+{
+ Q_D(QDeclarativeWebView);
+ if (d->pressTime == ms)
+ return;
+ d->pressTime = ms;
+ emit pressGrabTimeChanged();
+}
+
+void QDeclarativeWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeWebView);
+
+ setFocus (true);
+ QMouseEvent *me = sceneMouseEventToMouseEvent(event);
+
+ d->pressPoint = me->pos();
+ if (d->pressTime) {
+ d->pressTimer.start(d->pressTime,this);
+ setKeepMouseGrab(false);
+ } else {
+ grabMouse();
+ setKeepMouseGrab(true);
+ }
+
+ page()->event(me);
+ event->setAccepted(
+/*
+ It is not correct to send the press event upwards, if it is not accepted by WebKit
+ e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit
+ Might be a bug in WebKit, though
+ */
+#if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835
+ true
+#else
+ me->isAccepted()
+#endif
+ );
+ delete me;
+ if (!event->isAccepted()) {
+ QDeclarativePaintedItem::mousePressEvent(event);
+ }
+}
+
+void QDeclarativeWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeWebView);
+
+ QMouseEvent *me = sceneMouseEventToMouseEvent(event);
+ page()->event(me);
+ d->pressTimer.stop();
+ event->setAccepted(
+/*
+ It is not correct to send the press event upwards, if it is not accepted by WebKit
+ e.g. push button does not work, if done so as QGraphicsScene will not send all the events to WebKit
+ */
+#if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835
+ true
+#else
+ me->isAccepted()
+#endif
+ );
+ delete me;
+ if (!event->isAccepted()) {
+ QDeclarativePaintedItem::mouseReleaseEvent(event);
+ }
+ setKeepMouseGrab(false);
+ ungrabMouse();
+}
+
+void QDeclarativeWebView::timerEvent(QTimerEvent *event)
+{
+ Q_D(QDeclarativeWebView);
+ if (event->timerId() == d->pressTimer.timerId()) {
+ d->pressTimer.stop();
+ grabMouse();
+ setKeepMouseGrab(true);
+ }
+}
+
+void QDeclarativeWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QDeclarativeWebView);
+
+ QMouseEvent *me = sceneMouseEventToMouseEvent(event);
+ if (d->pressTimer.isActive()) {
+ if ((me->pos() - d->pressPoint).manhattanLength() > QApplication::startDragDistance()) {
+ d->pressTimer.stop();
+ }
+ }
+ if (keepMouseGrab()) {
+ page()->event(me);
+ event->setAccepted(
+/*
+ It is not correct to send the press event upwards, if it is not accepted by WebKit
+ e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit
+ Might be a bug in WebKit, though
+ */
+#if 1 // QT_VERSION <= 0x040500 // XXX see bug 230835
+ true
+#else
+ me->isAccepted()
+#endif
+ );
+ }
+ delete me;
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::mouseMoveEvent(event);
+
+}
+void QDeclarativeWebView::hoverMoveEvent (QGraphicsSceneHoverEvent * event)
+{
+ QMouseEvent *me = sceneHoverMoveEventToMouseEvent(event);
+ page()->event(me);
+ event->setAccepted(
+#if QT_VERSION <= 0x040500 // XXX see bug 230835
+ true
+#else
+ me->isAccepted()
+#endif
+ );
+ delete me;
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::hoverMoveEvent(event);
+}
+
+void QDeclarativeWebView::keyPressEvent(QKeyEvent* event)
+{
+ page()->event(event);
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::keyPressEvent(event);
+}
+
+void QDeclarativeWebView::keyReleaseEvent(QKeyEvent* event)
+{
+ page()->event(event);
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::keyReleaseEvent(event);
+}
+
+bool QDeclarativeWebView::sceneEvent(QEvent *event)
+{
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *k = static_cast<QKeyEvent *>(event);
+ if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
+ if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
+ page()->event(event);
+ if (event->isAccepted())
+ return true;
+ }
+ }
+ }
+ return QDeclarativePaintedItem::sceneEvent(event);
+}
+
+
+/*!
+ \qmlproperty action WebView::back
+ This property holds the action for causing the previous URL in the history to be displayed.
+*/
+QAction *QDeclarativeWebView::backAction() const
+{
+ return page()->action(QWebPage::Back);
+}
+
+/*!
+ \qmlproperty action WebView::forward
+ This property holds the action for causing the next URL in the history to be displayed.
+*/
+QAction *QDeclarativeWebView::forwardAction() const
+{
+ return page()->action(QWebPage::Forward);
+}
+
+/*!
+ \qmlproperty action WebView::reload
+ This property holds the action for reloading with the current URL
+*/
+QAction *QDeclarativeWebView::reloadAction() const
+{
+ return page()->action(QWebPage::Reload);
+}
+
+/*!
+ \qmlproperty action WebView::stop
+ This property holds the action for stopping loading with the current URL
+*/
+QAction *QDeclarativeWebView::stopAction() const
+{
+ return page()->action(QWebPage::Stop);
+}
+
+/*!
+ \qmlproperty real WebView::title
+ This property holds the title of the web page currently viewed
+
+ By default, this property contains an empty string.
+*/
+QString QDeclarativeWebView::title() const
+{
+ return page()->mainFrame()->title();
+}
+
+
+
+/*!
+ \qmlproperty pixmap WebView::icon
+ This property holds the icon associated with the web page currently viewed
+*/
+QPixmap QDeclarativeWebView::icon() const
+{
+ return page()->mainFrame()->icon().pixmap(QSize(256,256));
+}
+
+
+/*!
+ \qmlproperty real WebView::zoomFactor
+ This property holds the multiplier used to scale the contents of a Web page.
+*/
+void QDeclarativeWebView::setZoomFactor(qreal factor)
+{
+ Q_D(QDeclarativeWebView);
+ if (factor == page()->mainFrame()->zoomFactor())
+ return;
+
+ page()->mainFrame()->setZoomFactor(factor);
+ page()->setViewportSize(QSize(
+ d->preferredwidth>0 ? d->preferredwidth*factor : width()*factor,
+ d->preferredheight>0 ? d->preferredheight*factor : height()*factor));
+ expandToWebPage();
+
+ emit zoomFactorChanged();
+}
+
+qreal QDeclarativeWebView::zoomFactor() const
+{
+ return page()->mainFrame()->zoomFactor();
+}
+
+/*!
+ \qmlproperty string WebView::statusText
+
+ This property is the current status suggested by the current web page. In a web browser,
+ such status is often shown in some kind of status bar.
+*/
+void QDeclarativeWebView::setStatusText(const QString& s)
+{
+ Q_D(QDeclarativeWebView);
+ d->statusText = s;
+ emit statusTextChanged();
+}
+
+void QDeclarativeWebView::windowObjectCleared()
+{
+ Q_D(QDeclarativeWebView);
+ d->updateWindowObjects();
+}
+
+QString QDeclarativeWebView::statusText() const
+{
+ Q_D(const QDeclarativeWebView);
+ return d->statusText;
+}
+
+QWebPage *QDeclarativeWebView::page() const
+{
+ Q_D(const QDeclarativeWebView);
+
+ if (!d->page) {
+ QDeclarativeWebView *self = const_cast<QDeclarativeWebView*>(this);
+ QWebPage *wp = new QDeclarativeWebPage(self);
+
+ // QML items don't default to having a background,
+ // even though most we pages will set one anyway.
+ QPalette pal = QApplication::palette();
+ pal.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0));
+ wp->setPalette(pal);
+
+ wp->setNetworkAccessManager(qmlEngine(this)->networkAccessManager());
+
+ self->setPage(wp);
+
+ return wp;
+ }
+
+ return d->page;
+}
+
+
+// The QObject interface to settings().
+/*!
+ \qmlproperty string WebView::settings.standardFontFamily
+ \qmlproperty string WebView::settings.fixedFontFamily
+ \qmlproperty string WebView::settings.serifFontFamily
+ \qmlproperty string WebView::settings.sansSerifFontFamily
+ \qmlproperty string WebView::settings.cursiveFontFamily
+ \qmlproperty string WebView::settings.fantasyFontFamily
+
+ \qmlproperty int WebView::settings.minimumFontSize
+ \qmlproperty int WebView::settings.minimumLogicalFontSize
+ \qmlproperty int WebView::settings.defaultFontSize
+ \qmlproperty int WebView::settings.defaultFixedFontSize
+
+ \qmlproperty bool WebView::settings.autoLoadImages
+ \qmlproperty bool WebView::settings.javascriptEnabled
+ \qmlproperty bool WebView::settings.javaEnabled
+ \qmlproperty bool WebView::settings.pluginsEnabled
+ \qmlproperty bool WebView::settings.privateBrowsingEnabled
+ \qmlproperty bool WebView::settings.javascriptCanOpenWindows
+ \qmlproperty bool WebView::settings.javascriptCanAccessClipboard
+ \qmlproperty bool WebView::settings.developerExtrasEnabled
+ \qmlproperty bool WebView::settings.linksIncludedInFocusChain
+ \qmlproperty bool WebView::settings.zoomTextOnly
+ \qmlproperty bool WebView::settings.printElementBackgrounds
+ \qmlproperty bool WebView::settings.offlineStorageDatabaseEnabled
+ \qmlproperty bool WebView::settings.offlineWebApplicationCacheEnabled
+ \qmlproperty bool WebView::settings.localStorageDatabaseEnabled
+ \qmlproperty bool WebView::settings.localContentCanAccessRemoteUrls
+
+ These properties give access to the settings controlling the web view.
+
+ See QWebSettings for details of these properties.
+
+ \qml
+ WebView {
+ settings.pluginsEnabled: true
+ settings.standardFontFamily: "Arial"
+ ...
+ }
+ \endqml
+*/
+QDeclarativeWebSettings *QDeclarativeWebView::settingsObject() const
+{
+ Q_D(const QDeclarativeWebView);
+ d->settings.s = page()->settings();
+ return &d->settings;
+}
+
+void QDeclarativeWebView::setPage(QWebPage *page)
+{
+ Q_D(QDeclarativeWebView);
+ if (d->page == page)
+ return;
+ if (d->page) {
+ if (d->page->parent() == this) {
+ delete d->page;
+ } else {
+ d->page->disconnect(this);
+ }
+ }
+ d->page = page;
+ d->page->setViewportSize(QSize(
+ d->preferredwidth>0 ? d->preferredwidth : width(),
+ d->preferredheight>0 ? d->preferredheight : height()));
+ d->page->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff);
+ d->page->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff);
+ connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect)));
+ connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SLOT(pageUrlChanged()));
+ connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
+ connect(d->page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged()));
+ connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(noteContentsSizeChanged(QSize)));
+ connect(d->page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout()));
+
+ connect(d->page,SIGNAL(loadStarted()),this,SLOT(doLoadStarted()));
+ connect(d->page,SIGNAL(loadProgress(int)),this,SLOT(doLoadProgress(int)));
+ connect(d->page,SIGNAL(loadFinished(bool)),this,SLOT(doLoadFinished(bool)));
+ connect(d->page,SIGNAL(statusBarMessage(QString)),this,SLOT(setStatusText(QString)));
+
+ connect(d->page->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(windowObjectCleared()));
+}
+
+/*!
+ \qmlsignal WebView::onLoadStarted()
+
+ This handler is called when the web engine begins loading
+ a page. Later, WebView::onLoadFinished() or WebView::onLoadFailed()
+ will be emitted.
+*/
+
+/*!
+ \qmlsignal WebView::onLoadFinished()
+
+ This handler is called when the web engine \e successfully
+ finishes loading a page, including any component content
+ (WebView::onLoadFailed() will be emitted otherwise).
+
+ \sa progress
+*/
+
+/*!
+ \qmlsignal WebView::onLoadFailed()
+
+ This handler is called when the web engine fails loading
+ a page or any component content
+ (WebView::onLoadFinished() will be emitted on success).
+*/
+
+void QDeclarativeWebView::load(const QNetworkRequest &request,
+ QNetworkAccessManager::Operation operation,
+ const QByteArray &body)
+{
+ page()->mainFrame()->load(request, operation, body);
+}
+
+QString QDeclarativeWebView::html() const
+{
+ return page()->mainFrame()->toHtml();
+}
+
+/*!
+ \qmlproperty string WebView::html
+ This property holds HTML text set directly
+
+ The html property can be set as a string.
+
+ \qml
+ WebView {
+ html: "<p>This is <b>HTML</b>."
+ }
+ \endqml
+*/
+void QDeclarativeWebView::setHtml(const QString &html, const QUrl &baseUrl)
+{
+ Q_D(QDeclarativeWebView);
+ page()->setViewportSize(QSize(
+ d->preferredwidth>0 ? d->preferredwidth : width(),
+ d->preferredheight>0 ? d->preferredheight : height()));
+ if (isComponentComplete())
+ page()->mainFrame()->setHtml(html, baseUrl);
+ else {
+ d->pending = d->PendingHtml;
+ d->pending_url = baseUrl;
+ d->pending_string = html;
+ }
+ emit htmlChanged();
+}
+
+void QDeclarativeWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
+{
+ Q_D(QDeclarativeWebView);
+ page()->setViewportSize(QSize(
+ d->preferredwidth>0 ? d->preferredwidth : width(),
+ d->preferredheight>0 ? d->preferredheight : height()));
+
+ if (isComponentComplete())
+ page()->mainFrame()->setContent(data,mimeType,qmlContext(this)->resolvedUrl(baseUrl));
+ else {
+ d->pending = d->PendingContent;
+ d->pending_url = baseUrl;
+ d->pending_string = mimeType;
+ d->pending_data = data;
+ }
+}
+
+QWebHistory *QDeclarativeWebView::history() const
+{
+ return page()->history();
+}
+
+QWebSettings *QDeclarativeWebView::settings() const
+{
+ return page()->settings();
+}
+
+QDeclarativeWebView *QDeclarativeWebView::createWindow(QWebPage::WebWindowType type)
+{
+ Q_D(QDeclarativeWebView);
+ switch (type) {
+ case QWebPage::WebBrowserWindow: {
+ if (!d->newWindowComponent && d->newWindowParent)
+ qWarning("WebView::newWindowComponent not set - WebView::newWindowParent ignored");
+ else if (d->newWindowComponent && !d->newWindowParent)
+ qWarning("WebView::newWindowParent not set - WebView::newWindowComponent ignored");
+ else if (d->newWindowComponent && d->newWindowParent) {
+ QDeclarativeWebView *webview = 0;
+ QDeclarativeContext *windowContext = new QDeclarativeContext(qmlContext(this));
+
+ QObject *nobj = d->newWindowComponent->create(windowContext);
+ if (nobj) {
+ windowContext->setParent(nobj);
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(nobj);
+ if (!item) {
+ delete nobj;
+ } else {
+ webview = item->findChild<QDeclarativeWebView*>();
+ if (!webview) {
+ delete item;
+ } else {
+ nobj->setParent(d->newWindowParent);
+ static_cast<QGraphicsObject*>(item)->setParentItem(d->newWindowParent);
+ }
+ }
+ } else {
+ delete windowContext;
+ }
+
+ return webview;
+ }
+ }
+ break;
+ case QWebPage::WebModalDialog: {
+ // Not supported
+ }
+ }
+ return 0;
+}
+
+/*!
+ \qmlproperty component WebView::newWindowComponent
+
+ This property holds the component to use for new windows.
+ The component must have a WebView somewhere in its structure.
+
+ When the web engine requests a new window, it will be an instance of
+ this component.
+
+ The parent of the new window is set by newWindowParent. It must be set.
+*/
+QDeclarativeComponent *QDeclarativeWebView::newWindowComponent() const
+{
+ Q_D(const QDeclarativeWebView);
+ return d->newWindowComponent;
+}
+
+void QDeclarativeWebView::setNewWindowComponent(QDeclarativeComponent *newWindow)
+{
+ Q_D(QDeclarativeWebView);
+ if (newWindow == d->newWindowComponent)
+ return;
+ d->newWindowComponent = newWindow;
+ emit newWindowComponentChanged();
+}
+
+
+/*!
+ \qmlproperty item WebView::newWindowParent
+
+ The parent item for new windows.
+
+ \sa newWindowComponent
+*/
+QDeclarativeItem *QDeclarativeWebView::newWindowParent() const
+{
+ Q_D(const QDeclarativeWebView);
+ return d->newWindowParent;
+}
+
+void QDeclarativeWebView::setNewWindowParent(QDeclarativeItem *parent)
+{
+ Q_D(QDeclarativeWebView);
+ if (parent == d->newWindowParent)
+ return;
+ if (d->newWindowParent && parent) {
+ QList<QGraphicsItem *> children = d->newWindowParent->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ children.at(i)->setParentItem(parent);
+ }
+ }
+ d->newWindowParent = parent;
+ emit newWindowParentChanged();
+}
+
+/*!
+ Returns the area of the largest element at position (\a x,\a y) that is no larger
+ than \a maxwidth by \a maxheight pixels.
+
+ May return an area larger in the case when no smaller element is at the position.
+*/
+QRect QDeclarativeWebView::elementAreaAt(int x, int y, int maxwidth, int maxheight) const
+{
+ QWebHitTestResult hit = page()->mainFrame()->hitTestContent(QPoint(x,y));
+ QRect rv = hit.boundingRect();
+ QWebElement element = hit.enclosingBlockElement();
+ if (maxwidth<=0) maxwidth = INT_MAX;
+ if (maxheight<=0) maxheight = INT_MAX;
+ while (!element.parent().isNull() && element.geometry().width() <= maxwidth && element.geometry().height() <= maxheight) {
+ rv = element.geometry();
+ element = element.parent();
+ }
+ return rv;
+}
+
+/*!
+ \internal
+ \class QDeclarativeWebPage
+ \brief The QDeclarativeWebPage class is a QWebPage that can create QML plugins.
+
+ \sa QDeclarativeWebView
+*/
+QDeclarativeWebPage::QDeclarativeWebPage(QDeclarativeWebView *parent) :
+ QWebPage(parent)
+{
+}
+
+QDeclarativeWebPage::~QDeclarativeWebPage()
+{
+}
+
+void QDeclarativeWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID)
+{
+ qWarning() << sourceID << ':' << lineNumber << ':' << message;
+}
+
+QString QDeclarativeWebPage::chooseFile(QWebFrame *originatingFrame, const QString& oldFile)
+{
+ // Not supported (it's modal)
+ Q_UNUSED(originatingFrame)
+ Q_UNUSED(oldFile)
+ return oldFile;
+}
+
+void QDeclarativeWebPage::javaScriptAlert(QWebFrame *originatingFrame, const QString& msg)
+{
+ Q_UNUSED(originatingFrame)
+ emit viewItem()->alert(msg);
+}
+
+bool QDeclarativeWebPage::javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg)
+{
+ // Not supported (it's modal)
+ Q_UNUSED(originatingFrame)
+ Q_UNUSED(msg)
+ return false;
+}
+
+bool QDeclarativeWebPage::javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result)
+{
+ // Not supported (it's modal)
+ Q_UNUSED(originatingFrame)
+ Q_UNUSED(msg)
+ Q_UNUSED(defaultValue)
+ Q_UNUSED(result)
+ return false;
+}
+
+
+/*
+ Qt WebKit does not understand non-QWidget plugins, so dummy widgets
+ are created, parented to a single dummy tool window.
+
+ The requirements for QML object plugins are input to the Qt WebKit
+ non-QWidget plugin support, which will obsolete this kludge.
+*/
+class QWidget_Dummy_Plugin : public QWidget
+{
+ Q_OBJECT
+public:
+ static QWidget *dummy_shared_parent()
+ {
+ static QWidget *dsp = 0;
+ if (!dsp) {
+ dsp = new QWidget(0,Qt::Tool);
+ dsp->setGeometry(-10000,-10000,0,0);
+ dsp->show();
+ }
+ return dsp;
+ }
+ QWidget_Dummy_Plugin(const QUrl& url, QDeclarativeWebView *view, const QStringList &paramNames, const QStringList &paramValues) :
+ QWidget(dummy_shared_parent()),
+ propertyNames(paramNames),
+ propertyValues(paramValues),
+ webview(view)
+ {
+ QDeclarativeEngine *engine = qmlEngine(webview);
+ component = new QDeclarativeComponent(engine, url, this);
+ item = 0;
+ if (component->isLoading())
+ connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(qmlLoaded()));
+ else
+ qmlLoaded();
+ }
+
+public Q_SLOTS:
+ void qmlLoaded()
+ {
+ if (component->isError()) {
+ // ### Could instead give these errors to the WebView to handle.
+ qWarning() << component->errors();
+ return;
+ }
+ item = qobject_cast<QDeclarativeItem*>(component->create(qmlContext(webview)));
+ item->setParent(webview);
+ QString jsObjName;
+ for (int i=0; i<propertyNames.count(); ++i) {
+ if (propertyNames[i] != QLatin1String("type") && propertyNames[i] != QLatin1String("data")) {
+ item->setProperty(propertyNames[i].toUtf8(),propertyValues[i]);
+ if (propertyNames[i] == QLatin1String("objectname"))
+ jsObjName = propertyValues[i];
+ }
+ }
+ if (!jsObjName.isNull()) {
+ QWebFrame *f = webview->page()->mainFrame();
+ f->addToJavaScriptWindowObject(jsObjName, item);
+ }
+ resizeEvent(0);
+ delete component;
+ component = 0;
+ }
+ void resizeEvent(QResizeEvent*)
+ {
+ if (item) {
+ item->setX(x());
+ item->setY(y());
+ item->setWidth(width());
+ item->setHeight(height());
+ }
+ }
+
+private:
+ QDeclarativeComponent *component;
+ QDeclarativeItem *item;
+ QStringList propertyNames, propertyValues;
+ QDeclarativeWebView *webview;
+};
+
+QDeclarativeWebView *QDeclarativeWebPage::viewItem()
+{
+ return static_cast<QDeclarativeWebView*>(parent());
+}
+
+QObject *QDeclarativeWebPage::createPlugin(const QString &, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
+{
+ QUrl comp = qmlContext(viewItem())->resolvedUrl(url);
+ return new QWidget_Dummy_Plugin(comp,viewItem(),paramNames,paramValues);
+}
+
+QWebPage *QDeclarativeWebPage::createWindow(WebWindowType type)
+{
+ QDeclarativeWebView *newView = viewItem()->createWindow(type);
+ if (newView)
+ return newView->page();
+ return 0;
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativewebview.moc>
diff --git a/src/declarative/graphicsitems/qdeclarativewebview_p.h b/src/declarative/graphicsitems/qdeclarativewebview_p.h
new file mode 100644
index 0000000..a65aab3
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativewebview_p.h
@@ -0,0 +1,286 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEWEBVIEW_H
+#define QDECLARATIVEWEBVIEW_H
+
+#include "qdeclarativepainteditem_p.h"
+
+#include <QtGui/QAction>
+#include <QtCore/QUrl>
+#include <QtNetwork/qnetworkaccessmanager.h>
+#include <QtWebKit/QWebPage>
+
+QT_BEGIN_HEADER
+
+class QWebHistory;
+class QWebSettings;
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+class QDeclarativeWebViewPrivate;
+class QNetworkRequest;
+class QDeclarativeWebView;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeWebPage : public QWebPage
+{
+ Q_OBJECT
+public:
+ explicit QDeclarativeWebPage(QDeclarativeWebView *parent);
+ ~QDeclarativeWebPage();
+protected:
+ QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
+ QWebPage *createWindow(WebWindowType type);
+ void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID);
+ QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile);
+ void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg);
+ bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg);
+ bool javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result);
+
+private:
+ QDeclarativeWebView *viewItem();
+};
+
+
+class QDeclarativeWebViewAttached;
+class QDeclarativeWebSettings;
+
+//### TODO: browser plugins
+
+class Q_DECLARATIVE_EXPORT QDeclarativeWebView : public QDeclarativePaintedItem
+{
+ Q_OBJECT
+
+ Q_ENUMS(Status SelectionMode)
+
+ Q_PROPERTY(QString title READ title NOTIFY titleChanged)
+ Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged)
+ Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
+ Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged)
+
+ Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged)
+
+ Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime NOTIFY pressGrabTimeChanged)
+
+ Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged)
+ Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged)
+ Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+
+ Q_PROPERTY(QAction* reload READ reloadAction CONSTANT)
+ Q_PROPERTY(QAction* back READ backAction CONSTANT)
+ Q_PROPERTY(QAction* forward READ forwardAction CONSTANT)
+ Q_PROPERTY(QAction* stop READ stopAction CONSTANT)
+
+ Q_PROPERTY(QDeclarativeWebSettings* settings READ settingsObject CONSTANT)
+
+ Q_PROPERTY(QDeclarativeListProperty<QObject> javaScriptWindowObjects READ javaScriptWindowObjects CONSTANT)
+
+ Q_PROPERTY(QDeclarativeComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent NOTIFY newWindowComponentChanged)
+ Q_PROPERTY(QDeclarativeItem* newWindowParent READ newWindowParent WRITE setNewWindowParent NOTIFY newWindowParentChanged)
+
+ Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged)
+
+public:
+ QDeclarativeWebView(QDeclarativeItem *parent=0);
+ ~QDeclarativeWebView();
+
+ QUrl url() const;
+ void setUrl(const QUrl &);
+
+ QString title() const;
+
+ QPixmap icon() const;
+
+ qreal zoomFactor() const;
+ void setZoomFactor(qreal);
+ Q_INVOKABLE bool heuristicZoom(int clickX, int clickY, qreal maxzoom);
+ QRect elementAreaAt(int x, int y, int minwidth, int minheight) const;
+
+ int pressGrabTime() const;
+ void setPressGrabTime(int);
+
+ int preferredWidth() const;
+ void setPreferredWidth(int);
+ int preferredHeight() const;
+ void setPreferredHeight(int);
+
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+ qreal progress() const;
+ QString statusText() const;
+
+ QAction *reloadAction() const;
+ QAction *backAction() const;
+ QAction *forwardAction() const;
+ QAction *stopAction() const;
+
+ QWebPage *page() const;
+ void setPage(QWebPage *page);
+
+ void load(const QNetworkRequest &request,
+ QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
+ const QByteArray &body = QByteArray());
+
+ QString html() const;
+
+ void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
+ void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
+
+ QWebHistory *history() const;
+ QWebSettings *settings() const;
+ QDeclarativeWebSettings *settingsObject() const;
+
+ bool renderingEnabled() const;
+ void setRenderingEnabled(bool);
+
+ QDeclarativeListProperty<QObject> javaScriptWindowObjects();
+
+ static QDeclarativeWebViewAttached *qmlAttachedProperties(QObject *);
+
+ QDeclarativeComponent *newWindowComponent() const;
+ void setNewWindowComponent(QDeclarativeComponent *newWindow);
+ QDeclarativeItem *newWindowParent() const;
+ void setNewWindowParent(QDeclarativeItem *newWindow);
+
+Q_SIGNALS:
+ void preferredWidthChanged();
+ void preferredHeightChanged();
+ void urlChanged();
+ void progressChanged();
+ void statusChanged(Status);
+ void titleChanged(const QString&);
+ void iconChanged();
+ void statusTextChanged();
+ void htmlChanged();
+ void pressGrabTimeChanged();
+ void zoomFactorChanged();
+ void newWindowComponentChanged();
+ void newWindowParentChanged();
+ void renderingEnabledChanged();
+
+ void loadStarted();
+ void loadFinished();
+ void loadFailed();
+
+ void doubleClick(int clickX, int clickY);
+
+ void zoomTo(qreal zoom, int centerX, int centerY);
+
+ void alert(const QString& message);
+
+public Q_SLOTS:
+ QVariant evaluateJavaScript(const QString&);
+
+private Q_SLOTS:
+ void expandToWebPage();
+ void paintPage(const QRect&);
+ void doLoadStarted();
+ void doLoadProgress(int p);
+ void doLoadFinished(bool ok);
+ void setStatusText(const QString&);
+ void windowObjectCleared();
+ void pageUrlChanged();
+ void noteContentsSizeChanged(const QSize&);
+ void initialLayout();
+
+protected:
+ void drawContents(QPainter *, const QRect &);
+
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+ void timerEvent(QTimerEvent *event);
+ void hoverMoveEvent (QGraphicsSceneHoverEvent * event);
+ void keyPressEvent(QKeyEvent* event);
+ void keyReleaseEvent(QKeyEvent* event);
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
+ virtual void focusChanged(bool);
+ virtual bool sceneEvent(QEvent *event);
+ QDeclarativeWebView *createWindow(QWebPage::WebWindowType type);
+
+private:
+ void init();
+ virtual void componentComplete();
+ Q_DISABLE_COPY(QDeclarativeWebView)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeWebView)
+ QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *);
+ QMouseEvent *sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *);
+ friend class QDeclarativeWebPage;
+};
+
+class QDeclarativeWebViewAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName)
+public:
+ QDeclarativeWebViewAttached(QObject *parent)
+ : QObject(parent)
+ {
+ }
+
+ QString windowObjectName() const
+ {
+ return m_windowObjectName;
+ }
+
+ void setWindowObjectName(const QString &n)
+ {
+ m_windowObjectName = n;
+ }
+
+private:
+ QString m_windowObjectName;
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeWebView)
+QML_DECLARE_TYPEINFO(QDeclarativeWebView, QML_HAS_ATTACHED_PROPERTIES)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativewebview_p_p.h b/src/declarative/graphicsitems/qdeclarativewebview_p_p.h
new file mode 100644
index 0000000..258b472
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativewebview_p_p.h
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEWEBVIEW_P_H
+#define QDECLARATIVEWEBVIEW_P_H
+
+#include <qdeclarative.h>
+
+#include <QtWebKit/QWebPage>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeWebSettings : public QObject {
+ Q_OBJECT
+
+ Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily)
+ Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily)
+ Q_PROPERTY(QString serifFontFamily READ serifFontFamily WRITE setSerifFontFamily)
+ Q_PROPERTY(QString sansSerifFontFamily READ sansSerifFontFamily WRITE setSansSerifFontFamily)
+ Q_PROPERTY(QString cursiveFontFamily READ cursiveFontFamily WRITE setCursiveFontFamily)
+ Q_PROPERTY(QString fantasyFontFamily READ fantasyFontFamily WRITE setFantasyFontFamily)
+
+ Q_PROPERTY(int minimumFontSize READ minimumFontSize WRITE setMinimumFontSize)
+ Q_PROPERTY(int minimumLogicalFontSize READ minimumLogicalFontSize WRITE setMinimumLogicalFontSize)
+ Q_PROPERTY(int defaultFontSize READ defaultFontSize WRITE setDefaultFontSize)
+ Q_PROPERTY(int defaultFixedFontSize READ defaultFixedFontSize WRITE setDefaultFixedFontSize)
+
+ Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages)
+ Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled)
+ Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled)
+ Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled)
+ Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled)
+ Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows)
+ Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard)
+ Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled)
+ Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain)
+ Q_PROPERTY(bool zoomTextOnly READ zoomTextOnly WRITE setZoomTextOnly)
+ Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds)
+ Q_PROPERTY(bool offlineStorageDatabaseEnabled READ offlineStorageDatabaseEnabled WRITE setOfflineStorageDatabaseEnabled)
+ Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled)
+ Q_PROPERTY(bool localStorageDatabaseEnabled READ localStorageDatabaseEnabled WRITE setLocalStorageDatabaseEnabled)
+ Q_PROPERTY(bool localContentCanAccessRemoteUrls READ localContentCanAccessRemoteUrls WRITE setLocalContentCanAccessRemoteUrls)
+
+public:
+ QDeclarativeWebSettings() {}
+
+ QString standardFontFamily() const { return s->fontFamily(QWebSettings::StandardFont); }
+ void setStandardFontFamily(const QString& f) { s->setFontFamily(QWebSettings::StandardFont,f); }
+ QString fixedFontFamily() const { return s->fontFamily(QWebSettings::FixedFont); }
+ void setFixedFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FixedFont,f); }
+ QString serifFontFamily() const { return s->fontFamily(QWebSettings::SerifFont); }
+ void setSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SerifFont,f); }
+ QString sansSerifFontFamily() const { return s->fontFamily(QWebSettings::SansSerifFont); }
+ void setSansSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SansSerifFont,f); }
+ QString cursiveFontFamily() const { return s->fontFamily(QWebSettings::CursiveFont); }
+ void setCursiveFontFamily(const QString& f) { s->setFontFamily(QWebSettings::CursiveFont,f); }
+ QString fantasyFontFamily() const { return s->fontFamily(QWebSettings::FantasyFont); }
+ void setFantasyFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FantasyFont,f); }
+
+ int minimumFontSize() const { return s->fontSize(QWebSettings::MinimumFontSize); }
+ void setMinimumFontSize(int size) { s->setFontSize(QWebSettings::MinimumFontSize,size); }
+ int minimumLogicalFontSize() const { return s->fontSize(QWebSettings::MinimumLogicalFontSize); }
+ void setMinimumLogicalFontSize(int size) { s->setFontSize(QWebSettings::MinimumLogicalFontSize,size); }
+ int defaultFontSize() const { return s->fontSize(QWebSettings::DefaultFontSize); }
+ void setDefaultFontSize(int size) { s->setFontSize(QWebSettings::DefaultFontSize,size); }
+ int defaultFixedFontSize() const { return s->fontSize(QWebSettings::DefaultFixedFontSize); }
+ void setDefaultFixedFontSize(int size) { s->setFontSize(QWebSettings::DefaultFixedFontSize,size); }
+
+ bool autoLoadImages() const { return s->testAttribute(QWebSettings::AutoLoadImages); }
+ void setAutoLoadImages(bool on) { s->setAttribute(QWebSettings::AutoLoadImages, on); }
+ bool javascriptEnabled() const { return s->testAttribute(QWebSettings::JavascriptEnabled); }
+ void setJavascriptEnabled(bool on) { s->setAttribute(QWebSettings::JavascriptEnabled, on); }
+ bool javaEnabled() const { return s->testAttribute(QWebSettings::JavaEnabled); }
+ void setJavaEnabled(bool on) { s->setAttribute(QWebSettings::JavaEnabled, on); }
+ bool pluginsEnabled() const { return s->testAttribute(QWebSettings::PluginsEnabled); }
+ void setPluginsEnabled(bool on) { s->setAttribute(QWebSettings::PluginsEnabled, on); }
+ bool privateBrowsingEnabled() const { return s->testAttribute(QWebSettings::PrivateBrowsingEnabled); }
+ void setPrivateBrowsingEnabled(bool on) { s->setAttribute(QWebSettings::PrivateBrowsingEnabled, on); }
+ bool javascriptCanOpenWindows() const { return s->testAttribute(QWebSettings::JavascriptCanOpenWindows); }
+ void setJavascriptCanOpenWindows(bool on) { s->setAttribute(QWebSettings::JavascriptCanOpenWindows, on); }
+ bool javascriptCanAccessClipboard() const { return s->testAttribute(QWebSettings::JavascriptCanAccessClipboard); }
+ void setJavascriptCanAccessClipboard(bool on) { s->setAttribute(QWebSettings::JavascriptCanAccessClipboard, on); }
+ bool developerExtrasEnabled() const { return s->testAttribute(QWebSettings::DeveloperExtrasEnabled); }
+ void setDeveloperExtrasEnabled(bool on) { s->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); }
+ bool linksIncludedInFocusChain() const { return s->testAttribute(QWebSettings::LinksIncludedInFocusChain); }
+ void setLinksIncludedInFocusChain(bool on) { s->setAttribute(QWebSettings::LinksIncludedInFocusChain, on); }
+ bool zoomTextOnly() const { return s->testAttribute(QWebSettings::ZoomTextOnly); }
+ void setZoomTextOnly(bool on) { s->setAttribute(QWebSettings::ZoomTextOnly, on); }
+ bool printElementBackgrounds() const { return s->testAttribute(QWebSettings::PrintElementBackgrounds); }
+ void setPrintElementBackgrounds(bool on) { s->setAttribute(QWebSettings::PrintElementBackgrounds, on); }
+ bool offlineStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::OfflineStorageDatabaseEnabled); }
+ void setOfflineStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, on); }
+ bool offlineWebApplicationCacheEnabled() const { return s->testAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); }
+ void setOfflineWebApplicationCacheEnabled(bool on) { s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, on); }
+ bool localStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::LocalStorageDatabaseEnabled); }
+ void setLocalStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, on); }
+ bool localContentCanAccessRemoteUrls() const { return s->testAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); }
+ void setLocalContentCanAccessRemoteUrls(bool on) { s->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, on); }
+
+ QWebSettings *s;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeWebSettings)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
deleted file mode 100644
index 72b4717..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
+++ /dev/null
@@ -1,1059 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsanchors_p_p.h"
-
-#include "qmlgraphicsitem.h"
-#include "qmlgraphicsitem_p.h"
-
-#include <qmlinfo.h>
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-//TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)?
-//TODO: support non-parent, non-sibling (need to find lowest common ancestor)
-
-//### const item?
-//local position
-static qreal position(QmlGraphicsItem *item, QmlGraphicsAnchorLine::AnchorLine anchorLine)
-{
- qreal ret = 0.0;
- switch(anchorLine) {
- case QmlGraphicsAnchorLine::Left:
- ret = item->x();
- break;
- case QmlGraphicsAnchorLine::Right:
- ret = item->x() + item->width();
- break;
- case QmlGraphicsAnchorLine::Top:
- ret = item->y();
- break;
- case QmlGraphicsAnchorLine::Bottom:
- ret = item->y() + item->height();
- break;
- case QmlGraphicsAnchorLine::HCenter:
- ret = item->x() + item->width()/2;
- break;
- case QmlGraphicsAnchorLine::VCenter:
- ret = item->y() + item->height()/2;
- break;
- case QmlGraphicsAnchorLine::Baseline:
- ret = item->y() + item->baselineOffset();
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-//position when origin is 0,0
-static qreal adjustedPosition(QmlGraphicsItem *item, QmlGraphicsAnchorLine::AnchorLine anchorLine)
-{
- int ret = 0;
- switch(anchorLine) {
- case QmlGraphicsAnchorLine::Left:
- ret = 0;
- break;
- case QmlGraphicsAnchorLine::Right:
- ret = item->width();
- break;
- case QmlGraphicsAnchorLine::Top:
- ret = 0;
- break;
- case QmlGraphicsAnchorLine::Bottom:
- ret = item->height();
- break;
- case QmlGraphicsAnchorLine::HCenter:
- ret = item->width()/2;
- break;
- case QmlGraphicsAnchorLine::VCenter:
- ret = item->height()/2;
- break;
- case QmlGraphicsAnchorLine::Baseline:
- ret = item->baselineOffset();
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-/*!
- \internal
- \class QmlGraphicsAnchors
- \since 4.7
- \ingroup group_layouts
- \brief The QmlGraphicsAnchors class provides a way to lay out items relative to other items.
-
- \warning Currently, only anchoring to siblings or parent is supported.
-*/
-
-QmlGraphicsAnchors::QmlGraphicsAnchors(QObject *parent)
- : QObject(*new QmlGraphicsAnchorsPrivate(0), parent)
-{
- qFatal("QmlGraphicsAnchors::QmlGraphicsAnchors(QObject*) called");
-}
-
-QmlGraphicsAnchors::QmlGraphicsAnchors(QmlGraphicsItem *item, QObject *parent)
- : QObject(*new QmlGraphicsAnchorsPrivate(item), parent)
-{
-}
-
-QmlGraphicsAnchors::~QmlGraphicsAnchors()
-{
- Q_D(QmlGraphicsAnchors);
- d->remDepend(d->fill);
- d->remDepend(d->centerIn);
- d->remDepend(d->left.item);
- d->remDepend(d->right.item);
- d->remDepend(d->top.item);
- d->remDepend(d->bottom.item);
- d->remDepend(d->vCenter.item);
- d->remDepend(d->hCenter.item);
- d->remDepend(d->baseline.item);
-}
-
-void QmlGraphicsAnchorsPrivate::fillChanged()
-{
- if (!fill || !isItemComplete())
- return;
-
- if (updatingFill < 2) {
- ++updatingFill;
-
- if (fill == item->parentItem()) { //child-parent
- setItemPos(QPointF(leftMargin, topMargin));
- } else if (fill->parentItem() == item->parentItem()) { //siblings
- setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin));
- }
- setItemWidth(fill->width()-leftMargin-rightMargin);
- setItemHeight(fill->height()-topMargin-bottomMargin);
-
- --updatingFill;
- } else {
- // ### Make this certain :)
- qmlInfo(item) << QmlGraphicsAnchors::tr("Possible anchor loop detected on fill.");
- }
-
-}
-
-void QmlGraphicsAnchorsPrivate::centerInChanged()
-{
- if (!centerIn || fill || !isItemComplete())
- return;
-
- if (updatingCenterIn < 2) {
- ++updatingCenterIn;
-
- if (centerIn == item->parentItem()) {
- QPointF p((item->parentItem()->width() - item->width()) / 2. + hCenterOffset,
- (item->parentItem()->height() - item->height()) / 2. + vCenterOffset);
- setItemPos(p);
-
- } else if (centerIn->parentItem() == item->parentItem()) {
-
- QPointF p(centerIn->x() + (centerIn->width() - item->width()) / 2. + hCenterOffset,
- centerIn->y() + (centerIn->height() - item->height()) / 2. + vCenterOffset);
- setItemPos(p);
- }
-
- --updatingCenterIn;
- } else {
- // ### Make this certain :)
- qmlInfo(item) << QmlGraphicsAnchors::tr("Possible anchor loop detected on centerIn.");
- }
-}
-
-void QmlGraphicsAnchorsPrivate::clearItem(QmlGraphicsItem *item)
-{
- if (!item)
- return;
- if (fill == item)
- fill = 0;
- if (centerIn == item)
- centerIn = 0;
- if (left.item == item) {
- left.item = 0;
- usedAnchors &= ~QmlGraphicsAnchors::HasLeftAnchor;
- }
- if (right.item == item) {
- right.item = 0;
- usedAnchors &= ~QmlGraphicsAnchors::HasRightAnchor;
- }
- if (top.item == item) {
- top.item = 0;
- usedAnchors &= ~QmlGraphicsAnchors::HasTopAnchor;
- }
- if (bottom.item == item) {
- bottom.item = 0;
- usedAnchors &= ~QmlGraphicsAnchors::HasBottomAnchor;
- }
- if (vCenter.item == item) {
- vCenter.item = 0;
- usedAnchors &= ~QmlGraphicsAnchors::HasVCenterAnchor;
- }
- if (hCenter.item == item) {
- hCenter.item = 0;
- usedAnchors &= ~QmlGraphicsAnchors::HasHCenterAnchor;
- }
- if (baseline.item == item) {
- baseline.item = 0;
- usedAnchors &= ~QmlGraphicsAnchors::HasBaselineAnchor;
- }
-}
-
-void QmlGraphicsAnchorsPrivate::addDepend(QmlGraphicsItem *item)
-{
- if (!item)
- return;
- QmlGraphicsItemPrivate *p =
- static_cast<QmlGraphicsItemPrivate *>(QGraphicsItemPrivate::get(item));
- p->addItemChangeListener(this, QmlGraphicsItemPrivate::Geometry);
-}
-
-void QmlGraphicsAnchorsPrivate::remDepend(QmlGraphicsItem *item)
-{
- if (!item)
- return;
- QmlGraphicsItemPrivate *p =
- static_cast<QmlGraphicsItemPrivate *>(QGraphicsItemPrivate::get(item));
- p->removeItemChangeListener(this, QmlGraphicsItemPrivate::Geometry);
-}
-
-bool QmlGraphicsAnchorsPrivate::isItemComplete() const
-{
- return componentComplete;
-}
-
-void QmlGraphicsAnchors::classBegin()
-{
- Q_D(QmlGraphicsAnchors);
- d->componentComplete = false;
-}
-
-void QmlGraphicsAnchors::componentComplete()
-{
- Q_D(QmlGraphicsAnchors);
- d->componentComplete = true;
-}
-
-void QmlGraphicsAnchorsPrivate::setItemHeight(qreal v)
-{
- updatingMe = true;
- item->setHeight(v);
- updatingMe = false;
-}
-
-void QmlGraphicsAnchorsPrivate::setItemWidth(qreal v)
-{
- updatingMe = true;
- item->setWidth(v);
- updatingMe = false;
-}
-
-void QmlGraphicsAnchorsPrivate::setItemX(qreal v)
-{
- updatingMe = true;
- item->setX(v);
- updatingMe = false;
-}
-
-void QmlGraphicsAnchorsPrivate::setItemY(qreal v)
-{
- updatingMe = true;
- item->setY(v);
- updatingMe = false;
-}
-
-void QmlGraphicsAnchorsPrivate::setItemPos(const QPointF &v)
-{
- updatingMe = true;
- item->setPos(v);
- updatingMe = false;
-}
-
-void QmlGraphicsAnchorsPrivate::updateMe()
-{
- if (updatingMe) {
- updatingMe = false;
- return;
- }
-
- fillChanged();
- centerInChanged();
- updateHorizontalAnchors();
- updateVerticalAnchors();
-}
-
-void QmlGraphicsAnchorsPrivate::updateOnComplete()
-{
- fillChanged();
- centerInChanged();
- updateHorizontalAnchors();
- updateVerticalAnchors();
-}
-
-void QmlGraphicsAnchorsPrivate::itemGeometryChanged(QmlGraphicsItem *, const QRectF &newG, const QRectF &oldG)
-{
- fillChanged();
- centerInChanged();
-
- if (newG.x() != oldG.x() || newG.width() != oldG.width())
- updateHorizontalAnchors();
- if (newG.y() != oldG.y() || newG.height() != oldG.height())
- updateVerticalAnchors();
-}
-
-QmlGraphicsItem *QmlGraphicsAnchors::fill() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->fill;
-}
-
-void QmlGraphicsAnchors::setFill(QmlGraphicsItem *f)
-{
- Q_D(QmlGraphicsAnchors);
- if (d->fill == f)
- return;
-
- if (!f) {
- d->remDepend(d->fill);
- d->fill = f;
- emit fillChanged();
- return;
- }
- if (f != d->item->parentItem() && f->parentItem() != d->item->parentItem()){
- qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling.");
- return;
- }
- d->remDepend(d->fill);
- d->fill = f;
- d->addDepend(d->fill);
- emit fillChanged();
- d->fillChanged();
-}
-
-void QmlGraphicsAnchors::resetFill()
-{
- setFill(0);
-}
-
-QmlGraphicsItem *QmlGraphicsAnchors::centerIn() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->centerIn;
-}
-
-void QmlGraphicsAnchors::setCenterIn(QmlGraphicsItem* c)
-{
- Q_D(QmlGraphicsAnchors);
- if (d->centerIn == c)
- return;
-
- if (!c) {
- d->remDepend(d->centerIn);
- d->centerIn = c;
- emit centerInChanged();
- return;
- }
- if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){
- qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling.");
- return;
- }
-
- d->remDepend(d->centerIn);
- d->centerIn = c;
- d->addDepend(d->centerIn);
- emit centerInChanged();
- d->centerInChanged();
-}
-
-void QmlGraphicsAnchors::resetCenterIn()
-{
- setCenterIn(0);
-}
-
-bool QmlGraphicsAnchorsPrivate::calcStretch(const QmlGraphicsAnchorLine &edge1,
- const QmlGraphicsAnchorLine &edge2,
- int offset1,
- int offset2,
- QmlGraphicsAnchorLine::AnchorLine line,
- int &stretch)
-{
- bool edge1IsParent = (edge1.item == item->parentItem());
- bool edge2IsParent = (edge2.item == item->parentItem());
- bool edge1IsSibling = (edge1.item->parentItem() == item->parentItem());
- bool edge2IsSibling = (edge2.item->parentItem() == item->parentItem());
-
- bool invalid = false;
- if ((edge2IsParent && edge1IsParent) || (edge2IsSibling && edge1IsSibling)) {
- stretch = ((int)position(edge2.item, edge2.anchorLine) + offset2)
- - ((int)position(edge1.item, edge1.anchorLine) + offset1);
- } else if (edge2IsParent && edge1IsSibling) {
- stretch = ((int)position(edge2.item, edge2.anchorLine) + offset2)
- - ((int)position(item->parentItem(), line)
- + (int)position(edge1.item, edge1.anchorLine) + offset1);
- } else if (edge2IsSibling && edge1IsParent) {
- stretch = ((int)position(item->parentItem(), line) + (int)position(edge2.item, edge2.anchorLine) + offset2)
- - ((int)position(edge1.item, edge1.anchorLine) + offset1);
- } else
- invalid = true;
-
- return invalid;
-}
-
-void QmlGraphicsAnchorsPrivate::updateVerticalAnchors()
-{
- if (fill || centerIn || !isItemComplete())
- return;
-
- if (updatingVerticalAnchor < 2) {
- ++updatingVerticalAnchor;
- if (usedAnchors & QmlGraphicsAnchors::HasTopAnchor) {
- //Handle stretching
- bool invalid = true;
- int height = 0;
- if (usedAnchors & QmlGraphicsAnchors::HasBottomAnchor) {
- invalid = calcStretch(top, bottom, topMargin, -bottomMargin, QmlGraphicsAnchorLine::Top, height);
- } else if (usedAnchors & QmlGraphicsAnchors::HasVCenterAnchor) {
- invalid = calcStretch(top, vCenter, topMargin, vCenterOffset, QmlGraphicsAnchorLine::Top, height);
- height *= 2;
- }
- if (!invalid)
- setItemHeight(height);
-
- //Handle top
- if (top.item == item->parentItem()) {
- setItemY(adjustedPosition(top.item, top.anchorLine) + topMargin);
- } else if (top.item->parentItem() == item->parentItem()) {
- setItemY(position(top.item, top.anchorLine) + topMargin);
- }
- } else if (usedAnchors & QmlGraphicsAnchors::HasBottomAnchor) {
- //Handle stretching (top + bottom case is handled above)
- if (usedAnchors & QmlGraphicsAnchors::HasVCenterAnchor) {
- int height = 0;
- bool invalid = calcStretch(vCenter, bottom, vCenterOffset, -bottomMargin,
- QmlGraphicsAnchorLine::Top, height);
- if (!invalid)
- setItemHeight(height*2);
- }
-
- //Handle bottom
- if (bottom.item == item->parentItem()) {
- setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - item->height() - bottomMargin);
- } else if (bottom.item->parentItem() == item->parentItem()) {
- setItemY(position(bottom.item, bottom.anchorLine) - item->height() - bottomMargin);
- }
- } else if (usedAnchors & QmlGraphicsAnchors::HasVCenterAnchor) {
- //(stetching handled above)
-
- //Handle vCenter
- if (vCenter.item == item->parentItem()) {
- setItemY(adjustedPosition(vCenter.item, vCenter.anchorLine)
- - item->height()/2 + vCenterOffset);
- } else if (vCenter.item->parentItem() == item->parentItem()) {
- setItemY(position(vCenter.item, vCenter.anchorLine) - item->height()/2 + vCenterOffset);
- }
- } else if (usedAnchors & QmlGraphicsAnchors::HasBaselineAnchor) {
- //Handle baseline
- if (baseline.item == item->parentItem()) {
- setItemY(adjustedPosition(baseline.item, baseline.anchorLine)
- - item->baselineOffset() + baselineOffset);
- } else if (baseline.item->parentItem() == item->parentItem()) {
- setItemY(position(baseline.item, baseline.anchorLine)
- - item->baselineOffset() + baselineOffset);
- }
- }
- --updatingVerticalAnchor;
- } else {
- // ### Make this certain :)
- qmlInfo(item) << QmlGraphicsAnchors::tr("Possible anchor loop detected on vertical anchor.");
- }
-}
-
-void QmlGraphicsAnchorsPrivate::updateHorizontalAnchors()
-{
- if (fill || centerIn || !isItemComplete())
- return;
-
- if (updatingHorizontalAnchor < 2) {
- ++updatingHorizontalAnchor;
-
- if (usedAnchors & QmlGraphicsAnchors::HasLeftAnchor) {
- //Handle stretching
- bool invalid = true;
- int width = 0;
- if (usedAnchors & QmlGraphicsAnchors::HasRightAnchor) {
- invalid = calcStretch(left, right, leftMargin, -rightMargin, QmlGraphicsAnchorLine::Left, width);
- } else if (usedAnchors & QmlGraphicsAnchors::HasHCenterAnchor) {
- invalid = calcStretch(left, hCenter, leftMargin, hCenterOffset, QmlGraphicsAnchorLine::Left, width);
- width *= 2;
- }
- if (!invalid)
- setItemWidth(width);
-
- //Handle left
- if (left.item == item->parentItem()) {
- setItemX(adjustedPosition(left.item, left.anchorLine) + leftMargin);
- } else if (left.item->parentItem() == item->parentItem()) {
- setItemX(position(left.item, left.anchorLine) + leftMargin);
- }
- } else if (usedAnchors & QmlGraphicsAnchors::HasRightAnchor) {
- //Handle stretching (left + right case is handled in updateLeftAnchor)
- if (usedAnchors & QmlGraphicsAnchors::HasHCenterAnchor) {
- int width = 0;
- bool invalid = calcStretch(hCenter, right, hCenterOffset, -rightMargin,
- QmlGraphicsAnchorLine::Left, width);
- if (!invalid)
- setItemWidth(width*2);
- }
-
- //Handle right
- if (right.item == item->parentItem()) {
- setItemX(adjustedPosition(right.item, right.anchorLine) - item->width() - rightMargin);
- } else if (right.item->parentItem() == item->parentItem()) {
- setItemX(position(right.item, right.anchorLine) - item->width() - rightMargin);
- }
- } else if (usedAnchors & QmlGraphicsAnchors::HasHCenterAnchor) {
- //Handle hCenter
- if (hCenter.item == item->parentItem()) {
- setItemX(adjustedPosition(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset);
- } else if (hCenter.item->parentItem() == item->parentItem()) {
- setItemX(position(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset);
- }
- }
-
- --updatingHorizontalAnchor;
- } else {
- // ### Make this certain :)
- qmlInfo(item) << QmlGraphicsAnchors::tr("Possible anchor loop detected on horizontal anchor.");
- }
-}
-
-QmlGraphicsAnchorLine QmlGraphicsAnchors::top() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->top;
-}
-
-void QmlGraphicsAnchors::setTop(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlGraphicsAnchors);
- if (!d->checkVAnchorValid(edge) || d->top == edge)
- return;
-
- d->usedAnchors |= HasTopAnchor;
-
- if (!d->checkVValid()) {
- d->usedAnchors &= ~HasTopAnchor;
- return;
- }
-
- d->remDepend(d->top.item);
- d->top = edge;
- d->addDepend(d->top.item);
- emit topChanged();
- d->updateVerticalAnchors();
-}
-
-void QmlGraphicsAnchors::resetTop()
-{
- Q_D(QmlGraphicsAnchors);
- d->usedAnchors &= ~HasTopAnchor;
- d->remDepend(d->top.item);
- d->top = QmlGraphicsAnchorLine();
- emit topChanged();
- d->updateVerticalAnchors();
-}
-
-QmlGraphicsAnchorLine QmlGraphicsAnchors::bottom() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->bottom;
-}
-
-void QmlGraphicsAnchors::setBottom(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlGraphicsAnchors);
- if (!d->checkVAnchorValid(edge) || d->bottom == edge)
- return;
-
- d->usedAnchors |= HasBottomAnchor;
-
- if (!d->checkVValid()) {
- d->usedAnchors &= ~HasBottomAnchor;
- return;
- }
-
- d->remDepend(d->bottom.item);
- d->bottom = edge;
- d->addDepend(d->bottom.item);
- emit bottomChanged();
- d->updateVerticalAnchors();
-}
-
-void QmlGraphicsAnchors::resetBottom()
-{
- Q_D(QmlGraphicsAnchors);
- d->usedAnchors &= ~HasBottomAnchor;
- d->remDepend(d->bottom.item);
- d->bottom = QmlGraphicsAnchorLine();
- emit bottomChanged();
- d->updateVerticalAnchors();
-}
-
-QmlGraphicsAnchorLine QmlGraphicsAnchors::verticalCenter() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->vCenter;
-}
-
-void QmlGraphicsAnchors::setVerticalCenter(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlGraphicsAnchors);
- if (!d->checkVAnchorValid(edge) || d->vCenter == edge)
- return;
-
- d->usedAnchors |= HasVCenterAnchor;
-
- if (!d->checkVValid()) {
- d->usedAnchors &= ~HasVCenterAnchor;
- return;
- }
-
- d->remDepend(d->vCenter.item);
- d->vCenter = edge;
- d->addDepend(d->vCenter.item);
- emit verticalCenterChanged();
- d->updateVerticalAnchors();
-}
-
-void QmlGraphicsAnchors::resetVerticalCenter()
-{
- Q_D(QmlGraphicsAnchors);
- d->usedAnchors &= ~HasVCenterAnchor;
- d->remDepend(d->vCenter.item);
- d->vCenter = QmlGraphicsAnchorLine();
- emit verticalCenterChanged();
- d->updateVerticalAnchors();
-}
-
-QmlGraphicsAnchorLine QmlGraphicsAnchors::baseline() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->baseline;
-}
-
-void QmlGraphicsAnchors::setBaseline(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlGraphicsAnchors);
- if (!d->checkVAnchorValid(edge) || d->baseline == edge)
- return;
-
- d->usedAnchors |= HasBaselineAnchor;
-
- if (!d->checkVValid()) {
- d->usedAnchors &= ~HasBaselineAnchor;
- return;
- }
-
- d->remDepend(d->baseline.item);
- d->baseline = edge;
- d->addDepend(d->baseline.item);
- emit baselineChanged();
- d->updateVerticalAnchors();
-}
-
-void QmlGraphicsAnchors::resetBaseline()
-{
- Q_D(QmlGraphicsAnchors);
- d->usedAnchors &= ~HasBaselineAnchor;
- d->remDepend(d->baseline.item);
- d->baseline = QmlGraphicsAnchorLine();
- emit baselineChanged();
- d->updateVerticalAnchors();
-}
-
-QmlGraphicsAnchorLine QmlGraphicsAnchors::left() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->left;
-}
-
-void QmlGraphicsAnchors::setLeft(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlGraphicsAnchors);
- if (!d->checkHAnchorValid(edge) || d->left == edge)
- return;
-
- d->usedAnchors |= HasLeftAnchor;
-
- if (!d->checkHValid()) {
- d->usedAnchors &= ~HasLeftAnchor;
- return;
- }
-
- d->remDepend(d->left.item);
- d->left = edge;
- d->addDepend(d->left.item);
- emit leftChanged();
- d->updateHorizontalAnchors();
-}
-
-void QmlGraphicsAnchors::resetLeft()
-{
- Q_D(QmlGraphicsAnchors);
- d->usedAnchors &= ~HasLeftAnchor;
- d->remDepend(d->left.item);
- d->left = QmlGraphicsAnchorLine();
- emit leftChanged();
- d->updateHorizontalAnchors();
-}
-
-QmlGraphicsAnchorLine QmlGraphicsAnchors::right() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->right;
-}
-
-void QmlGraphicsAnchors::setRight(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlGraphicsAnchors);
- if (!d->checkHAnchorValid(edge) || d->right == edge)
- return;
-
- d->usedAnchors |= HasRightAnchor;
-
- if (!d->checkHValid()) {
- d->usedAnchors &= ~HasRightAnchor;
- return;
- }
-
- d->remDepend(d->right.item);
- d->right = edge;
- d->addDepend(d->right.item);
- emit rightChanged();
- d->updateHorizontalAnchors();
-}
-
-void QmlGraphicsAnchors::resetRight()
-{
- Q_D(QmlGraphicsAnchors);
- d->usedAnchors &= ~HasRightAnchor;
- d->remDepend(d->right.item);
- d->right = QmlGraphicsAnchorLine();
- emit rightChanged();
- d->updateHorizontalAnchors();
-}
-
-QmlGraphicsAnchorLine QmlGraphicsAnchors::horizontalCenter() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->hCenter;
-}
-
-void QmlGraphicsAnchors::setHorizontalCenter(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlGraphicsAnchors);
- if (!d->checkHAnchorValid(edge) || d->hCenter == edge)
- return;
-
- d->usedAnchors |= HasHCenterAnchor;
-
- if (!d->checkHValid()) {
- d->usedAnchors &= ~HasHCenterAnchor;
- return;
- }
-
- d->remDepend(d->hCenter.item);
- d->hCenter = edge;
- d->addDepend(d->hCenter.item);
- emit horizontalCenterChanged();
- d->updateHorizontalAnchors();
-}
-
-void QmlGraphicsAnchors::resetHorizontalCenter()
-{
- Q_D(QmlGraphicsAnchors);
- d->usedAnchors &= ~HasHCenterAnchor;
- d->remDepend(d->hCenter.item);
- d->hCenter = QmlGraphicsAnchorLine();
- emit horizontalCenterChanged();
- d->updateHorizontalAnchors();
-}
-
-qreal QmlGraphicsAnchors::leftMargin() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->leftMargin;
-}
-
-void QmlGraphicsAnchors::setLeftMargin(qreal offset)
-{
- Q_D(QmlGraphicsAnchors);
- if (d->leftMargin == offset)
- return;
- d->leftMargin = offset;
- if(d->fill)
- d->fillChanged();
- else
- d->updateHorizontalAnchors();
- emit leftMarginChanged();
-}
-
-qreal QmlGraphicsAnchors::rightMargin() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->rightMargin;
-}
-
-void QmlGraphicsAnchors::setRightMargin(qreal offset)
-{
- Q_D(QmlGraphicsAnchors);
- if (d->rightMargin == offset)
- return;
- d->rightMargin = offset;
- if(d->fill)
- d->fillChanged();
- else
- d->updateHorizontalAnchors();
- emit rightMarginChanged();
-}
-
-qreal QmlGraphicsAnchors::margins() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->margins;
-}
-
-void QmlGraphicsAnchors::setMargins(qreal offset)
-{
- Q_D(QmlGraphicsAnchors);
- if (d->margins == offset)
- return;
- //###Is it significantly faster to set them directly so we can call fillChanged only once?
- if(!d->rightMargin || d->rightMargin == d->margins)
- setRightMargin(offset);
- if(!d->leftMargin || d->leftMargin == d->margins)
- setLeftMargin(offset);
- if(!d->topMargin || d->topMargin == d->margins)
- setTopMargin(offset);
- if(!d->bottomMargin || d->bottomMargin == d->margins)
- setBottomMargin(offset);
- d->margins = offset;
- emit marginsChanged();
-
-}
-
-qreal QmlGraphicsAnchors::horizontalCenterOffset() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->hCenterOffset;
-}
-
-void QmlGraphicsAnchors::setHorizontalCenterOffset(qreal offset)
-{
- Q_D(QmlGraphicsAnchors);
- if (d->hCenterOffset == offset)
- return;
- d->hCenterOffset = offset;
- if(d->centerIn)
- d->centerInChanged();
- else
- d->updateHorizontalAnchors();
- emit horizontalCenterOffsetChanged();
-}
-
-qreal QmlGraphicsAnchors::topMargin() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->topMargin;
-}
-
-void QmlGraphicsAnchors::setTopMargin(qreal offset)
-{
- Q_D(QmlGraphicsAnchors);
- if (d->topMargin == offset)
- return;
- d->topMargin = offset;
- if(d->fill)
- d->fillChanged();
- else
- d->updateVerticalAnchors();
- emit topMarginChanged();
-}
-
-qreal QmlGraphicsAnchors::bottomMargin() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->bottomMargin;
-}
-
-void QmlGraphicsAnchors::setBottomMargin(qreal offset)
-{
- Q_D(QmlGraphicsAnchors);
- if (d->bottomMargin == offset)
- return;
- d->bottomMargin = offset;
- if(d->fill)
- d->fillChanged();
- else
- d->updateVerticalAnchors();
- emit bottomMarginChanged();
-}
-
-qreal QmlGraphicsAnchors::verticalCenterOffset() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->vCenterOffset;
-}
-
-void QmlGraphicsAnchors::setVerticalCenterOffset(qreal offset)
-{
- Q_D(QmlGraphicsAnchors);
- if (d->vCenterOffset == offset)
- return;
- d->vCenterOffset = offset;
- if(d->centerIn)
- d->centerInChanged();
- else
- d->updateVerticalAnchors();
- emit verticalCenterOffsetChanged();
-}
-
-qreal QmlGraphicsAnchors::baselineOffset() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->baselineOffset;
-}
-
-void QmlGraphicsAnchors::setBaselineOffset(qreal offset)
-{
- Q_D(QmlGraphicsAnchors);
- if (d->baselineOffset == offset)
- return;
- d->baselineOffset = offset;
- d->updateVerticalAnchors();
- emit baselineOffsetChanged();
-}
-
-QmlGraphicsAnchors::UsedAnchors QmlGraphicsAnchors::usedAnchors() const
-{
- Q_D(const QmlGraphicsAnchors);
- return d->usedAnchors;
-}
-
-bool QmlGraphicsAnchorsPrivate::checkHValid() const
-{
- if (usedAnchors & QmlGraphicsAnchors::HasLeftAnchor &&
- usedAnchors & QmlGraphicsAnchors::HasRightAnchor &&
- usedAnchors & QmlGraphicsAnchors::HasHCenterAnchor) {
- qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot specify left, right, and hcenter anchors.");
- return false;
- }
-
- return true;
-}
-
-bool QmlGraphicsAnchorsPrivate::checkHAnchorValid(QmlGraphicsAnchorLine anchor) const
-{
- if (!anchor.item) {
- qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to a null item.");
- return false;
- } else if (anchor.anchorLine & QmlGraphicsAnchorLine::Vertical_Mask) {
- qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor a horizontal edge to a vertical edge.");
- return false;
- } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){
- qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
- return false;
- } else if (anchor.item == item) {
- qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor item to self.");
- return false;
- }
-
- return true;
-}
-
-bool QmlGraphicsAnchorsPrivate::checkVValid() const
-{
- if (usedAnchors & QmlGraphicsAnchors::HasTopAnchor &&
- usedAnchors & QmlGraphicsAnchors::HasBottomAnchor &&
- usedAnchors & QmlGraphicsAnchors::HasVCenterAnchor) {
- qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot specify top, bottom, and vcenter anchors.");
- return false;
- } else if (usedAnchors & QmlGraphicsAnchors::HasBaselineAnchor &&
- (usedAnchors & QmlGraphicsAnchors::HasTopAnchor ||
- usedAnchors & QmlGraphicsAnchors::HasBottomAnchor ||
- usedAnchors & QmlGraphicsAnchors::HasVCenterAnchor)) {
- qmlInfo(item) << QmlGraphicsAnchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.");
- return false;
- }
-
- return true;
-}
-
-bool QmlGraphicsAnchorsPrivate::checkVAnchorValid(QmlGraphicsAnchorLine anchor) const
-{
- if (!anchor.item) {
- qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to a null item.");
- return false;
- } else if (anchor.anchorLine & QmlGraphicsAnchorLine::Horizontal_Mask) {
- qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor a vertical edge to a horizontal edge.");
- return false;
- } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){
- qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
- return false;
- } else if (anchor.item == item){
- qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor item to self.");
- return false;
- }
-
- return true;
-}
-
-#include <moc_qmlgraphicsanchors_p.cpp>
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p.h
deleted file mode 100644
index 41911ff..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsanchors_p.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSANCHORS_H
-#define QMLGRAPHICSANCHORS_H
-
-#include "qmlgraphicsitem.h"
-
-#include <qml.h>
-
-#include <QtCore/QObject>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsAnchorsPrivate;
-class QmlGraphicsAnchorLine;
-class Q_DECLARATIVE_EXPORT QmlGraphicsAnchors : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QmlGraphicsAnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged)
- Q_PROPERTY(QmlGraphicsAnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged)
- Q_PROPERTY(QmlGraphicsAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged)
- Q_PROPERTY(QmlGraphicsAnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged)
- Q_PROPERTY(QmlGraphicsAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged)
- Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged)
- Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged)
- Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged)
- Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
- Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
- Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged())
- Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
- Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
- Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged())
- Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())
- Q_PROPERTY(QmlGraphicsItem *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged)
- Q_PROPERTY(QmlGraphicsItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
-
-public:
- QmlGraphicsAnchors(QObject *parent=0);
- QmlGraphicsAnchors(QmlGraphicsItem *item, QObject *parent=0);
- virtual ~QmlGraphicsAnchors();
-
- enum UsedAnchor {
- HasLeftAnchor = 0x01,
- HasRightAnchor = 0x02,
- HasTopAnchor = 0x04,
- HasBottomAnchor = 0x08,
- HasHCenterAnchor = 0x10,
- HasVCenterAnchor = 0x20,
- HasBaselineAnchor = 0x40,
- Horizontal_Mask = HasLeftAnchor | HasRightAnchor | HasHCenterAnchor,
- Vertical_Mask = HasTopAnchor | HasBottomAnchor | HasVCenterAnchor | HasBaselineAnchor
- };
- Q_DECLARE_FLAGS(UsedAnchors, UsedAnchor)
-
- QmlGraphicsAnchorLine left() const;
- void setLeft(const QmlGraphicsAnchorLine &edge);
- void resetLeft();
-
- QmlGraphicsAnchorLine right() const;
- void setRight(const QmlGraphicsAnchorLine &edge);
- void resetRight();
-
- QmlGraphicsAnchorLine horizontalCenter() const;
- void setHorizontalCenter(const QmlGraphicsAnchorLine &edge);
- void resetHorizontalCenter();
-
- QmlGraphicsAnchorLine top() const;
- void setTop(const QmlGraphicsAnchorLine &edge);
- void resetTop();
-
- QmlGraphicsAnchorLine bottom() const;
- void setBottom(const QmlGraphicsAnchorLine &edge);
- void resetBottom();
-
- QmlGraphicsAnchorLine verticalCenter() const;
- void setVerticalCenter(const QmlGraphicsAnchorLine &edge);
- void resetVerticalCenter();
-
- QmlGraphicsAnchorLine baseline() const;
- void setBaseline(const QmlGraphicsAnchorLine &edge);
- void resetBaseline();
-
- qreal leftMargin() const;
- void setLeftMargin(qreal);
-
- qreal rightMargin() const;
- void setRightMargin(qreal);
-
- qreal horizontalCenterOffset() const;
- void setHorizontalCenterOffset(qreal);
-
- qreal topMargin() const;
- void setTopMargin(qreal);
-
- qreal bottomMargin() const;
- void setBottomMargin(qreal);
-
- qreal margins() const;
- void setMargins(qreal);
-
- qreal verticalCenterOffset() const;
- void setVerticalCenterOffset(qreal);
-
- qreal baselineOffset() const;
- void setBaselineOffset(qreal);
-
- QmlGraphicsItem *fill() const;
- void setFill(QmlGraphicsItem *);
- void resetFill();
-
- QmlGraphicsItem *centerIn() const;
- void setCenterIn(QmlGraphicsItem *);
- void resetCenterIn();
-
- UsedAnchors usedAnchors() const;
-
- void classBegin();
- void componentComplete();
-
-Q_SIGNALS:
- void leftChanged();
- void rightChanged();
- void topChanged();
- void bottomChanged();
- void verticalCenterChanged();
- void horizontalCenterChanged();
- void baselineChanged();
- void fillChanged();
- void centerInChanged();
- void leftMarginChanged();
- void rightMarginChanged();
- void topMarginChanged();
- void bottomMarginChanged();
- void marginsChanged();
- void verticalCenterOffsetChanged();
- void horizontalCenterOffsetChanged();
- void baselineOffsetChanged();
-
-private:
- friend class QmlGraphicsItem;
- Q_DISABLE_COPY(QmlGraphicsAnchors)
- Q_DECLARE_PRIVATE(QmlGraphicsAnchors)
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QmlGraphicsAnchors::UsedAnchors)
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsAnchors)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
deleted file mode 100644
index a2e41d3..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSANCHORS_P_H
-#define QMLGRAPHICSANCHORS_P_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 "qmlgraphicsanchors_p.h"
-#include "qmlgraphicsitemchangelistener_p.h"
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsAnchorLine
-{
-public:
- QmlGraphicsAnchorLine() : item(0), anchorLine(Invalid)
- {
- }
-
- enum AnchorLine {
- Invalid = 0x0,
- Left = 0x01,
- Right = 0x02,
- Top = 0x04,
- Bottom = 0x08,
- HCenter = 0x10,
- VCenter = 0x20,
- Baseline = 0x40,
- Horizontal_Mask = Left | Right | HCenter,
- Vertical_Mask = Top | Bottom | VCenter | Baseline
- };
-
- QmlGraphicsItem *item;
- AnchorLine anchorLine;
-
- bool operator==(const QmlGraphicsAnchorLine& other) const
- {
- return item == other.item && anchorLine == other.anchorLine;
- }
-};
-
-class QmlGraphicsAnchorsPrivate : public QObjectPrivate, public QmlGraphicsItemChangeListener
-{
- Q_DECLARE_PUBLIC(QmlGraphicsAnchors)
-public:
- QmlGraphicsAnchorsPrivate(QmlGraphicsItem *i)
- : updatingMe(false), updatingHorizontalAnchor(0),
- updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(i), usedAnchors(0), fill(0),
- centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
- margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0),
- componentComplete(true)
- {
- }
-
- void init()
- {
- }
-
- void clearItem(QmlGraphicsItem *);
-
- void addDepend(QmlGraphicsItem *);
- void remDepend(QmlGraphicsItem *);
- bool isItemComplete() const;
-
- bool updatingMe;
- int updatingHorizontalAnchor;
- int updatingVerticalAnchor;
- int updatingFill;
- int updatingCenterIn;
-
- void setItemHeight(qreal);
- void setItemWidth(qreal);
- void setItemX(qreal);
- void setItemY(qreal);
- void setItemPos(const QPointF &);
-
- void updateOnComplete();
- void updateMe();
-
- // QmlGraphicsItemGeometryListener interface
- void itemGeometryChanged(QmlGraphicsItem *, const QRectF &, const QRectF &);
- QmlGraphicsAnchorsPrivate *anchorPrivate() { return this; }
-
- bool checkHValid() const;
- bool checkVValid() const;
- bool checkHAnchorValid(QmlGraphicsAnchorLine anchor) const;
- bool checkVAnchorValid(QmlGraphicsAnchorLine anchor) const;
- bool calcStretch(const QmlGraphicsAnchorLine &edge1, const QmlGraphicsAnchorLine &edge2, int offset1, int offset2, QmlGraphicsAnchorLine::AnchorLine line, int &stretch);
-
- void updateHorizontalAnchors();
- void updateVerticalAnchors();
- void fillChanged();
- void centerInChanged();
-
- QmlGraphicsItem *item;
- QmlGraphicsAnchors::UsedAnchors usedAnchors;
-
- QmlGraphicsItem *fill;
- QmlGraphicsItem *centerIn;
-
- QmlGraphicsAnchorLine left;
- QmlGraphicsAnchorLine right;
- QmlGraphicsAnchorLine top;
- QmlGraphicsAnchorLine bottom;
- QmlGraphicsAnchorLine vCenter;
- QmlGraphicsAnchorLine hCenter;
- QmlGraphicsAnchorLine baseline;
-
- qreal leftMargin;
- qreal rightMargin;
- qreal topMargin;
- qreal bottomMargin;
- qreal margins;
- qreal vCenterOffset;
- qreal hCenterOffset;
- qreal baselineOffset;
-
- bool componentComplete;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QmlGraphicsAnchorLine)
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
deleted file mode 100644
index 4dea33c..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsanimatedimage_p.h"
-#include "qmlgraphicsanimatedimage_p_p.h"
-
-#include <qmlengine.h>
-
-#include <QMovie>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlGraphicsAnimatedImage
- \internal
-*/
-
-/*!
- \qmlclass AnimatedImage QmlGraphicsAnimatedImage
- \inherits Image
- \since 4.7
-
- This item provides for playing animations stored as images containing a series of frames,
- such as GIF files. The full list of supported formats can be determined with
- QMovie::supportedFormats().
-
- \table
- \row
- \o \image animatedimageitem.gif
- \o
- \qml
-Item {
- width: anim.width; height: anim.height+8
- AnimatedImage { id: anim; source: "pics/games-anim.gif" }
- Rectangle { color: "red"; width: 4; height: 8; y: anim.height
- x: (anim.width-width)*anim.currentFrame/(anim.frameCount-1)
- }
-}
- \endqml
- \endtable
-*/
-
-QmlGraphicsAnimatedImage::QmlGraphicsAnimatedImage(QmlGraphicsItem *parent)
- : QmlGraphicsImage(*(new QmlGraphicsAnimatedImagePrivate), parent)
-{
-}
-
-QmlGraphicsAnimatedImage::~QmlGraphicsAnimatedImage()
-{
- Q_D(QmlGraphicsAnimatedImage);
- delete d->_movie;
-}
-
-/*!
- \qmlproperty bool AnimatedImage::paused
- This property holds whether the animated image is paused or not
-
- Defaults to false, and can be set to true when you want to pause.
-*/
-bool QmlGraphicsAnimatedImage::isPaused() const
-{
- Q_D(const QmlGraphicsAnimatedImage);
- if(!d->_movie)
- return false;
- return d->_movie->state()==QMovie::Paused;
-}
-
-void QmlGraphicsAnimatedImage::setPaused(bool pause)
-{
- Q_D(QmlGraphicsAnimatedImage);
- if(pause == d->paused)
- return;
- d->paused = pause;
- if(!d->_movie)
- return;
- d->_movie->setPaused(pause);
-}
-/*!
- \qmlproperty bool AnimatedImage::playing
- This property holds whether the animated image is playing or not
-
- Defaults to true, so as to start playing immediately.
-*/
-bool QmlGraphicsAnimatedImage::isPlaying() const
-{
- Q_D(const QmlGraphicsAnimatedImage);
- if (!d->_movie)
- return false;
- return d->_movie->state()!=QMovie::NotRunning;
-}
-
-void QmlGraphicsAnimatedImage::setPlaying(bool play)
-{
- Q_D(QmlGraphicsAnimatedImage);
- if(play == d->playing)
- return;
- d->playing = play;
- if (!d->_movie)
- return;
- if (play)
- d->_movie->start();
- else
- d->_movie->stop();
-}
-
-/*!
- \qmlproperty int AnimatedImage::currentFrame
- \qmlproperty int AnimatedImage::frameCount
-
- currentFrame is the frame that is currently visible. Watching when this changes can
- allow other things to animate at the same time as the image. frameCount is the number
- of frames in the animation. For some animation formats, frameCount is unknown and set to zero.
-*/
-int QmlGraphicsAnimatedImage::currentFrame() const
-{
- Q_D(const QmlGraphicsAnimatedImage);
- if (!d->_movie)
- return d->preset_currentframe;
- return d->_movie->currentFrameNumber();
-}
-
-void QmlGraphicsAnimatedImage::setCurrentFrame(int frame)
-{
- Q_D(QmlGraphicsAnimatedImage);
- if (!d->_movie) {
- d->preset_currentframe = frame;
- return;
- }
- d->_movie->jumpToFrame(frame);
-}
-
-int QmlGraphicsAnimatedImage::frameCount() const
-{
- Q_D(const QmlGraphicsAnimatedImage);
- if (!d->_movie)
- return 0;
- return d->_movie->frameCount();
-}
-
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
-void QmlGraphicsAnimatedImage::setSource(const QUrl &url)
-{
- Q_D(QmlGraphicsAnimatedImage);
- if (url == d->url)
- return;
-
- delete d->_movie;
- d->_movie = 0;
-
- if (d->reply) {
- d->reply->deleteLater();
- d->reply = 0;
- }
-
- d->url = url;
-
- if (url.isEmpty()) {
- delete d->_movie;
- d->status = Null;
- } else {
-#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = toLocalFileOrQrc(url);
- if (!lf.isEmpty()) {
- //### should be unified with movieRequestFinished
- d->_movie = new QMovie(lf);
- if (!d->_movie->isValid()){
- qWarning() << "Error Reading Animated Image File" << d->url;
- delete d->_movie;
- d->_movie = 0;
- return;
- }
- connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
- this, SLOT(playingStatusChanged()));
- connect(d->_movie, SIGNAL(frameChanged(int)),
- this, SLOT(movieUpdate()));
- d->_movie->setCacheMode(QMovie::CacheAll);
- if(d->playing)
- d->_movie->start();
- else
- d->_movie->jumpToFrame(0);
- if(d->paused)
- d->_movie->setPaused(true);
- d->setPixmap(d->_movie->currentPixmap());
- d->status = Ready;
- d->progress = 1.0;
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit progressChanged(d->progress);
- return;
- }
-#endif
- d->status = Loading;
- QNetworkRequest req(d->url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- d->reply = qmlEngine(this)->networkAccessManager()->get(req);
- QObject::connect(d->reply, SIGNAL(finished()),
- this, SLOT(movieRequestFinished()));
- }
-
- emit statusChanged(d->status);
-}
-
-void QmlGraphicsAnimatedImage::movieRequestFinished()
-{
- Q_D(QmlGraphicsAnimatedImage);
- d->_movie = new QMovie(d->reply);
- if (!d->_movie->isValid()){
- qWarning() << "Error Reading Animated Image File " << d->url;
- delete d->_movie;
- d->_movie = 0;
- return;
- }
- connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
- this, SLOT(playingStatusChanged()));
- connect(d->_movie, SIGNAL(frameChanged(int)),
- this, SLOT(movieUpdate()));
- d->_movie->setCacheMode(QMovie::CacheAll);
- if(d->playing)
- d->_movie->start();
- if (d->paused || !d->playing) {
- d->_movie->jumpToFrame(d->preset_currentframe);
- d->preset_currentframe = 0;
- }
- if(d->paused)
- d->_movie->setPaused(true);
- d->setPixmap(d->_movie->currentPixmap());
-}
-
-void QmlGraphicsAnimatedImage::movieUpdate()
-{
- Q_D(QmlGraphicsAnimatedImage);
- d->setPixmap(d->_movie->currentPixmap());
- emit frameChanged();
-}
-
-void QmlGraphicsAnimatedImage::playingStatusChanged()
-{
- Q_D(QmlGraphicsAnimatedImage);
- if((d->_movie->state() != QMovie::NotRunning) != d->playing){
- d->playing = (d->_movie->state() != QMovie::NotRunning);
- emit playingChanged();
- }
- if((d->_movie->state() == QMovie::Paused) != d->paused){
- d->playing = (d->_movie->state() == QMovie::Paused);
- emit pausedChanged();
- }
-}
-
-void QmlGraphicsAnimatedImage::componentComplete()
-{
- Q_D(QmlGraphicsAnimatedImage);
- QmlGraphicsImage::componentComplete();
- if (!d->reply) {
- setCurrentFrame(d->preset_currentframe);
- d->preset_currentframe = 0;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p.h b/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p.h
deleted file mode 100644
index a6cee0d..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSANIMATEDIMAGE_H
-#define QMLGRAPHICSANIMATEDIMAGE_H
-
-#include "qmlgraphicsimage_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QMovie;
-class QmlGraphicsAnimatedImagePrivate;
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsAnimatedImage : public QmlGraphicsImage
-{
- Q_OBJECT
-
- Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
- Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
- Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged)
- Q_PROPERTY(int frameCount READ frameCount)
-public:
- QmlGraphicsAnimatedImage(QmlGraphicsItem *parent=0);
- ~QmlGraphicsAnimatedImage();
-
- bool isPlaying() const;
- void setPlaying(bool play);
-
- bool isPaused() const;
- void setPaused(bool pause);
-
- int currentFrame() const;
- void setCurrentFrame(int frame);
-
- int frameCount() const;
-
- // Extends QmlGraphicsImage's src property*/
- virtual void setSource(const QUrl&);
-
-Q_SIGNALS:
- void playingChanged();
- void pausedChanged();
- void frameChanged();
-
-private Q_SLOTS:
- void movieUpdate();
- void movieRequestFinished();
- void playingStatusChanged();
-
-protected:
- void componentComplete();
-
-private:
- Q_DISABLE_COPY(QmlGraphicsAnimatedImage)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsAnimatedImage)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsAnimatedImage)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p_p.h
deleted file mode 100644
index 5e04a93..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p_p.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSANIMATEDIMAGE_P_H
-#define QMLGRAPHICSANIMATEDIMAGE_P_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 "qmlgraphicsimage_p_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QMovie;
-class QNetworkReply;
-
-class QmlGraphicsAnimatedImagePrivate : public QmlGraphicsImagePrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsAnimatedImage)
-
-public:
- QmlGraphicsAnimatedImagePrivate()
- : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0)
- {
- }
-
- bool playing;
- bool paused;
- int preset_currentframe;
- QMovie *_movie;
- QNetworkReply *reply;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLGRAPHICSANIMATEDIMAGE_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
deleted file mode 100644
index 25a220f..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
+++ /dev/null
@@ -1,408 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsborderimage_p.h"
-#include "qmlgraphicsborderimage_p_p.h"
-
-#include <qmlengine.h>
-
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QFile>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass BorderImage QmlGraphicsBorderImage
- \brief The BorderImage element provides an image that can be used as a border.
- \inherits Item
- \since 4.7
-
- \snippet snippets/declarative/border-image.qml 0
-
- \image BorderImage.png
- */
-
-/*!
- \class QmlGraphicsBorderImage BorderImage
- \internal
- \brief The QmlGraphicsBorderImage class provides an image item that you can add to a QmlView.
-*/
-
-QmlGraphicsBorderImage::QmlGraphicsBorderImage(QmlGraphicsItem *parent)
- : QmlGraphicsImageBase(*(new QmlGraphicsBorderImagePrivate), parent)
-{
-}
-
-QmlGraphicsBorderImage::~QmlGraphicsBorderImage()
-{
- Q_D(QmlGraphicsBorderImage);
- if (d->sciReply)
- d->sciReply->deleteLater();
- if (d->sciPendingPixmapCache)
- QmlPixmapCache::cancel(d->sciurl, this);
-}
-/*!
- \qmlproperty enum BorderImage::status
-
- This property holds the status of image loading. It can be one of:
- \list
- \o Null - no image has been set
- \o Ready - the image has been loaded
- \o Loading - the image is currently being loaded
- \o Error - an error occurred while loading the image
- \endlist
-
- \sa progress
-*/
-
-/*!
- \qmlproperty real BorderImage::progress
-
- This property holds the progress of image loading, from 0.0 (nothing loaded)
- to 1.0 (finished).
-
- \sa status
-*/
-
-/*!
- \qmlproperty bool BorderImage::smooth
-
- Set this property if you want the image to be smoothly filtered when scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the image is displayed at its natural size, this property has no visual or
- performance effect.
-
- \note Generally scaling artifacts are only visible if the image is stationary on
- the screen. A common pattern when animating an image is to disable smooth
- filtering at the beginning of the animation and reenable it at the conclusion.
-*/
-
-/*!
- \qmlproperty url BorderImage::source
-
- BorderImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.
-
- It can also handle .sci files, which are a Qml-specific format. A .sci file uses a simple text-based format that specifies
- the borders, the image file and the tile rules.
-
- The following .sci file sets the borders to 10 on each side for the image \c picture.png:
- \qml
- border.left: 10
- border.top: 10
- border.bottom: 10
- border.right: 10
- source: picture.png
- \endqml
-
- The URL may be absolute, or relative to the URL of the component.
-*/
-
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
-
-void QmlGraphicsBorderImage::setSource(const QUrl &url)
-{
- Q_D(QmlGraphicsBorderImage);
- //equality is fairly expensive, so we bypass for simple, common case
- if ((d->url.isEmpty() == url.isEmpty()) && url == d->url)
- return;
-
- if (d->sciReply) {
- d->sciReply->deleteLater();
- d->sciReply = 0;
- }
-
- if (d->pendingPixmapCache) {
- QmlPixmapCache::cancel(d->url, this);
- d->pendingPixmapCache = false;
- }
- if (d->sciPendingPixmapCache) {
- QmlPixmapCache::cancel(d->sciurl, this);
- d->sciPendingPixmapCache = false;
- }
-
- d->url = url;
- d->sciurl = QUrl();
- if (d->progress != 0.0) {
- d->progress = 0.0;
- emit progressChanged(d->progress);
- }
-
- if (url.isEmpty()) {
- d->pix = QPixmap();
- d->status = Null;
- setImplicitWidth(0);
- setImplicitHeight(0);
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- update();
- } else {
- d->status = Loading;
- if (d->url.path().endsWith(QLatin1String(".sci"))) {
-#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = toLocalFileOrQrc(d->url);
- if (!lf.isEmpty()) {
- QFile file(lf);
- file.open(QIODevice::ReadOnly);
- setGridScaledImage(QmlGraphicsGridScaledImage(&file));
- } else
-#endif
- {
- QNetworkRequest req(d->url);
- d->sciReply = qmlEngine(this)->networkAccessManager()->get(req);
- QObject::connect(d->sciReply, SIGNAL(finished()),
- this, SLOT(sciRequestFinished()));
- }
- } else {
- QmlPixmapReply::Status status = QmlPixmapCache::get(d->url, &d->pix);
- if (status != QmlPixmapReply::Ready && status != QmlPixmapReply::Error) {
- QmlPixmapReply *reply = QmlPixmapCache::request(qmlEngine(this), d->url);
- d->pendingPixmapCache = true;
- connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
- connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(requestProgress(qint64,qint64)));
- } else {
- //### should be unified with requestFinished
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
-
- if (d->pix.isNull())
- d->status = Error;
- if (d->status == Loading)
- d->status = Ready;
- d->progress = 1.0;
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit progressChanged(d->progress);
- update();
- }
- }
- }
-
- emit statusChanged(d->status);
-}
-
-/*!
- \qmlproperty int BorderImage::border.left
- \qmlproperty int BorderImage::border.right
- \qmlproperty int BorderImage::border.top
- \qmlproperty int BorderImage::border.bottom
-
- \target ImagexmlpropertiesscaleGrid
-
- The 4 border lines (2 horizontal and 2 vertical) break an image into 9 sections, as shown below:
-
- \image declarative-scalegrid.png
-
- When the image is scaled:
- \list
- \i the corners (sections 1, 3, 7, and 9) are not scaled at all
- \i the middle (section 5) is scaled according to BorderImage::horizontalTileMode and BorderImage::verticalTileMode
- \i sections 2 and 8 are scaled according to BorderImage::horizontalTileMode
- \i sections 4 and 6 are scaled according to BorderImage::verticalTileMode
- \endlist
-
- Each border line (left, right, top, and bottom) specifies an offset from the respective side. For example, \c{border.bottom: 10} sets the bottom line 10 pixels up from the bottom of the image.
-
- The border lines can also be specified using a
- \l {BorderImage::source}{.sci file}.
-*/
-
-QmlGraphicsScaleGrid *QmlGraphicsBorderImage::border()
-{
- Q_D(QmlGraphicsBorderImage);
- return d->getScaleGrid();
-}
-
-/*!
- \qmlproperty TileMode BorderImage::horizontalTileMode
- \qmlproperty TileMode BorderImage::verticalTileMode
-
- This property describes how to repeat or stretch the middle parts of the border image.
-
- \list
- \o Stretch - Scale the image to fit to the available area.
- \o Repeat - Tile the image until there is no more space. May crop the last image.
- \o Round - Like Repeat, but scales the images down to ensure that the last image is not cropped.
- \endlist
-*/
-QmlGraphicsBorderImage::TileMode QmlGraphicsBorderImage::horizontalTileMode() const
-{
- Q_D(const QmlGraphicsBorderImage);
- return d->horizontalTileMode;
-}
-
-void QmlGraphicsBorderImage::setHorizontalTileMode(TileMode t)
-{
- Q_D(QmlGraphicsBorderImage);
- if (t != d->horizontalTileMode) {
- d->horizontalTileMode = t;
- emit horizontalTileModeChanged();
- update();
- }
-}
-
-QmlGraphicsBorderImage::TileMode QmlGraphicsBorderImage::verticalTileMode() const
-{
- Q_D(const QmlGraphicsBorderImage);
- return d->verticalTileMode;
-}
-
-void QmlGraphicsBorderImage::setVerticalTileMode(TileMode t)
-{
- Q_D(QmlGraphicsBorderImage);
- if (t != d->verticalTileMode) {
- d->verticalTileMode = t;
- emit verticalTileModeChanged();
- update();
- }
-}
-
-void QmlGraphicsBorderImage::setGridScaledImage(const QmlGraphicsGridScaledImage& sci)
-{
- Q_D(QmlGraphicsBorderImage);
- if (!sci.isValid()) {
- d->status = Error;
- emit statusChanged(d->status);
- } else {
- QmlGraphicsScaleGrid *sg = border();
- sg->setTop(sci.gridTop());
- sg->setBottom(sci.gridBottom());
- sg->setLeft(sci.gridLeft());
- sg->setRight(sci.gridRight());
- d->horizontalTileMode = sci.horizontalTileRule();
- d->verticalTileMode = sci.verticalTileRule();
-
- d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));
- QmlPixmapReply::Status status = QmlPixmapCache::get(d->sciurl, &d->pix);
- if (status != QmlPixmapReply::Ready && status != QmlPixmapReply::Error) {
- QmlPixmapReply *reply = QmlPixmapCache::request(qmlEngine(this), d->sciurl);
- d->sciPendingPixmapCache = true;
- connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
- connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(requestProgress(qint64,qint64)));
- } else {
- //### should be unified with requestFinished
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
-
- if (d->pix.isNull())
- d->status = Error;
- if (d->status == Loading)
- d->status = Ready;
- d->progress = 1.0;
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit progressChanged(1.0);
- update();
- }
- }
-}
-
-void QmlGraphicsBorderImage::requestFinished()
-{
- Q_D(QmlGraphicsBorderImage);
-
- if (d->url.path().endsWith(QLatin1String(".sci"))) {
- d->sciPendingPixmapCache = false;
- QmlPixmapCache::get(d->sciurl, &d->pix);
- } else {
- d->pendingPixmapCache = false;
- if (QmlPixmapCache::get(d->url, &d->pix) != QmlPixmapReply::Ready)
- d->status = Error;
- }
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
-
- if (d->status == Loading)
- d->status = Ready;
- d->progress = 1.0;
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit progressChanged(1.0);
- update();
-}
-
-void QmlGraphicsBorderImage::sciRequestFinished()
-{
- Q_D(QmlGraphicsBorderImage);
- if (d->sciReply->error() != QNetworkReply::NoError) {
- d->status = Error;
- d->sciReply->deleteLater();
- d->sciReply = 0;
- emit statusChanged(d->status);
- } else {
- QmlGraphicsGridScaledImage sci(d->sciReply);
- d->sciReply->deleteLater();
- d->sciReply = 0;
- setGridScaledImage(sci);
- }
-}
-
-void QmlGraphicsBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
-{
- Q_D(QmlGraphicsBorderImage);
- if (d->pix.isNull())
- return;
-
- bool oldAA = p->testRenderHint(QPainter::Antialiasing);
- bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
- if (d->smooth)
- p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
-
- const QmlGraphicsScaleGrid *border = d->getScaleGrid();
- QMargins margins(border->left(), border->top(), border->right(), border->bottom());
- QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode);
- qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, d->pix, d->pix.rect(), margins, rules);
- if (d->smooth) {
- p->setRenderHint(QPainter::Antialiasing, oldAA);
- p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage_p.h b/src/declarative/graphicsitems/qmlgraphicsborderimage_p.h
deleted file mode 100644
index 32dc388..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage_p.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSBORDERIMAGE_H
-#define QMLGRAPHICSBORDERIMAGE_H
-
-#include "qmlgraphicsimagebase_p.h"
-
-#include <QtNetwork/qnetworkreply.h>
-
-QT_BEGIN_HEADER
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsScaleGrid;
-class QmlGraphicsGridScaledImage;
-class QmlGraphicsBorderImagePrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsBorderImage : public QmlGraphicsImageBase
-{
- Q_OBJECT
- Q_ENUMS(TileMode)
-
- Q_PROPERTY(QmlGraphicsScaleGrid *border READ border CONSTANT)
- Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode NOTIFY horizontalTileModeChanged)
- Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged)
-
-public:
- QmlGraphicsBorderImage(QmlGraphicsItem *parent=0);
- ~QmlGraphicsBorderImage();
-
- QmlGraphicsScaleGrid *border();
-
- enum TileMode { Stretch = Qt::StretchTile, Repeat = Qt::RepeatTile, Round = Qt::RoundTile };
-
- TileMode horizontalTileMode() const;
- void setHorizontalTileMode(TileMode);
-
- TileMode verticalTileMode() const;
- void setVerticalTileMode(TileMode);
-
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
- void setSource(const QUrl &url);
-
-Q_SIGNALS:
- void horizontalTileModeChanged();
- void verticalTileModeChanged();
-
-private:
- void setGridScaledImage(const QmlGraphicsGridScaledImage& sci);
-
-private Q_SLOTS:
- void requestFinished();
- void sciRequestFinished();
-
-private:
- Q_DISABLE_COPY(QmlGraphicsBorderImage)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsBorderImage)
-};
-
-QT_END_NAMESPACE
-QML_DECLARE_TYPE(QmlGraphicsBorderImage)
-QT_END_HEADER
-
-#endif // QMLGRAPHICSBORDERIMAGE_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage_p_p.h b/src/declarative/graphicsitems/qmlgraphicsborderimage_p_p.h
deleted file mode 100644
index b97ae6d..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage_p_p.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSBORDERIMAGE_P_H
-#define QMLGRAPHICSBORDERIMAGE_P_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 "qmlgraphicsimagebase_p_p.h"
-#include "qmlgraphicsscalegrid_p_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkReply;
-class QmlGraphicsBorderImagePrivate : public QmlGraphicsImageBasePrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsBorderImage)
-
-public:
- QmlGraphicsBorderImagePrivate()
- : border(0), sciReply(0),
- sciPendingPixmapCache(false),
- horizontalTileMode(QmlGraphicsBorderImage::Stretch),
- verticalTileMode(QmlGraphicsBorderImage::Stretch)
- {
- }
-
- ~QmlGraphicsBorderImagePrivate()
- {
- }
-
- QmlGraphicsScaleGrid *getScaleGrid()
- {
- Q_Q(QmlGraphicsBorderImage);
- if (!border)
- border = new QmlGraphicsScaleGrid(q);
- return border;
- }
-
- QmlGraphicsScaleGrid *border;
- QUrl sciurl;
- QNetworkReply *sciReply;
- bool sciPendingPixmapCache;
- QmlGraphicsBorderImage::TileMode horizontalTileMode;
- QmlGraphicsBorderImage::TileMode verticalTileMode;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLGRAPHICSBORDERIMAGE_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicseffects.cpp b/src/declarative/graphicsitems/qmlgraphicseffects.cpp
deleted file mode 100644
index 6a93b12..0000000
--- a/src/declarative/graphicsitems/qmlgraphicseffects.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qml.h>
-
-#include <QtGui/qgraphicseffect.h>
-
-/*!
- \qmlclass Blur QGraphicsBlurEffect
- \brief The Blur object provides a blur effect.
-
- A blur effect blurs the source item. This effect is useful for reducing details;
- for example, when the a source loses focus and attention should be drawn to other
- elements. Use blurRadius to control the level of detail and blurHint to control
- the quality of the blur.
-
- By default, the blur radius is 5 pixels.
-
- \img graphicseffect-blur.png
-*/
-
-/*!
- \qmlproperty real Blur::blurRadius
-
- This controls how blurry an item will appear.
-
- A smaller radius produces a sharper appearance, and a larger radius produces
- a more blurred appearance.
-
- The default radius is 5 pixels.
-*/
-/*!
- \qmlproperty enumeration Blur::blurHint
-
- Use Qt.PerformanceHint to specify a faster blur or Qt.QualityHint hint
- to specify a higher quality blur.
-
- If the blur radius is animated, it is recommended you use Qt.PerformanceHint.
-
- The default hint is Qt.PerformanceHint.
-*/
-
-/*!
- \qmlclass Colorize QGraphicsColorizeEffect
- \brief The Colorize object provides a colorize effect.
-
- A colorize effect renders the source item with a tint of its color.
-
- By default, the color is light blue.
-
- \img graphicseffect-colorize.png
-*/
-
-/*!
- \qmlproperty color Colorize::color
- The color of the effect.
-
- By default, the color is light blue.
-*/
-
-/*!
- \qmlproperty real Colorize::strength
-
- To what extent the source item is "colored". A strength of 0.0 is equal to no effect,
- while 1.0 means full colorization. By default, the strength is 1.0.
-*/
-
-
-/*!
- \qmlclass DropShadow QGraphicsDropShadowEffect
- \brief The DropShadow object provides a drop shadow effect.
-
- A drop shadow effect renders the source item with a drop shadow. The color of
- the drop shadow can be modified using the color property. The drop
- shadow offset can be modified using the xOffset and yOffset properties and the blur
- radius of the drop shadow can be changed with the blurRadius property.
-
- By default, the drop shadow is a semi-transparent dark gray shadow,
- blurred with a radius of 1 at an offset of 8 pixels towards the lower right.
-
- \img graphicseffect-drop-shadow.png
-*/
-
-/*!
- \qmlproperty real DropShadow::xOffset
- \qmlproperty real DropShadow::yOffset
- The shadow offset in pixels.
-
- By default, xOffset and yOffset are 8 pixels.
-*/
-
-/*!
- \qmlproperty real DropShadow::blurRadius
- The blur radius in pixels of the drop shadow.
-
- Using a smaller radius results in a sharper shadow, whereas using a bigger
- radius results in a more blurred shadow.
-
- By default, the blur radius is 1 pixel.
-*/
-
-/*!
- \qmlproperty color DropShadow::color
- The color of the drop shadow.
-
- By default, the drop color is a semi-transparent dark gray.
-*/
-
-
-/*!
- \qmlclass Opacity QGraphicsOpacityEffect
- \brief The Opacity object provides an opacity effect.
-
- An opacity effect renders the source with an opacity. This effect is useful
- for making the source semi-transparent, similar to a fade-in/fade-out
- sequence. The opacity can be modified using the opacity property.
-
- By default, the opacity is 0.7.
-
- \img graphicseffect-opacity.png
-*/
-
-/*!
- \qmlproperty real Opacity::opacity
- This property specifies how opaque an item should appear.
-
- The value should be in the range of 0.0 to 1.0, where 0.0 is
- fully transparent and 1.0 is fully opaque.
-
- By default, the opacity is 0.7.
-*/
-
diff --git a/src/declarative/graphicsitems/qmlgraphicseffects_p.h b/src/declarative/graphicsitems/qmlgraphicseffects_p.h
deleted file mode 100644
index 4b94a14..0000000
--- a/src/declarative/graphicsitems/qmlgraphicseffects_p.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSEFFECTS_P_H
-#define QMLGRAPHICSEFFECTS_P_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 <qml.h>
-#include <QtGui/qgraphicseffect.h>
-
-QML_DECLARE_TYPE(QGraphicsEffect)
-QML_DECLARE_TYPE(QGraphicsBlurEffect)
-QML_DECLARE_TYPE(QGraphicsColorizeEffect)
-QML_DECLARE_TYPE(QGraphicsDropShadowEffect)
-QML_DECLARE_TYPE(QGraphicsOpacityEffect)
-
-#endif // QMLGRAPHICSEFFECTS_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsevents.cpp b/src/declarative/graphicsitems/qmlgraphicsevents.cpp
deleted file mode 100644
index e8ba885..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsevents.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsevents_p_p.h"
-
-QT_BEGIN_NAMESPACE
-/*!
- \qmlclass KeyEvent QmlGraphicsKeyEvent
- \since 4.7
- \brief The KeyEvent object provides information about a key event.
-
- For example, the following changes the Item's state property when the Enter
- key is pressed:
- \qml
-Item {
- focus: true
- Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
-}
- \endqml
-*/
-
-/*!
- \internal
- \class QmlGraphicsKeyEvent
-*/
-
-/*!
- \qmlproperty int KeyEvent::key
-
- This property holds the code of the key that was pressed or released.
-
- See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. These codes are
- independent of the underlying window system. Note that this
- function does not distinguish between capital and non-capital
- letters, use the text() function (returning the Unicode text the
- key generated) for this purpose.
-
- A value of either 0 or \l {Qt::Key_unknown}{Qt.Key_Unknown} means that the event is not
- the result of a known key; for example, it may be the result of
- a compose sequence, a keyboard macro, or due to key event
- compression.
-*/
-
-/*!
- \qmlproperty string KeyEvent::text
-
- This property holds the Unicode text that the key generated.
- The text returned can be an empty string in cases where modifier keys,
- such as Shift, Control, Alt, and Meta, are being pressed or released.
- In such cases \c key will contain a valid value
-*/
-
-/*!
- \qmlproperty bool KeyEvent::isAutoRepeat
-
- This property holds whether this event comes from an auto-repeating key.
-*/
-
-/*!
- \qmlproperty int KeyEvent::count
-
- This property holds the number of keys involved in this event. If \l KeyEvent::text
- is not empty, this is simply the length of the string.
-*/
-
-/*!
- \qmlproperty bool KeyEvent::accepted
-
- Setting \a accepted to true prevents the key event from being
- propagated to the item's parent.
-
- Generally, if the item acts on the key event then it should be accepted
- so that ancestor items do not also respond to the same event.
-*/
-
-
-/*!
- \qmlclass MouseEvent QmlGraphicsMouseEvent
- \brief The MouseEvent object provides information about a mouse event.
-
- The position of the mouse can be found via the x and y properties.
- The button that caused the event is available via the button property.
-*/
-
-/*!
- \internal
- \class QmlGraphicsMouseEvent
-*/
-
-/*!
- \qmlproperty int MouseEvent::x
- \qmlproperty int MouseEvent::y
-
- These properties hold the position of the mouse event.
-*/
-
-/*!
- \qmlproperty enum MouseEvent::button
-
- This property holds the button that caused the event. It can be one of:
- \list
- \o Qt.LeftButton
- \o Qt.RightButton
- \o Qt.MidButton
- \endlist
-*/
-
-/*!
- \qmlproperty bool MouseEvent::wasHeld
-
- This property is true if the mouse button has been held pressed longer the
- threshold (800ms).
-*/
-
-/*!
- \qmlproperty int MouseEvent::buttons
-
- This property holds the mouse buttons pressed when the event was generated.
- For mouse move events, this is all buttons that are pressed down. For mouse
- press and double click events this includes the button that caused the event.
- For mouse release events this excludes the button that caused the event.
-
- It contains a bitwise combination of:
- \list
- \o Qt.LeftButton
- \o Qt.RightButton
- \o Qt.MidButton
- \endlist
-*/
-
-/*!
- \qmlproperty int MouseEvent::modifiers
-
- This property holds the keyboard modifier flags that existed immediately
- before the event occurred.
-
- It contains a bitwise combination of:
- \list
- \o Qt.NoModifier - No modifier key is pressed.
- \o Qt.ShiftModifier - A Shift key on the keyboard is pressed.
- \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
- \o Qt.AltModifier - An Alt key on the keyboard is pressed.
- \o Qt.MetaModifier - A Meta key on the keyboard is pressed.
- \o Qt.KeypadModifier - A keypad button is pressed.
- \endlist
-
- For example, to react to a Shift key + Left mouse button click:
- \qml
-MouseArea {
- onClicked: { if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) doSomething(); }
-}
- \endqml
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsevents_p_p.h b/src/declarative/graphicsitems/qmlgraphicsevents_p_p.h
deleted file mode 100644
index 0ed852a..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsevents_p_p.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSEVENTS_P_H
-#define QMLGRAPHICSEVENTS_P_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 <qml.h>
-
-#include <QtCore/qobject.h>
-#include <QtGui/qevent.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsKeyEvent : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int key READ key)
- Q_PROPERTY(QString text READ text)
- Q_PROPERTY(int modifiers READ modifiers)
- Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat)
- Q_PROPERTY(int count READ count)
- Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
-
-public:
- QmlGraphicsKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
- : event(type, key, modifiers, text, autorep, count) { event.setAccepted(false); }
- QmlGraphicsKeyEvent(const QKeyEvent &ke)
- : event(ke) { event.setAccepted(false); }
-
- int key() const { return event.key(); }
- QString text() const { return event.text(); }
- int modifiers() const { return event.modifiers(); }
- bool isAutoRepeat() const { return event.isAutoRepeat(); }
- int count() const { return event.count(); }
-
- bool isAccepted() { return event.isAccepted(); }
- void setAccepted(bool accepted) { event.setAccepted(accepted); }
-
-private:
- QKeyEvent event;
-};
-
-class QmlGraphicsMouseEvent : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int x READ x)
- Q_PROPERTY(int y READ y)
- Q_PROPERTY(int button READ button)
- Q_PROPERTY(int buttons READ buttons)
- Q_PROPERTY(int modifiers READ modifiers)
- Q_PROPERTY(bool wasHeld READ wasHeld)
- Q_PROPERTY(bool isClick READ isClick)
- Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
-
-public:
- QmlGraphicsMouseEvent(int x, int y, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers
- , bool isClick=false, bool wasHeld=false)
- : _x(x), _y(y), _button(button), _buttons(buttons), _modifiers(modifiers)
- , _wasHeld(wasHeld), _isClick(isClick), _accepted(true) {}
-
- int x() const { return _x; }
- int y() const { return _y; }
- int button() const { return _button; }
- int buttons() const { return _buttons; }
- int modifiers() const { return _modifiers; }
- bool wasHeld() const { return _wasHeld; }
- bool isClick() const { return _isClick; }
-
- bool isAccepted() { return _accepted; }
- void setAccepted(bool accepted) { _accepted = accepted; }
-
-private:
- int _x;
- int _y;
- Qt::MouseButton _button;
- Qt::MouseButtons _buttons;
- Qt::KeyboardModifiers _modifiers;
- bool _wasHeld;
- bool _isClick;
- bool _accepted;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsKeyEvent)
-QML_DECLARE_TYPE(QmlGraphicsMouseEvent)
-
-#endif // QMLGRAPHICSEVENTS_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
deleted file mode 100644
index e92fea4..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ /dev/null
@@ -1,1324 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsflickable_p.h"
-#include "qmlgraphicsflickable_p_p.h"
-
-#include <QGraphicsSceneMouseEvent>
-#include <QPointer>
-#include <QTimer>
-
-QT_BEGIN_NAMESPACE
-
-
-// FlickThreshold determines how far the "mouse" must have moved
-// before we perform a flick.
-static const int FlickThreshold = 20;
-
-// Really slow flicks can be annoying.
-static const int minimumFlickVelocity = 200;
-
-QmlGraphicsFlickableVisibleArea::QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent)
- : QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.)
- , m_yPosition(0.), m_heightRatio(0.)
-{
-}
-
-qreal QmlGraphicsFlickableVisibleArea::widthRatio() const
-{
- return m_widthRatio;
-}
-
-qreal QmlGraphicsFlickableVisibleArea::xPosition() const
-{
- return m_xPosition;
-}
-
-qreal QmlGraphicsFlickableVisibleArea::heightRatio() const
-{
- return m_heightRatio;
-}
-
-qreal QmlGraphicsFlickableVisibleArea::yPosition() const
-{
- return m_yPosition;
-}
-
-void QmlGraphicsFlickableVisibleArea::updateVisible()
-{
- QmlGraphicsFlickablePrivate *p = static_cast<QmlGraphicsFlickablePrivate *>(QGraphicsItemPrivate::get(flickable));
- bool pageChange = false;
-
- // Vertical
- const qreal viewheight = flickable->height();
- const qreal maxyextent = -flickable->maxYExtent() + flickable->minYExtent();
- qreal pagePos = (-p->_moveY.value() + flickable->minYExtent()) / (maxyextent + viewheight);
- qreal pageSize = viewheight / (maxyextent + viewheight);
-
- if (pageSize != m_heightRatio) {
- m_heightRatio = pageSize;
- pageChange = true;
- }
- if (pagePos != m_yPosition) {
- m_yPosition = pagePos;
- pageChange = true;
- }
-
- // Horizontal
- const qreal viewwidth = flickable->width();
- const qreal maxxextent = -flickable->maxXExtent() + flickable->minXExtent();
- pagePos = (-p->_moveX.value() + flickable->minXExtent()) / (maxxextent + viewwidth);
- pageSize = viewwidth / (maxxextent + viewwidth);
-
- if (pageSize != m_widthRatio) {
- m_widthRatio = pageSize;
- pageChange = true;
- }
- if (pagePos != m_xPosition) {
- m_xPosition = pagePos;
- pageChange = true;
- }
- if (pageChange)
- emit pageChanged();
-}
-
-
-QmlGraphicsFlickablePrivate::QmlGraphicsFlickablePrivate()
- : viewport(new QmlGraphicsItem)
- , _moveX(this, &QmlGraphicsFlickablePrivate::setRoundedViewportX)
- , _moveY(this, &QmlGraphicsFlickablePrivate::setRoundedViewportY)
- , vWidth(-1), vHeight(-1), overShoot(true), flicked(false), moving(false), stealMouse(false)
- , pressed(false), atXEnd(false), atXBeginning(true), atYEnd(false), atYBeginning(true)
- , interactive(true), deceleration(500), maxVelocity(2000), reportedVelocitySmoothing(100)
- , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(200)
- , horizontalVelocity(this), verticalVelocity(this), vTime(0), visibleArea(0)
- , flickDirection(QmlGraphicsFlickable::AutoFlickDirection)
-{
-}
-
-void QmlGraphicsFlickablePrivate::init()
-{
- Q_Q(QmlGraphicsFlickable);
- viewport->setParent(q);
- QObject::connect(&timeline, SIGNAL(updated()), q, SLOT(ticked()));
- QObject::connect(&timeline, SIGNAL(completed()), q, SLOT(movementEnding()));
- q->setAcceptedMouseButtons(Qt::LeftButton);
- q->setFiltersChildEvents(true);
- QObject::connect(viewport, SIGNAL(xChanged()), q, SIGNAL(positionXChanged()));
- QObject::connect(viewport, SIGNAL(yChanged()), q, SIGNAL(positionYChanged()));
- QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange()));
- QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(widthChange()));
-}
-
-void QmlGraphicsFlickablePrivate::flickX(qreal velocity)
-{
- Q_Q(QmlGraphicsFlickable);
- qreal maxDistance = -1;
- // -ve velocity means list is moving up
- if (velocity > 0) {
- const qreal minX = q->minXExtent();
- if (_moveX.value() < minX)
- maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0));
- flickTargetX = minX;
- } else {
- const qreal maxX = q->maxXExtent();
- if (_moveX.value() > maxX)
- maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0);
- flickTargetX = maxX;
- }
- if (maxDistance > 0) {
- qreal v = velocity;
- if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
- if (v < 0)
- v = -maxVelocity;
- else
- v = maxVelocity;
- }
- timeline.reset(_moveX);
- timeline.accel(_moveX, v, deceleration, maxDistance);
- timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this));
- if (!flicked) {
- flicked = true;
- emit q->flickingChanged();
- emit q->flickStarted();
- }
- } else {
- timeline.reset(_moveX);
- fixupX();
- }
-}
-
-void QmlGraphicsFlickablePrivate::flickY(qreal velocity)
-{
- Q_Q(QmlGraphicsFlickable);
- qreal maxDistance = -1;
- // -ve velocity means list is moving up
- if (velocity > 0) {
- const qreal minY = q->minYExtent();
- if (_moveY.value() < minY)
- maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0));
- flickTargetY = minY;
- } else {
- const qreal maxY = q->maxYExtent();
- if (_moveY.value() > maxY)
- maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0);
- flickTargetY = maxY;
- }
- if (maxDistance > 0) {
- qreal v = velocity;
- if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
- if (v < 0)
- v = -maxVelocity;
- else
- v = maxVelocity;
- }
- timeline.reset(_moveY);
- timeline.accel(_moveY, v, deceleration, maxDistance);
- timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this));
- if (!flicked) {
- flicked = true;
- emit q->flickingChanged();
- emit q->flickStarted();
- }
- } else {
- timeline.reset(_moveY);
- fixupY();
- }
-}
-
-void QmlGraphicsFlickablePrivate::fixupX()
-{
- Q_Q(QmlGraphicsFlickable);
- if (!q->xflick() || _moveX.timeLine())
- return;
-
- if (_moveX.value() > q->minXExtent() || (q->maxXExtent() > q->minXExtent())) {
- timeline.reset(_moveX);
- if (_moveX.value() != q->minXExtent()) {
- if (fixupDuration)
- timeline.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
- _moveY.setValue(q->minYExtent());
- }
- //emit flickingChanged();
- } else if (_moveX.value() < q->maxXExtent()) {
- timeline.reset(_moveX);
- if (fixupDuration)
- timeline.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
- _moveY.setValue(q->maxYExtent());
- //emit flickingChanged();
- } else {
- flicked = false;
- }
-
- vTime = timeline.time();
-}
-
-void QmlGraphicsFlickablePrivate::fixupY_callback(void *data)
-{
- ((QmlGraphicsFlickablePrivate *)data)->fixupY();
-}
-
-void QmlGraphicsFlickablePrivate::fixupX_callback(void *data)
-{
- ((QmlGraphicsFlickablePrivate *)data)->fixupX();
-}
-
-void QmlGraphicsFlickablePrivate::fixupY()
-{
- Q_Q(QmlGraphicsFlickable);
- if (!q->yflick() || _moveY.timeLine())
- return;
-
- if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
- timeline.reset(_moveY);
- if (_moveY.value() != q->minYExtent()) {
- if (fixupDuration)
- timeline.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
- _moveY.setValue(q->minYExtent());
- }
- //emit flickingChanged();
- } else if (_moveY.value() < q->maxYExtent()) {
- timeline.reset(_moveY);
- if (fixupDuration)
- timeline.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
- _moveY.setValue(q->maxYExtent());
- //emit flickingChanged();
- } else {
- flicked = false;
- }
-
- vTime = timeline.time();
-}
-
-void QmlGraphicsFlickablePrivate::updateBeginningEnd()
-{
- Q_Q(QmlGraphicsFlickable);
- bool atBoundaryChange = false;
-
- // Vertical
- const int maxyextent = int(-q->maxYExtent());
- const qreal ypos = -_moveY.value();
- bool atBeginning = (ypos <= -q->minYExtent());
- bool atEnd = (maxyextent <= ypos);
-
- if (atBeginning != atYBeginning) {
- atYBeginning = atBeginning;
- atBoundaryChange = true;
- }
- if (atEnd != atYEnd) {
- atYEnd = atEnd;
- atBoundaryChange = true;
- }
-
- // Horizontal
- const int maxxextent = int(-q->maxXExtent());
- const qreal xpos = -_moveX.value();
- atBeginning = (xpos <= -q->minXExtent());
- atEnd = (maxxextent <= xpos);
-
- if (atBeginning != atXBeginning) {
- atXBeginning = atBeginning;
- atBoundaryChange = true;
- }
- if (atEnd != atXEnd) {
- atXEnd = atEnd;
- atBoundaryChange = true;
- }
-
- if (atBoundaryChange)
- emit q->isAtBoundaryChanged();
-
- if (visibleArea)
- visibleArea->updateVisible();
-}
-
-/*!
- \qmlclass Flickable QmlGraphicsFlickable
- \brief The Flickable item provides a surface that can be "flicked".
- \inherits Item
-
- Flickable places its children on a surface that can be dragged and flicked.
-
- \code
- Flickable {
- width: 200; height: 200; viewportWidth: image.width; viewportHeight: image.height
- Image { id: image; source: "bigimage.png" }
- }
- \endcode
-
- \image flickable.gif
-
- \note Flickable does not automatically clip its contents. If
- it is not full-screen it is likely that \c clip should be set
- to true.
-
- \note Due to an implementation detail items placed inside a flickable cannot anchor to it by
- id, use 'parent' instead.
-*/
-
-/*!
- \qmlsignal Flickable::onMovementStarted()
-
- This handler is called when the view begins moving due to user
- interaction.
-*/
-
-/*!
- \qmlsignal Flickable::onMovementEnded()
-
- This handler is called when the view stops moving due to user
- interaction. If a flick was generated, this handler will
- be triggered once the flick stops. If a flick was not
- generated, the handler will be triggered when the
- user stops dragging - i.e. a mouse or touch release.
-*/
-
-/*!
- \qmlsignal Flickable::onFlickStarted()
-
- This handler is called when the view is flicked. A flick
- starts from the point that the mouse or touch is released,
- while still in motion.
-*/
-
-/*!
- \qmlsignal Flickable::onFlickEnded()
-
- This handler is called when the view stops moving due to a flick.
-*/
-
-/*!
- \qmlproperty real Flickable::visibleArea.xPosition
- \qmlproperty real Flickable::visibleArea.widthRatio
- \qmlproperty real Flickable::visibleArea.yPosition
- \qmlproperty real Flickable::visibleArea.heightRatio
-
- These properties describe the position and size of the currently viewed area.
- The size is defined as the percentage of the full view currently visible,
- scaled to 0.0 - 1.0. The page position is in the range 0.0 (beginning) to
- size ratio (end), i.e. yPosition is in the range 0.0 - heightRatio.
-
- These properties are typically used to draw a scrollbar, for example:
- \code
- Rectangle {
- opacity: 0.5; anchors.right: MyListView.right-2; width: 6
- y: MyListView.visibleArea.yPosition * MyListView.height
- height: MyListView.visibleArea.heightRatio * MyListView.height
- }
- \endcode
-*/
-
-QmlGraphicsFlickable::QmlGraphicsFlickable(QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsFlickablePrivate), parent)
-{
- Q_D(QmlGraphicsFlickable);
- d->init();
-}
-
-QmlGraphicsFlickable::QmlGraphicsFlickable(QmlGraphicsFlickablePrivate &dd, QmlGraphicsItem *parent)
- : QmlGraphicsItem(dd, parent)
-{
- Q_D(QmlGraphicsFlickable);
- d->init();
-}
-
-QmlGraphicsFlickable::~QmlGraphicsFlickable()
-{
-}
-
-/*!
- \qmlproperty int Flickable::viewportX
- \qmlproperty int Flickable::viewportY
-
- These properties hold the surface coordinate currently at the top-left
- corner of the Flickable. For example, if you flick an image up 100 pixels,
- \c yPosition will be 100.
-*/
-qreal QmlGraphicsFlickable::viewportX() const
-{
- Q_D(const QmlGraphicsFlickable);
- return -d->_moveX.value();
-}
-
-void QmlGraphicsFlickable::setViewportX(qreal pos)
-{
- Q_D(QmlGraphicsFlickable);
- pos = qRound(pos);
- d->timeline.reset(d->_moveX);
- d->vTime = d->timeline.time();
- if (-pos != d->_moveX.value()) {
- d->_moveX.setValue(-pos);
- viewportMoved();
- }
-}
-
-qreal QmlGraphicsFlickable::viewportY() const
-{
- Q_D(const QmlGraphicsFlickable);
- return -d->_moveY.value();
-}
-
-void QmlGraphicsFlickable::setViewportY(qreal pos)
-{
- Q_D(QmlGraphicsFlickable);
- pos = qRound(pos);
- d->timeline.reset(d->_moveY);
- d->vTime = d->timeline.time();
- if (-pos != d->_moveY.value()) {
- d->_moveY.setValue(-pos);
- viewportMoved();
- }
-}
-
-/*!
- \qmlproperty bool Flickable::interactive
-
- A user cannot drag or flick a Flickable that is not interactive.
-
- This property is useful for temporarily disabling flicking. This allows
- special interaction with Flickable's children: for example, you might want to
- freeze a flickable map while viewing detailed information on a location popup that is a child of the Flickable.
-*/
-bool QmlGraphicsFlickable::isInteractive() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->interactive;
-}
-
-void QmlGraphicsFlickable::setInteractive(bool interactive)
-{
- Q_D(QmlGraphicsFlickable);
- if (interactive != d->interactive) {
- d->interactive = interactive;
- if (!interactive && d->flicked) {
- d->timeline.clear();
- d->vTime = d->timeline.time();
- d->flicked = false;
- emit flickingChanged();
- emit flickEnded();
- }
- emit interactiveChanged();
- }
-}
-
-/*!
- \qmlproperty real Flickable::horizontalVelocity
- \qmlproperty real Flickable::verticalVelocity
- \qmlproperty real Flickable::reportedVelocitySmoothing
-
- The instantaneous velocity of movement along the x and y axes, in pixels/sec.
-
- The reported velocity is smoothed to avoid erratic output.
- reportedVelocitySmoothing determines how much smoothing is applied.
-*/
-qreal QmlGraphicsFlickable::horizontalVelocity() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->horizontalVelocity.value();
-}
-
-qreal QmlGraphicsFlickable::verticalVelocity() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->verticalVelocity.value();
-}
-
-/*!
- \qmlproperty bool Flickable::atXBeginning
- \qmlproperty bool Flickable::atXEnd
- \qmlproperty bool Flickable::atYBeginning
- \qmlproperty bool Flickable::atYEnd
-
- These properties are true if the flickable view is positioned at the beginning,
- or end respecively.
-*/
-bool QmlGraphicsFlickable::isAtXEnd() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->atXEnd;
-}
-
-bool QmlGraphicsFlickable::isAtXBeginning() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->atXBeginning;
-}
-
-bool QmlGraphicsFlickable::isAtYEnd() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->atYEnd;
-}
-
-bool QmlGraphicsFlickable::isAtYBeginning() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->atYBeginning;
-}
-
-void QmlGraphicsFlickable::ticked()
-{
- viewportMoved();
-}
-
-QmlGraphicsItem *QmlGraphicsFlickable::viewport()
-{
- Q_D(QmlGraphicsFlickable);
- return d->viewport;
-}
-
-QmlGraphicsFlickableVisibleArea *QmlGraphicsFlickable::visibleArea()
-{
- Q_D(QmlGraphicsFlickable);
- if (!d->visibleArea)
- d->visibleArea = new QmlGraphicsFlickableVisibleArea(this);
- return d->visibleArea;
-}
-
-/*!
- \qmlproperty enumeration Flickable::flickDirection
-
- This property determines which directions the view can be flicked.
-
- \list
- \o AutoFlickDirection (default) - allows flicking vertically if the
- \e viewportHeight is not equal to the \e height of the Flickable.
- Allows flicking horizontally if the \e viewportWidth is not equal
- to the \e width of the Flickable.
- \o HorizontalFlick - allows flicking horizontally.
- \o VerticalFlick - allows flicking vertically.
- \o HorizontalAndVerticalFlick - allows flicking in both directions.
- \endlist
-*/
-QmlGraphicsFlickable::FlickDirection QmlGraphicsFlickable::flickDirection() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->flickDirection;
-}
-
-void QmlGraphicsFlickable::setFlickDirection(FlickDirection direction)
-{
- Q_D(QmlGraphicsFlickable);
- if (direction != d->flickDirection) {
- d->flickDirection = direction;
- emit flickDirectionChanged();
- }
-}
-
-void QmlGraphicsFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- if (interactive && timeline.isActive() && (qAbs(velocityX) > 10 || qAbs(velocityY) > 10))
- stealMouse = true; // If we've been flicked then steal the click.
- else
- stealMouse = false;
- pressed = true;
- timeline.clear();
- velocityX = 0;
- velocityY = 0;
- lastPos = QPoint();
- QmlGraphicsItemPrivate::start(lastPosTime);
- pressPos = event->pos();
- pressX = _moveX.value();
- pressY = _moveY.value();
- flicked = false;
- QmlGraphicsItemPrivate::start(pressTime);
- QmlGraphicsItemPrivate::start(velocityTime);
-}
-
-void QmlGraphicsFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_Q(QmlGraphicsFlickable);
- if (!interactive || lastPosTime.isNull())
- return;
- bool rejectY = false;
- bool rejectX = false;
- bool moved = false;
-
- if (q->yflick()) {
- int dy = int(event->pos().y() - pressPos.y());
- if (qAbs(dy) > QApplication::startDragDistance() || QmlGraphicsItemPrivate::elapsed(pressTime) > 200) {
- qreal newY = dy + pressY;
- const qreal minY = q->minYExtent();
- const qreal maxY = q->maxYExtent();
- if (newY > minY)
- newY = minY + (newY - minY) / 2;
- if (newY < maxY && maxY - minY <= 0)
- newY = maxY + (newY - maxY) / 2;
- if (!q->overShoot() && (newY > minY || newY < maxY)) {
- if (newY > minY)
- newY = minY;
- else if (newY < maxY)
- newY = maxY;
- else
- rejectY = true;
- }
- if (!rejectY) {
- _moveY.setValue(newY);
- moved = true;
- }
- if (qAbs(dy) > QApplication::startDragDistance())
- stealMouse = true;
- }
- }
-
- if (q->xflick()) {
- int dx = int(event->pos().x() - pressPos.x());
- if (qAbs(dx) > QApplication::startDragDistance() || QmlGraphicsItemPrivate::elapsed(pressTime) > 200) {
- qreal newX = dx + pressX;
- const qreal minX = q->minXExtent();
- const qreal maxX = q->maxXExtent();
- if (newX > minX)
- newX = minX + (newX - minX) / 2;
- if (newX < maxX && maxX - minX <= 0)
- newX = maxX + (newX - maxX) / 2;
- if (!q->overShoot() && (newX > minX || newX < maxX)) {
- if (newX > minX)
- newX = minX;
- else if (newX < maxX)
- newX = maxX;
- else
- rejectX = true;
- }
- if (!rejectX) {
- _moveX.setValue(newX);
- moved = true;
- }
-
- if (qAbs(dx) > QApplication::startDragDistance())
- stealMouse = true;
- }
- }
-
- if (!lastPos.isNull()) {
- qreal elapsed = qreal(QmlGraphicsItemPrivate::restart(lastPosTime)) / 1000.;
- if (elapsed <= 0)
- elapsed = 1;
- if (q->yflick()) {
- qreal diff = event->pos().y() - lastPos.y();
- // average to reduce the effect of spurious moves
- velocityY += diff / elapsed;
- velocityY /= 2;
- }
-
- if (q->xflick()) {
- qreal diff = event->pos().x() - lastPos.x();
- // average to reduce the effect of spurious moves
- velocityX += diff / elapsed;
- velocityX /= 2;
- }
- }
-
- if (rejectY) velocityY = 0;
- if (rejectX) velocityX = 0;
-
- if (moved) {
- q->movementStarting();
- q->viewportMoved();
- }
-
- lastPos = event->pos();
-}
-
-void QmlGraphicsFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_Q(QmlGraphicsFlickable);
- pressed = false;
- if (lastPosTime.isNull())
- return;
-
- if (QmlGraphicsItemPrivate::elapsed(lastPosTime) > 100) {
- // if we drag then pause before release we should not cause a flick.
- velocityX = 0.0;
- velocityY = 0.0;
- }
-
- vTime = timeline.time();
- if (qAbs(velocityY) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) {
- qreal velocity = velocityY;
- if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
- velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
- flickY(velocity);
- } else {
- fixupY();
- }
-
- if (qAbs(velocityX) > 10 && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) {
- qreal velocity = velocityX;
- if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
- velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
- flickX(velocity);
- } else {
- fixupX();
- }
-
- stealMouse = false;
- lastPosTime = QTime();
-
- if (!timeline.isActive())
- q->movementEnding();
-}
-
-void QmlGraphicsFlickable::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsFlickable);
- if (d->interactive) {
- d->handleMousePressEvent(event);
- event->accept();
- } else {
- QmlGraphicsItem::mousePressEvent(event);
- }
-}
-
-void QmlGraphicsFlickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsFlickable);
- if (d->interactive) {
- d->handleMouseMoveEvent(event);
- event->accept();
- } else {
- QmlGraphicsItem::mouseMoveEvent(event);
- }
-}
-
-void QmlGraphicsFlickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsFlickable);
- if (d->interactive) {
- d->clearDelayedPress();
- d->handleMouseReleaseEvent(event);
- event->accept();
- ungrabMouse();
- } else {
- QmlGraphicsItem::mouseReleaseEvent(event);
- }
-}
-
-void QmlGraphicsFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
-{
- Q_D(QmlGraphicsFlickable);
- if (!d->interactive) {
- QmlGraphicsItem::wheelEvent(event);
- } else if (yflick()) {
- if (event->delta() > 0)
- d->velocityY = qMax(event->delta() - d->verticalVelocity.value(), qreal(250.0));
- else
- d->velocityY = qMin(event->delta() - d->verticalVelocity.value(), qreal(-250.0));
- d->flicked = false;
- d->flickY(d->velocityY);
- event->accept();
- } else if (xflick()) {
- if (event->delta() > 0)
- d->velocityX = qMax(event->delta() - d->horizontalVelocity.value(), qreal(250.0));
- else
- d->velocityX = qMin(event->delta() - d->horizontalVelocity.value(), qreal(-250.0));
- d->flicked = false;
- d->flickX(d->velocityX);
- event->accept();
- } else {
- QmlGraphicsItem::wheelEvent(event);
- }
-}
-
-void QmlGraphicsFlickablePrivate::captureDelayedPress(QGraphicsSceneMouseEvent *event)
-{
- Q_Q(QmlGraphicsFlickable);
- if (!q->scene() || pressDelay <= 0)
- return;
- delayedPressTarget = q->scene()->mouseGrabberItem();
- delayedPressEvent = new QGraphicsSceneMouseEvent(event->type());
- delayedPressEvent->setAccepted(false);
- for (int i = 0x1; i <= 0x10; i <<= 1) {
- if (event->buttons() & i) {
- Qt::MouseButton button = Qt::MouseButton(i);
- delayedPressEvent->setButtonDownPos(button, event->buttonDownPos(button));
- delayedPressEvent->setButtonDownScenePos(button, event->buttonDownScenePos(button));
- delayedPressEvent->setButtonDownScreenPos(button, event->buttonDownScreenPos(button));
- }
- }
- delayedPressEvent->setButtons(event->buttons());
- delayedPressEvent->setButton(event->button());
- delayedPressEvent->setPos(event->pos());
- delayedPressEvent->setScenePos(event->scenePos());
- delayedPressEvent->setScreenPos(event->screenPos());
- delayedPressEvent->setLastPos(event->lastPos());
- delayedPressEvent->setLastScenePos(event->lastScenePos());
- delayedPressEvent->setLastScreenPos(event->lastScreenPos());
- delayedPressEvent->setModifiers(event->modifiers());
- delayedPressTimer.start(pressDelay, q);
-}
-
-void QmlGraphicsFlickablePrivate::clearDelayedPress()
-{
- if (delayedPressEvent) {
- delayedPressTimer.stop();
- delete delayedPressEvent;
- delayedPressEvent = 0;
- }
-}
-
-void QmlGraphicsFlickablePrivate::setRoundedViewportX(qreal x)
-{
- viewport->setX(qRound(x));
-}
-
-void QmlGraphicsFlickablePrivate::setRoundedViewportY(qreal y)
-{
- viewport->setY(qRound(y));
-}
-
-void QmlGraphicsFlickable::timerEvent(QTimerEvent *event)
-{
- Q_D(QmlGraphicsFlickable);
- if (event->timerId() == d->delayedPressTimer.timerId()) {
- d->delayedPressTimer.stop();
- if (d->delayedPressEvent) {
- QmlGraphicsItem *grabber = scene() ? qobject_cast<QmlGraphicsItem*>(scene()->mouseGrabberItem()) : 0;
- if (!grabber || grabber != this)
- scene()->sendEvent(d->delayedPressTarget, d->delayedPressEvent);
- delete d->delayedPressEvent;
- d->delayedPressEvent = 0;
- }
- }
-}
-
-qreal QmlGraphicsFlickable::minYExtent() const
-{
- return 0.0;
-}
-
-qreal QmlGraphicsFlickable::minXExtent() const
-{
- return 0.0;
-}
-
-/* returns -ve */
-qreal QmlGraphicsFlickable::maxXExtent() const
-{
- return width() - vWidth();
-}
-/* returns -ve */
-qreal QmlGraphicsFlickable::maxYExtent() const
-{
- return height() - vHeight();
-}
-
-void QmlGraphicsFlickable::viewportMoved()
-{
- Q_D(QmlGraphicsFlickable);
-
- int elapsed = QmlGraphicsItemPrivate::restart(d->velocityTime);
- if (!elapsed)
- return;
-
- qreal prevY = d->lastFlickablePosition.x();
- qreal prevX = d->lastFlickablePosition.y();
- d->velocityTimeline.clear();
- if (d->pressed) {
- qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / elapsed;
- qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / elapsed;
- d->velocityTimeline.move(d->horizontalVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->horizontalVelocity, 0, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->verticalVelocity, verticalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->verticalVelocity, 0, d->reportedVelocitySmoothing);
- } else {
- if (d->timeline.time() > d->vTime) {
- qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / (d->timeline.time() - d->vTime);
- qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / (d->timeline.time() - d->vTime);
- d->horizontalVelocity.setValue(horizontalVelocity);
- d->verticalVelocity.setValue(verticalVelocity);
- }
- }
-
- d->lastFlickablePosition = QPointF(d->_moveY.value(), d->_moveX.value());
-
- d->vTime = d->timeline.time();
- d->updateBeginningEnd();
-}
-
-void QmlGraphicsFlickable::cancelFlick()
-{
- Q_D(QmlGraphicsFlickable);
- d->timeline.reset(d->_moveX);
- d->timeline.reset(d->_moveY);
- movementEnding();
-}
-
-void QmlGraphicsFlickablePrivate::data_append(QmlListProperty<QObject> *prop, QObject *o)
-{
- QmlGraphicsItem *i = qobject_cast<QmlGraphicsItem *>(o);
- if (i)
- i->setParentItem(static_cast<QmlGraphicsFlickablePrivate*>(prop->data)->viewport);
- else
- o->setParent(prop->object);
-}
-
-QmlListProperty<QObject> QmlGraphicsFlickable::flickableData()
-{
- Q_D(QmlGraphicsFlickable);
- return QmlListProperty<QObject>(this, (void *)d, QmlGraphicsFlickablePrivate::data_append);
-}
-
-QmlListProperty<QmlGraphicsItem> QmlGraphicsFlickable::flickableChildren()
-{
- Q_D(QmlGraphicsFlickable);
- return d->viewport->fxChildren();
-}
-
-/*!
- \qmlproperty bool Flickable::overShoot
- This property holds the number of pixels the surface may overshoot the
- Flickable's boundaries when flicked.
-
- If overShoot is non-zero the contents can be flicked beyond the boundary
- of the Flickable before being moved back to the boundary. This provides
- the feeling that the edges of the view are soft, rather than a hard
- physical boundary.
-*/
-bool QmlGraphicsFlickable::overShoot() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->overShoot;
-}
-
-void QmlGraphicsFlickable::setOverShoot(bool o)
-{
- Q_D(QmlGraphicsFlickable);
- if (d->overShoot == o)
- return;
- d->overShoot = o;
- emit overShootChanged();
-}
-
-/*!
- \qmlproperty int Flickable::viewportWidth
- \qmlproperty int Flickable::viewportHeight
-
- The dimensions of the viewport (the surface controlled by Flickable). Typically this
- should be set to the combined size of the items placed in the Flickable.
-
- \code
- Flickable {
- width: 320; height: 480; viewportWidth: image.width; viewportHeight: image.height
- Image { id: image; source: "bigimage.png" }
- }
- \endcode
-*/
-qreal QmlGraphicsFlickable::viewportWidth() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->vWidth;
-}
-
-void QmlGraphicsFlickable::setViewportWidth(qreal w)
-{
- Q_D(QmlGraphicsFlickable);
- if (d->vWidth == w)
- return;
- d->vWidth = w;
- if (w < 0)
- d->viewport->setWidth(width());
- else
- d->viewport->setWidth(w);
- // Make sure that we're entirely in view.
- if (!d->pressed)
- d->fixupX();
- emit viewportWidthChanged();
- d->updateBeginningEnd();
-}
-
-void QmlGraphicsFlickable::widthChange()
-{
- Q_D(QmlGraphicsFlickable);
- if (d->vWidth < 0) {
- d->viewport->setWidth(width());
- emit viewportWidthChanged();
- }
- d->updateBeginningEnd();
-}
-
-void QmlGraphicsFlickable::heightChange()
-{
- Q_D(QmlGraphicsFlickable);
- if (d->vHeight < 0) {
- d->viewport->setHeight(height());
- emit viewportHeightChanged();
- }
- d->updateBeginningEnd();
-}
-
-qreal QmlGraphicsFlickable::viewportHeight() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->vHeight;
-}
-
-void QmlGraphicsFlickable::setViewportHeight(qreal h)
-{
- Q_D(QmlGraphicsFlickable);
- if (d->vHeight == h)
- return;
- d->vHeight = h;
- if (h < 0)
- d->viewport->setHeight(height());
- else
- d->viewport->setHeight(h);
- // Make sure that we're entirely in view.
- if (!d->pressed)
- d->fixupY();
- emit viewportHeightChanged();
- d->updateBeginningEnd();
-}
-
-qreal QmlGraphicsFlickable::vWidth() const
-{
- Q_D(const QmlGraphicsFlickable);
- if (d->vWidth < 0)
- return width();
- else
- return d->vWidth;
-}
-
-qreal QmlGraphicsFlickable::vHeight() const
-{
- Q_D(const QmlGraphicsFlickable);
- if (d->vHeight < 0)
- return height();
- else
- return d->vHeight;
-}
-
-bool QmlGraphicsFlickable::xflick() const
-{
- Q_D(const QmlGraphicsFlickable);
- if (d->flickDirection == QmlGraphicsFlickable::AutoFlickDirection)
- return vWidth() != width();
- return d->flickDirection & QmlGraphicsFlickable::HorizontalFlick;
-}
-
-bool QmlGraphicsFlickable::yflick() const
-{
- Q_D(const QmlGraphicsFlickable);
- if (d->flickDirection == QmlGraphicsFlickable::AutoFlickDirection)
- return vHeight() != height();
- return d->flickDirection & QmlGraphicsFlickable::VerticalFlick;
-}
-
-bool QmlGraphicsFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsFlickable);
- QGraphicsSceneMouseEvent mouseEvent(event->type());
- QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect();
-
- QGraphicsScene *s = scene();
- QmlGraphicsItem *grabber = s ? qobject_cast<QmlGraphicsItem*>(s->mouseGrabberItem()) : 0;
- if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
- mouseEvent.setAccepted(false);
- for (int i = 0x1; i <= 0x10; i <<= 1) {
- if (event->buttons() & i) {
- Qt::MouseButton button = Qt::MouseButton(i);
- mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button)));
- }
- }
- mouseEvent.setScenePos(event->scenePos());
- mouseEvent.setLastScenePos(event->lastScenePos());
- mouseEvent.setPos(mapFromScene(event->scenePos()));
- mouseEvent.setLastPos(mapFromScene(event->lastScenePos()));
-
- switch(mouseEvent.type()) {
- case QEvent::GraphicsSceneMouseMove:
- d->handleMouseMoveEvent(&mouseEvent);
- break;
- case QEvent::GraphicsSceneMousePress:
- if (d->delayedPressEvent)
- return false;
-
- d->handleMousePressEvent(&mouseEvent);
- d->captureDelayedPress(event);
- break;
- case QEvent::GraphicsSceneMouseRelease:
- if (d->delayedPressEvent) {
- scene()->sendEvent(d->delayedPressTarget, d->delayedPressEvent);
- d->clearDelayedPress();
- }
- d->handleMouseReleaseEvent(&mouseEvent);
- break;
- default:
- break;
- }
- grabber = qobject_cast<QmlGraphicsItem*>(s->mouseGrabberItem());
- if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this) {
- d->clearDelayedPress();
- grabMouse();
- }
-
- return d->stealMouse || d->delayedPressEvent;
- } else if (!d->lastPosTime.isNull()) {
- d->lastPosTime = QTime();
- }
- if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease)
- d->clearDelayedPress();
- return false;
-}
-
-bool QmlGraphicsFlickable::sceneEventFilter(QGraphicsItem *i, QEvent *e)
-{
- Q_D(QmlGraphicsFlickable);
- if (!isVisible() || !d->interactive)
- return QmlGraphicsItem::sceneEventFilter(i, e);
- switch (e->type()) {
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseMove:
- case QEvent::GraphicsSceneMouseRelease:
- return sendMouseEvent(static_cast<QGraphicsSceneMouseEvent *>(e));
- default:
- break;
- }
-
- return QmlGraphicsItem::sceneEventFilter(i, e);
-}
-
-/*!
- \qmlproperty real Flickable::maximumFlickVelocity
- This property holds the maximum velocity that the user can flick the view in pixels/second.
-
- The default is 2000 pixels/s
-*/
-qreal QmlGraphicsFlickable::maximumFlickVelocity() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->maxVelocity;
-}
-
-void QmlGraphicsFlickable::setMaximumFlickVelocity(qreal v)
-{
- Q_D(QmlGraphicsFlickable);
- if (v == d->maxVelocity)
- return;
- d->maxVelocity = v;
- emit maximumFlickVelocityChanged();
-}
-
-/*!
- \qmlproperty real Flickable::flickDeceleration
- This property holds the rate at which a flick will decelerate.
-
- The default is 500.
-*/
-qreal QmlGraphicsFlickable::flickDeceleration() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->deceleration;
-}
-
-void QmlGraphicsFlickable::setFlickDeceleration(qreal deceleration)
-{
- Q_D(QmlGraphicsFlickable);
- if (deceleration == d->deceleration)
- return;
- d->deceleration = deceleration;
- emit flickDecelerationChanged();
-}
-
-/*!
- \qmlproperty bool Flickable::flicking
-
- This property holds whether the view is currently moving due to
- the user flicking the view.
-*/
-bool QmlGraphicsFlickable::isFlicking() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->flicked;
-}
-
-/*!
- \qmlproperty int Flickable::pressDelay
-
- This property holds the time to delay (ms) delivering a press to
- children of the Flickable. This can be useful where reacting
- to a press before a flicking action has undesireable effects.
-
- If the flickable is dragged/flicked before the delay times out
- the press event will not be delivered. If the button is released
- within the timeout, both the press and release will be delivered.
-*/
-int QmlGraphicsFlickable::pressDelay() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->pressDelay;
-}
-
-void QmlGraphicsFlickable::setPressDelay(int delay)
-{
- Q_D(QmlGraphicsFlickable);
- if (d->pressDelay == delay)
- return;
- d->pressDelay = delay;
- emit pressDelayChanged();
-}
-
-qreal QmlGraphicsFlickable::reportedVelocitySmoothing() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->reportedVelocitySmoothing;
-}
-
-void QmlGraphicsFlickable::setReportedVelocitySmoothing(qreal reportedVelocitySmoothing)
-{
- Q_D(QmlGraphicsFlickable);
- Q_ASSERT(reportedVelocitySmoothing >= 0);
- if (reportedVelocitySmoothing == d->reportedVelocitySmoothing)
- return;
- d->reportedVelocitySmoothing = reportedVelocitySmoothing;
- emit reportedVelocitySmoothingChanged(reportedVelocitySmoothing);
-}
-
-/*!
- \qmlproperty bool Flickable::moving
-
- This property holds whether the view is currently moving due to
- the user either dragging or flicking the view.
-*/
-bool QmlGraphicsFlickable::isMoving() const
-{
- Q_D(const QmlGraphicsFlickable);
- return d->moving;
-}
-
-void QmlGraphicsFlickable::movementStarting()
-{
- Q_D(QmlGraphicsFlickable);
- if (!d->moving) {
- d->moving = true;
- emit movingChanged();
- emit movementStarted();
- }
-}
-
-void QmlGraphicsFlickable::movementEnding()
-{
- Q_D(QmlGraphicsFlickable);
- if (d->moving) {
- d->moving = false;
- emit movingChanged();
- emit movementEnded();
- }
- if (d->flicked) {
- d->flicked = false;
- emit flickingChanged();
- emit flickEnded();
- }
- d->horizontalVelocity.setValue(0);
- d->verticalVelocity.setValue(0);
-}
-
-void QmlGraphicsFlickablePrivate::updateVelocity()
-{
- Q_Q(QmlGraphicsFlickable);
- emit q->horizontalVelocityChanged();
- emit q->verticalVelocityChanged();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
deleted file mode 100644
index 580d01e..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSFLICKABLE_H
-#define QMLGRAPHICSFLICKABLE_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsFlickablePrivate;
-class QmlGraphicsFlickableVisibleArea;
-class Q_DECLARATIVE_EXPORT QmlGraphicsFlickable : public QmlGraphicsItem
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal viewportWidth READ viewportWidth WRITE setViewportWidth NOTIFY viewportWidthChanged)
- Q_PROPERTY(qreal viewportHeight READ viewportHeight WRITE setViewportHeight NOTIFY viewportHeightChanged)
- Q_PROPERTY(qreal viewportX READ viewportX WRITE setViewportX NOTIFY positionXChanged)
- Q_PROPERTY(qreal viewportY READ viewportY WRITE setViewportY NOTIFY positionYChanged)
-
- Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
- Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
- Q_PROPERTY(qreal reportedVelocitySmoothing READ reportedVelocitySmoothing WRITE setReportedVelocitySmoothing NOTIFY reportedVelocitySmoothingChanged)
-
- Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot NOTIFY overShootChanged)
- Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
- Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
- Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
- Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
- Q_PROPERTY(FlickDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickDirectionChanged)
-
- Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
- Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
-
- Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
- Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
- Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
- Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
-
- Q_PROPERTY(QmlGraphicsFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
-
- Q_PROPERTY(QmlListProperty<QObject> flickableData READ flickableData)
- Q_PROPERTY(QmlListProperty<QmlGraphicsItem> flickableChildren READ flickableChildren)
- Q_CLASSINFO("DefaultProperty", "flickableData")
-
- Q_ENUMS(FlickDirection)
-
-public:
- QmlGraphicsFlickable(QmlGraphicsItem *parent=0);
- ~QmlGraphicsFlickable();
-
- QmlListProperty<QObject> flickableData();
- QmlListProperty<QmlGraphicsItem> flickableChildren();
-
- bool overShoot() const;
- void setOverShoot(bool);
-
- qreal viewportWidth() const;
- void setViewportWidth(qreal);
-
- qreal viewportHeight() const;
- void setViewportHeight(qreal);
-
- qreal viewportX() const;
- void setViewportX(qreal pos);
-
- qreal viewportY() const;
- void setViewportY(qreal pos);
-
- bool isMoving() const;
- bool isFlicking() const;
-
- int pressDelay() const;
- void setPressDelay(int delay);
-
- qreal reportedVelocitySmoothing() const;
- void setReportedVelocitySmoothing(qreal);
-
- qreal maximumFlickVelocity() const;
- void setMaximumFlickVelocity(qreal);
-
- qreal flickDeceleration() const;
- void setFlickDeceleration(qreal);
-
- bool isInteractive() const;
- void setInteractive(bool);
-
- qreal horizontalVelocity() const;
- qreal verticalVelocity() const;
-
- bool isAtXEnd() const;
- bool isAtXBeginning() const;
- bool isAtYEnd() const;
- bool isAtYBeginning() const;
-
- QmlGraphicsItem *viewport();
-
- enum FlickDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
- FlickDirection flickDirection() const;
- void setFlickDirection(FlickDirection);
-
-Q_SIGNALS:
- void viewportWidthChanged();
- void viewportHeightChanged();
- void positionXChanged();
- void positionYChanged();
- void movingChanged();
- void flickingChanged();
- void movementStarted();
- void movementEnded();
- void flickStarted();
- void flickEnded();
- void reportedVelocitySmoothingChanged(int);
- void horizontalVelocityChanged();
- void verticalVelocityChanged();
- void isAtBoundaryChanged();
- void pageChanged();
- void flickDirectionChanged();
- void interactiveChanged();
- void overShootChanged();
- void maximumFlickVelocityChanged();
- void flickDecelerationChanged();
- void pressDelayChanged();
-
-protected:
- virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void wheelEvent(QGraphicsSceneWheelEvent *event);
- void timerEvent(QTimerEvent *event);
-
- QmlGraphicsFlickableVisibleArea *visibleArea();
-
-protected Q_SLOTS:
- virtual void ticked();
- void movementStarting();
- void movementEnding();
- void heightChange();
- void widthChange();
-
-protected:
- virtual qreal minXExtent() const;
- virtual qreal minYExtent() const;
- virtual qreal maxXExtent() const;
- virtual qreal maxYExtent() const;
- qreal vWidth() const;
- qreal vHeight() const;
- virtual void viewportMoved();
- bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
-
- bool xflick() const;
- bool yflick() const;
- void cancelFlick();
-
-protected:
- QmlGraphicsFlickable(QmlGraphicsFlickablePrivate &dd, QmlGraphicsItem *parent);
-
-private:
- Q_DISABLE_COPY(QmlGraphicsFlickable)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsFlickable)
- friend class QmlGraphicsFlickableVisibleArea;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsFlickable)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
deleted file mode 100644
index e58cc0c..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSFLICKABLE_P_H
-#define QMLGRAPHICSFLICKABLE_P_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 "qmlgraphicsflickable_p.h"
-
-#include "qmlgraphicsitem_p.h"
-
-#include <qml.h>
-#include <qmltimeline_p_p.h>
-#include <qmlanimation_p_p.h>
-
-#include <qdatetime.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsFlickableVisibleArea;
-class QmlGraphicsFlickablePrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsFlickable)
-
-public:
- QmlGraphicsFlickablePrivate();
- void init();
- virtual void flickX(qreal velocity);
- virtual void flickY(qreal velocity);
- virtual void fixupX();
- virtual void fixupY();
- void updateBeginningEnd();
-
- void captureDelayedPress(QGraphicsSceneMouseEvent *event);
- void clearDelayedPress();
-
- void setRoundedViewportX(qreal x);
- void setRoundedViewportY(qreal y);
-
-public:
- QmlGraphicsItem *viewport;
- QmlTimeLineValueProxy<QmlGraphicsFlickablePrivate> _moveX;
- QmlTimeLineValueProxy<QmlGraphicsFlickablePrivate> _moveY;
- QmlTimeLine timeline;
- qreal vWidth;
- qreal vHeight;
- bool overShoot : 1;
- bool flicked : 1;
- bool moving : 1;
- bool stealMouse : 1;
- bool pressed : 1;
- bool atXEnd : 1;
- bool atXBeginning : 1;
- bool atYEnd : 1;
- bool atYBeginning : 1;
- bool interactive : 1;
- QTime lastPosTime;
- QPointF lastPos;
- QPointF pressPos;
- qreal pressX;
- qreal pressY;
- qreal velocityX;
- qreal velocityY;
- QTime pressTime;
- qreal deceleration;
- qreal maxVelocity;
- QTime velocityTime;
- QPointF lastFlickablePosition;
- qreal reportedVelocitySmoothing;
- qreal flickTargetX;
- qreal flickTargetY;
- QGraphicsSceneMouseEvent *delayedPressEvent;
- QGraphicsItem *delayedPressTarget;
- QBasicTimer delayedPressTimer;
- int pressDelay;
- int fixupDuration;
-
- static void fixupY_callback(void *);
- static void fixupX_callback(void *);
-
- void updateVelocity();
- struct Velocity : public QmlTimeLineValue
- {
- Velocity(QmlGraphicsFlickablePrivate *p)
- : parent(p) {}
- virtual void setValue(qreal v) {
- QmlTimeLineValue::setValue(v);
- parent->updateVelocity();
- }
- QmlGraphicsFlickablePrivate *parent;
- };
- Velocity horizontalVelocity;
- Velocity verticalVelocity;
- int vTime;
- QmlTimeLine velocityTimeline;
- QmlGraphicsFlickableVisibleArea *visibleArea;
- QmlGraphicsFlickable::FlickDirection flickDirection;
-
- void handleMousePressEvent(QGraphicsSceneMouseEvent *);
- void handleMouseMoveEvent(QGraphicsSceneMouseEvent *);
- void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *);
-
- // flickableData property
- static void data_append(QmlListProperty<QObject> *, QObject *);
-};
-
-class QmlGraphicsFlickableVisibleArea : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal xPosition READ xPosition NOTIFY pageChanged)
- Q_PROPERTY(qreal yPosition READ yPosition NOTIFY pageChanged)
- Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY pageChanged)
- Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY pageChanged)
-
-public:
- QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent=0);
-
- qreal xPosition() const;
- qreal widthRatio() const;
- qreal yPosition() const;
- qreal heightRatio() const;
-
- void updateVisible();
-
-signals:
- void pageChanged();
-
-private:
- QmlGraphicsFlickable *flickable;
- qreal m_xPosition;
- qreal m_widthRatio;
- qreal m_yPosition;
- qreal m_heightRatio;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsFlickableVisibleArea)
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
deleted file mode 100644
index f51c203..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsflipable_p.h"
-
-#include "qmlgraphicsitem_p.h"
-
-#include <qmlinfo.h>
-
-#include <QtGui/qgraphicstransform.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsFlipablePrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsFlipable)
-public:
- QmlGraphicsFlipablePrivate() : current(QmlGraphicsFlipable::Front), front(0), back(0) {}
-
- void updateSceneTransformFromParent();
-
- QmlGraphicsFlipable::Side current;
- QmlGraphicsItem *front;
- QmlGraphicsItem *back;
-};
-
-/*!
- \qmlclass Flipable QmlGraphicsFlipable
- \since 4.7
- \brief The Flipable item provides a surface that can be flipped.
- \inherits Item
-
- Flipable allows you to specify a front and a back and then flip between those sides.
-
- Here's an example that flips between the front and back sides when clicked:
-
- \qml
-
- Flipable {
- id: flipable
- width: 250; height: 250
- property int angle: 0
-
- transform: Rotation {
- id: rotation
- origin.x: flipable.width/2; origin.y: flipable.height/2
- axis.x: 0; axis.y: 1; axis.z: 0 // rotate around y-axis
- angle: flipable.angle
- }
-
- front: Image { source: "front.png" }
- back: Image { source: "back.png" }
-
- states: State {
- name: "back"
- PropertyChanges { target: flipable; angle: 180 }
- }
-
- transitions: Transition {
- NumberAnimation { properties: "angle"; duration: 2000 }
- }
-
- MouseArea {
- // change between default and 'back' states
- onClicked: flipable.state = (flipable.state == 'back' ? '' : 'back')
- anchors.fill: parent
- }
- }
- \endqml
-
- \image flipable.gif
-*/
-
-/*!
- \internal
- \class QmlGraphicsFlipable
- \brief The QmlGraphicsFlipable class provides a flipable surface.
-
- \ingroup group_widgets
-
- QmlGraphicsFlipable allows you to specify a front and a back, as well as an
- axis for the flip.
-*/
-
-QmlGraphicsFlipable::QmlGraphicsFlipable(QmlGraphicsItem *parent)
-: QmlGraphicsItem(*(new QmlGraphicsFlipablePrivate), parent)
-{
-}
-
-QmlGraphicsFlipable::~QmlGraphicsFlipable()
-{
-}
-
-/*!
- \qmlproperty Item Flipable::front
- \qmlproperty Item Flipable::back
-
- The front and back sides of the flipable.
-*/
-
-QmlGraphicsItem *QmlGraphicsFlipable::front()
-{
- Q_D(const QmlGraphicsFlipable);
- return d->front;
-}
-
-void QmlGraphicsFlipable::setFront(QmlGraphicsItem *front)
-{
- Q_D(QmlGraphicsFlipable);
- if (d->front) {
- qmlInfo(this) << tr("front is a write-once property");
- return;
- }
- d->front = front;
- d->front->setParentItem(this);
- if (Back == d->current)
- d->front->setOpacity(0.);
-}
-
-QmlGraphicsItem *QmlGraphicsFlipable::back()
-{
- Q_D(const QmlGraphicsFlipable);
- return d->back;
-}
-
-void QmlGraphicsFlipable::setBack(QmlGraphicsItem *back)
-{
- Q_D(QmlGraphicsFlipable);
- if (d->back) {
- qmlInfo(this) << tr("back is a write-once property");
- return;
- }
- d->back = back;
- d->back->setParentItem(this);
- if (Front == d->current)
- d->back->setOpacity(0.);
-}
-
-/*!
- \qmlproperty enumeration Flipable::side
-
- The side of the Flippable currently visible. Possible values are \c
- Front and \c Back.
-*/
-QmlGraphicsFlipable::Side QmlGraphicsFlipable::side() const
-{
- Q_D(const QmlGraphicsFlipable);
- if (d->dirtySceneTransform)
- const_cast<QmlGraphicsFlipablePrivate *>(d)->updateSceneTransformFromParent();
-
- return d->current;
-}
-
-// determination on the currently visible side of the flipable
-// has to be done on the complete scene transform to give
-// correct results.
-void QmlGraphicsFlipablePrivate::updateSceneTransformFromParent()
-{
- Q_Q(QmlGraphicsFlipable);
-
- QmlGraphicsItemPrivate::updateSceneTransformFromParent();
- QPointF p1(0, 0);
- QPointF p2(1, 0);
- QPointF p3(1, 1);
-
- p1 = sceneTransform.map(p1);
- p2 = sceneTransform.map(p2);
- p3 = sceneTransform.map(p3);
-
- qreal cross = (p1.x() - p2.x()) * (p3.y() - p2.y()) -
- (p1.y() - p2.y()) * (p3.x() - p2.x());
-
- QmlGraphicsFlipable::Side newSide;
- if (cross > 0) {
- newSide = QmlGraphicsFlipable::Back;
- } else {
- newSide = QmlGraphicsFlipable::Front;
- }
-
- if (newSide != current) {
- current = newSide;
- if (current == QmlGraphicsFlipable::Back) {
- QTransform mat;
- mat.translate(back->width()/2,back->height()/2);
- if (back->width() && p1.x() >= p2.x())
- mat.rotate(180, Qt::YAxis);
- if (back->height() && p2.y() >= p3.y())
- mat.rotate(180, Qt::XAxis);
- mat.translate(-back->width()/2,-back->height()/2);
- back->setTransform(mat);
- }
- if (front)
- front->setOpacity((current==QmlGraphicsFlipable::Front)?1.:0.);
- if (back)
- back->setOpacity((current==QmlGraphicsFlipable::Back)?1.:0.);
- emit q->sideChanged();
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable_p.h b/src/declarative/graphicsitems/qmlgraphicsflipable_p.h
deleted file mode 100644
index 2b9e44e..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsflipable_p.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSFLIPABLE_H
-#define QMLGRAPHICSFLIPABLE_H
-
-#include "qmlgraphicsitem.h"
-
-#include <QtCore/QObject>
-#include <QtGui/QTransform>
-#include <QtGui/qvector3d.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsFlipablePrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsFlipable : public QmlGraphicsItem
-{
- Q_OBJECT
-
- Q_ENUMS(Side)
- Q_PROPERTY(QmlGraphicsItem *front READ front WRITE setFront)
- Q_PROPERTY(QmlGraphicsItem *back READ back WRITE setBack)
- Q_PROPERTY(Side side READ side NOTIFY sideChanged)
- //### flipAxis
- //### flipRotation
-public:
- QmlGraphicsFlipable(QmlGraphicsItem *parent=0);
- ~QmlGraphicsFlipable();
-
- QmlGraphicsItem *front();
- void setFront(QmlGraphicsItem *);
-
- QmlGraphicsItem *back();
- void setBack(QmlGraphicsItem *);
-
- enum Side { Front, Back };
- Side side() const;
-
-Q_SIGNALS:
- void sideChanged();
-
-private:
- Q_DISABLE_COPY(QmlGraphicsFlipable)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsFlipable)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsFlipable)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSFLIPABLE_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp b/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp
deleted file mode 100644
index 4d7af54..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsfocuspanel_p.h"
-
-#include <QtGui/qgraphicsscene.h>
-#include <QEvent>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass FocusPanel QmlGraphicsFocusPanel
- \since 4.7
- \brief The FocusPanel item explicitly creates a focus panel.
- \inherits Item
-
- Focus panels assist in keyboard focus handling when building QML
- applications. All the details are covered in the
- \l {qmlfocus}{keyboard focus documentation}.
-*/
-
-/*!
- \internal
- \class QmlGraphicsFocusPanel
-*/
-
-QmlGraphicsFocusPanel::QmlGraphicsFocusPanel(QmlGraphicsItem *parent) :
- QmlGraphicsItem(parent)
-{
- setFlag(ItemIsPanel);
-}
-
-QmlGraphicsFocusPanel::~QmlGraphicsFocusPanel()
-{
-}
-
-/*!
- \qmlproperty bool FocusPanel::active
-
- Sets whether the item is the active focus panel.
-*/
-
-bool QmlGraphicsFocusPanel::sceneEvent(QEvent *event)
-{
- if (event->type() == QEvent::WindowActivate ||
- event->type() == QEvent::WindowDeactivate)
- emit activeChanged();
- return QmlGraphicsItem::sceneEvent(event);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsfocuspanel_p.h b/src/declarative/graphicsitems/qmlgraphicsfocuspanel_p.h
deleted file mode 100644
index 935b04e..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsfocuspanel_p.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSFOCUSPANEL_H
-#define QMLGRAPHICSFOCUSPANEL_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsFocusPanel : public QmlGraphicsItem
-{
- Q_OBJECT
- Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
-public:
- QmlGraphicsFocusPanel(QmlGraphicsItem *parent=0);
- virtual ~QmlGraphicsFocusPanel();
-
-Q_SIGNALS:
- void activeChanged();
-
-protected:
- bool sceneEvent(QEvent *event);
-
-private:
- Q_DISABLE_COPY(QmlGraphicsFocusPanel)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsFocusPanel)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSFOCUSPANEL_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp b/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp
deleted file mode 100644
index bba471a..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsfocusscope_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass FocusScope QmlGraphicsFocusScope
- \since 4.7
- \brief The FocusScope object explicitly creates a focus scope.
- \inherits Item
-
- Focus scopes assist in keyboard focus handling when building reusable QML
- components. All the details are covered in the
- \l {qmlfocus}{keyboard focus documentation}.
-*/
-
-/*!
- \internal
- \class QmlGraphicsFocusScope
-*/
-
-QmlGraphicsFocusScope::QmlGraphicsFocusScope(QmlGraphicsItem *parent) :
- QmlGraphicsItem(parent)
-{
- setFlag(QGraphicsItem::ItemIsFocusScope);
-}
-
-QmlGraphicsFocusScope::~QmlGraphicsFocusScope()
-{
-}
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsfocusscope_p.h b/src/declarative/graphicsitems/qmlgraphicsfocusscope_p.h
deleted file mode 100644
index ca53b01..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsfocusscope_p.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSFOCUSSCOPE_H
-#define QMLGRAPHICSFOCUSSCOPE_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-//### set component root as focusscope
-class Q_DECLARATIVE_EXPORT QmlGraphicsFocusScope : public QmlGraphicsItem
-{
- Q_OBJECT
-public:
- QmlGraphicsFocusScope(QmlGraphicsItem *parent=0);
- virtual ~QmlGraphicsFocusScope();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsFocusScope)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSFOCUSSCOPE_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp
deleted file mode 100644
index 692f7a9..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsgraphicsobjectcontainer_p.h"
-
-#include "qmlgraphicsitem_p.h"
-
-#include <QGraphicsObject>
-#include <QGraphicsWidget>
-#include <QGraphicsSceneResizeEvent>
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsGraphicsObjectContainerPrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsGraphicsObjectContainer)
-
-public:
- QmlGraphicsGraphicsObjectContainerPrivate() : QmlGraphicsItemPrivate(), graphicsObject(0), syncedResize(false)
- { }
-
- void _q_updateSize();
-
- void setFiltering(bool on)
- {
- Q_Q(QmlGraphicsGraphicsObjectContainer);
- if (graphicsObject && graphicsObject->isWidget()) {
- if (!on) {
- graphicsObject->removeEventFilter(q);
- QObject::disconnect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
- QObject::disconnect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
- } else {
- graphicsObject->installEventFilter(q);
- QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
- QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
- }
- }
- }
-
-
- QGraphicsObject *graphicsObject;
- bool syncedResize;
-};
-
-
-/*!
- \qmlclass GraphicsObjectContainer QmlGraphicsGraphicsObjectContainer
- \since 4.7
- \brief The GraphicsObjectContainer element allows you to add QGraphicsObjects into Fluid UI elements.
-
- While any QObject based class can be exposed to QML, QmlGraphicsItem
- provides a lot of important functionality, including anchors and proper
- management of child items. GraphicsObjectContainer helps provide these
- functions to other QGraphicsObjects, so that they can be used unaltered in
- a QML scene. QGraphicsObjects, which are not QmlGraphicsItems, and which are
- placed in a QML scene outside of a GraphicsObjectContainer, will not appear
- on screen at all.
-
- A GraphicsObjectContainer can have one element inside it, and it must be a
- QGraphicsObject or subclass which has been exposed to the QML engine.
- The graphics object inside the GraphicsObjectContainer can then be used
- like any other item in QML with the exception of not being reparentable
- and not having the standard properties of QML items (such as anchors).
-
- As the contained object is positioned relative to the container, anchors
- affecting the container item will affect the onscreen position of the
- contained item. If synchronizedResizing is set to true, then anchors
- affecting the container item's size will also affect the contained item's
- size.
-
- Example:
- \code
- import Qt 4.6
- import MyApp 2.1 as Widgets
- Rectangle{
- id: rect
- property alias widgetPropertyThree: widget.myThirdProperty;
- GraphicsObjectContainer{
- synchronizedResizing: true
- anchors.margins: 10
- anchors.fill: parent
- Widgets.MyWidget{
- myProperty: "A Value"
- myOtherProperty: rect.color
- }
- }
- }
- \endcode
-*/
-
-/*!
- \internal
- \class QmlGraphicsGraphicsObjectContainer
- \brief The QmlGraphicsGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications.
-*/
-
-QmlGraphicsGraphicsObjectContainer::QmlGraphicsGraphicsObjectContainer(QmlGraphicsItem *parent)
-: QmlGraphicsItem(*new QmlGraphicsGraphicsObjectContainerPrivate, parent)
-{
-}
-
-QmlGraphicsGraphicsObjectContainer::~QmlGraphicsGraphicsObjectContainer()
-{
-}
-
-QGraphicsObject *QmlGraphicsGraphicsObjectContainer::graphicsObject() const
-{
- Q_D(const QmlGraphicsGraphicsObjectContainer);
- return d->graphicsObject;
-}
-
-/*!
- \qmlproperty QGraphicsObject GraphicsObjectContainer::graphicsObject
- The QGraphicsObject associated with this element.
-*/
-void QmlGraphicsGraphicsObjectContainer::setGraphicsObject(QGraphicsObject *object)
-{
- Q_D(QmlGraphicsGraphicsObjectContainer);
- if (object == d->graphicsObject)
- return;
-
- //### remove previously set item?
-
- d->setFiltering(false);
-
- d->graphicsObject = object;
-
- if (d->graphicsObject) {
- d->graphicsObject->setParentItem(this);
-
- if (d->syncedResize && d->graphicsObject->isWidget()) {
- QGraphicsWidget *gw = static_cast<QGraphicsWidget*>(d->graphicsObject);
- QSizeF gwSize = gw->size(); //### should we use sizeHint?
- QSizeF newSize = gwSize;
- if (heightValid())
- newSize.setHeight(height());
- if (widthValid())
- newSize.setWidth(width());
- if (gwSize != newSize)
- gw->resize(newSize);
-
- gwSize = gw->size();
- setImplicitWidth(gwSize.width());
- setImplicitHeight(gwSize.height());
-
- d->setFiltering(true);
- }
- }
-}
-
-QVariant QmlGraphicsGraphicsObjectContainer::itemChange(GraphicsItemChange change, const QVariant &value)
-{
- Q_D(QmlGraphicsGraphicsObjectContainer);
- if (change == ItemSceneHasChanged) {
- QGraphicsObject *o = d->graphicsObject;
- d->graphicsObject = 0;
- setGraphicsObject(o);
- }
- return QmlGraphicsItem::itemChange(change, value);
-}
-
-bool QmlGraphicsGraphicsObjectContainer::eventFilter(QObject *watched, QEvent *e)
-{
- Q_D(QmlGraphicsGraphicsObjectContainer);
- if (watched == d->graphicsObject && e->type() == QEvent::GraphicsSceneResize) {
- if (d->graphicsObject && d->graphicsObject->isWidget() && d->syncedResize) {
- QSizeF newSize = static_cast<QGraphicsWidget*>(d->graphicsObject)->size();
- setImplicitWidth(newSize.width());
- setImplicitHeight(newSize.height());
- }
- }
- return QmlGraphicsItem::eventFilter(watched, e);
-}
-
-/*!
- \qmlproperty bool GraphicsObjectContainer::synchronizedResizing
-
- This property determines whether or not the container and graphics object will synchronize their
- sizes.
-
- \note This property only applies when wrapping a QGraphicsWidget.
-
- If synchronizedResizing is enabled, the container and widget will
- synchronize their sizes as follows.
- \list
- \o If a size has been set on the container, the widget will be resized to the container.
- Any changes in the container's size will be reflected in the widget.
-
- \o \e Otherwise, the container will initially be sized to the preferred size of the widget.
- Any changes to the container's size will be reflected in the widget, and any changes to the
- widget's size will be reflected in the container.
- \endlist
-*/
-bool QmlGraphicsGraphicsObjectContainer::synchronizedResizing() const
-{
- Q_D(const QmlGraphicsGraphicsObjectContainer);
- return d->syncedResize;
-}
-
-void QmlGraphicsGraphicsObjectContainer::setSynchronizedResizing(bool on)
-{
- Q_D(QmlGraphicsGraphicsObjectContainer);
- if (on == d->syncedResize)
- return;
-
- d->syncedResize = on;
- d->setFiltering(on);
-}
-
-void QmlGraphicsGraphicsObjectContainerPrivate::_q_updateSize()
-{
- if (!graphicsObject || !graphicsObject->isWidget() || !syncedResize)
- return;
-
- QGraphicsWidget *gw = static_cast<QGraphicsWidget*>(graphicsObject);
- const QSizeF newSize(width, height);
- gw->resize(newSize);
-
- //### will respecting the widgets min/max ever get us in trouble? (all other items always
- // size to exactly what you tell them)
- /*QSizeF constrainedSize = newSize.expandedTo(gw->minimumSize()).boundedTo(gw->maximumSize());
- gw->resize(constrainedSize);
- if (constrainedSize != newSize) {
- setImplicitWidth(constrainedSize.width());
- setImplicitHeight(constrainedSize.height());
- }*/
-}
-
-#include <moc_qmlgraphicsgraphicsobjectcontainer_p.cpp>
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer_p.h b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer_p.h
deleted file mode 100644
index e263aa0..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer_p.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSGRAPHICSOBJECTCONTAINER_H
-#define QMLGRAPHICSGRAPHICSOBJECTCONTAINER_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QGraphicsObject;
-class QmlGraphicsGraphicsObjectContainerPrivate;
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsGraphicsObjectContainer : public QmlGraphicsItem
-{
- Q_OBJECT
-
- Q_CLASSINFO("DefaultProperty", "graphicsObject")
- Q_PROPERTY(QGraphicsObject *graphicsObject READ graphicsObject WRITE setGraphicsObject)
- Q_PROPERTY(bool synchronizedResizing READ synchronizedResizing WRITE setSynchronizedResizing)
-
-public:
- QmlGraphicsGraphicsObjectContainer(QmlGraphicsItem *parent = 0);
- ~QmlGraphicsGraphicsObjectContainer();
-
- QGraphicsObject *graphicsObject() const;
- void setGraphicsObject(QGraphicsObject *);
-
- bool synchronizedResizing() const;
- void setSynchronizedResizing(bool on);
-
-protected:
- QVariant itemChange(GraphicsItemChange change, const QVariant &value);
- bool eventFilter(QObject *watched, QEvent *e);
-
-private:
- Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsGraphicsObjectContainer)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QGraphicsObject)
-QML_DECLARE_TYPE(QmlGraphicsGraphicsObjectContainer)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSGRAPHICSOBJECTCONTAINER_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
deleted file mode 100644
index ab87c03..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ /dev/null
@@ -1,1723 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsgridview_p.h"
-
-#include "qmlgraphicsvisualitemmodel_p.h"
-#include "qmlgraphicsflickable_p_p.h"
-
-#include <qmleasefollow_p.h>
-
-#include <qlistmodelinterface_p.h>
-#include <QKeyEvent>
-
-QT_BEGIN_NAMESPACE
-
-QHash<QObject*, QmlGraphicsGridViewAttached*> QmlGraphicsGridViewAttached::attachedProperties;
-
-
-//----------------------------------------------------------------------------
-
-class FxGridItem
-{
-public:
- FxGridItem(QmlGraphicsItem *i, QmlGraphicsGridView *v) : item(i), view(v) {
- attached = QmlGraphicsGridViewAttached::properties(item);
- attached->m_view = view;
- }
- ~FxGridItem() {}
-
- qreal rowPos() const { return (view->flow() == QmlGraphicsGridView::LeftToRight ? item->y() : item->x()); }
- qreal colPos() const { return (view->flow() == QmlGraphicsGridView::LeftToRight ? item->x() : item->y()); }
- qreal endRowPos() const {
- return view->flow() == QmlGraphicsGridView::LeftToRight
- ? item->y() + view->cellHeight() - 1
- : item->x() + view->cellWidth() - 1;
- }
- void setPosition(qreal col, qreal row) {
- if (view->flow() == QmlGraphicsGridView::LeftToRight) {
- item->setPos(QPointF(col, row));
- } else {
- item->setPos(QPointF(row, col));
- }
- }
-
- QmlGraphicsItem *item;
- QmlGraphicsGridView *view;
- QmlGraphicsGridViewAttached *attached;
- int index;
-};
-
-//----------------------------------------------------------------------------
-
-class QmlGraphicsGridViewPrivate : public QmlGraphicsFlickablePrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsGridView)
-
-public:
- QmlGraphicsGridViewPrivate()
- : currentItem(0), flow(QmlGraphicsGridView::LeftToRight)
- , visiblePos(0), visibleIndex(0) , currentIndex(-1)
- , cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1)
- , highlightComponent(0), highlight(0), trackedItem(0)
- , moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0)
- , bufferMode(NoBuffer)
- , ownModel(false), wrap(false), autoHighlight(true)
- , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false)
- , deferredRelease(false) {}
-
- void init();
- void clear();
- FxGridItem *createItem(int modelIndex);
- void releaseItem(FxGridItem *item);
- void refill(qreal from, qreal to, bool doBuffer=false);
-
- void updateGrid();
- void scheduleLayout();
- void layout(bool removed=false);
- void updateUnrequestedIndexes();
- void updateUnrequestedPositions();
- void updateTrackedItem();
- void createHighlight();
- void updateHighlight();
- void updateCurrent(int modelIndex);
-
- FxGridItem *visibleItem(int modelIndex) const {
- if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) {
- for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) {
- FxGridItem *item = visibleItems.at(i);
- if (item->index == modelIndex)
- return item;
- }
- }
- return 0;
- }
-
- qreal position() const {
- Q_Q(const QmlGraphicsGridView);
- return flow == QmlGraphicsGridView::LeftToRight ? q->viewportY() : q->viewportX();
- }
- void setPosition(qreal pos) {
- Q_Q(QmlGraphicsGridView);
- if (flow == QmlGraphicsGridView::LeftToRight)
- q->setViewportY(pos);
- else
- q->setViewportX(pos);
- }
- int size() const {
- Q_Q(const QmlGraphicsGridView);
- return flow == QmlGraphicsGridView::LeftToRight ? q->height() : q->width();
- }
- qreal startPosition() const {
- qreal pos = 0;
- if (!visibleItems.isEmpty())
- pos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize();
- return pos;
- }
-
- qreal endPosition() const {
- qreal pos = 0;
- if (model && model->count())
- pos = rowPosAt(model->count() - 1) + rowSize();
- return pos;
- }
-
- bool isValid() const {
- return model && model->count() && model->isValid();
- }
-
- int rowSize() const {
- return flow == QmlGraphicsGridView::LeftToRight ? cellHeight : cellWidth;
- }
- int colSize() const {
- return flow == QmlGraphicsGridView::LeftToRight ? cellWidth : cellHeight;
- }
-
- qreal colPosAt(int modelIndex) const {
- if (FxGridItem *item = visibleItem(modelIndex))
- return item->colPos();
- if (!visibleItems.isEmpty()) {
- if (modelIndex < visibleIndex) {
- int count = (visibleIndex - modelIndex) % columns;
- int col = visibleItems.first()->colPos() / colSize();
- col = (columns - count + col) % columns;
- return col * colSize();
- } else {
- int count = columns - 1 - (modelIndex - visibleItems.last()->index - 1) % columns;
- return visibleItems.last()->colPos() - count * colSize();
- }
- } else {
- return (modelIndex % columns) * colSize();
- }
- return 0;
- }
- qreal rowPosAt(int modelIndex) const {
- if (FxGridItem *item = visibleItem(modelIndex))
- return item->rowPos();
- if (!visibleItems.isEmpty()) {
- if (modelIndex < visibleIndex) {
- int firstCol = visibleItems.first()->colPos() / colSize();
- int col = visibleIndex - modelIndex + (columns - firstCol - 1);
- int rows = col / columns;
- return visibleItems.first()->rowPos() - rows * rowSize();
- } else {
- int count = modelIndex - visibleItems.last()->index;
- int col = visibleItems.last()->colPos() + count * colSize();
- int rows = col / (columns * colSize());
- return visibleItems.last()->rowPos() + rows * rowSize();
- }
- } else {
- return (modelIndex / columns) * rowSize();
- }
- return 0;
- }
-
- FxGridItem *firstVisibleItem() const {
- const qreal pos = position();
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxGridItem *item = visibleItems.at(i);
- if (item->index != -1 && item->endRowPos() > pos)
- return item;
- }
- return visibleItems.count() ? visibleItems.first() : 0;
- }
-
- // Map a model index to visibleItems list index.
- // These may differ if removed items are still present in the visible list,
- // e.g. doing a removal animation
- int mapFromModel(int modelIndex) const {
- if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count())
- return -1;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxGridItem *listItem = visibleItems.at(i);
- if (listItem->index == modelIndex)
- return i + visibleIndex;
- if (listItem->index > modelIndex)
- return -1;
- }
- return -1; // Not in visibleList
- }
-
- // for debugging only
- void checkVisible() const {
- int skip = 0;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxGridItem *listItem = visibleItems.at(i);
- if (listItem->index == -1) {
- ++skip;
- } else if (listItem->index != visibleIndex + i - skip) {
- for (int j = 0; j < visibleItems.count(); j++)
- qDebug() << " index" << j << "item index" << visibleItems.at(j)->index;
- qFatal("index %d %d %d", visibleIndex, i, listItem->index);
- }
- }
- }
-
- QGuard<QmlGraphicsVisualModel> model;
- QVariant modelVariant;
- QList<FxGridItem*> visibleItems;
- QHash<QmlGraphicsItem*,int> unrequestedItems;
- FxGridItem *currentItem;
- QmlGraphicsGridView::Flow flow;
- int visiblePos;
- int visibleIndex;
- int currentIndex;
- int cellWidth;
- int cellHeight;
- int columns;
- int requestedIndex;
- QmlComponent *highlightComponent;
- FxGridItem *highlight;
- FxGridItem *trackedItem;
- enum MovementReason { Other, SetIndex, Mouse };
- MovementReason moveReason;
- int buffer;
- QmlEaseFollow *highlightXAnimator;
- QmlEaseFollow *highlightYAnimator;
- enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 };
- BufferMode bufferMode;
-
- bool ownModel : 1;
- bool wrap : 1;
- bool autoHighlight : 1;
- bool fixCurrentVisibility : 1;
- bool lazyRelease : 1;
- bool layoutScheduled : 1;
- bool deferredRelease : 1;
-};
-
-void QmlGraphicsGridViewPrivate::init()
-{
- Q_Q(QmlGraphicsGridView);
- q->setFlag(QGraphicsItem::ItemIsFocusScope);
- QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(sizeChange()));
- QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(sizeChange()));
- q->setFlickDirection(QmlGraphicsFlickable::VerticalFlick);
-}
-
-void QmlGraphicsGridViewPrivate::clear()
-{
- for (int i = 0; i < visibleItems.count(); ++i)
- releaseItem(visibleItems.at(i));
- visibleItems.clear();
- visiblePos = 0;
- visibleIndex = 0;
- releaseItem(currentItem);
- currentItem = 0;
- createHighlight();
- trackedItem = 0;
-}
-
-FxGridItem *QmlGraphicsGridViewPrivate::createItem(int modelIndex)
-{
- Q_Q(QmlGraphicsGridView);
- // create object
- requestedIndex = modelIndex;
- FxGridItem *listItem = 0;
- if (QmlGraphicsItem *item = model->item(modelIndex, false)) {
- listItem = new FxGridItem(item, q);
- listItem->index = modelIndex;
- // complete
- model->completeItem();
- listItem->item->setZValue(1);
- listItem->item->setParent(q->viewport());
- unrequestedItems.remove(listItem->item);
- }
- requestedIndex = 0;
- return listItem;
-}
-
-
-void QmlGraphicsGridViewPrivate::releaseItem(FxGridItem *item)
-{
- Q_Q(QmlGraphicsGridView);
- if (!item || !model)
- return;
- if (trackedItem == item) {
- QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
- QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
- trackedItem = 0;
- }
- if (model->release(item->item) == 0) {
- // item was not destroyed, and we no longer reference it.
- unrequestedItems.insert(item->item, model->indexOf(item->item, q));
- }
- delete item;
-}
-
-void QmlGraphicsGridViewPrivate::refill(qreal from, qreal to, bool doBuffer)
-{
- Q_Q(QmlGraphicsGridView);
- if (!isValid() || !q->isComponentComplete())
- return;
-
- qreal bufferFrom = from - buffer;
- qreal bufferTo = to + buffer;
- qreal fillFrom = from;
- qreal fillTo = to;
- if (doBuffer && (bufferMode & BufferAfter))
- fillTo = bufferTo;
- if (doBuffer && (bufferMode & BufferBefore))
- fillFrom = bufferFrom;
-
- bool changed = false;
-
- int colPos = colPosAt(visibleIndex);
- int rowPos = rowPosAt(visibleIndex);
- int modelIndex = visibleIndex;
- if (visibleItems.count()) {
- rowPos = visibleItems.last()->rowPos();
- colPos = visibleItems.last()->colPos() + colSize();
- if (colPos > colSize() * (columns-1)) {
- colPos = 0;
- rowPos += rowSize();
- }
- int i = visibleItems.count() - 1;
- while (i > 0 && visibleItems.at(i)->index == -1)
- --i;
- modelIndex = visibleItems.at(i)->index + 1;
- }
- int colNum = colPos / colSize();
-
- FxGridItem *item = 0;
-
- // Item creation and release is staggered in order to avoid
- // creating/releasing multiple items in one frame
- // while flicking (as much as possible).
- while (modelIndex < model->count() && rowPos <= fillTo + rowSize()*(columns - colNum)/(columns+1)) {
-// qDebug() << "refill: append item" << modelIndex;
- if (!(item = createItem(modelIndex)))
- break;
- item->setPosition(colPos, rowPos);
- visibleItems.append(item);
- colPos += colSize();
- colNum++;
- if (colPos > colSize() * (columns-1)) {
- colPos = 0;
- colNum = 0;
- rowPos += rowSize();
- }
- ++modelIndex;
- changed = true;
- if (doBuffer) // never buffer more than one item per frame
- break;
- }
-
- if (visibleItems.count()) {
- rowPos = visibleItems.first()->rowPos();
- colPos = visibleItems.first()->colPos() - colSize();
- if (colPos < 0) {
- colPos = colSize() * (columns - 1);
- rowPos -= rowSize();
- }
- }
- colNum = colPos / colSize();
- while (visibleIndex > 0 && rowPos + rowSize() - 1 >= fillFrom - rowSize()*(colNum+1)/(columns+1)){
-// qDebug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos;
- if (!(item = createItem(visibleIndex-1)))
- break;
- --visibleIndex;
- item->setPosition(colPos, rowPos);
- visibleItems.prepend(item);
- colPos -= colSize();
- colNum--;
- if (colPos < 0) {
- colPos = colSize() * (columns - 1);
- colNum = columns-1;
- rowPos -= rowSize();
- }
- changed = true;
- if (doBuffer) // never buffer more than one item per frame
- break;
- }
-
- if (!lazyRelease || !changed || deferredRelease) { // avoid destroying items in the same frame that we create
- while (visibleItems.count() > 1
- && (item = visibleItems.first())
- && item->endRowPos() < bufferFrom - rowSize()*(item->colPos()/colSize()+1)/(columns+1)) {
- if (item->attached->delayRemove())
- break;
-// qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endRowPos();
- if (item->index != -1)
- visibleIndex++;
- visibleItems.removeFirst();
- releaseItem(item);
- changed = true;
- }
- while (visibleItems.count() > 1
- && (item = visibleItems.last())
- && item->rowPos() > bufferTo + rowSize()*(columns - item->colPos()/colSize())/(columns+1)) {
- if (item->attached->delayRemove())
- break;
-// qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1;
- visibleItems.removeLast();
- releaseItem(item);
- changed = true;
- }
- deferredRelease = false;
- } else {
- deferredRelease = true;
- }
- if (changed) {
- if (flow == QmlGraphicsGridView::LeftToRight)
- q->setViewportHeight(endPosition() - startPosition());
- else
- q->setViewportWidth(endPosition() - startPosition());
- } else if (!doBuffer && buffer && bufferMode != NoBuffer) {
- refill(from, to, true);
- }
- lazyRelease = false;
-}
-
-void QmlGraphicsGridViewPrivate::updateGrid()
-{
- Q_Q(QmlGraphicsGridView);
- columns = (int)qMax((flow == QmlGraphicsGridView::LeftToRight ? q->width() : q->height()) / colSize(), qreal(1.));
- if (isValid()) {
- if (flow == QmlGraphicsGridView::LeftToRight)
- q->setViewportHeight(endPosition() - startPosition());
- else
- q->setViewportWidth(endPosition() - startPosition());
- }
-}
-
-void QmlGraphicsGridViewPrivate::scheduleLayout()
-{
- Q_Q(QmlGraphicsGridView);
- if (!layoutScheduled) {
- layoutScheduled = true;
- QMetaObject::invokeMethod(q, "layout", Qt::QueuedConnection);
- }
-}
-
-void QmlGraphicsGridViewPrivate::layout(bool removed)
-{
- Q_Q(QmlGraphicsGridView);
- layoutScheduled = false;
- if (visibleItems.count()) {
- qreal rowPos = visibleItems.first()->rowPos();
- qreal colPos = visibleItems.first()->colPos();
- int col = visibleIndex % columns;
- if (colPos != col * colSize()) {
- if (removed)
- rowPos -= rowSize();
- colPos = col * colSize();
- visibleItems.first()->setPosition(colPos, rowPos);
- }
- for (int i = 1; i < visibleItems.count(); ++i) {
- FxGridItem *item = visibleItems.at(i);
- colPos += colSize();
- if (colPos > colSize() * (columns-1)) {
- colPos = 0;
- rowPos += rowSize();
- }
- item->setPosition(colPos, rowPos);
- }
- }
- q->refill();
- updateHighlight();
- moveReason = Other;
- if (flow == QmlGraphicsGridView::LeftToRight) {
- q->setViewportHeight(endPosition() - startPosition());
- fixupY();
- } else {
- q->setViewportWidth(endPosition() - startPosition());
- fixupX();
- }
- updateUnrequestedPositions();
-}
-
-void QmlGraphicsGridViewPrivate::updateUnrequestedIndexes()
-{
- Q_Q(QmlGraphicsGridView);
- QHash<QmlGraphicsItem*,int>::iterator it;
- for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it)
- *it = model->indexOf(it.key(), q);
-}
-
-void QmlGraphicsGridViewPrivate::updateUnrequestedPositions()
-{
- QHash<QmlGraphicsItem*,int>::const_iterator it;
- for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) {
- if (flow == QmlGraphicsGridView::LeftToRight) {
- it.key()->setPos(QPointF(colPosAt(*it), rowPosAt(*it)));
- } else {
- it.key()->setPos(QPointF(rowPosAt(*it), colPosAt(*it)));
- }
- }
-}
-
-void QmlGraphicsGridViewPrivate::updateTrackedItem()
-{
- Q_Q(QmlGraphicsGridView);
- FxGridItem *item = currentItem;
- if (highlight)
- item = highlight;
-
- FxGridItem *oldTracked = trackedItem;
-
- if (trackedItem && item != trackedItem) {
- QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
- QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
- trackedItem = 0;
- }
-
- if (!trackedItem && item) {
- trackedItem = item;
- QObject::connect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
- QObject::connect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
- }
- if (trackedItem && trackedItem != oldTracked)
- q->trackedPositionChanged();
-}
-
-void QmlGraphicsGridViewPrivate::createHighlight()
-{
- Q_Q(QmlGraphicsGridView);
- bool changed = false;
- if (highlight) {
- if (trackedItem == highlight)
- trackedItem = 0;
- delete highlight->item;
- delete highlight;
- highlight = 0;
- delete highlightXAnimator;
- delete highlightYAnimator;
- highlightXAnimator = 0;
- highlightYAnimator = 0;
- changed = true;
- }
-
- if (currentItem) {
- QmlGraphicsItem *item = 0;
- if (highlightComponent) {
- QmlContext *highlightContext = new QmlContext(qmlContext(q));
- QObject *nobj = highlightComponent->create(highlightContext);
- if (nobj) {
- highlightContext->setParent(nobj);
- item = qobject_cast<QmlGraphicsItem *>(nobj);
- if (!item)
- delete nobj;
- } else {
- delete highlightContext;
- }
- } else {
- item = new QmlGraphicsItem;
- item->setParent(q->viewport());
- }
- if (item) {
- item->setParent(q->viewport());
- highlight = new FxGridItem(item, q);
- highlightXAnimator = new QmlEaseFollow(q);
- highlightXAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("x")));
- highlightXAnimator->setDuration(150);
- highlightXAnimator->setEnabled(autoHighlight);
- highlightYAnimator = new QmlEaseFollow(q);
- highlightYAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("y")));
- highlightYAnimator->setDuration(150);
- highlightYAnimator->setEnabled(autoHighlight);
- changed = true;
- }
- }
- if (changed)
- emit q->highlightChanged();
-}
-
-void QmlGraphicsGridViewPrivate::updateHighlight()
-{
- if ((!currentItem && highlight) || (currentItem && !highlight))
- createHighlight();
- if (currentItem && autoHighlight && highlight && !moving) {
- // auto-update highlight
- highlightXAnimator->setSourceValue(currentItem->item->x());
- highlightYAnimator->setSourceValue(currentItem->item->y());
- highlight->item->setWidth(currentItem->item->width());
- highlight->item->setHeight(currentItem->item->height());
- }
- updateTrackedItem();
-}
-
-void QmlGraphicsGridViewPrivate::updateCurrent(int modelIndex)
-{
- Q_Q(QmlGraphicsGridView);
- if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) {
- if (currentItem) {
- currentItem->attached->setIsCurrentItem(false);
- releaseItem(currentItem);
- currentItem = 0;
- currentIndex = -1;
- updateHighlight();
- emit q->currentIndexChanged();
- }
- return;
- }
-
- if (currentItem && currentIndex == modelIndex) {
- updateHighlight();
- return;
- }
-
- FxGridItem *oldCurrentItem = currentItem;
- currentIndex = modelIndex;
- currentItem = createItem(modelIndex);
- fixCurrentVisibility = true;
- if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item))
- oldCurrentItem->attached->setIsCurrentItem(false);
- if (currentItem) {
- currentItem->setPosition(colPosAt(modelIndex), rowPosAt(modelIndex));
- currentItem->item->setFocus(true);
- currentItem->attached->setIsCurrentItem(true);
- }
- updateHighlight();
- emit q->currentIndexChanged();
- releaseItem(oldCurrentItem);
-}
-
-//----------------------------------------------------------------------------
-
-/*!
- \qmlclass GridView QmlGraphicsGridView
- \inherits Flickable
- \brief The GridView item provides a grid view of items provided by a model.
-
- The model is typically provided by a QAbstractListModel "C++ model object",
- but can also be created directly in QML.
-
- The items are laid out top to bottom (vertically) or left to right (horizontally)
- and may be flicked to scroll.
-
- The below example creates a very simple grid, using a QML model.
-
- \image gridview.png
-
- \snippet doc/src/snippets/declarative/gridview/gridview.qml 3
-
- The model is defined as a ListModel using QML:
- \quotefile doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml
-
- In this case ListModel is a handy way for us to test our UI. In practice
- the model would be implemented in C++, or perhaps via a SQL data source.
-*/
-QmlGraphicsGridView::QmlGraphicsGridView(QmlGraphicsItem *parent)
- : QmlGraphicsFlickable(*(new QmlGraphicsGridViewPrivate), parent)
-{
- Q_D(QmlGraphicsGridView);
- d->init();
-}
-
-QmlGraphicsGridView::~QmlGraphicsGridView()
-{
- Q_D(QmlGraphicsGridView);
- d->clear();
- if (d->ownModel)
- delete d->model;
-}
-
-/*!
- \qmlattachedproperty bool GridView::isCurrentItem
- This attched property is true if this delegate is the current item; otherwise false.
-
- It is attached to each instance of the delegate.
-*/
-
-/*!
- \qmlattachedproperty GridView GridView::view
- This attached property holds the view that manages this delegate instance.
-
- It is attached to each instance of the delegate.
-*/
-
-/*!
- \qmlattachedproperty bool GridView::delayRemove
- This attached property holds whether the delegate may be destroyed.
-
- It is attached to each instance of the delegate.
-
- It is sometimes necessary to delay the destruction of an item
- until an animation completes.
-
- The example below ensures that the animation completes before
- the item is removed from the grid.
-
- \code
- Component {
- id: myDelegate
- Item {
- id: wrapper
- GridView.onRemove: SequentialAnimation {
- PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: true }
- NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
- PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: false }
- }
- }
- }
- \endcode
-*/
-
-/*!
- \qmlattachedsignal GridView::onAdd()
- This attached handler is called immediately after an item is added to the view.
-*/
-
-/*!
- \qmlattachedsignal GridView::onRemove()
- This attached handler is called immediately before an item is removed from the view.
-*/
-
-
-/*!
- \qmlproperty model GridView::model
- This property holds the model providing data for the grid.
-
- The model provides a set of data that is used to create the items
- for the view. For large or dynamic datasets the model is usually
- provided by a C++ model object. The C++ model object must be a \l
- {QAbstractItemModel} subclass, a VisualModel, or a simple list.
-
- \sa {qmlmodels}{Data Models}
-*/
-QVariant QmlGraphicsGridView::model() const
-{
- Q_D(const QmlGraphicsGridView);
- return d->modelVariant;
-}
-
-void QmlGraphicsGridView::setModel(const QVariant &model)
-{
- Q_D(QmlGraphicsGridView);
- if (d->model) {
- disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
- disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
- disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
- disconnect(d->model, SIGNAL(createdItem(int, QmlGraphicsItem*)), this, SLOT(createdItem(int,QmlGraphicsItem*)));
- disconnect(d->model, SIGNAL(destroyingItem(QmlGraphicsItem*)), this, SLOT(destroyingItem(QmlGraphicsItem*)));
- }
- d->clear();
- d->modelVariant = model;
- QObject *object = qvariant_cast<QObject*>(model);
- QmlGraphicsVisualModel *vim = 0;
- if (object && (vim = qobject_cast<QmlGraphicsVisualModel *>(object))) {
- if (d->ownModel) {
- delete d->model;
- d->ownModel = false;
- }
- d->model = vim;
- } else {
- if (!d->ownModel) {
- d->model = new QmlGraphicsVisualDataModel(qmlContext(this));
- d->ownModel = true;
- }
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model))
- dataModel->setModel(model);
- }
- if (d->model) {
- if (isComponentComplete()) {
- refill();
- if (d->currentIndex >= d->model->count() || d->currentIndex < 0) {
- setCurrentIndex(0);
- } else {
- d->moveReason = QmlGraphicsGridViewPrivate::SetIndex;
- d->updateCurrent(d->currentIndex);
- }
- }
- connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
- connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
- connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
- connect(d->model, SIGNAL(createdItem(int, QmlGraphicsItem*)), this, SLOT(createdItem(int,QmlGraphicsItem*)));
- connect(d->model, SIGNAL(destroyingItem(QmlGraphicsItem*)), this, SLOT(destroyingItem(QmlGraphicsItem*)));
- emit countChanged();
- }
-}
-
-/*!
- \qmlproperty component GridView::delegate
-
- The delegate provides a template defining each item instantiated by the view.
- The index is exposed as an accessible \c index property. Properties of the
- model are also available depending upon the type of \l {qmlmodels}{Data Model}.
-
- Note that the GridView will layout the items based on the size of the root item
- in the delegate.
-
- Here is an example delegate:
- \snippet doc/src/snippets/declarative/gridview/gridview.qml 0
-*/
-QmlComponent *QmlGraphicsGridView::delegate() const
-{
- Q_D(const QmlGraphicsGridView);
- if (d->model) {
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model))
- return dataModel->delegate();
- }
-
- return 0;
-}
-
-void QmlGraphicsGridView::setDelegate(QmlComponent *delegate)
-{
- Q_D(QmlGraphicsGridView);
- if (delegate == this->delegate())
- return;
-
- if (!d->ownModel) {
- d->model = new QmlGraphicsVisualDataModel(qmlContext(this));
- d->ownModel = true;
- }
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) {
- dataModel->setDelegate(delegate);
- if (isComponentComplete()) {
- refill();
- d->moveReason = QmlGraphicsGridViewPrivate::SetIndex;
- d->updateCurrent(d->currentIndex);
- }
- }
-}
-
-/*!
- \qmlproperty int GridView::currentIndex
- \qmlproperty Item GridView::currentItem
-
- \c currentIndex holds the index of the current item.
- \c currentItem is the current item. Note that the position of the current item
- may only be approximate until it becomes visible in the view.
-*/
-int QmlGraphicsGridView::currentIndex() const
-{
- Q_D(const QmlGraphicsGridView);
- return d->currentIndex;
-}
-
-void QmlGraphicsGridView::setCurrentIndex(int index)
-{
- Q_D(QmlGraphicsGridView);
- if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) {
- d->moveReason = QmlGraphicsGridViewPrivate::SetIndex;
- cancelFlick();
- d->updateCurrent(index);
- } else {
- d->currentIndex = index;
- }
-}
-
-QmlGraphicsItem *QmlGraphicsGridView::currentItem()
-{
- Q_D(QmlGraphicsGridView);
- if (!d->currentItem)
- return 0;
- return d->currentItem->item;
-}
-
-/*!
- \qmlproperty Item GridView::highlightItem
-
- \c highlightItem holds the highlight item, which was created
- from the \l highlight component.
-
- The highlightItem is managed by the view unless
- \l highlightFollowsCurrentItem is set to false.
-
- \sa highlight, highlightFollowsCurrentItem
-*/
-QmlGraphicsItem *QmlGraphicsGridView::highlightItem()
-{
- Q_D(QmlGraphicsGridView);
- if (!d->highlight)
- return 0;
- return d->highlight->item;
-}
-
-/*!
- \qmlproperty int GridView::count
- This property holds the number of items in the view.
-*/
-int QmlGraphicsGridView::count() const
-{
- Q_D(const QmlGraphicsGridView);
- if (d->model)
- return d->model->count();
- return 0;
-}
-
-/*!
- \qmlproperty component GridView::highlight
- This property holds the component to use as the highlight.
-
- An instance of the highlight component will be created for each view.
- The geometry of the resultant component instance will be managed by the view
- so as to stay with the current item, unless the highlightFollowsCurrentItem property is false.
-
- The below example demonstrates how to make a simple highlight:
- \snippet doc/src/snippets/declarative/gridview/gridview.qml 1
-
- \sa highlightItem, highlightFollowsCurrentItem
-*/
-QmlComponent *QmlGraphicsGridView::highlight() const
-{
- Q_D(const QmlGraphicsGridView);
- return d->highlightComponent;
-}
-
-void QmlGraphicsGridView::setHighlight(QmlComponent *highlight)
-{
- Q_D(QmlGraphicsGridView);
- if (highlight != d->highlightComponent) {
- d->highlightComponent = highlight;
- d->updateCurrent(d->currentIndex);
- }
-}
-
-/*!
- \qmlproperty bool GridView::highlightFollowsCurrentItem
- This property sets whether the highlight is managed by the view.
-
- If highlightFollowsCurrentItem is true, the highlight will be moved smoothly
- to follow the current item. If highlightFollowsCurrentItem is false, the
- highlight will not be moved by the view, and must be implemented
- by the highlight component, for example:
-
- \code
- Component {
- id: myHighlight
- Rectangle {
- id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60
- y: SpringFollow { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
- x: SpringFollow { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
- }
- }
- \endcode
-*/
-bool QmlGraphicsGridView::highlightFollowsCurrentItem() const
-{
- Q_D(const QmlGraphicsGridView);
- return d->autoHighlight;
-}
-
-void QmlGraphicsGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
-{
- Q_D(QmlGraphicsGridView);
- if (d->autoHighlight != autoHighlight) {
- d->autoHighlight = autoHighlight;
- if (d->highlightXAnimator) {
- d->highlightXAnimator->setEnabled(d->autoHighlight);
- d->highlightYAnimator->setEnabled(d->autoHighlight);
- }
- d->updateHighlight();
- }
-}
-
-/*!
- \qmlproperty enumeration GridView::flow
- This property holds the flow of the grid.
-
- Possible values are \c LeftToRight (default) and \c TopToBottom.
-
- If \a flow is \c LeftToRight, the view will scroll vertically.
- If \a flow is \c TopToBottom, the view will scroll horizontally.
-*/
-QmlGraphicsGridView::Flow QmlGraphicsGridView::flow() const
-{
- Q_D(const QmlGraphicsGridView);
- return d->flow;
-}
-
-void QmlGraphicsGridView::setFlow(Flow flow)
-{
- Q_D(QmlGraphicsGridView);
- if (d->flow != flow) {
- d->flow = flow;
- if (d->flow == LeftToRight) {
- setViewportWidth(-1);
- setFlickDirection(QmlGraphicsFlickable::VerticalFlick);
- } else {
- setViewportHeight(-1);
- setFlickDirection(QmlGraphicsFlickable::HorizontalFlick);
- }
- d->clear();
- d->updateGrid();
- refill();
- d->updateCurrent(d->currentIndex);
- }
-}
-
-/*!
- \qmlproperty bool GridView::keyNavigationWraps
- This property holds whether the grid wraps key navigation
-
- If this property is true then key presses to move off of one end of the grid will cause the
- selection to jump to the other side.
-*/
-bool QmlGraphicsGridView::isWrapEnabled() const
-{
- Q_D(const QmlGraphicsGridView);
- return d->wrap;
-}
-
-void QmlGraphicsGridView::setWrapEnabled(bool wrap)
-{
- Q_D(QmlGraphicsGridView);
- d->wrap = wrap;
-}
-
-/*!
- \qmlproperty int GridView::cacheBuffer
- This property holds the number of off-screen pixels to cache.
-
- This property determines the number of pixels above the top of the view
- and below the bottom of the view to cache. Setting this value can make
- scrolling the view smoother at the expense of additional memory usage.
-*/
-int QmlGraphicsGridView::cacheBuffer() const
-{
- Q_D(const QmlGraphicsGridView);
- return d->buffer;
-}
-
-void QmlGraphicsGridView::setCacheBuffer(int buffer)
-{
- Q_D(QmlGraphicsGridView);
- if (d->buffer != buffer) {
- d->buffer = buffer;
- if (isComponentComplete())
- refill();
- }
-}
-
-/*!
- \qmlproperty int GridView::cellWidth
- \qmlproperty int GridView::cellHeight
-
- These properties holds the width and height of each cell in the grid
-
- The default cell size is 100x100.
-*/
-int QmlGraphicsGridView::cellWidth() const
-{
- Q_D(const QmlGraphicsGridView);
- return d->cellWidth;
-}
-
-void QmlGraphicsGridView::setCellWidth(int cellWidth)
-{
- Q_D(QmlGraphicsGridView);
- if (cellWidth != d->cellWidth && cellWidth > 0) {
- d->cellWidth = qMax(1, cellWidth);
- d->updateGrid();
- emit cellWidthChanged();
- d->layout();
- }
-}
-
-int QmlGraphicsGridView::cellHeight() const
-{
- Q_D(const QmlGraphicsGridView);
- return d->cellHeight;
-}
-
-void QmlGraphicsGridView::setCellHeight(int cellHeight)
-{
- Q_D(QmlGraphicsGridView);
- if (cellHeight != d->cellHeight && cellHeight > 0) {
- d->cellHeight = qMax(1, cellHeight);
- d->updateGrid();
- emit cellHeightChanged();
- d->layout();
- }
-}
-
-void QmlGraphicsGridView::sizeChange()
-{
- Q_D(QmlGraphicsGridView);
- if (isComponentComplete()) {
- d->updateGrid();
- d->layout();
- }
-}
-
-void QmlGraphicsGridView::viewportMoved()
-{
- Q_D(QmlGraphicsGridView);
- QmlGraphicsFlickable::viewportMoved();
- d->lazyRelease = true;
- if (d->flicked) {
- if (yflick()) {
- if (d->velocityY > 0)
- d->bufferMode = QmlGraphicsGridViewPrivate::BufferBefore;
- else if (d->velocityY < 0)
- d->bufferMode = QmlGraphicsGridViewPrivate::BufferAfter;
- }
-
- if (xflick()) {
- if (d->velocityX > 0)
- d->bufferMode = QmlGraphicsGridViewPrivate::BufferBefore;
- else if (d->velocityX < 0)
- d->bufferMode = QmlGraphicsGridViewPrivate::BufferAfter;
- }
- }
- refill();
-}
-
-qreal QmlGraphicsGridView::minYExtent() const
-{
- Q_D(const QmlGraphicsGridView);
- if (d->flow == QmlGraphicsGridView::TopToBottom)
- return QmlGraphicsFlickable::minYExtent();
- return -d->startPosition();
-}
-
-qreal QmlGraphicsGridView::maxYExtent() const
-{
- Q_D(const QmlGraphicsGridView);
- if (d->flow == QmlGraphicsGridView::TopToBottom)
- return QmlGraphicsFlickable::maxYExtent();
- qreal extent = -(d->endPosition() - height());
- const qreal minY = minYExtent();
- if (extent > minY)
- extent = minY;
- return extent;
-}
-
-qreal QmlGraphicsGridView::minXExtent() const
-{
- Q_D(const QmlGraphicsGridView);
- if (d->flow == QmlGraphicsGridView::LeftToRight)
- return QmlGraphicsFlickable::minXExtent();
- return -d->startPosition();
-}
-
-qreal QmlGraphicsGridView::maxXExtent() const
-{
- Q_D(const QmlGraphicsGridView);
- if (d->flow == QmlGraphicsGridView::LeftToRight)
- return QmlGraphicsFlickable::maxXExtent();
- qreal extent = -(d->endPosition() - width());
- const qreal minX = minXExtent();
- if (extent > minX)
- extent = minX;
- return extent;
-}
-
-void QmlGraphicsGridView::keyPressEvent(QKeyEvent *event)
-{
- Q_D(QmlGraphicsGridView);
- QmlGraphicsFlickable::keyPressEvent(event);
- if (event->isAccepted())
- return;
- if (d->model && d->model->count() && d->interactive) {
- d->moveReason = QmlGraphicsGridViewPrivate::SetIndex;
- int oldCurrent = currentIndex();
- switch (event->key()) {
- case Qt::Key_Up:
- moveCurrentIndexUp();
- break;
- case Qt::Key_Down:
- moveCurrentIndexDown();
- break;
- case Qt::Key_Left:
- moveCurrentIndexLeft();
- break;
- case Qt::Key_Right:
- moveCurrentIndexRight();
- break;
- default:
- break;
- }
- if (oldCurrent != currentIndex()) {
- event->accept();
- return;
- }
- }
- d->moveReason = QmlGraphicsGridViewPrivate::Other;
- event->ignore();
-}
-
-/*!
- \qmlmethod GridView::moveCurrentIndexUp()
-
- Move the currentIndex up one item in the view.
- The current index will wrap if keyNavigationWraps is true and it
- is currently at the end.
-*/
-void QmlGraphicsGridView::moveCurrentIndexUp()
-{
- Q_D(QmlGraphicsGridView);
- if (d->flow == QmlGraphicsGridView::LeftToRight) {
- if (currentIndex() >= d->columns || d->wrap) {
- int index = currentIndex() - d->columns;
- setCurrentIndex(index >= 0 ? index : d->model->count()-1);
- }
- } else {
- if (currentIndex() > 0 || d->wrap) {
- int index = currentIndex() - 1;
- setCurrentIndex(index >= 0 ? index : d->model->count()-1);
- }
- }
-}
-
-/*!
- \qmlmethod GridView::moveCurrentIndexDown()
-
- Move the currentIndex down one item in the view.
- The current index will wrap if keyNavigationWraps is true and it
- is currently at the end.
-*/
-void QmlGraphicsGridView::moveCurrentIndexDown()
-{
- Q_D(QmlGraphicsGridView);
- if (d->flow == QmlGraphicsGridView::LeftToRight) {
- if (currentIndex() < d->model->count() - d->columns || d->wrap) {
- int index = currentIndex()+d->columns;
- setCurrentIndex(index < d->model->count() ? index : 0);
- }
- } else {
- if (currentIndex() < d->model->count() - 1 || d->wrap) {
- int index = currentIndex() + 1;
- setCurrentIndex(index < d->model->count() ? index : 0);
- }
- }
-}
-
-/*!
- \qmlmethod GridView::moveCurrentIndexLeft()
-
- Move the currentIndex left one item in the view.
- The current index will wrap if keyNavigationWraps is true and it
- is currently at the end.
-*/
-void QmlGraphicsGridView::moveCurrentIndexLeft()
-{
- Q_D(QmlGraphicsGridView);
- if (d->flow == QmlGraphicsGridView::LeftToRight) {
- if (currentIndex() > 0 || d->wrap) {
- int index = currentIndex() - 1;
- setCurrentIndex(index >= 0 ? index : d->model->count()-1);
- }
- } else {
- if (currentIndex() >= d->columns || d->wrap) {
- int index = currentIndex() - d->columns;
- setCurrentIndex(index >= 0 ? index : d->model->count()-1);
- }
- }
-}
-
-/*!
- \qmlmethod GridView::moveCurrentIndexRight()
-
- Move the currentIndex right one item in the view.
- The current index will wrap if keyNavigationWraps is true and it
- is currently at the end.
-*/
-void QmlGraphicsGridView::moveCurrentIndexRight()
-{
- Q_D(QmlGraphicsGridView);
- if (d->flow == QmlGraphicsGridView::LeftToRight) {
- if (currentIndex() < d->model->count() - 1 || d->wrap) {
- int index = currentIndex() + 1;
- setCurrentIndex(index < d->model->count() ? index : 0);
- }
- } else {
- if (currentIndex() < d->model->count() - d->columns || d->wrap) {
- int index = currentIndex()+d->columns;
- setCurrentIndex(index < d->model->count() ? index : 0);
- }
- }
-}
-
-void QmlGraphicsGridView::positionViewAtIndex(int index)
-{
- Q_D(QmlGraphicsGridView);
- if (!d->isValid() || index < 0 || index >= d->model->count())
- return;
-
- qreal maxExtent = d->flow == QmlGraphicsGridView::LeftToRight ? -maxYExtent() : -maxXExtent();
- FxGridItem *item = d->visibleItem(index);
- if (item) {
- // Already created - just move to top of view
- int pos = qMin(item->rowPos(), maxExtent);
- d->setPosition(pos);
- } else {
- int pos = d->rowPosAt(index);
- // save the currently visible items in case any of them end up visible again
- QList<FxGridItem*> oldVisible = d->visibleItems;
- d->visibleItems.clear();
- d->visibleIndex = index - index % d->columns;
- d->setPosition(pos);
- // setPosition() will cause refill. Adjust if we have moved beyond range
- if (d->position() > maxExtent)
- d->setPosition(maxExtent);
- // now release the reference to all the old visible items.
- for (int i = 0; i < oldVisible.count(); ++i)
- d->releaseItem(oldVisible.at(i));
- }
-}
-
-
-void QmlGraphicsGridView::componentComplete()
-{
- Q_D(QmlGraphicsGridView);
- QmlGraphicsFlickable::componentComplete();
- d->updateGrid();
- refill();
- if (d->currentIndex < 0)
- d->updateCurrent(0);
- else
- d->updateCurrent(d->currentIndex);
-}
-
-void QmlGraphicsGridView::trackedPositionChanged()
-{
- Q_D(QmlGraphicsGridView);
- if (!d->trackedItem || !d->currentItem)
- return;
- if (!isFlicking() && !d->moving && d->moveReason == QmlGraphicsGridViewPrivate::SetIndex) {
- const qreal viewPos = d->position();
- if (d->trackedItem->rowPos() < viewPos && d->currentItem->rowPos() < viewPos) {
- d->setPosition(d->currentItem->rowPos() < d->trackedItem->rowPos() ? d->trackedItem->rowPos() : d->currentItem->rowPos());
- } else if (d->trackedItem->endRowPos() > viewPos + d->size()
- && d->currentItem->endRowPos() > viewPos + d->size()) {
- qreal pos;
- if (d->trackedItem->endRowPos() < d->currentItem->endRowPos()) {
- pos = d->trackedItem->endRowPos() - d->size();
- if (d->rowSize() > d->size())
- pos = d->trackedItem->rowPos();
- } else {
- pos = d->currentItem->endRowPos() - d->size();
- if (d->rowSize() > d->size())
- pos = d->currentItem->rowPos();
- }
- d->setPosition(pos);
- }
- }
-}
-
-void QmlGraphicsGridView::itemsInserted(int modelIndex, int count)
-{
- Q_D(QmlGraphicsGridView);
- if (!d->visibleItems.count() || d->model->count() <= 1) {
- refill();
- d->updateCurrent(qMax(0, qMin(d->currentIndex, d->model->count()-1)));
- emit countChanged();
- return;
- }
-
- int index = d->mapFromModel(modelIndex);
- if (index == -1) {
- int i = d->visibleItems.count() - 1;
- while (i > 0 && d->visibleItems.at(i)->index == -1)
- --i;
- if (d->visibleItems.at(i)->index + 1 == modelIndex) {
- // Special case of appending an item to the model.
- index = d->visibleIndex + d->visibleItems.count();
- } else {
- if (modelIndex <= d->visibleIndex) {
- // Insert before visible items
- d->visibleIndex += count;
- for (int i = 0; i < d->visibleItems.count(); ++i) {
- FxGridItem *listItem = d->visibleItems.at(i);
- if (listItem->index != -1 && listItem->index >= modelIndex)
- listItem->index += count;
- }
- }
- if (d->currentIndex >= modelIndex) {
- // adjust current item index
- d->currentIndex += count;
- if (d->currentItem)
- d->currentItem->index = d->currentIndex;
- }
- d->layout();
- emit countChanged();
- return;
- }
- }
-
- // At least some of the added items will be visible
- int insertCount = count;
- if (index < d->visibleIndex) {
- insertCount -= d->visibleIndex - index;
- index = d->visibleIndex;
- modelIndex = d->visibleIndex;
- }
-
- index -= d->visibleIndex;
- int to = d->buffer+d->position()+d->size()-1;
- int colPos, rowPos;
- if (index < d->visibleItems.count()) {
- colPos = d->visibleItems.at(index)->colPos();
- rowPos = d->visibleItems.at(index)->rowPos();
- } else {
- // appending items to visible list
- colPos = d->visibleItems.at(index-1)->colPos() + d->colSize();
- rowPos = d->visibleItems.at(index-1)->rowPos();
- if (colPos > d->colSize() * (d->columns-1)) {
- colPos = 0;
- rowPos += d->rowSize();
- }
- }
-
- QList<FxGridItem*> added;
- int i = 0;
- while (i < insertCount && rowPos <= to + d->rowSize()*(d->columns - (colPos/d->colSize()))/qreal(d->columns)) {
- FxGridItem *item = d->createItem(modelIndex + i);
- d->visibleItems.insert(index, item);
- item->setPosition(colPos, rowPos);
- added.append(item);
- colPos += d->colSize();
- if (colPos > d->colSize() * (d->columns-1)) {
- colPos = 0;
- rowPos += d->rowSize();
- }
- ++index;
- ++i;
- }
- if (i < insertCount) {
- // We didn't insert all our new items, which means anything
- // beyond the current index is not visible - remove it.
- while (d->visibleItems.count() > index) {
- d->releaseItem(d->visibleItems.takeLast());
- }
- }
-
- if (d->currentIndex >= modelIndex) {
- // adjust current item index
- d->currentIndex += count;
- if (d->currentItem) {
- d->currentItem->index = d->currentIndex;
- d->currentItem->setPosition(d->colPosAt(d->currentIndex), d->rowPosAt(d->currentIndex));
- }
- }
- // Update the indexes of the following visible items.
- for (; index < d->visibleItems.count(); ++index) {
- FxGridItem *listItem = d->visibleItems.at(index);
- if (listItem->index != -1)
- listItem->index += count;
- }
-
- // everything is in order now - emit add() signal
- for (int j = 0; j < added.count(); ++j)
- added.at(j)->attached->emitAdd();
- d->layout();
- emit countChanged();
-}
-
-void QmlGraphicsGridView::itemsRemoved(int modelIndex, int count)
-{
- Q_D(QmlGraphicsGridView);
- bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count;
- bool removedVisible = false;
-
- // Remove the items from the visible list, skipping anything already marked for removal
- QList<FxGridItem*>::Iterator it = d->visibleItems.begin();
- while (it != d->visibleItems.end()) {
- FxGridItem *item = *it;
- if (item->index == -1 || item->index < modelIndex) {
- // already removed, or before removed items
- if (item->index < modelIndex)
- removedVisible = true;
- ++it;
- } else if (item->index >= modelIndex + count) {
- // after removed items
- item->index -= count;
- ++it;
- } else {
- // removed item
- removedVisible = true;
- item->attached->emitRemove();
- if (item->attached->delayRemove()) {
- item->index = -1;
- connect(item->attached, SIGNAL(delayRemoveChanged()), this, SLOT(destroyRemoved()), Qt::QueuedConnection);
- ++it;
- } else {
- it = d->visibleItems.erase(it);
- d->releaseItem(item);
- }
- }
- }
-
- // fix current
- if (d->currentIndex >= modelIndex + count) {
- d->currentIndex -= count;
- if (d->currentItem)
- d->currentItem->index -= count;
- } else if (currentRemoved) {
- // current item has been removed.
- d->releaseItem(d->currentItem);
- d->currentItem = 0;
- d->currentIndex = -1;
- d->updateCurrent(qMin(modelIndex, d->model->count()-1));
- }
-
- // update visibleIndex
- for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
- if ((*it)->index != -1) {
- d->visibleIndex = (*it)->index;
- break;
- }
- }
-
- if (removedVisible) {
- if (d->visibleItems.isEmpty()) {
- d->visibleIndex = 0;
- d->setPosition(0);
- refill();
- } else {
- // Correct the positioning of the items
- d->scheduleLayout();
- }
- }
-
- emit countChanged();
-}
-
-void QmlGraphicsGridView::layout()
-{
- Q_D(QmlGraphicsGridView);
- if (d->layoutScheduled)
- d->layout();
-}
-
-void QmlGraphicsGridView::destroyRemoved()
-{
- Q_D(QmlGraphicsGridView);
- for (QList<FxGridItem*>::Iterator it = d->visibleItems.begin();
- it != d->visibleItems.end();) {
- FxGridItem *listItem = *it;
- if (listItem->index == -1 && listItem->attached->delayRemove() == false) {
- d->releaseItem(listItem);
- it = d->visibleItems.erase(it);
- } else {
- ++it;
- }
- }
-
- // Correct the positioning of the items
- d->layout();
-}
-
-void QmlGraphicsGridView::itemsMoved(int from, int to, int count)
-{
- Q_D(QmlGraphicsGridView);
- QHash<int,FxGridItem*> moved;
-
- bool removedBeforeVisible = false;
- FxGridItem *firstItem = d->firstVisibleItem();
-
- if (from < to && from < d->visibleIndex && to > d->visibleIndex)
- removedBeforeVisible = true;
-
- QList<FxGridItem*>::Iterator it = d->visibleItems.begin();
- while (it != d->visibleItems.end()) {
- FxGridItem *item = *it;
- if (item->index >= from && item->index < from + count) {
- // take the items that are moving
- item->index += (to-from);
- moved.insert(item->index, item);
- it = d->visibleItems.erase(it);
- if (item->rowPos() < firstItem->rowPos())
- removedBeforeVisible = true;
- } else {
- if (item->index > from && item->index != -1) {
- // move everything after the moved items.
- item->index -= count;
- if (item->index < d->visibleIndex)
- d->visibleIndex = item->index;
- } else if (item->index != -1) {
- removedBeforeVisible = true;
- }
- ++it;
- }
- }
-
- int remaining = count;
- int endIndex = d->visibleIndex;
- it = d->visibleItems.begin();
- while (it != d->visibleItems.end()) {
- FxGridItem *item = *it;
- if (remaining && item->index >= to && item->index < to + count) {
- // place items in the target position, reusing any existing items
- FxGridItem *movedItem = moved.take(item->index);
- if (!movedItem)
- movedItem = d->createItem(item->index);
- it = d->visibleItems.insert(it, movedItem);
- ++it;
- --remaining;
- } else {
- if (item->index != -1) {
- if (item->index >= to) {
- // update everything after the moved items.
- item->index += count;
- }
- endIndex = item->index;
- }
- ++it;
- }
- }
-
- // If we have moved items to the end of the visible items
- // then add any existing moved items that we have
- while (FxGridItem *item = moved.take(endIndex+1)) {
- d->visibleItems.append(item);
- ++endIndex;
- }
-
- // update visibleIndex
- for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
- if ((*it)->index != -1) {
- d->visibleIndex = (*it)->index;
- break;
- }
- }
-
- // Fix current index
- if (d->currentIndex >= 0 && d->currentItem) {
- int oldCurrent = d->currentIndex;
- d->currentIndex = d->model->indexOf(d->currentItem->item, this);
- if (oldCurrent != d->currentIndex) {
- d->currentItem->index = d->currentIndex;
- emit currentIndexChanged();
- }
- }
-
- // Whatever moved items remain are no longer visible items.
- while (moved.count()) {
- int idx = moved.begin().key();
- FxGridItem *item = moved.take(idx);
- if (item->item == d->currentItem->item)
- item->setPosition(d->colPosAt(idx), d->rowPosAt(idx));
- d->releaseItem(item);
- }
-
- d->layout(removedBeforeVisible);
-}
-
-void QmlGraphicsGridView::createdItem(int index, QmlGraphicsItem *item)
-{
- Q_D(QmlGraphicsGridView);
- item->setParentItem(this);
- if (d->requestedIndex != index) {
- item->setParentItem(this);
- d->unrequestedItems.insert(item, index);
- if (d->flow == QmlGraphicsGridView::LeftToRight) {
- item->setPos(QPointF(d->colPosAt(index), d->rowPosAt(index)));
- } else {
- item->setPos(QPointF(d->rowPosAt(index), d->colPosAt(index)));
- }
- }
-}
-
-void QmlGraphicsGridView::destroyingItem(QmlGraphicsItem *item)
-{
- Q_D(QmlGraphicsGridView);
- d->unrequestedItems.remove(item);
-}
-
-
-void QmlGraphicsGridView::refill()
-{
- Q_D(QmlGraphicsGridView);
- d->refill(d->position(), d->position()+d->size()-1);
-}
-
-
-QmlGraphicsGridViewAttached *QmlGraphicsGridView::qmlAttachedProperties(QObject *obj)
-{
- return QmlGraphicsGridViewAttached::properties(obj);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h
deleted file mode 100644
index bd18daf..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSGRIDVIEW_H
-#define QMLGRAPHICSGRIDVIEW_H
-
-#include "qmlgraphicsflickable_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QmlGraphicsVisualModel;
-class QmlGraphicsGridViewAttached;
-class QmlGraphicsGridViewPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsGridView : public QmlGraphicsFlickable
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsGridView)
-
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
- Q_PROPERTY(QmlGraphicsItem *currentItem READ currentItem NOTIFY currentIndexChanged)
- Q_PROPERTY(int count READ count NOTIFY countChanged)
-
- Q_PROPERTY(QmlComponent *highlight READ highlight WRITE setHighlight)
- Q_PROPERTY(QmlGraphicsItem *highlightItem READ highlightItem NOTIFY highlightChanged)
- Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
-
- Q_PROPERTY(Flow flow READ flow WRITE setFlow)
- Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
- Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
- Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged)
- Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged)
- Q_CLASSINFO("DefaultProperty", "data")
-
-public:
- QmlGraphicsGridView(QmlGraphicsItem *parent=0);
- ~QmlGraphicsGridView();
-
- QVariant model() const;
- void setModel(const QVariant &);
-
- QmlComponent *delegate() const;
- void setDelegate(QmlComponent *);
-
- int currentIndex() const;
- void setCurrentIndex(int idx);
-
- QmlGraphicsItem *currentItem();
- QmlGraphicsItem *highlightItem();
- int count() const;
-
- QmlComponent *highlight() const;
- void setHighlight(QmlComponent *highlight);
-
- bool highlightFollowsCurrentItem() const;
- void setHighlightFollowsCurrentItem(bool);
-
- Q_ENUMS(Flow)
- enum Flow { LeftToRight, TopToBottom };
- Flow flow() const;
- void setFlow(Flow);
-
- bool isWrapEnabled() const;
- void setWrapEnabled(bool);
-
- int cacheBuffer() const;
- void setCacheBuffer(int);
-
- int cellWidth() const;
- void setCellWidth(int);
-
- int cellHeight() const;
- void setCellHeight(int);
-
- static QmlGraphicsGridViewAttached *qmlAttachedProperties(QObject *);
-
-public Q_SLOTS:
- void moveCurrentIndexUp();
- void moveCurrentIndexDown();
- void moveCurrentIndexLeft();
- void moveCurrentIndexRight();
- void positionViewAtIndex(int index);
-
-Q_SIGNALS:
- void countChanged();
- void currentIndexChanged();
- void cellWidthChanged();
- void cellHeightChanged();
- void highlightChanged();
-
-protected:
- virtual void viewportMoved();
- virtual qreal minYExtent() const;
- virtual qreal maxYExtent() const;
- virtual qreal minXExtent() const;
- virtual qreal maxXExtent() const;
- virtual void keyPressEvent(QKeyEvent *);
- virtual void componentComplete();
-
-private Q_SLOTS:
- void trackedPositionChanged();
- void itemsInserted(int index, int count);
- void itemsRemoved(int index, int count);
- void itemsMoved(int from, int to, int count);
- void destroyRemoved();
- void createdItem(int index, QmlGraphicsItem *item);
- void destroyingItem(QmlGraphicsItem *item);
- void sizeChange();
- void layout();
-
-private:
- void refill();
-};
-
-class QmlGraphicsGridViewAttached : public QObject
-{
- Q_OBJECT
-public:
- QmlGraphicsGridViewAttached(QObject *parent)
- : QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
- ~QmlGraphicsGridViewAttached() {
- attachedProperties.remove(parent());
- }
-
- Q_PROPERTY(QmlGraphicsGridView *view READ view CONSTANT)
- QmlGraphicsGridView *view() { return m_view; }
-
- Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
- bool isCurrentItem() const { return m_isCurrent; }
- void setIsCurrentItem(bool c) {
- if (m_isCurrent != c) {
- m_isCurrent = c;
- emit currentItemChanged();
- }
- }
-
- Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
- bool delayRemove() const { return m_delayRemove; }
- void setDelayRemove(bool delay) {
- if (m_delayRemove != delay) {
- m_delayRemove = delay;
- emit delayRemoveChanged();
- }
- }
-
- static QmlGraphicsGridViewAttached *properties(QObject *obj) {
- QmlGraphicsGridViewAttached *rv = attachedProperties.value(obj);
- if (!rv) {
- rv = new QmlGraphicsGridViewAttached(obj);
- attachedProperties.insert(obj, rv);
- }
- return rv;
- }
-
- void emitAdd() { emit add(); }
- void emitRemove() { emit remove(); }
-
-Q_SIGNALS:
- void currentItemChanged();
- void delayRemoveChanged();
- void add();
- void remove();
-
-public:
- QmlGraphicsGridView *m_view;
- bool m_isCurrent;
- bool m_delayRemove;
-
- static QHash<QObject*, QmlGraphicsGridViewAttached*> attachedProperties;
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsGridView)
-QML_DECLARE_TYPEINFO(QmlGraphicsGridView, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
deleted file mode 100644
index 6e93c52..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp
+++ /dev/null
@@ -1,368 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsimage_p.h"
-#include "qmlgraphicsimage_p_p.h"
-
-#include <QKeyEvent>
-#include <QPainter>
-
-QT_BEGIN_NAMESPACE
-
-
-/*!
- \qmlclass Image QmlGraphicsImage
- \since 4.7
- \brief The Image element allows you to add bitmaps to a scene.
- \inherits Item
-
- The Image element supports untransformed, stretched and tiled.
-
- For an explanation of stretching and tiling, see the fillMode property description.
-
- Examples:
- \table
- \row
- \o \image declarative-qtlogo1.png
- \o Untransformed
- \qml
- Image { source: "pics/qtlogo.png" }
- \endqml
- \row
- \o \image declarative-qtlogo2.png
- \o fillMode: Stretch (default)
- \qml
- Image {
- width: 160
- height: 160
- source: "pics/qtlogo.png"
- }
- \endqml
- \row
- \o \image declarative-qtlogo3.png
- \o fillMode: Tile
- \qml
- Image {
- fillMode: Image.Tile
- width: 160; height: 160
- source: "pics/qtlogo.png"
- }
- \endqml
- \row
- \o \image declarative-qtlogo6.png
- \o fillMode: TileVertically
- \qml
- Image {
- fillMode: Image.TileVertically
- width: 160; height: 160
- source: "pics/qtlogo.png"
- }
- \endqml
- \row
- \o \image declarative-qtlogo5.png
- \o fillMode: TileHorizontally
- \qml
- Image {
- fillMode: Image.TileHorizontally
- width: 160; height: 160
- source: "pics/qtlogo.png"
- }
- \endqml
- \endtable
- */
-
-/*!
- \internal
- \class QmlGraphicsImage Image
- \brief The QmlGraphicsImage class provides an image item that you can add to a QmlView.
-
- \ingroup group_coreitems
-
- Example:
- \qml
- Image { source: "pics/star.png" }
- \endqml
-
- A QmlGraphicsImage object can be instantiated in Qml using the tag \l Image.
-*/
-
-QmlGraphicsImage::QmlGraphicsImage(QmlGraphicsItem *parent)
- : QmlGraphicsImageBase(*(new QmlGraphicsImagePrivate), parent)
-{
- connect(this, SIGNAL(sourceChanged(QUrl)), this, SLOT(updatePaintedGeometry()));
-}
-
-QmlGraphicsImage::QmlGraphicsImage(QmlGraphicsImagePrivate &dd, QmlGraphicsItem *parent)
- : QmlGraphicsImageBase(dd, parent)
-{
-}
-
-QmlGraphicsImage::~QmlGraphicsImage()
-{
-}
-
-void QmlGraphicsImage::setSource(const QUrl &url)
-{
- QmlGraphicsImageBase::setSource(url);
- updatePaintedGeometry();
-}
-
-/*!
- \qmlproperty QPixmap Image::pixmap
-
- This property holds the QPixmap image to display.
-
- This is useful for displaying images provided by a C++ implementation,
- for example, a model may provide a data role of type QPixmap.
-*/
-
-QPixmap QmlGraphicsImage::pixmap() const
-{
- Q_D(const QmlGraphicsImage);
- return d->pix;
-}
-
-void QmlGraphicsImage::setPixmap(const QPixmap &pix)
-{
- Q_D(QmlGraphicsImage);
- if (!d->url.isEmpty())
- return;
- d->setPixmap(pix);
-}
-
-void QmlGraphicsImagePrivate::setPixmap(const QPixmap &pixmap)
-{
- Q_Q(QmlGraphicsImage);
- pix = pixmap;
-
- q->setImplicitWidth(pix.width());
- q->setImplicitHeight(pix.height());
- status = pix.isNull() ? QmlGraphicsImageBase::Null : QmlGraphicsImageBase::Ready;
-
- q->update();
- emit q->pixmapChanged();
-}
-
-/*!
- \qmlproperty enumeration Image::fillMode
-
- Set this property to define what happens when the image set for the item is smaller
- than the size of the item.
-
- \list
- \o Stretch - the image is scaled to fit
- \o PreserveAspectFit - the image is scaled uniformly to fit without cropping
- \o PreserveAspectCrop - the image is scaled uniformly to fill, cropping if necessary
- \o Tile - the image is duplicated horizontally and vertically
- \o TileVertically - the image is stretched horizontally and tiled vertically
- \o TileHorizontally - the image is stretched vertically and tiled horizontally
- \endlist
-
- \image declarative-image_fillMode.gif
-*/
-QmlGraphicsImage::FillMode QmlGraphicsImage::fillMode() const
-{
- Q_D(const QmlGraphicsImage);
- return d->fillMode;
-}
-
-void QmlGraphicsImage::setFillMode(FillMode mode)
-{
- Q_D(QmlGraphicsImage);
- if (d->fillMode == mode)
- return;
- d->fillMode = mode;
- update();
- updatePaintedGeometry();
- emit fillModeChanged();
-}
-
-qreal QmlGraphicsImage::paintedWidth() const
-{
- Q_D(const QmlGraphicsImage);
- return d->paintedWidth;
-}
-
-qreal QmlGraphicsImage::paintedHeight() const
-{
- Q_D(const QmlGraphicsImage);
- return d->paintedHeight;
-}
-
-/*!
- \qmlproperty enum Image::status
-
- This property holds the status of image loading. It can be one of:
- \list
- \o Null - no image has been set
- \o Ready - the image has been loaded
- \o Loading - the image is currently being loaded
- \o Error - an error occurred while loading the image
- \endlist
-
- \sa progress
-*/
-
-/*!
- \qmlproperty real Image::progress
-
- This property holds the progress of image loading, from 0.0 (nothing loaded)
- to 1.0 (finished).
-
- \sa status
-*/
-
-/*!
- \qmlproperty bool Image::smooth
-
- Set this property if you want the image to be smoothly filtered when scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the image is displayed at its natural size, this property has no visual or
- performance effect.
-
- \note Generally scaling artifacts are only visible if the image is stationary on
- the screen. A common pattern when animating an image is to disable smooth
- filtering at the beginning of the animation and reenable it at the conclusion.
-*/
-
-void QmlGraphicsImage::updatePaintedGeometry()
-{
- Q_D(QmlGraphicsImage);
-
- if (d->fillMode == PreserveAspectFit) {
- qreal widthScale = width() / qreal(d->pix.width());
- qreal heightScale = height() / qreal(d->pix.height());
- if (!d->pix.width() || !d->pix.height())
- return;
- if (widthScale <= heightScale) {
- d->paintedWidth = width();
- d->paintedHeight = widthScale * qreal(d->pix.height());
- } else if(heightScale < widthScale) {
- d->paintedWidth = heightScale * qreal(d->pix.width());
- d->paintedHeight = height();
- }
- } else {
- d->paintedWidth = width();
- d->paintedHeight = height();
- }
- emit paintedGeometryChanged();
-}
-
-void QmlGraphicsImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- QmlGraphicsImageBase::geometryChanged(newGeometry, oldGeometry);
- updatePaintedGeometry();
-}
-
-/*!
- \qmlproperty url Image::source
-
- Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.
-
- The URL may be absolute, or relative to the URL of the component.
-*/
-
-void QmlGraphicsImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
-{
- Q_D(QmlGraphicsImage);
- if (d->pix.isNull())
- return;
-
- bool oldAA = p->testRenderHint(QPainter::Antialiasing);
- bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
- if (d->smooth)
- p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
-
- if (width() != d->pix.width() || height() != d->pix.height()) {
- if (d->fillMode >= Tile) {
- if (d->fillMode == Tile)
- p->drawTiledPixmap(QRectF(0,0,width(),height()), d->pix);
- else if (d->fillMode == TileVertically)
- p->drawTiledPixmap(QRectF(0,0,d->pix.width(),height()), d->pix);
- else
- p->drawTiledPixmap(QRectF(0,0,width(),d->pix.height()), d->pix);
- } else {
- qreal widthScale = width() / qreal(d->pix.width());
- qreal heightScale = height() / qreal(d->pix.height());
-
- QTransform scale;
-
- if (d->fillMode == PreserveAspectFit) {
- if (widthScale <= heightScale) {
- heightScale = widthScale;
- scale.translate(0, (height() - heightScale * d->pix.height()) / 2);
- } else if(heightScale < widthScale) {
- widthScale = heightScale;
- scale.translate((width() - widthScale * d->pix.width()) / 2, 0);
- }
- } else if (d->fillMode == PreserveAspectCrop) {
- if (widthScale < heightScale) {
- widthScale = heightScale;
- scale.translate((width() - widthScale * d->pix.width()) / 2, 0);
- } else if(heightScale < widthScale) {
- heightScale = widthScale;
- scale.translate(0, (height() - heightScale * d->pix.height()) / 2);
- }
- }
- if (clip()) {
- p->save();
- p->setClipRect(boundingRect(), Qt::IntersectClip);
- }
- scale.scale(widthScale, heightScale);
- QTransform old = p->transform();
- p->setWorldTransform(scale * old);
- p->drawPixmap(0, 0, d->pix);
- p->setWorldTransform(old);
- if (clip()) {
- p->restore();
- }
- }
- } else {
- p->drawPixmap(0, 0, d->pix);
- }
-
- if (d->smooth) {
- p->setRenderHint(QPainter::Antialiasing, oldAA);
- p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage_p.h b/src/declarative/graphicsitems/qmlgraphicsimage_p.h
deleted file mode 100644
index b8befeb..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsimage_p.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSIMAGE_H
-#define QMLGRAPHICSIMAGE_H
-
-#include "qmlgraphicsimagebase_p.h"
-
-#include <QtNetwork/qnetworkreply.h>
-
-QT_BEGIN_HEADER
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsImagePrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsImage : public QmlGraphicsImageBase
-{
- Q_OBJECT
- Q_ENUMS(FillMode)
-
- Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap NOTIFY pixmapChanged DESIGNABLE false)
- Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
- Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedGeometryChanged)
- Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedGeometryChanged)
-
-public:
- QmlGraphicsImage(QmlGraphicsItem *parent=0);
- ~QmlGraphicsImage();
-
- enum FillMode { Stretch, PreserveAspectFit, PreserveAspectCrop, Tile, TileVertically, TileHorizontally };
- FillMode fillMode() const;
- void setFillMode(FillMode);
-
- QPixmap pixmap() const;
- void setPixmap(const QPixmap &);
-
- qreal paintedWidth() const;
- qreal paintedHeight() const;
-
- void setSource(const QUrl &url);
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
-
-Q_SIGNALS:
- void fillModeChanged();
- void paintedGeometryChanged();
-
-protected:
- QmlGraphicsImage(QmlGraphicsImagePrivate &dd, QmlGraphicsItem *parent);
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
-
-protected Q_SLOTS:
- void updatePaintedGeometry();
-
-private:
- Q_DISABLE_COPY(QmlGraphicsImage)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsImage)
-};
-
-QT_END_NAMESPACE
-QML_DECLARE_TYPE(QmlGraphicsImage)
-QT_END_HEADER
-
-#endif // QMLGRAPHICSIMAGE_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h b/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h
deleted file mode 100644
index e404935..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSIMAGE_P_H
-#define QMLGRAPHICSIMAGE_P_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 "qmlgraphicsitem_p.h"
-#include "qmlgraphicsimagebase_p_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsImagePrivate : public QmlGraphicsImageBasePrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsImage)
-
-public:
- QmlGraphicsImagePrivate()
- : fillMode(QmlGraphicsImage::Stretch), paintedWidth(0), paintedHeight(0)
- {
- }
-
- QmlGraphicsImage::FillMode fillMode;
- qreal paintedWidth;
- qreal paintedHeight;
- void setPixmap(const QPixmap &pix);
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLGRAPHICSIMAGE_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp b/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp
deleted file mode 100644
index c09b661..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsimagebase_p.h"
-#include "qmlgraphicsimagebase_p_p.h"
-
-#include <qmlengine.h>
-#include <qmlpixmapcache_p.h>
-
-#include <QFile>
-
-QT_BEGIN_NAMESPACE
-
-QmlGraphicsImageBase::QmlGraphicsImageBase(QmlGraphicsImageBasePrivate &dd, QmlGraphicsItem *parent)
- : QmlGraphicsItem(dd, parent)
-{
- setFlag(QGraphicsItem::ItemHasNoContents, false);
-}
-
-QmlGraphicsImageBase::~QmlGraphicsImageBase()
-{
- Q_D(QmlGraphicsImageBase);
- if (d->pendingPixmapCache)
- QmlPixmapCache::cancel(d->url, this);
-}
-
-QmlGraphicsImageBase::Status QmlGraphicsImageBase::status() const
-{
- Q_D(const QmlGraphicsImageBase);
- return d->status;
-}
-
-
-qreal QmlGraphicsImageBase::progress() const
-{
- Q_D(const QmlGraphicsImageBase);
- return d->progress;
-}
-
-QUrl QmlGraphicsImageBase::source() const
-{
- Q_D(const QmlGraphicsImageBase);
- return d->url;
-}
-
-void QmlGraphicsImageBase::setSource(const QUrl &url)
-{
- Q_D(QmlGraphicsImageBase);
- //equality is fairly expensive, so we bypass for simple, common case
- if ((d->url.isEmpty() == url.isEmpty()) && url == d->url)
- return;
-
- if (d->pendingPixmapCache) {
- QmlPixmapCache::cancel(d->url, this);
- d->pendingPixmapCache = false;
- }
-
- d->url = url;
- if (d->progress != 0.0) {
- d->progress = 0.0;
- emit progressChanged(d->progress);
- }
-
- if (url.isEmpty()) {
- d->pix = QPixmap();
- d->status = Null;
- setImplicitWidth(0);
- setImplicitHeight(0);
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit pixmapChanged();
- update();
- } else {
- d->status = Loading;
- QmlPixmapReply::Status status = QmlPixmapCache::get(d->url, &d->pix);
- if (status != QmlPixmapReply::Ready && status != QmlPixmapReply::Error) {
- QmlPixmapReply *reply = QmlPixmapCache::request(qmlEngine(this), d->url);
- d->pendingPixmapCache = true;
-
- static int replyDownloadProgress = -1;
- static int replyFinished = -1;
- static int thisRequestProgress = -1;
- static int thisRequestFinished = -1;
- if (replyDownloadProgress == -1) {
- replyDownloadProgress =
- QmlPixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
- replyFinished =
- QmlPixmapReply::staticMetaObject.indexOfSignal("finished()");
- thisRequestProgress =
- QmlGraphicsImageBase::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)");
- thisRequestFinished =
- QmlGraphicsImageBase::staticMetaObject.indexOfSlot("requestFinished()");
- }
-
- QMetaObject::connect(reply, replyFinished, this,
- thisRequestFinished, Qt::DirectConnection);
- QMetaObject::connect(reply, replyDownloadProgress, this,
- thisRequestProgress, Qt::DirectConnection);
- } else {
- //### should be unified with requestFinished
- if (status == QmlPixmapReply::Ready) {
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
-
- if (d->status == Loading)
- d->status = Ready;
- } else {
- d->status = Error;
- }
- d->progress = 1.0;
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit progressChanged(d->progress);
- emit pixmapChanged();
- update();
- }
- }
-
- emit statusChanged(d->status);
-}
-
-void QmlGraphicsImageBase::requestFinished()
-{
- Q_D(QmlGraphicsImageBase);
-
- d->pendingPixmapCache = false;
-
- if (QmlPixmapCache::get(d->url, &d->pix) != QmlPixmapReply::Ready)
- d->status = Error;
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
-
- if (d->status == Loading)
- d->status = Ready;
- d->progress = 1.0;
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit progressChanged(1.0);
- emit pixmapChanged();
- update();
-}
-
-void QmlGraphicsImageBase::requestProgress(qint64 received, qint64 total)
-{
- Q_D(QmlGraphicsImageBase);
- if (d->status == Loading && total > 0) {
- d->progress = qreal(received)/total;
- emit progressChanged(d->progress);
- }
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsimagebase_p.h b/src/declarative/graphicsitems/qmlgraphicsimagebase_p.h
deleted file mode 100644
index e8bda4c..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsimagebase_p.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSIMAGEBASE_H
-#define QMLGRAPHICSIMAGEBASE_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsImageBasePrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsImageBase : public QmlGraphicsItem
-{
- Q_OBJECT
- Q_ENUMS(Status)
-
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
-
-public:
- ~QmlGraphicsImageBase();
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
- qreal progress() const;
-
- QUrl source() const;
- virtual void setSource(const QUrl &url);
-
-Q_SIGNALS:
- void sourceChanged(const QUrl &);
- void statusChanged(Status);
- void progressChanged(qreal progress);
- void pixmapChanged();
-
-protected:
- QmlGraphicsImageBase(QmlGraphicsImageBasePrivate &dd, QmlGraphicsItem *parent);
-
-private Q_SLOTS:
- virtual void requestFinished();
- void requestProgress(qint64,qint64);
-
-private:
- Q_DISABLE_COPY(QmlGraphicsImageBase)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsImageBase)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSIMAGEBASE_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsimagebase_p_p.h b/src/declarative/graphicsitems/qmlgraphicsimagebase_p_p.h
deleted file mode 100644
index d86785f..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsimagebase_p_p.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSIMAGEBASE_P_H
-#define QMLGRAPHICSIMAGEBASE_P_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 "qmlgraphicsitem_p.h"
-
-#include <QtCore/QPointer>
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkReply;
-class QmlGraphicsImageBasePrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsImageBase)
-
-public:
- QmlGraphicsImageBasePrivate()
- : status(QmlGraphicsImageBase::Null),
- progress(0.0),
- pendingPixmapCache(false)
- {
- }
-
- QPixmap pix;
- QmlGraphicsImageBase::Status status;
- QUrl url;
- qreal progress;
- bool pendingPixmapCache;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
deleted file mode 100644
index fce4e36..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ /dev/null
@@ -1,2838 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsitem_p.h"
-#include "qmlgraphicsitem.h"
-
-#include "qmlgraphicsevents_p_p.h"
-
-#include <qfxperf_p_p.h>
-#include <qmlengine.h>
-#include <qmlopenmetaobject_p.h>
-#include <qmlstate_p.h>
-#include <qmlview.h>
-#include <qmlstategroup_p.h>
-#include <qmlcomponent.h>
-
-#include <QDebug>
-#include <QPen>
-#include <QFile>
-#include <QEvent>
-#include <QGraphicsSceneMouseEvent>
-#include <QtCore/qnumeric.h>
-#include <QtScript/qscriptengine.h>
-#include <QtGui/qgraphicstransform.h>
-#include <QtGui/qgraphicseffect.h>
-#include <qlistmodelinterface_p.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef FLT_MAX
-#define FLT_MAX 1E+37
-#endif
-
-#include "qmlgraphicseffects.cpp"
-
-/*!
- \qmlclass Transform QGraphicsTransform
- \since 4.7
- \brief The Transform elements provide a way of building advanced transformations on Items.
-
- The Transform elements let you create and control advanced transformations that can be configured
- independently using specialized properties.
-
- You can assign any number of Transform elements to an Item. Each Transform is applied in order,
- one at a time, to the Item it's assigned to.
-
- \sa Rotation, Scale
-*/
-
-/*!
- \qmlclass Scale QGraphicsScale
- \since 4.7
- \brief The Scale object provides a way to scale an Item.
-
- The Scale object gives more control over scaling than using Item's scale property. Specifically,
- it allows a different scale for the x and y axes, and allows the scale to be relative to an
- arbitrary point.
-
- The following example scales the X axis of the Rectangle, relative to its interior point 25, 25:
- \qml
- Rectangle {
- width: 100; height: 100
- color: "blue"
- transform: Scale { origin.x: 25; origin.y: 25; xScale: 3}
- }
- \endqml
-*/
-
-/*!
- \qmlproperty real Scale::origin.x
- \qmlproperty real Scale::origin.y
-
- The point that the item is scaled from (i.e., the point that stays fixed relative to the parent as
- the rest of the item grows). By default the origin is 0, 0.
-*/
-
-/*!
- \qmlproperty real Scale::xScale
-
- The scaling factor for the X axis.
-*/
-
-/*!
- \qmlproperty real Scale::yScale
-
- The scaling factor for the Y axis.
-*/
-
-/*!
- \qmlclass Rotation QGraphicsRotation
- \since 4.7
- \brief The Rotation object provides a way to rotate an Item.
-
- The Rotation object gives more control over rotation than using Item's rotation property.
- Specifically, it allows (z axis) rotation to be relative to an arbitrary point.
-
- The following example rotates a Rectangle around its interior point 25, 25:
- \qml
- Rectangle {
- width: 100; height: 100
- color: "blue"
- transform: Rotation { origin.x: 25; origin.y: 25; angle: 45}
- }
- \endqml
-
- Rotation also provides a way to specify 3D-like rotations for Items. For these types of
- rotations you must specify the axis to rotate around in addition to the origin point.
-
- The following example shows various 3D-like rotations applied to an \l Image.
- \snippet doc/src/snippets/declarative/rotation.qml 0
-
- \image axisrotation.png
-*/
-
-/*!
- \qmlproperty real Rotation::origin.x
- \qmlproperty real Rotation::origin.y
-
- The origin point of the rotation (i.e., the point that stays fixed relative to the parent as
- the rest of the item rotates). By default the origin is 0, 0.
-*/
-
-/*!
- \qmlproperty real Rotation::axis.x
- \qmlproperty real Rotation::axis.y
- \qmlproperty real Rotation::axis.z
-
- The axis to rotate around. For simple (2D) rotation around a point, you do not need to specify an axis,
- as the default axis is the z axis (\c{ axis { x: 0; y: 0; z: 1 } }).
-
- For a typical 3D-like rotation you will usually specify both the origin and the axis.
-
- \image 3d-rotation-axis.png
-*/
-
-/*!
- \qmlproperty real Rotation::angle
-
- The angle to rotate, in degrees clockwise.
-*/
-
-
-/*!
- \group group_animation
- \title Animation
-*/
-
-/*!
- \group group_coreitems
- \title Basic Items
-*/
-
-/*!
- \group group_effects
- \title Effects
-*/
-
-/*!
- \group group_layouts
- \title Layouts
-*/
-
-/*!
- \group group_states
- \title States and Transitions
-*/
-
-/*!
- \group group_utility
- \title Utility
-*/
-
-/*!
- \group group_views
- \title Views
-*/
-
-/*!
- \group group_widgets
- \title Widgets
-*/
-
-/*!
- \internal
- \class QmlGraphicsContents
- \ingroup group_utility
- \brief The QmlGraphicsContents class gives access to the height and width of an item's contents.
-
-*/
-
-QmlGraphicsContents::QmlGraphicsContents() : m_x(0), m_y(0), m_width(0), m_height(0)
-{
-}
-
-/*!
- \qmlproperty real Item::childrenRect.x
- \qmlproperty real Item::childrenRect.y
- \qmlproperty real Item::childrenRect.width
- \qmlproperty real Item::childrenRect.height
-
- The childrenRect properties allow an item access to the geometry of its
- children. This property is useful if you have an item that needs to be
- sized to fit its children.
-*/
-
-QRectF QmlGraphicsContents::rectF() const
-{
- return QRectF(m_x, m_y, m_width, m_height);
-}
-
-//TODO: optimization: only check sender(), if there is one
-void QmlGraphicsContents::calcHeight()
-{
- qreal oldy = m_y;
- qreal oldheight = m_height;
-
- qreal top = FLT_MAX;
- qreal bottom = 0;
-
- QList<QGraphicsItem *> children = m_item->childItems();
- for (int i = 0; i < children.count(); ++i) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(i));
- if(!child)//### Should this be ignoring non-QmlGraphicsItem graphicsobjects?
- continue;
- qreal y = child->y();
- if (y + child->height() > bottom)
- bottom = y + child->height();
- if (y < top)
- top = y;
- }
- if (!children.isEmpty())
- m_y = top;
- m_height = qMax(bottom - top, qreal(0.0));
-
- if (m_height != oldheight || m_y != oldy)
- emit rectChanged();
-}
-
-//TODO: optimization: only check sender(), if there is one
-void QmlGraphicsContents::calcWidth()
-{
- qreal oldx = m_x;
- qreal oldwidth = m_width;
-
- qreal left = FLT_MAX;
- qreal right = 0;
-
- QList<QGraphicsItem *> children = m_item->childItems();
- for (int i = 0; i < children.count(); ++i) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(i));
- if(!child)//### Should this be ignoring non-QmlGraphicsItem graphicsobjects?
- continue;
- qreal x = child->x();
- if (x + child->width() > right)
- right = x + child->width();
- if (x < left)
- left = x;
- }
- if (!children.isEmpty())
- m_x = left;
- m_width = qMax(right - left, qreal(0.0));
-
- if (m_width != oldwidth || m_x != oldx)
- emit rectChanged();
-}
-
-void QmlGraphicsContents::setItem(QmlGraphicsItem *item)
-{
- m_item = item;
-
- QList<QGraphicsItem *> children = m_item->childItems();
- for (int i = 0; i < children.count(); ++i) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(i));
- if(!child)//### Should this be ignoring non-QmlGraphicsItem graphicsobjects?
- continue;
- connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight()));
- connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight()));
- connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth()));
- connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth()));
- connect(this, SIGNAL(rectChanged()), m_item, SIGNAL(childrenRectChanged()));
- }
-
- calcHeight();
- calcWidth();
-}
-
-QmlGraphicsItemKeyFilter::QmlGraphicsItemKeyFilter(QmlGraphicsItem *item)
-: m_next(0)
-{
- QmlGraphicsItemPrivate *p =
- item?static_cast<QmlGraphicsItemPrivate *>(QGraphicsItemPrivate::get(item)):0;
- if (p) {
- m_next = p->keyHandler;
- p->keyHandler = this;
- }
-}
-
-QmlGraphicsItemKeyFilter::~QmlGraphicsItemKeyFilter()
-{
-}
-
-void QmlGraphicsItemKeyFilter::keyPressed(QKeyEvent *event)
-{
- if (m_next) m_next->keyPressed(event);
-}
-
-void QmlGraphicsItemKeyFilter::keyReleased(QKeyEvent *event)
-{
- if (m_next) m_next->keyReleased(event);
-}
-
-void QmlGraphicsItemKeyFilter::inputMethodEvent(QInputMethodEvent *event)
-{
- if (m_next) m_next->inputMethodEvent(event);
-}
-
-QVariant QmlGraphicsItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- if (m_next) return m_next->inputMethodQuery(query);
- return QVariant();
-}
-
-void QmlGraphicsItemKeyFilter::componentComplete()
-{
- if (m_next) m_next->componentComplete();
-}
-
-
-/*!
- \qmlclass KeyNavigation
- \since 4.7
- \brief The KeyNavigation attached property supports key navigation by arrow keys.
-
- It is common in key-based UIs to use arrow keys to navigate
- between focussed items. The KeyNavigation property provides a
- convenient way of specifying which item will gain focus
- when an arrow key is pressed. The following example provides
- key navigation for a 2x2 grid of items.
-
- \code
- Grid {
- columns: 2
- width: 100; height: 100
- Rectangle {
- id: item1
- focus: true
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.right: item2
- KeyNavigation.down: item3
- }
- Rectangle {
- id: item2
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.left: item1
- KeyNavigation.down: item4
- }
- Rectangle {
- id: item3
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.right: item4
- KeyNavigation.up: item1
- }
- Rectangle {
- id: item4
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.left: item3
- KeyNavigation.up: item2
- }
- }
- \endcode
-
- KeyNavigation receives key events after the item it is attached to.
- If the item accepts an arrow key event, the KeyNavigation
- attached property will not receive an event for that key.
-
- If an item has been set for a direction and the KeyNavigation
- attached property receives the corresponding
- key press and release events, the events will be accepted by
- KeyNaviagtion and will not propagate any further.
-
- \sa {Keys}{Keys attached property}
-*/
-
-/*!
- \qmlproperty Item KeyNavigation::left
- \qmlproperty Item KeyNavigation::right
- \qmlproperty Item KeyNavigation::up
- \qmlproperty Item KeyNavigation::down
-
- These properties hold the item to assign focus to
- when Key_Left, Key_Right, Key_Up or Key_Down are
- pressed.
-*/
-
-QmlGraphicsKeyNavigationAttached::QmlGraphicsKeyNavigationAttached(QObject *parent)
-: QObject(*(new QmlGraphicsKeyNavigationAttachedPrivate), parent),
- QmlGraphicsItemKeyFilter(qobject_cast<QmlGraphicsItem*>(parent))
-{
-}
-
-QmlGraphicsKeyNavigationAttached *
-QmlGraphicsKeyNavigationAttached::qmlAttachedProperties(QObject *obj)
-{
- return new QmlGraphicsKeyNavigationAttached(obj);
-}
-
-QmlGraphicsItem *QmlGraphicsKeyNavigationAttached::left() const
-{
- Q_D(const QmlGraphicsKeyNavigationAttached);
- return d->left;
-}
-
-void QmlGraphicsKeyNavigationAttached::setLeft(QmlGraphicsItem *i)
-{
- Q_D(QmlGraphicsKeyNavigationAttached);
- d->left = i;
- emit changed();
-}
-
-QmlGraphicsItem *QmlGraphicsKeyNavigationAttached::right() const
-{
- Q_D(const QmlGraphicsKeyNavigationAttached);
- return d->right;
-}
-
-void QmlGraphicsKeyNavigationAttached::setRight(QmlGraphicsItem *i)
-{
- Q_D(QmlGraphicsKeyNavigationAttached);
- d->right = i;
- emit changed();
-}
-
-QmlGraphicsItem *QmlGraphicsKeyNavigationAttached::up() const
-{
- Q_D(const QmlGraphicsKeyNavigationAttached);
- return d->up;
-}
-
-void QmlGraphicsKeyNavigationAttached::setUp(QmlGraphicsItem *i)
-{
- Q_D(QmlGraphicsKeyNavigationAttached);
- d->up = i;
- emit changed();
-}
-
-QmlGraphicsItem *QmlGraphicsKeyNavigationAttached::down() const
-{
- Q_D(const QmlGraphicsKeyNavigationAttached);
- return d->down;
-}
-
-void QmlGraphicsKeyNavigationAttached::setDown(QmlGraphicsItem *i)
-{
- Q_D(QmlGraphicsKeyNavigationAttached);
- d->down = i;
- emit changed();
-}
-
-void QmlGraphicsKeyNavigationAttached::keyPressed(QKeyEvent *event)
-{
- Q_D(QmlGraphicsKeyNavigationAttached);
-
- event->ignore();
-
- switch(event->key()) {
- case Qt::Key_Left:
- if (d->left) {
- d->left->setFocus(true);
- event->accept();
- }
- break;
- case Qt::Key_Right:
- if (d->right) {
- d->right->setFocus(true);
- event->accept();
- }
- break;
- case Qt::Key_Up:
- if (d->up) {
- d->up->setFocus(true);
- event->accept();
- }
- break;
- case Qt::Key_Down:
- if (d->down) {
- d->down->setFocus(true);
- event->accept();
- }
- break;
- default:
- break;
- }
-
- if (!event->isAccepted()) QmlGraphicsItemKeyFilter::keyPressed(event);
-}
-
-void QmlGraphicsKeyNavigationAttached::keyReleased(QKeyEvent *event)
-{
- Q_D(QmlGraphicsKeyNavigationAttached);
-
- event->ignore();
-
- switch(event->key()) {
- case Qt::Key_Left:
- if (d->left) {
- event->accept();
- }
- break;
- case Qt::Key_Right:
- if (d->right) {
- event->accept();
- }
- break;
- case Qt::Key_Up:
- if (d->up) {
- event->accept();
- }
- break;
- case Qt::Key_Down:
- if (d->down) {
- event->accept();
- }
- break;
- default:
- break;
- }
-
- if (!event->isAccepted()) QmlGraphicsItemKeyFilter::keyReleased(event);
-}
-
-/*!
- \qmlclass Keys
- \since 4.7
- \brief The Keys attached property provides key handling to Items.
-
- All visual primitives support key handling via the \e Keys
- attached property. Keys can be handled via the \e onPressed
- and \e onReleased signal properties.
-
- The signal properties have a \l KeyEvent parameter, named
- \e event which contains details of the event. If a key is
- handled \e event.accepted should be set to true to prevent the
- event from propagating up the item heirarchy.
-
- \code
- Item {
- focus: true
- Keys.onPressed: {
- if (event.key == Qt.Key_Left) {
- console.log("move left");
- event.accepted = true;
- }
- }
- }
- \endcode
-
- Some keys may alternatively be handled via specific signal properties,
- for example \e onSelectPressed. These handlers automatically set
- \e event.accepted to true.
-
- \code
- Item {
- focus: true
- Keys.onLeftPressed: console.log("move left")
- }
- \endcode
-
- See \l {Qt::Key}{Qt.Key} for the list of keyboard codes.
-
- \sa KeyEvent, {KeyNavigation}{KeyNavigation attached property}
-*/
-
-/*!
- \qmlproperty bool Keys::enabled
-
- This flags enables key handling if true (default); otherwise
- no key handlers will be called.
-*/
-
-/*!
- \qmlproperty List<Object> Keys::forwardTo
-
- This property provides a way to forward key presses, key releases, and keyboard input
- coming from input methods to other items. This can be useful when you want
- one item to handle some keys (e.g. the up and down arrow keys), and another item to
- handle other keys (e.g. the left and right arrow keys). Once an item that has been
- forwarded keys accepts the event it is no longer forwarded to items later in the
- list.
-
- This example forwards key events to two lists:
- \qml
- ListView { id: list1 ... }
- ListView { id: list2 ... }
- Keys.forwardTo: [list1, list2]
- focus: true
- \endqml
-*/
-
-/*!
- \qmlsignal Keys::onPressed(event)
-
- This handler is called when a key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onReleased(event)
-
- This handler is called when a key has been released. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDigit0Pressed(event)
-
- This handler is called when the digit '0' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDigit1Pressed(event)
-
- This handler is called when the digit '1' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDigit2Pressed(event)
-
- This handler is called when the digit '2' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDigit3Pressed(event)
-
- This handler is called when the digit '3' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDigit4Pressed(event)
-
- This handler is called when the digit '4' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDigit5Pressed(event)
-
- This handler is called when the digit '5' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDigit6Pressed(event)
-
- This handler is called when the digit '6' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDigit7Pressed(event)
-
- This handler is called when the digit '7' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDigit8Pressed(event)
-
- This handler is called when the digit '8' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDigit9Pressed(event)
-
- This handler is called when the digit '9' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onLeftPressed(event)
-
- This handler is called when the Left arrow has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onRightPressed(event)
-
- This handler is called when the Right arrow has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onUpPressed(event)
-
- This handler is called when the Up arrow has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDownPressed(event)
-
- This handler is called when the Down arrow has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onAsteriskPressed(event)
-
- This handler is called when the Asterisk '*' has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onEscapePressed(event)
-
- This handler is called when the Escape key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onReturnPressed(event)
-
- This handler is called when the Return key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onEnterPressed(event)
-
- This handler is called when the Enter key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onDeletePressed(event)
-
- This handler is called when the Delete key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onSpacePressed(event)
-
- This handler is called when the Space key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onBackPressed(event)
-
- This handler is called when the Back key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onCancelPressed(event)
-
- This handler is called when the Cancel key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onSelectPressed(event)
-
- This handler is called when the Select key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onYesPressed(event)
-
- This handler is called when the Yes key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onNoPressed(event)
-
- This handler is called when the No key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onContext1Pressed(event)
-
- This handler is called when the Context1 key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onContext2Pressed(event)
-
- This handler is called when the Context2 key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onContext3Pressed(event)
-
- This handler is called when the Context3 key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onContext4Pressed(event)
-
- This handler is called when the Context4 key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onCallPressed(event)
-
- This handler is called when the Call key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onHangupPressed(event)
-
- This handler is called when the Hangup key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onFlipPressed(event)
-
- This handler is called when the Flip key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onMenuPressed(event)
-
- This handler is called when the Menu key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onVolumeUpPressed(event)
-
- This handler is called when the VolumeUp key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-/*!
- \qmlsignal Keys::onVolumeDownPressed(event)
-
- This handler is called when the VolumeDown key has been pressed. The \a event
- parameter provides information about the event.
-*/
-
-const QmlGraphicsKeysAttached::SigMap QmlGraphicsKeysAttached::sigMap[] = {
- { Qt::Key_Left, "leftPressed" },
- { Qt::Key_Right, "rightPressed" },
- { Qt::Key_Up, "upPressed" },
- { Qt::Key_Down, "downPressed" },
- { Qt::Key_Asterisk, "asteriskPressed" },
- { Qt::Key_NumberSign, "numberSignPressed" },
- { Qt::Key_Escape, "escapePressed" },
- { Qt::Key_Return, "returnPressed" },
- { Qt::Key_Enter, "enterPressed" },
- { Qt::Key_Delete, "deletePressed" },
- { Qt::Key_Space, "spacePressed" },
- { Qt::Key_Back, "backPressed" },
- { Qt::Key_Cancel, "cancelPressed" },
- { Qt::Key_Select, "selectPressed" },
- { Qt::Key_Yes, "yesPressed" },
- { Qt::Key_No, "noPressed" },
- { Qt::Key_Context1, "context1Pressed" },
- { Qt::Key_Context2, "context2Pressed" },
- { Qt::Key_Context3, "context3Pressed" },
- { Qt::Key_Context4, "context4Pressed" },
- { Qt::Key_Call, "callPressed" },
- { Qt::Key_Hangup, "hangupPressed" },
- { Qt::Key_Flip, "flipPressed" },
- { Qt::Key_Menu, "menuPressed" },
- { Qt::Key_VolumeUp, "volumeUpPressed" },
- { Qt::Key_VolumeDown, "volumeDownPressed" },
- { 0, 0 }
-};
-
-bool QmlGraphicsKeysAttachedPrivate::isConnected(const char *signalName)
-{
- return isSignalConnected(signalIndex(signalName));
-}
-
-QmlGraphicsKeysAttached::QmlGraphicsKeysAttached(QObject *parent)
-: QObject(*(new QmlGraphicsKeysAttachedPrivate), parent),
- QmlGraphicsItemKeyFilter(qobject_cast<QmlGraphicsItem*>(parent))
-{
- Q_D(QmlGraphicsKeysAttached);
- d->item = qobject_cast<QmlGraphicsItem*>(parent);
-}
-
-QmlGraphicsKeysAttached::~QmlGraphicsKeysAttached()
-{
-}
-
-void QmlGraphicsKeysAttached::componentComplete()
-{
- Q_D(QmlGraphicsKeysAttached);
- if (d->item) {
- for (int ii = 0; ii < d->targets.count(); ++ii) {
- QGraphicsItem *targetItem = d->finalFocusProxy(d->targets.at(ii));
- if (targetItem && (targetItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) {
- d->item->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
- break;
- }
- }
- }
-}
-
-void QmlGraphicsKeysAttached::keyPressed(QKeyEvent *event)
-{
- Q_D(QmlGraphicsKeysAttached);
- if (!d->enabled || d->inPress) {
- event->ignore();
- return;
- }
-
- // first process forwards
- if (d->item && d->item->scene()) {
- d->inPress = true;
- for (int ii = 0; ii < d->targets.count(); ++ii) {
- QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii));
- if (i) {
- d->item->scene()->sendEvent(i, event);
- if (event->isAccepted()) {
- d->inPress = false;
- return;
- }
- }
- }
- d->inPress = false;
- }
-
- QmlGraphicsKeyEvent ke(*event);
- QByteArray keySignal = keyToSignal(event->key());
- if (!keySignal.isEmpty()) {
- keySignal += "(QmlGraphicsKeyEvent*)";
- if (d->isConnected(keySignal)) {
- // If we specifically handle a key then default to accepted
- ke.setAccepted(true);
- int idx = QmlGraphicsKeysAttached::staticMetaObject.indexOfSignal(keySignal);
- metaObject()->method(idx).invoke(this, Qt::DirectConnection, Q_ARG(QmlGraphicsKeyEvent*, &ke));
- }
- }
- if (!ke.isAccepted())
- emit pressed(&ke);
- event->setAccepted(ke.isAccepted());
-
- if (!event->isAccepted()) QmlGraphicsItemKeyFilter::keyPressed(event);
-}
-
-void QmlGraphicsKeysAttached::keyReleased(QKeyEvent *event)
-{
- Q_D(QmlGraphicsKeysAttached);
- if (!d->enabled || d->inRelease) {
- event->ignore();
- return;
- }
-
- if (d->item && d->item->scene()) {
- d->inRelease = true;
- for (int ii = 0; ii < d->targets.count(); ++ii) {
- QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii));
- if (i) {
- d->item->scene()->sendEvent(i, event);
- if (event->isAccepted()) {
- d->inRelease = false;
- return;
- }
- }
- }
- d->inRelease = false;
- }
-
- QmlGraphicsKeyEvent ke(*event);
- emit released(&ke);
- event->setAccepted(ke.isAccepted());
-
- if (!event->isAccepted()) QmlGraphicsItemKeyFilter::keyReleased(event);
-}
-
-void QmlGraphicsKeysAttached::inputMethodEvent(QInputMethodEvent *event)
-{
- Q_D(QmlGraphicsKeysAttached);
- if (d->item && !d->inIM && d->item->scene()) {
- d->inIM = true;
- for (int ii = 0; ii < d->targets.count(); ++ii) {
- QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii));
- if (i && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod)) {
- d->item->scene()->sendEvent(i, event);
- if (event->isAccepted()) {
- d->imeItem = i;
- d->inIM = false;
- return;
- }
- }
- }
- d->inIM = false;
- }
- if (!event->isAccepted()) QmlGraphicsItemKeyFilter::inputMethodEvent(event);
-}
-
-class QmlGraphicsItemAccessor : public QGraphicsItem
-{
-public:
- QVariant doInputMethodQuery(Qt::InputMethodQuery query) const {
- return QGraphicsItem::inputMethodQuery(query);
- }
-};
-
-QVariant QmlGraphicsKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- Q_D(const QmlGraphicsKeysAttached);
- if (d->item) {
- for (int ii = 0; ii < d->targets.count(); ++ii) {
- QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii));
- if (i && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod) && i == d->imeItem) { //### how robust is i == d->imeItem check?
- QVariant v = static_cast<QmlGraphicsItemAccessor *>(i)->doInputMethodQuery(query);
- if (v.userType() == QVariant::RectF)
- v = d->item->mapRectFromItem(i, v.toRectF()); //### cost?
- return v;
- }
- }
- }
- return QmlGraphicsItemKeyFilter::inputMethodQuery(query);
-}
-
-QmlGraphicsKeysAttached *QmlGraphicsKeysAttached::qmlAttachedProperties(QObject *obj)
-{
- return new QmlGraphicsKeysAttached(obj);
-}
-
-/*!
- \class QmlGraphicsItem
- \since 4.7
- \brief The QmlGraphicsItem class provides the most basic of all visual items in QML.
-
- All visual items in Qt Declarative inherit from QmlGraphicsItem. Although QmlGraphicsItem
- has no visual appearance, it defines all the properties that are
- common across visual items - such as the x and y position, the
- width and height, \l {anchor-layout}{anchoring} and key handling.
-
- You can subclass QmlGraphicsItem to provide your own custom visual item that inherits
- these features.
-*/
-
-/*!
- \qmlclass Item QmlGraphicsItem
- \since 4.7
- \brief The Item is the most basic of all visual items in QML.
-
- All visual items in Qt Declarative inherit from Item. Although Item
- has no visual appearance, it defines all the properties that are
- common across visual items - such as the x and y position, the
- width and height, \l {anchor-layout}{anchoring} and key handling.
-
- Item is also useful for grouping items together.
-
- \qml
- Item {
- Image {
- source: "tile.png"
- }
- Image {
- x: 80
- width: 100
- height: 100
- source: "tile.png"
- }
- Image {
- x: 190
- width: 100
- height: 100
- fillMode: Image.Tile
- source: "tile.png"
- }
- }
- \endqml
-
- \section1 Identity
-
- Each item has an "id" - the identifier of the Item.
-
- The identifier can be used in bindings and other expressions to
- refer to the item. For example:
-
- \qml
- Text { id: myText; ... }
- Text { text: myText.text }
- \endqml
-
- The identifier is available throughout to the \l {components}{component}
- where it is declared. The identifier must be unique in the component.
-
- The id should not be thought of as a "property" - it makes no sense
- to write \c myText.id, for example.
-
- \section1 Key Handling
-
- Key handling is available to all Item-based visual elements via the \l {Keys}{Keys}
- attached property. The \e Keys attached property provides basic handlers such
- as \l {Keys::onPressed}{onPressed} and \l {Keys::onReleased}{onReleased},
- as well as handlers for specific keys, such as
- \l {Keys::onCancelPressed}{onCancelPressed}. The example below
- assigns \l {qmlfocus}{focus} to the item and handles
- the Left key via the general \e onPressed handler and the Select key via the
- onSelectPressed handler:
-
- \qml
- Item {
- focus: true
- Keys.onPressed: {
- if (event.key == Qt.Key_Left) {
- console.log("move left");
- event.accepted = true;
- }
- }
- Keys.onSelectPressed: console.log("Selected");
- }
- \endqml
-
- See the \l {Keys}{Keys} attached property for detailed documentation.
-
- \ingroup group_coreitems
-*/
-
-/*!
- \property QmlGraphicsItem::baseline
- \internal
-*/
-
-/*!
- \property QmlGraphicsItem::effect
- \internal
-*/
-
-/*!
- \property QmlGraphicsItem::focus
- \internal
-*/
-
-/*!
- \property QmlGraphicsItem::wantsFocus
- \internal
-*/
-
-/*!
- \property QmlGraphicsItem::transformOrigin
- \internal
-*/
-
-/*!
- \fn void QmlGraphicsItem::childrenRectChanged()
- \internal
-*/
-
-/*!
- \fn void QmlGraphicsItem::baselineOffsetChanged()
- \internal
-*/
-
-/*!
- \fn void QmlGraphicsItem::widthChanged()
- \internal
-*/
-
-/*!
- \fn void QmlGraphicsItem::heightChanged()
- \internal
-*/
-
-/*!
- \fn void QmlGraphicsItem::stateChanged(const QString &state)
- \internal
-*/
-
-/*!
- \fn void QmlGraphicsItem::parentChanged()
- \internal
-*/
-
-/*! \fn void QmlGraphicsItem::transformOriginChanged(TransformOrigin)
- \internal
-*/
-
-/*!
- \fn void QmlGraphicsItem::childrenChanged()
- \internal
-*/
-
-/*!
- \fn void QmlGraphicsItem::focusChanged()
- \internal
-*/
-
-/*!
- \fn void QmlGraphicsItem::wantsFocusChanged()
- \internal
-*/
-
-// ### Must fix
-struct RegisterAnchorLineAtStartup {
- RegisterAnchorLineAtStartup() {
- qRegisterMetaType<QmlGraphicsAnchorLine>("QmlGraphicsAnchorLine");
- }
-};
-static RegisterAnchorLineAtStartup registerAnchorLineAtStartup;
-
-
-/*!
- \fn QmlGraphicsItem::QmlGraphicsItem(QmlGraphicsItem *parent)
-
- Constructs a QmlGraphicsItem with the given \a parent.
-*/
-QmlGraphicsItem::QmlGraphicsItem(QmlGraphicsItem* parent)
- : QGraphicsObject(*(new QmlGraphicsItemPrivate), parent, 0)
-{
- Q_D(QmlGraphicsItem);
- d->init(parent);
-}
-
-/*! \internal
-*/
-QmlGraphicsItem::QmlGraphicsItem(QmlGraphicsItemPrivate &dd, QmlGraphicsItem *parent)
- : QGraphicsObject(dd, parent, 0)
-{
- Q_D(QmlGraphicsItem);
- d->init(parent);
-}
-
-/*!
- Destroys the QmlGraphicsItem.
-*/
-QmlGraphicsItem::~QmlGraphicsItem()
-{
- Q_D(QmlGraphicsItem);
- for (int ii = 0; ii < d->changeListeners.count(); ++ii) {
- QmlGraphicsAnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate();
- if (anchor)
- anchor->clearItem(this);
- }
- if (!d->parent || (parentItem() && !parentItem()->QGraphicsItem::d_ptr->inDestructor)) {
- for (int ii = 0; ii < d->changeListeners.count(); ++ii) {
- QmlGraphicsAnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate();
- if (anchor && anchor->item && anchor->item->parentItem() != this) //child will be deleted anyway
- anchor->updateOnComplete();
- }
- }
- for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
- const QmlGraphicsItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
- if (change.types & QmlGraphicsItemPrivate::Destroyed)
- change.listener->itemDestroyed(this);
- }
- d->changeListeners.clear();
- delete d->_anchorLines; d->_anchorLines = 0;
- delete d->_anchors; d->_anchors = 0;
- delete d->_stateGroup; d->_stateGroup = 0;
-}
-
-/*!
- \qmlproperty enum Item::transformOrigin
- This property holds the origin point around which scale and rotation transform.
-
- Nine transform origins are available, as shown in the image below.
-
- \image declarative-transformorigin.png
-
- This example rotates an image around its bottom-right corner.
- \qml
- Image {
- source: "myimage.png"
- transformOrigin: Item.BottomRight
- rotate: 45
- }
- \endqml
-
- The default transform origin is \c Center.
-*/
-
-/*!
- \qmlproperty Item Item::parent
- This property holds the parent of the item.
-*/
-
-/*!
- \property QmlGraphicsItem::parent
- This property holds the parent of the item.
-*/
-void QmlGraphicsItem::setParentItem(QmlGraphicsItem *parent)
-{
- QmlGraphicsItem *oldParent = parentItem();
- if (parent == oldParent || !parent) return;
-
- QObject::setParent(parent);
- QGraphicsObject::setParentItem(parent);
-}
-
-/*!
- \fn void QmlGraphicsItem::setParent(QmlGraphicsItem *parent)
- \overload
- Sets both the parent object and parent item to \a parent. This
- function avoids the programming error of calling setParent()
- when you mean setParentItem().
-*/
-
-/*!
- Returns the QmlGraphicsItem parent of this item.
-*/
-QmlGraphicsItem *QmlGraphicsItem::parentItem() const
-{
- return qobject_cast<QmlGraphicsItem *>(QGraphicsObject::parentItem());
-}
-
-/*!
- \qmlproperty list<Item> Item::children
- \qmlproperty list<Object> Item::resources
-
- The children property contains the list of visual children of this item.
- The resources property contains non-visual resources that you want to
- reference by name.
-
- Generally you can rely on Item's default property to handle all this for
- you, but it can come in handy in some cases.
-
- \qml
- Item {
- children: [
- Text {},
- Rectangle {}
- ]
- resources: [
- Component {
- id: myComponent
- Text {}
- }
- ]
- }
- \endqml
-*/
-
-/*!
- \property QmlGraphicsItem::children
- \internal
-*/
-
-/*!
- \property QmlGraphicsItem::resources
- \internal
-*/
-
-/*!
- Returns true if construction of the QML component is complete; otherwise
- returns false.
-
- It is often desireable to delay some processing until the component is
- completed.
-
- \sa componentComplete()
-*/
-bool QmlGraphicsItem::isComponentComplete() const
-{
- Q_D(const QmlGraphicsItem);
- return d->_componentComplete;
-}
-
-/*!
- \property QmlGraphicsItem::anchors
- \internal
-*/
-
-/*! \internal */
-QmlGraphicsAnchors *QmlGraphicsItem::anchors()
-{
- Q_D(QmlGraphicsItem);
- return d->anchors();
-}
-
-void QmlGraphicsItemPrivate::data_append(QmlListProperty<QObject> *prop, QObject *o)
-{
- QmlGraphicsItem *i = qobject_cast<QmlGraphicsItem *>(o);
- if (i)
- i->setParentItem(static_cast<QmlGraphicsItem *>(prop->object));
- else
- o->setParent(static_cast<QmlGraphicsItem *>(prop->object));
-}
-
-QObject *QmlGraphicsItemPrivate::resources_at(QmlListProperty<QObject> *prop, int index)
-{
- QObjectList children = prop->object->children();
- if (index < children.count())
- return children.at(index);
- else
- return 0;
-}
-
-void QmlGraphicsItemPrivate::resources_append(QmlListProperty<QObject> *prop, QObject *o)
-{
- o->setParent(prop->object);
-}
-
-int QmlGraphicsItemPrivate::resources_count(QmlListProperty<QObject> *prop)
-{
- return prop->object->children().count();
-}
-
-QmlGraphicsItem *QmlGraphicsItemPrivate::children_at(QmlListProperty<QmlGraphicsItem> *prop, int index)
-{
- QList<QGraphicsItem *> children = static_cast<QmlGraphicsItem*>(prop->object)->childItems();
-
- if (index < children.count())
- return qobject_cast<QmlGraphicsItem *>(children.at(index));
- else
- return 0;
-}
-
-void QmlGraphicsItemPrivate::children_append(QmlListProperty<QmlGraphicsItem> *prop, QmlGraphicsItem *i)
-{
- if (i)
- i->setParentItem(static_cast<QmlGraphicsItem*>(prop->object));
-}
-
-int QmlGraphicsItemPrivate::children_count(QmlListProperty<QmlGraphicsItem> *prop)
-{
- return static_cast<QmlGraphicsItem*>(prop->object)->childItems().count();
-}
-
-int QmlGraphicsItemPrivate::transform_count(QmlListProperty<QGraphicsTransform> *list)
-{
- QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
- if (object) {
- QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
- return d->transformData ? d->transformData->graphicsTransforms.size() : 0;
- } else {
- return 0;
- }
-}
-
-void QmlGraphicsItemPrivate::transform_append(QmlListProperty<QGraphicsTransform> *list, QGraphicsTransform *item)
-{
- QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
- if (object)
- QGraphicsItemPrivate::get(object)->appendGraphicsTransform(item);
-}
-
-QGraphicsTransform *QmlGraphicsItemPrivate::transform_at(QmlListProperty<QGraphicsTransform> *list, int idx)
-{
- QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
- if (object) {
- QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
- if (!d->transformData)
- return 0;
- return d->transformData->graphicsTransforms.at(idx);
- } else {
- return 0;
- }
-}
-
-void QmlGraphicsItemPrivate::transform_clear(QmlListProperty<QGraphicsTransform> *list)
-{
- QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
- if (object) {
- QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
- if (!d->transformData)
- return;
- object->setTransformations(QList<QGraphicsTransform *>());
- }
-}
-
-/*!
- \qmlproperty list<Object> Item::data
- \default
-
- The data property is allows you to freely mix visual children and resources
- of an item. If you assign a visual item to the data list it becomes
- a child and if you assign any other object type, it is added as a resource.
-
- So you can write:
- \qml
- Item {
- Text {}
- Rectangle {}
- Script {}
- }
- \endqml
-
- instead of:
- \qml
- Item {
- children: [
- Text {},
- Rectangle {}
- ]
- resources: [
- Script {}
- ]
- }
- \endqml
-
- data is a behind-the-scenes property: you should never need to explicitly
- specify it.
- */
-
-/*!
- \property QmlGraphicsItem::data
- \internal
-*/
-
-/*! \internal */
-QmlListProperty<QObject> QmlGraphicsItem::data()
-{
- return QmlListProperty<QObject>(this, 0, QmlGraphicsItemPrivate::data_append);
-}
-
-/*!
- \property QmlGraphicsItem::childrenRect
- \brief The geometry of an item's children.
-
- childrenRect provides an easy way to access the (collective) position and size of the item's children.
-*/
-QRectF QmlGraphicsItem::childrenRect()
-{
- Q_D(QmlGraphicsItem);
- if (!d->_contents) {
- d->_contents = new QmlGraphicsContents;
- d->_contents->setParent(this);
- d->_contents->setItem(this);
- }
- return d->_contents->rectF();
-}
-
-bool QmlGraphicsItem::clip() const
-{
- return flags() & ItemClipsChildrenToShape;
-}
-
-void QmlGraphicsItem::setClip(bool c)
-{
- if (clip() == c)
- return;
- setFlag(ItemClipsChildrenToShape, c);
- emit clipChanged();
-}
-
-/*!
- \qmlproperty real Item::x
- \qmlproperty real Item::y
- \qmlproperty real Item::width
- \qmlproperty real Item::height
-
- Defines the item's position and size relative to its parent.
-
- \qml
- Item { x: 100; y: 100; width: 100; height: 100 }
- \endqml
- */
-
-/*!
- \property QmlGraphicsItem::width
-
- Defines the item's width relative to its parent.
- */
-
-/*!
- \property QmlGraphicsItem::height
-
- Defines the item's height relative to its parent.
- */
-
-/*!
- \qmlproperty real Item::z
-
- Sets the stacking order of the item. By default the stacking order is 0.
-
- Items with a higher stacking value are drawn on top of items with a
- lower stacking order. Items with the same stacking value are drawn
- bottom up in the order they appear. Items with a negative stacking
- value are drawn under their parent's content.
-
- The following example shows the various effects of stacking order.
-
- \table
- \row
- \o \image declarative-item_stacking1.png
- \o Same \c z - later children above earlier children:
- \qml
- Item {
- Rectangle {
- color: "red"
- width: 100; height: 100
- }
- Rectangle {
- color: "blue"
- x: 50; y: 50; width: 100; height: 100
- }
- }
- \endqml
- \row
- \o \image declarative-item_stacking2.png
- \o Higher \c z on top:
- \qml
- Item {
- Rectangle {
- z: 1
- color: "red"
- width: 100; height: 100
- }
- Rectangle {
- color: "blue"
- x: 50; y: 50; width: 100; height: 100
- }
- }
- \endqml
- \row
- \o \image declarative-item_stacking3.png
- \o Same \c z - children above parents:
- \qml
- Item {
- Rectangle {
- color: "red"
- width: 100; height: 100
- Rectangle {
- color: "blue"
- x: 50; y: 50; width: 100; height: 100
- }
- }
- }
- \endqml
- \row
- \o \image declarative-item_stacking4.png
- \o Lower \c z below:
- \qml
- Item {
- Rectangle {
- color: "red"
- width: 100; height: 100
- Rectangle {
- z: -1
- color: "blue"
- x: 50; y: 50; width: 100; height: 100
- }
- }
- }
- \endqml
- \endtable
- */
-
-/*!
- \qmlproperty bool Item::visible
-
- Whether the item is visible. By default this is true.
-
- \note visible is not linked to actual visibility; if an item
- moves off screen, or the opacity changes to 0, this will
- not affect the visible property.
-*/
-
-
-/*!
- This function is called to handle this item's changes in
- geometry from \a oldGeometry to \a newGeometry. If the two
- geometries are the same, it doesn't do anything.
- */
-void QmlGraphicsItem::geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry)
-{
- Q_D(QmlGraphicsItem);
-
- if (d->_anchors)
- d->_anchors->d_func()->updateMe();
-
- if (transformOrigin() != QmlGraphicsItem::TopLeft)
- setTransformOriginPoint(d->computeTransformOrigin());
-
- if (newGeometry.x() != oldGeometry.x())
- emit xChanged();
- if (newGeometry.width() != oldGeometry.width())
- emit widthChanged();
- if (newGeometry.y() != oldGeometry.y())
- emit yChanged();
- if (newGeometry.height() != oldGeometry.height())
- emit heightChanged();
-
- for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
- const QmlGraphicsItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
- if (change.types & QmlGraphicsItemPrivate::Geometry)
- change.listener->itemGeometryChanged(this, newGeometry, oldGeometry);
- }
-}
-
-void QmlGraphicsItemPrivate::removeItemChangeListener(QmlGraphicsItemChangeListener *listener, ChangeTypes types)
-{
- ChangeListener change(listener, types);
- changeListeners.removeOne(change);
-}
-
-/*! \internal */
-void QmlGraphicsItem::keyPressEvent(QKeyEvent *event)
-{
- Q_D(QmlGraphicsItem);
- if (d->keyHandler)
- d->keyHandler->keyPressed(event);
- else
- event->ignore();
-}
-
-/*! \internal */
-void QmlGraphicsItem::keyReleaseEvent(QKeyEvent *event)
-{
- Q_D(QmlGraphicsItem);
- if (d->keyHandler)
- d->keyHandler->keyReleased(event);
- else
- event->ignore();
-}
-
-/*! \internal */
-void QmlGraphicsItem::inputMethodEvent(QInputMethodEvent *event)
-{
- Q_D(QmlGraphicsItem);
- if (d->keyHandler)
- d->keyHandler->inputMethodEvent(event);
- else
- event->ignore();
-}
-
-/*! \internal */
-QVariant QmlGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- Q_D(const QmlGraphicsItem);
- QVariant v;
- if (d->keyHandler)
- v = d->keyHandler->inputMethodQuery(query);
-
- if (!v.isValid())
- v = QGraphicsObject::inputMethodQuery(query);
-
- return v;
-}
-
-/*!
- \internal
-*/
-QmlGraphicsAnchorLine QmlGraphicsItem::left() const
-{
- Q_D(const QmlGraphicsItem);
- return d->anchorLines()->left;
-}
-
-/*!
- \internal
-*/
-QmlGraphicsAnchorLine QmlGraphicsItem::right() const
-{
- Q_D(const QmlGraphicsItem);
- return d->anchorLines()->right;
-}
-
-/*!
- \internal
-*/
-QmlGraphicsAnchorLine QmlGraphicsItem::horizontalCenter() const
-{
- Q_D(const QmlGraphicsItem);
- return d->anchorLines()->hCenter;
-}
-
-/*!
- \internal
-*/
-QmlGraphicsAnchorLine QmlGraphicsItem::top() const
-{
- Q_D(const QmlGraphicsItem);
- return d->anchorLines()->top;
-}
-
-/*!
- \internal
-*/
-QmlGraphicsAnchorLine QmlGraphicsItem::bottom() const
-{
- Q_D(const QmlGraphicsItem);
- return d->anchorLines()->bottom;
-}
-
-/*!
- \internal
-*/
-QmlGraphicsAnchorLine QmlGraphicsItem::verticalCenter() const
-{
- Q_D(const QmlGraphicsItem);
- return d->anchorLines()->vCenter;
-}
-
-
-/*!
- \internal
-*/
-QmlGraphicsAnchorLine QmlGraphicsItem::baseline() const
-{
- Q_D(const QmlGraphicsItem);
- return d->anchorLines()->baseline;
-}
-
-/*!
- \property QmlGraphicsItem::top
- \internal
-*/
-
-/*!
- \property QmlGraphicsItem::bottom
- \internal
-*/
-
-/*!
- \property QmlGraphicsItem::left
- \internal
-*/
-
-/*!
- \property QmlGraphicsItem::right
- \internal
-*/
-
-/*!
- \property QmlGraphicsItem::horizontalCenter
- \internal
-*/
-
-/*!
- \property QmlGraphicsItem::verticalCenter
- \internal
-*/
-
-/*!
- \qmlproperty AnchorLine Item::top
- \qmlproperty AnchorLine Item::bottom
- \qmlproperty AnchorLine Item::left
- \qmlproperty AnchorLine Item::right
- \qmlproperty AnchorLine Item::horizontalCenter
- \qmlproperty AnchorLine Item::verticalCenter
- \qmlproperty AnchorLine Item::baseline
-
- The anchor lines of the item.
-
- For more information see \l {anchor-layout}{Anchor Layouts}.
-*/
-
-/*!
- \qmlproperty AnchorLine Item::anchors.top
- \qmlproperty AnchorLine Item::anchors.bottom
- \qmlproperty AnchorLine Item::anchors.left
- \qmlproperty AnchorLine Item::anchors.right
- \qmlproperty AnchorLine Item::anchors.horizontalCenter
- \qmlproperty AnchorLine Item::anchors.verticalCenter
- \qmlproperty AnchorLine Item::anchors.baseline
-
- \qmlproperty Item Item::anchors.fill
- \qmlproperty Item Item::anchors.centerIn
-
- \qmlproperty real Item::anchors.margins
- \qmlproperty real Item::anchors.topMargin
- \qmlproperty real Item::anchors.bottomMargin
- \qmlproperty real Item::anchors.leftMargin
- \qmlproperty real Item::anchors.rightMargin
- \qmlproperty real Item::anchors.horizontalCenterOffset
- \qmlproperty real Item::anchors.verticalCenterOffset
- \qmlproperty real Item::anchors.baselineOffset
-
- Anchors provide a way to position an item by specifying its
- relationship with other items.
-
- Margins apply to top, bottom, left, right, and fill anchors.
- The margins property can be used to set all of the various margins at once, to the same value.
-
- Offsets apply for horizontal center, vertical center, and baseline anchors.
-
- \table
- \row
- \o \image declarative-anchors_example.png
- \o Text anchored to Image, horizontally centered and vertically below, with a margin.
- \qml
- Image { id: pic; ... }
- Text {
- id: label
- anchors.horizontalCenter: pic.horizontalCenter
- anchors.top: pic.bottom
- anchors.topMargin: 5
- ...
- }
- \endqml
- \row
- \o \image declarative-anchors_example2.png
- \o
- Left of Text anchored to right of Image, with a margin. The y
- property of both defaults to 0.
-
- \qml
- Image { id: pic; ... }
- Text {
- id: label
- anchors.left: pic.right
- anchors.leftMargin: 5
- ...
- }
- \endqml
- \endtable
-
- anchors.fill provides a convenient way for one item to have the
- same geometry as another item, and is equivalent to connecting all
- four directional anchors.
-
- \note You can only anchor an item to siblings or a parent.
-
- For more information see \l {anchor-layout}{Anchor Layouts}.
-*/
-
-/*!
- \property QmlGraphicsItem::baselineOffset
- \brief The position of the item's baseline in local coordinates.
-
- The baseline of a Text item is the imaginary line on which the text
- sits. Controls containing text usually set their baseline to the
- baseline of their text.
-
- For non-text items, a default baseline offset of 0 is used.
-*/
-qreal QmlGraphicsItem::baselineOffset() const
-{
- Q_D(const QmlGraphicsItem);
- if (!d->_baselineOffset.isValid()) {
- return 0.0;
- } else
- return d->_baselineOffset;
-}
-
-void QmlGraphicsItem::setBaselineOffset(qreal offset)
-{
- Q_D(QmlGraphicsItem);
- if (offset == d->_baselineOffset)
- return;
-
- d->_baselineOffset = offset;
- emit baselineOffsetChanged();
-
- for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
- const QmlGraphicsItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
- if (change.types & QmlGraphicsItemPrivate::Geometry) {
- QmlGraphicsAnchorsPrivate *anchor = change.listener->anchorPrivate();
- if (anchor)
- anchor->updateVerticalAnchors();
- }
- }
-}
-
-/*!
- \qmlproperty real Item::rotation
- This property holds the rotation of the item in degrees clockwise.
-
- This specifies how many degrees to rotate the item around its transformOrigin.
- The default rotation is 0 degrees (i.e. not rotated at all).
-
- \table
- \row
- \o \image declarative-rotation.png
- \o
- \qml
- Rectangle {
- color: "blue"
- width: 100; height: 100
- Rectangle {
- color: "red"
- x: 25; y: 25; width: 50; height: 50
- rotation: 30
- }
- }
- \endqml
- \endtable
-*/
-
-/*!
- \qmlproperty real Item::scale
- This property holds the scale of the item.
-
- A scale of less than 1 means the item will be displayed smaller than
- normal, and a scale of greater than 1 means the item will be
- displayed larger than normal. A negative scale means the item will
- be mirrored.
-
- By default, items are displayed at a scale of 1 (i.e. at their
- normal size).
-
- Scaling is from the item's transformOrigin.
-
- \table
- \row
- \o \image declarative-scale.png
- \o
- \qml
- Rectangle {
- color: "blue"
- width: 100; height: 100
- Rectangle {
- color: "green"
- width: 25; height: 25
- }
- Rectangle {
- color: "red"
- x: 25; y: 25; width: 50; height: 50
- scale: 1.4
- }
- }
- \endqml
- \endtable
-*/
-
-/*!
- \qmlproperty real Item::opacity
-
- The opacity of the item. Opacity is specified as a number between 0
- (fully transparent) and 1 (fully opaque). The default is 1.
-
- Opacity is an \e inherited attribute. That is, the opacity is
- also applied individually to child items. In almost all cases this
- is what you want. If you can spot the issue in the following
- example, you might need to use an \l Opacity effect instead.
-
- \table
- \row
- \o \image declarative-item_opacity1.png
- \o
- \qml
- Item {
- Rectangle {
- color: "red"
- width: 100; height: 100
- Rectangle {
- color: "blue"
- x: 50; y: 50; width: 100; height: 100
- }
- }
- }
- \endqml
- \row
- \o \image declarative-item_opacity2.png
- \o
- \qml
- Item {
- Rectangle {
- opacity: 0.5
- color: "red"
- width: 100; height: 100
- Rectangle {
- color: "blue"
- x: 50; y: 50; width: 100; height: 100
- }
- }
- }
- \endqml
- \endtable
-*/
-
-/*!
- Returns a value indicating whether mouse input should
- remain with this item exclusively.
-
- \sa setKeepMouseGrab()
- */
-bool QmlGraphicsItem::keepMouseGrab() const
-{
- Q_D(const QmlGraphicsItem);
- return d->_keepMouse;
-}
-
-/*!
- The flag indicating whether the mouse should remain
- with this item is set to \a keep.
-
- This is useful for items that wish to grab and keep mouse
- interaction following a predefined gesture. For example,
- an item that is interested in horizontal mouse movement
- may set keepMouseGrab to true once a threshold has been
- exceeded. Once keepMouseGrab has been set to true, filtering
- items will not react to mouse events.
-
- If the item does not indicate that it wishes to retain mouse grab,
- a filtering item may steal the grab. For example, Flickable may attempt
- to steal a mouse grab if it detects that the user has begun to
- move the viewport.
-
- \sa keepMouseGrab()
- */
-void QmlGraphicsItem::setKeepMouseGrab(bool keep)
-{
- Q_D(QmlGraphicsItem);
- d->_keepMouse = keep;
-}
-
-/*!
- \internal
-
- This function emits the \e focusChanged signal.
-
- Subclasses overriding this function should call up
- to their base class.
-*/
-void QmlGraphicsItem::focusChanged(bool flag)
-{
- Q_UNUSED(flag);
- emit focusChanged();
-}
-
-/*! \internal */
-QmlListProperty<QmlGraphicsItem> QmlGraphicsItem::fxChildren()
-{
- return QmlListProperty<QmlGraphicsItem>(this, 0, QmlGraphicsItemPrivate::children_append,
- QmlGraphicsItemPrivate::children_count,
- QmlGraphicsItemPrivate::children_at);
-}
-
-/*! \internal */
-QmlListProperty<QObject> QmlGraphicsItem::resources()
-{
- return QmlListProperty<QObject>(this, 0, QmlGraphicsItemPrivate::resources_append,
- QmlGraphicsItemPrivate::resources_count,
- QmlGraphicsItemPrivate::resources_at);
-}
-
-/*!
- \qmlproperty list<State> Item::states
- This property holds a list of states defined by the item.
-
- \qml
- Item {
- states: [
- State { ... },
- State { ... }
- ...
- ]
- }
- \endqml
-
- \sa {qmlstate}{States}
-*/
-
-/*!
- \property QmlGraphicsItem::states
- \internal
-*/
-/*! \internal */
-QmlListProperty<QmlState> QmlGraphicsItem::states()
-{
- Q_D(QmlGraphicsItem);
- return d->states()->statesProperty();
-}
-
-/*!
- \qmlproperty list<Transition> Item::transitions
- This property holds a list of transitions defined by the item.
-
- \qml
- Item {
- transitions: [
- Transition { ... },
- Transition { ... }
- ...
- ]
- }
- \endqml
-
- \sa {state-transitions}{Transitions}
-*/
-
-/*!
- \property QmlGraphicsItem::transitions
- \internal
-*/
-
-/*! \internal */
-QmlListProperty<QmlTransition> QmlGraphicsItem::transitions()
-{
- Q_D(QmlGraphicsItem);
- return d->states()->transitionsProperty();
-}
-
-/*
- \qmlproperty list<Filter> Item::filter
- This property holds a list of graphical filters to be applied to the item.
-
- \l {Filter}{Filters} include things like \l {Blur}{blurring}
- the item, or giving it a \l Reflection. Some
- filters may not be available on all canvases; if a filter is not
- available on a certain canvas, it will simply not be applied for
- that canvas (but the QML will still be considered valid).
-
- \qml
- Item {
- filter: [
- Blur { ... },
- Relection { ... }
- ...
- ]
- }
- \endqml
-*/
-
-/*!
- \qmlproperty bool Item::clip
- This property holds whether clipping is enabled.
-
- if clipping is enabled, an item will clip its own painting, as well
- as the painting of its children, to its bounding rectangle.
-
- Non-rectangular clipping regions are not supported for performance reasons.
-*/
-
-/*!
- \property QmlGraphicsItem::clip
- This property holds whether clipping is enabled.
-
- if clipping is enabled, an item will clip its own painting, as well
- as the painting of its children, to its bounding rectangle.
-
- Non-rectangular clipping regions are not supported for performance reasons.
-*/
-
-/*!
- \qmlproperty string Item::state
-
- This property holds the name of the current state of the item.
-
- This property is often used in scripts to change between states. For
- example:
-
- \qml
- Script {
- function toggle() {
- if (button.state == 'On')
- button.state = 'Off';
- else
- button.state = 'On';
- }
- }
- \endqml
-
- If the item is in its base state (i.e. no explicit state has been
- set), \c state will be a blank string. Likewise, you can return an
- item to its base state by setting its current state to \c ''.
-
- \sa {qmlstates}{States}
-*/
-
-/*!
- \property QmlGraphicsItem::state
- \internal
-*/
-
-/*! \internal */
-QString QmlGraphicsItem::state() const
-{
- Q_D(const QmlGraphicsItem);
- if (!d->_stateGroup)
- return QString();
- else
- return d->_stateGroup->state();
-}
-
-/*! \internal */
-void QmlGraphicsItem::setState(const QString &state)
-{
- Q_D(QmlGraphicsItem);
- d->states()->setState(state);
-}
-
-/*!
- \qmlproperty list<Transform> Item::transform
- This property holds the list of transformations to apply.
-
- For more information see \l Transform.
-*/
-
-/*!
- \property QmlGraphicsItem::transform
- \internal
-*/
-
-/*! \internal */
-QmlListProperty<QGraphicsTransform> QmlGraphicsItem::transform()
-{
- Q_D(QmlGraphicsItem);
- return QmlListProperty<QGraphicsTransform>(this, 0, d->transform_append, d->transform_count,
- d->transform_at, d->transform_clear);
-}
-
-/*!
- \internal
-
- classBegin() is called when the item is constructed, but its
- properties have not yet been set.
-
- \sa componentComplete(), isComponentComplete()
-*/
-void QmlGraphicsItem::classBegin()
-{
- Q_D(QmlGraphicsItem);
- d->_componentComplete = false;
- if (d->_stateGroup)
- d->_stateGroup->classBegin();
- if (d->_anchors)
- d->_anchors->classBegin();
-}
-
-/*!
- \internal
-
- componentComplete() is called when all items in the component
- have been constructed. It is often desireable to delay some
- processing until the component is complete an all bindings in the
- component have been resolved.
-*/
-void QmlGraphicsItem::componentComplete()
-{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::ItemComponentComplete> cc;
-#endif
-
- Q_D(QmlGraphicsItem);
- d->_componentComplete = true;
- if (d->_stateGroup)
- d->_stateGroup->componentComplete();
- if (d->_anchors) {
- d->_anchors->componentComplete();
- d->_anchors->d_func()->updateOnComplete();
- }
- if (d->keyHandler)
- d->keyHandler->componentComplete();
-}
-
-QmlStateGroup *QmlGraphicsItemPrivate::states()
-{
- Q_Q(QmlGraphicsItem);
- if (!_stateGroup) {
- _stateGroup = new QmlStateGroup;
- if (!_componentComplete)
- _stateGroup->classBegin();
- QObject::connect(_stateGroup, SIGNAL(stateChanged(QString)),
- q, SIGNAL(stateChanged(QString)));
- }
-
- return _stateGroup;
-}
-
-QmlGraphicsItemPrivate::AnchorLines::AnchorLines(QmlGraphicsItem *q)
-{
- left.item = q;
- left.anchorLine = QmlGraphicsAnchorLine::Left;
- right.item = q;
- right.anchorLine = QmlGraphicsAnchorLine::Right;
- hCenter.item = q;
- hCenter.anchorLine = QmlGraphicsAnchorLine::HCenter;
- top.item = q;
- top.anchorLine = QmlGraphicsAnchorLine::Top;
- bottom.item = q;
- bottom.anchorLine = QmlGraphicsAnchorLine::Bottom;
- vCenter.item = q;
- vCenter.anchorLine = QmlGraphicsAnchorLine::VCenter;
- baseline.item = q;
- baseline.anchorLine = QmlGraphicsAnchorLine::Baseline;
-}
-
-QPointF QmlGraphicsItemPrivate::computeTransformOrigin() const
-{
- Q_Q(const QmlGraphicsItem);
-
- QRectF br = q->boundingRect();
-
- switch(origin) {
- default:
- case QmlGraphicsItem::TopLeft:
- return QPointF(0, 0);
- case QmlGraphicsItem::Top:
- return QPointF(br.width() / 2., 0);
- case QmlGraphicsItem::TopRight:
- return QPointF(br.width(), 0);
- case QmlGraphicsItem::Left:
- return QPointF(0, br.height() / 2.);
- case QmlGraphicsItem::Center:
- return QPointF(br.width() / 2., br.height() / 2.);
- case QmlGraphicsItem::Right:
- return QPointF(br.width(), br.height() / 2.);
- case QmlGraphicsItem::BottomLeft:
- return QPointF(0, br.height());
- case QmlGraphicsItem::Bottom:
- return QPointF(br.width() / 2., br.height());
- case QmlGraphicsItem::BottomRight:
- return QPointF(br.width(), br.height());
- }
-}
-
-/*! \internal */
-bool QmlGraphicsItem::sceneEvent(QEvent *event)
-{
- bool rv = QGraphicsItem::sceneEvent(event);
-
- if (event->type() == QEvent::FocusIn ||
- event->type() == QEvent::FocusOut) {
- focusChanged(hasFocus());
- }
-
- return rv;
-}
-
-/*! \internal */
-QVariant QmlGraphicsItem::itemChange(GraphicsItemChange change,
- const QVariant &value)
-{
- Q_D(const QmlGraphicsItem);
- switch (change) {
- case ItemParentHasChanged:
- emit parentChanged();
- break;
- case ItemChildAddedChange:
- case ItemChildRemovedChange:
- emit childrenChanged();
- break;
- case ItemVisibleHasChanged: {
- for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
- const QmlGraphicsItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
- if (change.types & QmlGraphicsItemPrivate::Visibility) {
- change.listener->itemVisibilityChanged(this);
- }
- }
- }
- break;
- case ItemOpacityHasChanged: {
- for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
- const QmlGraphicsItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
- if (change.types & QmlGraphicsItemPrivate::Opacity) {
- change.listener->itemOpacityChanged(this);
- }
- }
- }
- break;
- default:
- break;
- }
-
- return QGraphicsItem::itemChange(change, value);
-}
-
-/*! \internal */
-QRectF QmlGraphicsItem::boundingRect() const
-{
- Q_D(const QmlGraphicsItem);
- return QRectF(0, 0, d->width, d->height);
-}
-
-/*!
- \enum QmlGraphicsItem::TransformOrigin
-
- Controls the point about which simple transforms like scale apply.
-
- \value TopLeft The top-left corner of the item.
- \value Top The center point of the top of the item.
- \value TopRight The top-right corner of the item.
- \value Left The left most point of the vertical middle.
- \value Center The center of the item.
- \value Right The right most point of the vertical middle.
- \value BottomLeft The bottom-left corner of the item.
- \value Bottom The center point of the bottom of the item.
- \value BottomRight The bottom-right corner of the item.
-*/
-
-/*!
- Returns the current transform origin.
-*/
-QmlGraphicsItem::TransformOrigin QmlGraphicsItem::transformOrigin() const
-{
- Q_D(const QmlGraphicsItem);
- return d->origin;
-}
-
-/*!
- Set the transform \a origin.
-*/
-void QmlGraphicsItem::setTransformOrigin(TransformOrigin origin)
-{
- Q_D(QmlGraphicsItem);
- if (origin != d->origin) {
- d->origin = origin;
- QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin());
- emit transformOriginChanged(d->origin);
- }
-}
-
-/*!
- \property QmlGraphicsItem::smooth
- \brief whether the item is smoothly transformed.
-
- This property is provided purely for the purpose of optimization. Turning
- smooth transforms off is faster, but looks worse; turning smooth
- transformations on is slower, but looks better.
-
- By default smooth transformations are off.
-*/
-
-/*!
- Returns true if the item should be drawn with antialiasing and
- smooth pixmap filtering, false otherwise.
-
- The default is false.
-
- \sa setSmooth()
-*/
-bool QmlGraphicsItem::smooth() const
-{
- Q_D(const QmlGraphicsItem);
- return d->smooth;
-}
-
-/*!
- Sets whether the item should be drawn with antialiasing and
- smooth pixmap filtering to \a smooth.
-
- \sa smooth()
-*/
-void QmlGraphicsItem::setSmooth(bool smooth)
-{
- Q_D(QmlGraphicsItem);
- if (d->smooth == smooth)
- return;
- d->smooth = smooth;
- emit smoothChanged();
- update();
-}
-
-qreal QmlGraphicsItem::width() const
-{
- Q_D(const QmlGraphicsItem);
- return d->width;
-}
-
-void QmlGraphicsItem::setWidth(qreal w)
-{
- Q_D(QmlGraphicsItem);
- if (qIsNaN(w))
- return;
-
- d->widthValid = true;
- if (d->width == w)
- return;
-
- qreal oldWidth = d->width;
-
- prepareGeometryChange();
- d->width = w;
- update();
-
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(x(), y(), oldWidth, height()));
-}
-
-void QmlGraphicsItem::resetWidth()
-{
- Q_D(QmlGraphicsItem);
- d->widthValid = false;
- setImplicitWidth(implicitWidth());
-}
-
-/*!
- Returns the width of the item that is implied by other properties that determine the content.
-*/
-qreal QmlGraphicsItem::implicitWidth() const
-{
- Q_D(const QmlGraphicsItem);
- return d->implicitWidth;
-}
-
-/*!
- Sets the implied width of the item to \a w.
- This is the width implied by other properties that determine the content.
-*/
-void QmlGraphicsItem::setImplicitWidth(qreal w)
-{
- Q_D(QmlGraphicsItem);
- d->implicitWidth = w;
- if (d->width == w || widthValid())
- return;
-
- qreal oldWidth = d->width;
-
- prepareGeometryChange();
- d->width = w;
- update();
-
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(x(), y(), oldWidth, height()));
-}
-
-/*!
- Returns whether the width property has been set explicitly.
-*/
-bool QmlGraphicsItem::widthValid() const
-{
- Q_D(const QmlGraphicsItem);
- return d->widthValid;
-}
-
-qreal QmlGraphicsItem::height() const
-{
- Q_D(const QmlGraphicsItem);
- return d->height;
-}
-
-void QmlGraphicsItem::setHeight(qreal h)
-{
- Q_D(QmlGraphicsItem);
- if (qIsNaN(h))
- return;
-
- d->heightValid = true;
- if (d->height == h)
- return;
-
- qreal oldHeight = d->height;
-
- prepareGeometryChange();
- d->height = h;
- update();
-
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(x(), y(), width(), oldHeight));
-}
-
-void QmlGraphicsItem::resetHeight()
-{
- Q_D(QmlGraphicsItem);
- d->heightValid = false;
- setImplicitHeight(implicitHeight());
-}
-
-/*!
- Returns the height of the item that is implied by other properties that determine the content.
-*/
-qreal QmlGraphicsItem::implicitHeight() const
-{
- Q_D(const QmlGraphicsItem);
- return d->implicitHeight;
-}
-
-/*!
- Sets the implied height of the item to \a h.
- This is the height implied by other properties that determine the content.
-*/
-void QmlGraphicsItem::setImplicitHeight(qreal h)
-{
- Q_D(QmlGraphicsItem);
- d->implicitHeight = h;
- if (d->height == h || heightValid())
- return;
-
- qreal oldHeight = d->height;
-
- prepareGeometryChange();
- d->height = h;
- update();
-
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(x(), y(), width(), oldHeight));
-}
-
-/*!
- Returns whether the height property has been set explicitly.
-*/
-bool QmlGraphicsItem::heightValid() const
-{
- Q_D(const QmlGraphicsItem);
- return d->heightValid;
-}
-
-/*!
- \qmlproperty bool Item::wantsFocus
-
- This property indicates whether the item has has an active focus request.
-
- \sa {qmlfocus}{Keyboard Focus}
-*/
-
-/*! \internal */
-bool QmlGraphicsItem::wantsFocus() const
-{
- return focusItem() != 0;
-}
-
-/*!
- \qmlproperty bool Item::focus
- This property indicates whether the item has keyboard input focus. Set this
- property to true to request focus.
-
- \sa {qmlfocus}{Keyboard Focus}
-*/
-
-/*! \internal */
-bool QmlGraphicsItem::hasFocus() const
-{
- return QGraphicsItem::hasFocus();
-}
-
-/*! \internal */
-void QmlGraphicsItem::setFocus(bool focus)
-{
- if (focus)
- QGraphicsItem::setFocus(Qt::OtherFocusReason);
- else
- QGraphicsItem::clearFocus();
-}
-
-/*!
- \reimp
- \internal
-*/
-void QmlGraphicsItem::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
-{
-}
-
-/*!
- \reimp
- \internal
-*/
-bool QmlGraphicsItem::event(QEvent *ev)
-{
- return QGraphicsObject::event(ev);
-}
-
-QDebug operator<<(QDebug debug, QmlGraphicsItem *item)
-{
- if (!item) {
- debug << "QmlGraphicsItem(0)";
- return debug;
- }
-
- debug << item->metaObject()->className() << "(this =" << ((void*)item)
- << ", parent =" << ((void*)item->parentItem())
- << ", geometry =" << QRectF(item->pos(), QSizeF(item->width(), item->height()))
- << ", z =" << item->zValue() << ')';
- return debug;
-}
-
-int QmlGraphicsItemPrivate::consistentTime = -1;
-void QmlGraphicsItemPrivate::setConsistentTime(int t)
-{
- consistentTime = t;
-}
-
-QTime QmlGraphicsItemPrivate::currentTime()
-{
- if (consistentTime == -1)
- return QTime::currentTime();
- else
- return QTime(0, 0).addMSecs(consistentTime);
-}
-
-void QmlGraphicsItemPrivate::start(QTime &t)
-{
- t = currentTime();
-}
-
-int QmlGraphicsItemPrivate::elapsed(QTime &t)
-{
- int n = t.msecsTo(currentTime());
- if (n < 0) // passed midnight
- n += 86400 * 1000;
- return n;
-}
-
-int QmlGraphicsItemPrivate::restart(QTime &t)
-{
- QTime time = currentTime();
- int n = t.msecsTo(time);
- if (n < 0) // passed midnight
- n += 86400*1000;
- t = time;
- return n;
-}
-
-QT_END_NAMESPACE
-
-#include <moc_qmlgraphicsitem.cpp>
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.h b/src/declarative/graphicsitems/qmlgraphicsitem.h
deleted file mode 100644
index 891fc88..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsitem.h
+++ /dev/null
@@ -1,243 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSITEM_H
-#define QMLGRAPHICSITEM_H
-
-#include <qml.h>
-#include <qmlcomponent.h>
-
-#include <QtCore/QObject>
-#include <QtCore/QList>
-#include <QtGui/qgraphicsitem.h>
-#include <QtGui/qgraphicstransform.h>
-#include <QtGui/qfont.h>
-#include <QtGui/qaction.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlState;
-class QmlGraphicsAnchorLine;
-class QmlTransition;
-class QmlGraphicsKeyEvent;
-class QmlGraphicsAnchors;
-class QmlGraphicsItemPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsItem : public QGraphicsObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QmlParserStatus)
-
- Q_PROPERTY(QmlGraphicsItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL)
- Q_PROPERTY(QmlListProperty<QObject> data READ data DESIGNABLE false)
- Q_PROPERTY(QmlListProperty<QmlGraphicsItem> children READ fxChildren DESIGNABLE false NOTIFY childrenChanged)
- Q_PROPERTY(QmlListProperty<QObject> resources READ resources DESIGNABLE false)
- Q_PROPERTY(QmlListProperty<QmlState> states READ states DESIGNABLE false)
- Q_PROPERTY(QmlListProperty<QmlTransition> transitions READ transitions DESIGNABLE false)
- Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
- Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL)
- Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL)
- Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL)
- Q_PROPERTY(QmlGraphicsAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL)
- Q_PROPERTY(QmlGraphicsAnchorLine left READ left CONSTANT FINAL)
- Q_PROPERTY(QmlGraphicsAnchorLine right READ right CONSTANT FINAL)
- Q_PROPERTY(QmlGraphicsAnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL)
- Q_PROPERTY(QmlGraphicsAnchorLine top READ top CONSTANT FINAL)
- Q_PROPERTY(QmlGraphicsAnchorLine bottom READ bottom CONSTANT FINAL)
- Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL)
- Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline CONSTANT FINAL)
- Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
- Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged) // ### move to QGI/QGO, NOTIFY
- Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
- Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged)
- Q_PROPERTY(QmlListProperty<QGraphicsTransform> transform READ transform DESIGNABLE false FINAL)
- Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged)
- Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
- Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect)
- Q_ENUMS(TransformOrigin)
- Q_CLASSINFO("DefaultProperty", "data")
-
-public:
- enum TransformOrigin {
- TopLeft, Top, TopRight,
- Left, Center, Right,
- BottomLeft, Bottom, BottomRight
- };
-
- QmlGraphicsItem(QmlGraphicsItem *parent = 0);
- virtual ~QmlGraphicsItem();
-
- QmlGraphicsItem *parentItem() const;
- void setParentItem(QmlGraphicsItem *parent);
- void setParent(QmlGraphicsItem *parent) { setParentItem(parent); }
-
- QmlListProperty<QObject> data();
- QmlListProperty<QmlGraphicsItem> fxChildren();
- QmlListProperty<QObject> resources();
-
- QmlGraphicsAnchors *anchors();
- QRectF childrenRect();
-
- bool clip() const;
- void setClip(bool);
-
- QmlListProperty<QmlState> states();
- QmlListProperty<QmlTransition> transitions();
-
- QString state() const;
- void setState(const QString &);
-
- qreal baselineOffset() const;
- void setBaselineOffset(qreal);
-
- QmlListProperty<QGraphicsTransform> transform();
-
- qreal width() const;
- void setWidth(qreal);
- void resetWidth();
- qreal implicitWidth() const;
-
- qreal height() const;
- void setHeight(qreal);
- void resetHeight();
- qreal implicitHeight() const;
-
- TransformOrigin transformOrigin() const;
- void setTransformOrigin(TransformOrigin);
-
- bool smooth() const;
- void setSmooth(bool);
-
- QRectF boundingRect() const;
- virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
-
- bool wantsFocus() const;
- bool hasFocus() const;
- void setFocus(bool);
-
- bool keepMouseGrab() const;
- void setKeepMouseGrab(bool);
-
- QmlGraphicsAnchorLine left() const;
- QmlGraphicsAnchorLine right() const;
- QmlGraphicsAnchorLine horizontalCenter() const;
- QmlGraphicsAnchorLine top() const;
- QmlGraphicsAnchorLine bottom() const;
- QmlGraphicsAnchorLine verticalCenter() const;
- QmlGraphicsAnchorLine baseline() const;
-
-Q_SIGNALS:
- void widthChanged();
- void heightChanged();
- void childrenChanged();
- void childrenRectChanged();
- void baselineOffsetChanged();
- void stateChanged(const QString &);
- void focusChanged();
- void wantsFocusChanged();
- void parentChanged();
- void transformOriginChanged(TransformOrigin);
- void smoothChanged();
- void clipChanged();
-
-protected:
- bool isComponentComplete() const;
- virtual bool sceneEvent(QEvent *);
- virtual bool event(QEvent *);
- virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
-
- void setImplicitWidth(qreal);
- bool widthValid() const; // ### better name?
- void setImplicitHeight(qreal);
- bool heightValid() const; // ### better name?
-
- virtual void classBegin();
- virtual void componentComplete();
- virtual void focusChanged(bool);
- virtual void keyPressEvent(QKeyEvent *event);
- virtual void keyReleaseEvent(QKeyEvent *event);
- virtual void inputMethodEvent(QInputMethodEvent *);
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
- virtual void geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry);
-
-protected:
- QmlGraphicsItem(QmlGraphicsItemPrivate &dd, QmlGraphicsItem *parent = 0);
-
-private:
- friend class QmlStatePrivate;
- friend class QmlGraphicsAnchors;
- Q_DISABLE_COPY(QmlGraphicsItem)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsItem)
-};
-
-template<typename T>
- T qobject_cast(QGraphicsObject *o)
-{
- QObject *obj = o;
- return qobject_cast<T>(obj);
-}
-
-// ### move to QGO
-template<typename T>
-T qobject_cast(QGraphicsItem *item)
-{
- if (!item) return 0;
- QObject *o = item->toGraphicsObject();
- return qobject_cast<T>(o);
-}
-
-QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, QmlGraphicsItem *item);
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsItem)
-QML_DECLARE_TYPE(QGraphicsTransform)
-QML_DECLARE_TYPE(QGraphicsScale)
-QML_DECLARE_TYPE(QGraphicsRotation)
-QML_DECLARE_TYPE(QAction)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSITEM_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
deleted file mode 100644
index 4860b83..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h
+++ /dev/null
@@ -1,471 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSITEM_P_H
-#define QMLGRAPHICSITEM_P_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 "qmlgraphicsitem.h"
-
-#include "qmlgraphicsanchors_p.h"
-#include "qmlgraphicsanchors_p_p.h"
-#include "qmlgraphicsitemchangelistener_p.h"
-#include <private/qpodvector_p.h>
-
-#include "../util/qmlstate_p.h"
-#include "../util/qmlnullablevalue_p_p.h"
-#include <qml.h>
-#include <qmlcontext.h>
-
-#include <QtCore/qlist.h>
-#include <QtCore/qdebug.h>
-
-#include <private/qgraphicsitem_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkReply;
-class QmlGraphicsItemKeyFilter;
-
-//### merge into private?
-class QmlGraphicsContents : public QObject
-{
- Q_OBJECT
-public:
- QmlGraphicsContents();
-
- QRectF rectF() const;
-
- void setItem(QmlGraphicsItem *item);
-
-public Q_SLOTS:
- void calcHeight();
- void calcWidth();
-
-Q_SIGNALS:
- void rectChanged();
-
-private:
- QmlGraphicsItem *m_item;
- qreal m_x;
- qreal m_y;
- qreal m_width;
- qreal m_height;
-};
-
-class QmlGraphicsItemPrivate : public QGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsItem)
-
-public:
- QmlGraphicsItemPrivate()
- : _anchors(0), _contents(0),
- _baselineOffset(0),
- _anchorLines(0),
- _stateGroup(0), origin(QmlGraphicsItem::Center),
- widthValid(false), heightValid(false),
- _componentComplete(true), _keepMouse(false),
- smooth(false), keyHandler(0),
- width(0), height(0), implicitWidth(0), implicitHeight(0)
- {
- QGraphicsItemPrivate::acceptedMouseButtons = 0;
- QGraphicsItemPrivate::flags = QGraphicsItem::GraphicsItemFlags(
- QGraphicsItem::ItemHasNoContents
- | QGraphicsItem::ItemIsFocusable
- | QGraphicsItem::ItemNegativeZStacksBehindParent);
-
- }
-
- void init(QmlGraphicsItem *parent)
- {
- Q_Q(QmlGraphicsItem);
-
- if (parent)
- q->setParentItem(parent);
- _baselineOffset.invalidate();
- mouseSetsFocus = false;
- }
-
- QString _id;
-
- // data property
- static void data_append(QmlListProperty<QObject> *, QObject *);
-
- // resources property
- static QObject *resources_at(QmlListProperty<QObject> *, int);
- static void resources_append(QmlListProperty<QObject> *, QObject *);
- static int resources_count(QmlListProperty<QObject> *);
-
- // children property
- static QmlGraphicsItem *children_at(QmlListProperty<QmlGraphicsItem> *, int);
- static void children_append(QmlListProperty<QmlGraphicsItem> *, QmlGraphicsItem *);
- static int children_count(QmlListProperty<QmlGraphicsItem> *);
-
- // transform property
- static int transform_count(QmlListProperty<QGraphicsTransform> *list);
- static void transform_append(QmlListProperty<QGraphicsTransform> *list, QGraphicsTransform *);
- static QGraphicsTransform *transform_at(QmlListProperty<QGraphicsTransform> *list, int);
- static void transform_clear(QmlListProperty<QGraphicsTransform> *list);
-
- QmlGraphicsAnchors *anchors() {
- if (!_anchors) {
- Q_Q(QmlGraphicsItem);
- _anchors = new QmlGraphicsAnchors(q);
- if (!_componentComplete)
- _anchors->classBegin();
- }
- return _anchors;
- }
- QmlGraphicsAnchors *_anchors;
- QmlGraphicsContents *_contents;
-
- QmlNullableValue<qreal> _baselineOffset;
-
- struct AnchorLines {
- AnchorLines(QmlGraphicsItem *);
- QmlGraphicsAnchorLine left;
- QmlGraphicsAnchorLine right;
- QmlGraphicsAnchorLine hCenter;
- QmlGraphicsAnchorLine top;
- QmlGraphicsAnchorLine bottom;
- QmlGraphicsAnchorLine vCenter;
- QmlGraphicsAnchorLine baseline;
- };
- mutable AnchorLines *_anchorLines;
- AnchorLines *anchorLines() const {
- Q_Q(const QmlGraphicsItem);
- if (!_anchorLines) _anchorLines =
- new AnchorLines(const_cast<QmlGraphicsItem *>(q));
- return _anchorLines;
- }
-
- enum ChangeType {
- Geometry = 0x01,
- SiblingOrder = 0x02,
- Visibility = 0x04,
- Opacity = 0x08,
- Destroyed = 0x10
- };
-
- Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
-
- struct ChangeListener {
- ChangeListener(QmlGraphicsItemChangeListener *l, QmlGraphicsItemPrivate::ChangeTypes t) : listener(l), types(t) {}
- QmlGraphicsItemChangeListener *listener;
- QmlGraphicsItemPrivate::ChangeTypes types;
- bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; }
- };
-
- void addItemChangeListener(QmlGraphicsItemChangeListener *listener, ChangeTypes types) {
- changeListeners.append(ChangeListener(listener, types));
- }
- void removeItemChangeListener(QmlGraphicsItemChangeListener *, ChangeTypes types);
- QPODVector<ChangeListener,4> changeListeners;
-
- QmlStateGroup *states();
- QmlStateGroup *_stateGroup;
-
- QmlGraphicsItem::TransformOrigin origin:4;
- bool widthValid:1;
- bool heightValid:1;
- bool _componentComplete:1;
- bool _keepMouse:1;
- bool smooth:1;
-
- QmlGraphicsItemKeyFilter *keyHandler;
-
- qreal width;
- qreal height;
- qreal implicitWidth;
- qreal implicitHeight;
-
- QPointF computeTransformOrigin() const;
-
- virtual void setPosHelper(const QPointF &pos)
- {
- Q_Q(QmlGraphicsItem);
- QRectF oldGeometry(this->pos.x(), this->pos.y(), width, height);
- QGraphicsItemPrivate::setPosHelper(pos);
- q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), width, height), oldGeometry);
- }
-
- // Reimplemented from QGraphicsItemPrivate
- virtual void subFocusItemChange()
- {
- emit q_func()->wantsFocusChanged();
- }
-
- // Reimplemented from QGraphicsItemPrivate
- virtual void siblingOrderChange()
- {
- Q_Q(QmlGraphicsItem);
- for(int ii = 0; ii < changeListeners.count(); ++ii) {
- const QmlGraphicsItemPrivate::ChangeListener &change = changeListeners.at(ii);
- if (change.types & QmlGraphicsItemPrivate::SiblingOrder) {
- change.listener->itemSiblingOrderChanged(q);
- }
- }
- }
-
- static int consistentTime;
- static QTime currentTime();
- static void Q_DECLARATIVE_EXPORT setConsistentTime(int t);
- static void start(QTime &);
- static int elapsed(QTime &);
- static int restart(QTime &);
-};
-
-/*
- Key filters can be installed on a QmlGraphicsItem, but not removed. Currently they
- are only used by attached objects (which are only destroyed on Item
- destruction), so this isn't a problem. If in future this becomes any form
- of public API, they will have to support removal too.
-*/
-class QmlGraphicsItemKeyFilter
-{
-public:
- QmlGraphicsItemKeyFilter(QmlGraphicsItem * = 0);
- virtual ~QmlGraphicsItemKeyFilter();
-
- virtual void keyPressed(QKeyEvent *event);
- virtual void keyReleased(QKeyEvent *event);
- virtual void inputMethodEvent(QInputMethodEvent *event);
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
- virtual void componentComplete();
-
-private:
- QmlGraphicsItemKeyFilter *m_next;
-};
-
-class QmlGraphicsKeyNavigationAttachedPrivate : public QObjectPrivate
-{
-public:
- QmlGraphicsKeyNavigationAttachedPrivate()
- : QObjectPrivate(), left(0), right(0), up(0), down(0) {}
-
- QmlGraphicsItem *left;
- QmlGraphicsItem *right;
- QmlGraphicsItem *up;
- QmlGraphicsItem *down;
-};
-
-class QmlGraphicsKeyNavigationAttached : public QObject, public QmlGraphicsItemKeyFilter
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlGraphicsKeyNavigationAttached)
-
- Q_PROPERTY(QmlGraphicsItem *left READ left WRITE setLeft NOTIFY changed)
- Q_PROPERTY(QmlGraphicsItem *right READ right WRITE setRight NOTIFY changed)
- Q_PROPERTY(QmlGraphicsItem *up READ up WRITE setUp NOTIFY changed)
- Q_PROPERTY(QmlGraphicsItem *down READ down WRITE setDown NOTIFY changed)
-public:
- QmlGraphicsKeyNavigationAttached(QObject * = 0);
-
- QmlGraphicsItem *left() const;
- void setLeft(QmlGraphicsItem *);
- QmlGraphicsItem *right() const;
- void setRight(QmlGraphicsItem *);
- QmlGraphicsItem *up() const;
- void setUp(QmlGraphicsItem *);
- QmlGraphicsItem *down() const;
- void setDown(QmlGraphicsItem *);
-
- static QmlGraphicsKeyNavigationAttached *qmlAttachedProperties(QObject *);
-
-Q_SIGNALS:
- void changed();
-
-private:
- virtual void keyPressed(QKeyEvent *event);
- virtual void keyReleased(QKeyEvent *event);
-};
-
-class QmlGraphicsKeysAttachedPrivate : public QObjectPrivate
-{
-public:
- QmlGraphicsKeysAttachedPrivate()
- : QObjectPrivate(), inPress(false), inRelease(false)
- , inIM(false), enabled(true), imeItem(0), item(0)
- {}
-
- bool isConnected(const char *signalName);
-
- QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const
- {
- QGraphicsItem *fp;
- while ((fp = item->focusProxy()))
- item = fp;
- return item;
- }
-
- //loop detection
- bool inPress:1;
- bool inRelease:1;
- bool inIM:1;
-
- bool enabled : 1;
-
- QGraphicsItem *imeItem;
- QList<QmlGraphicsItem *> targets;
- QmlGraphicsItem *item;
-};
-
-class QmlGraphicsKeysAttached : public QObject, public QmlGraphicsItemKeyFilter
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlGraphicsKeysAttached)
-
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(QmlListProperty<QmlGraphicsItem> forwardTo READ forwardTo)
-
-public:
- QmlGraphicsKeysAttached(QObject *parent=0);
- ~QmlGraphicsKeysAttached();
-
- bool enabled() const { Q_D(const QmlGraphicsKeysAttached); return d->enabled; }
- void setEnabled(bool enabled) {
- Q_D(QmlGraphicsKeysAttached);
- if (enabled != d->enabled) {
- d->enabled = enabled;
- emit enabledChanged();
- }
- }
-
- QmlListProperty<QmlGraphicsItem> forwardTo() {
- Q_D(QmlGraphicsKeysAttached);
- return QmlListProperty<QmlGraphicsItem>(this, d->targets);
- }
-
- virtual void componentComplete();
-
- static QmlGraphicsKeysAttached *qmlAttachedProperties(QObject *);
-
-Q_SIGNALS:
- void enabledChanged();
- void pressed(QmlGraphicsKeyEvent *event);
- void released(QmlGraphicsKeyEvent *event);
- void digit0Pressed(QmlGraphicsKeyEvent *event);
- void digit1Pressed(QmlGraphicsKeyEvent *event);
- void digit2Pressed(QmlGraphicsKeyEvent *event);
- void digit3Pressed(QmlGraphicsKeyEvent *event);
- void digit4Pressed(QmlGraphicsKeyEvent *event);
- void digit5Pressed(QmlGraphicsKeyEvent *event);
- void digit6Pressed(QmlGraphicsKeyEvent *event);
- void digit7Pressed(QmlGraphicsKeyEvent *event);
- void digit8Pressed(QmlGraphicsKeyEvent *event);
- void digit9Pressed(QmlGraphicsKeyEvent *event);
-
- void leftPressed(QmlGraphicsKeyEvent *event);
- void rightPressed(QmlGraphicsKeyEvent *event);
- void upPressed(QmlGraphicsKeyEvent *event);
- void downPressed(QmlGraphicsKeyEvent *event);
-
- void asteriskPressed(QmlGraphicsKeyEvent *event);
- void numberSignPressed(QmlGraphicsKeyEvent *event);
- void escapePressed(QmlGraphicsKeyEvent *event);
- void returnPressed(QmlGraphicsKeyEvent *event);
- void enterPressed(QmlGraphicsKeyEvent *event);
- void deletePressed(QmlGraphicsKeyEvent *event);
- void spacePressed(QmlGraphicsKeyEvent *event);
- void backPressed(QmlGraphicsKeyEvent *event);
- void cancelPressed(QmlGraphicsKeyEvent *event);
- void selectPressed(QmlGraphicsKeyEvent *event);
- void yesPressed(QmlGraphicsKeyEvent *event);
- void noPressed(QmlGraphicsKeyEvent *event);
- void context1Pressed(QmlGraphicsKeyEvent *event);
- void context2Pressed(QmlGraphicsKeyEvent *event);
- void context3Pressed(QmlGraphicsKeyEvent *event);
- void context4Pressed(QmlGraphicsKeyEvent *event);
- void callPressed(QmlGraphicsKeyEvent *event);
- void hangupPressed(QmlGraphicsKeyEvent *event);
- void flipPressed(QmlGraphicsKeyEvent *event);
- void menuPressed(QmlGraphicsKeyEvent *event);
- void volumeUpPressed(QmlGraphicsKeyEvent *event);
- void volumeDownPressed(QmlGraphicsKeyEvent *event);
-
-private:
- virtual void keyPressed(QKeyEvent *event);
- virtual void keyReleased(QKeyEvent *event);
- virtual void inputMethodEvent(QInputMethodEvent *);
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
-
- const QByteArray keyToSignal(int key) {
- QByteArray keySignal;
- if (key >= Qt::Key_0 && key <= Qt::Key_9) {
- keySignal = "digit0Pressed";
- keySignal[5] = '0' + (key - Qt::Key_0);
- } else {
- int i = 0;
- while (sigMap[i].key && sigMap[i].key != key)
- ++i;
- keySignal = sigMap[i].sig;
- }
- return keySignal;
- }
-
- struct SigMap {
- int key;
- const char *sig;
- };
-
- static const SigMap sigMap[];
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QmlGraphicsItemPrivate::ChangeTypes);
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsKeysAttached)
-QML_DECLARE_TYPEINFO(QmlGraphicsKeysAttached, QML_HAS_ATTACHED_PROPERTIES)
-QML_DECLARE_TYPE(QmlGraphicsKeyNavigationAttached)
-QML_DECLARE_TYPEINFO(QmlGraphicsKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES)
-
-#endif // QMLGRAPHICSITEM_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsitemchangelistener_p.h b/src/declarative/graphicsitems/qmlgraphicsitemchangelistener_p.h
deleted file mode 100644
index a1c7b89..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsitemchangelistener_p.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSITEMCHANGELISTENER
-#define QMLGRAPHICSITEMCHANGELISTENER
-
-//
-// 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>
-
-QT_BEGIN_NAMESPACE
-
-class QRectF;
-class QmlGraphicsItem;
-class QmlGraphicsAnchorsPrivate;
-class QmlGraphicsItemChangeListener
-{
-public:
- virtual void itemGeometryChanged(QmlGraphicsItem *, const QRectF &, const QRectF &) {}
- virtual void itemSiblingOrderChanged(QmlGraphicsItem *) {}
- virtual void itemVisibilityChanged(QmlGraphicsItem *) {}
- virtual void itemOpacityChanged(QmlGraphicsItem *) {}
- virtual void itemDestroyed(QmlGraphicsItem *) {}
- virtual QmlGraphicsAnchorsPrivate *anchorPrivate() { return 0; }
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLGRAPHICSITEMCHANGELISTENER
diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
deleted file mode 100644
index 121026e..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsitemsmodule_p.h"
-
-#include <QtGui/qaction.h>
-#include <QtGui/qvalidator.h>
-#include <QtGui/qgraphicseffect.h>
-
-#include "qmlgraphicsevents_p_p.h"
-#include "qmlgraphicseffects_p.h"
-#include "qmlgraphicsscalegrid_p_p.h"
-#include "qmlgraphicsanimatedimage_p.h"
-#include "qmlgraphicsborderimage_p.h"
-#include "qmlgraphicspositioners_p.h"
-#include "qmlgraphicsmousearea_p.h"
-#include "qmlgraphicsflickable_p.h"
-#include "qmlgraphicsflickable_p_p.h"
-#include "qmlgraphicsflipable_p.h"
-#include "qmlgraphicsfocuspanel_p.h"
-#include "qmlgraphicsfocusscope_p.h"
-#include "qmlgraphicsgraphicsobjectcontainer_p.h"
-#include "qmlgraphicsgridview_p.h"
-#include "qmlgraphicsimage_p.h"
-#include "qmlgraphicsitem_p.h"
-#include "qmlgraphicslayoutitem_p.h"
-#include "qmlgraphicslistview_p.h"
-#include "qmlgraphicsloader_p.h"
-#include "qmlgraphicsmousearea_p.h"
-#include "qmlgraphicsparticles_p.h"
-#include "qmlgraphicspath_p.h"
-#include "qmlgraphicspathview_p.h"
-#include "qmlgraphicsrectangle_p.h"
-#include "qmlgraphicsrepeater_p.h"
-#include "qmlgraphicstext_p.h"
-#include "qmlgraphicstextedit_p.h"
-#include "qmlgraphicstextinput_p.h"
-#include "qmlgraphicsvisualitemmodel_p.h"
-#ifdef QT_WEBKIT_LIB
-#include "qmlgraphicswebview_p.h"
-#include "qmlgraphicswebview_p_p.h"
-#endif
-#include "qmlgraphicsanchors_p.h"
-
-void QmlGraphicsItemModule::defineModule()
-{
- QML_REGISTER_TYPE(Qt,4,6,AnimatedImage,QmlGraphicsAnimatedImage);
- QML_REGISTER_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect);
- QML_REGISTER_TYPE(Qt,4,6,BorderImage,QmlGraphicsBorderImage);
- QML_REGISTER_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect);
- QML_REGISTER_TYPE(Qt,4,6,Column,QmlGraphicsColumn);
- QML_REGISTER_TYPE(Qt,4,6,Drag,QmlGraphicsDrag);
- QML_REGISTER_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect);
- QML_REGISTER_TYPE(Qt,4,6,Flickable,QmlGraphicsFlickable);
- QML_REGISTER_TYPE(Qt,4,6,Flipable,QmlGraphicsFlipable);
- QML_REGISTER_TYPE(Qt,4,6,Flow,QmlGraphicsFlow);
- QML_REGISTER_TYPE(Qt,4,6,FocusPanel,QmlGraphicsFocusPanel);
- QML_REGISTER_TYPE(Qt,4,6,FocusScope,QmlGraphicsFocusScope);
- QML_REGISTER_TYPE(Qt,4,6,Gradient,QmlGraphicsGradient);
- QML_REGISTER_TYPE(Qt,4,6,GradientStop,QmlGraphicsGradientStop);
- QML_REGISTER_TYPE(Qt,4,6,GraphicsObjectContainer,QmlGraphicsGraphicsObjectContainer);
- QML_REGISTER_TYPE(Qt,4,6,Grid,QmlGraphicsGrid);
- QML_REGISTER_TYPE(Qt,4,6,GridView,QmlGraphicsGridView);
- QML_REGISTER_TYPE(Qt,4,6,Image,QmlGraphicsImage);
- QML_REGISTER_TYPE(Qt,4,6,Item,QmlGraphicsItem);
- QML_REGISTER_TYPE(Qt,4,6,KeyNavigation,QmlGraphicsKeyNavigationAttached);
- QML_REGISTER_TYPE(Qt,4,6,Keys,QmlGraphicsKeysAttached);
- QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QmlGraphicsLayoutItem);
- QML_REGISTER_TYPE(Qt,4,6,ListView,QmlGraphicsListView);
- QML_REGISTER_TYPE(Qt,4,6,Loader,QmlGraphicsLoader);
- QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseArea);
- QML_REGISTER_TYPE(Qt,4,6,MouseArea,QmlGraphicsMouseArea);
- QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect);
- QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QmlGraphicsParticleMotion);
- QML_REGISTER_TYPE(Qt,4,6,ParticleMotionGravity,QmlGraphicsParticleMotionGravity);
- QML_REGISTER_TYPE(Qt,4,6,ParticleMotionLinear,QmlGraphicsParticleMotionLinear);
- QML_REGISTER_TYPE(Qt,4,6,ParticleMotionWander,QmlGraphicsParticleMotionWander);
- QML_REGISTER_TYPE(Qt,4,6,Particles,QmlGraphicsParticles);
- QML_REGISTER_TYPE(Qt,4,6,Path,QmlGraphicsPath);
- QML_REGISTER_TYPE(Qt,4,6,PathAttribute,QmlGraphicsPathAttribute);
- QML_REGISTER_TYPE(Qt,4,6,PathCubic,QmlGraphicsPathCubic);
- QML_REGISTER_TYPE(Qt,4,6,PathLine,QmlGraphicsPathLine);
- QML_REGISTER_TYPE(Qt,4,6,PathPercent,QmlGraphicsPathPercent);
- QML_REGISTER_TYPE(Qt,4,6,PathQuad,QmlGraphicsPathQuad);
- QML_REGISTER_TYPE(Qt,4,6,PathView,QmlGraphicsPathView);
- QML_REGISTER_TYPE(Qt,4,6,Pen,QmlGraphicsPen);
- QML_REGISTER_TYPE(Qt,4,6,QIntValidator,QIntValidator);
-#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
- QML_REGISTER_TYPE(Qt,4,7,QDoubleValidator,QDoubleValidator);
- QML_REGISTER_TYPE(Qt,4,7,QRegExpValidator,QRegExpValidator);
-#endif
- QML_REGISTER_TYPE(Qt,4,6,Rectangle,QmlGraphicsRectangle);
- QML_REGISTER_TYPE(Qt,4,6,Repeater,QmlGraphicsRepeater);
- QML_REGISTER_TYPE(Qt,4,6,Rotation,QGraphicsRotation);
- QML_REGISTER_TYPE(Qt,4,6,Row,QmlGraphicsRow);
- QML_REGISTER_TYPE(Qt,4,6,Scale,QGraphicsScale);
- QML_REGISTER_TYPE(Qt,4,6,Text,QmlGraphicsText);
- QML_REGISTER_TYPE(Qt,4,6,TextEdit,QmlGraphicsTextEdit);
- QML_REGISTER_TYPE(Qt,4,6,TextInput,QmlGraphicsTextInput);
- QML_REGISTER_TYPE(Qt,4,6,ViewSection,QmlGraphicsViewSection);
- QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QmlGraphicsFlickableVisibleArea);
- QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QmlGraphicsVisualDataModel);
- QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QmlGraphicsVisualItemModel);
-#ifdef QT_WEBKIT_LIB
- QML_REGISTER_TYPE(Qt,4,6,WebView,QmlGraphicsWebView);
-#endif
-
- QML_REGISTER_NOCREATE_TYPE(QmlGraphicsAnchors);
- QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect);
- QML_REGISTER_NOCREATE_TYPE(QmlGraphicsKeyEvent);
- QML_REGISTER_NOCREATE_TYPE(QmlGraphicsMouseEvent);
- QML_REGISTER_NOCREATE_TYPE(QGraphicsObject);
- QML_REGISTER_NOCREATE_TYPE(QGraphicsTransform);
- QML_REGISTER_NOCREATE_TYPE(QmlGraphicsPathElement);
- QML_REGISTER_NOCREATE_TYPE(QmlGraphicsCurve);
- QML_REGISTER_NOCREATE_TYPE(QmlGraphicsScaleGrid);
- QML_REGISTER_NOCREATE_TYPE(QValidator);
- QML_REGISTER_NOCREATE_TYPE(QmlGraphicsVisualModel);
- QML_REGISTER_NOCREATE_TYPE(QAction);
-#ifdef QT_WEBKIT_LIB
- QML_REGISTER_NOCREATE_TYPE(QmlGraphicsWebSettings);
-#endif
-}
diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h b/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h
deleted file mode 100644
index 76fea7e..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSITEMMODULE_H
-#define QMLGRAPHICSITEMMODULE_H
-
-#include <qml.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsItemModule
-{
-public:
- static void defineModule();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSITEMMODULE_H
diff --git a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp
deleted file mode 100644
index b55beda..0000000
--- a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicslayoutitem_p.h"
-
-#include <QDebug>
-
-#include <limits.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass LayoutItem QmlGraphicsLayoutItem
- \since 4.7
- \brief The LayoutItem element allows you to place your Fluid UI elements inside a classical Qt layout.
-
- LayoutItem is a variant of Item with a couple of additional properties. These properties provide the size hints
- needed for items to work in conjunction with Qt Layouts. The Qt Layout will resize the LayoutItem as appropriate,
- taking its size hints into account, and you can propagate this to the other elements in your UI via anchors and bindings.
-
- This is a QGraphicsLayoutItem subclass, and the properties merely expose the QGraphicsLayoutItem functionality to QML.
- See the QGraphicsLayoutItem documentation for further details.
-*/
-
-/*!
- \internal
- \class QmlGraphicsLayoutItem
- \brief The QmlGraphicsLayoutItem class allows you to place your Fluid UI elements inside a classical Qt layout.
-*/
-
-
-/*!
- \qmlproperty QSizeF LayoutItem::maximumSize
-
- The maximumSize property can be set to specify the maximum desired size of this LayoutItem
-*/
-
-/*!
- \qmlproperty QSizeF LayoutItem::minimumSize
-
- The minimumSize property can be set to specify the minimum desired size of this LayoutItem
-*/
-
-/*!
- \qmlproperty QSizeF LayoutItem::preferredSize
-
- The preferredSize property can be set to specify the preferred size of this LayoutItem
-*/
-
-QmlGraphicsLayoutItem::QmlGraphicsLayoutItem(QmlGraphicsItem* parent)
- : QmlGraphicsItem(parent), m_maximumSize(INT_MAX,INT_MAX), m_minimumSize(0,0), m_preferredSize(0,0)
-{
- setGraphicsItem(this);
-}
-
-void QmlGraphicsLayoutItem::setGeometry(const QRectF & rect)
-{
- setX(rect.x());
- setY(rect.y());
- setWidth(rect.width());
- setHeight(rect.height());
-}
-
-QSizeF QmlGraphicsLayoutItem::sizeHint(Qt::SizeHint w, const QSizeF &constraint) const
-{
- Q_UNUSED(constraint);
- if(w == Qt::MinimumSize){
- return m_minimumSize;
- }else if(w == Qt::MaximumSize){
- return m_maximumSize;
- }else{
- return m_preferredSize;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicslayoutitem_p.h b/src/declarative/graphicsitems/qmlgraphicslayoutitem_p.h
deleted file mode 100644
index fbc891d..0000000
--- a/src/declarative/graphicsitems/qmlgraphicslayoutitem_p.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSGRAPHICSLAYOUTITEM_H
-#define QMLGRAPHICSGRAPHICSLAYOUTITEM_H
-#include "qmlgraphicsitem.h"
-
-#include <QGraphicsLayoutItem>
-#include <QSizeF>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsLayoutItem : public QmlGraphicsItem, public QGraphicsLayoutItem
-{
- Q_OBJECT
- Q_INTERFACES(QGraphicsLayoutItem)
- Q_PROPERTY(QSizeF maximumSize READ maximumSize WRITE setMaximumSize NOTIFY maximumSizeChanged)
- Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize NOTIFY minimumSizeChanged)
- Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize NOTIFY preferredSizeChanged)
-public:
- QmlGraphicsLayoutItem(QmlGraphicsItem* parent=0);
-
- QSizeF maximumSize() const { return m_maximumSize; }
- void setMaximumSize(const QSizeF &s) { if(s==m_maximumSize) return; m_maximumSize = s; emit maximumSizeChanged(); }
-
- QSizeF minimumSize() const { return m_minimumSize; }
- void setMinimumSize(const QSizeF &s) { if(s==m_minimumSize) return; m_minimumSize = s; emit minimumSizeChanged(); }
-
- QSizeF preferredSize() const { return m_preferredSize; }
- void setPreferredSize(const QSizeF &s) { if(s==m_preferredSize) return; m_preferredSize = s; emit preferredSizeChanged(); }
-
- virtual void setGeometry(const QRectF & rect);
-protected:
- virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
-
-Q_SIGNALS:
- void maximumSizeChanged();
- void minimumSizeChanged();
- void preferredSizeChanged();
-
-private:
- QSizeF m_maximumSize;
- QSizeF m_minimumSize;
- QSizeF m_preferredSize;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsLayoutItem)
-
-QT_END_HEADER
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
deleted file mode 100644
index 28b21c9..0000000
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ /dev/null
@@ -1,2716 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicslistview_p.h"
-
-#include "qmlgraphicsflickable_p_p.h"
-#include "qmlgraphicsvisualitemmodel_p.h"
-
-#include <qmleasefollow_p.h>
-#include <qmlexpression.h>
-#include <qmlengine.h>
-
-#include <qlistmodelinterface_p.h>
-#include <QKeyEvent>
-
-QT_BEGIN_NAMESPACE
-
-void QmlGraphicsViewSection::setProperty(const QString &property)
-{
- if (property != m_property) {
- m_property = property;
- emit changed();
- }
-}
-
-void QmlGraphicsViewSection::setCriteria(QmlGraphicsViewSection::SectionCriteria criteria)
-{
- if (criteria != m_criteria) {
- m_criteria = criteria;
- emit changed();
- }
-}
-
-void QmlGraphicsViewSection::setDelegate(QmlComponent *delegate)
-{
- if (delegate != m_delegate) {
- m_delegate = delegate;
- emit delegateChanged();
- }
-}
-
-QString QmlGraphicsViewSection::sectionString(const QString &value)
-{
- if (m_criteria == FirstCharacter)
- return value.isEmpty() ? QString() : value.at(0);
- else
- return value;
-}
-
-//----------------------------------------------------------------------------
-
-class FxListItem
-{
-public:
- FxListItem(QmlGraphicsItem *i, QmlGraphicsListView *v) : item(i), section(0), view(v) {
- attached = static_cast<QmlGraphicsListViewAttached*>(qmlAttachedPropertiesObject<QmlGraphicsListView>(item));
- if (attached)
- attached->m_view = view;
- }
- ~FxListItem() {}
- qreal position() const {
- if (section)
- return (view->orientation() == QmlGraphicsListView::Vertical ? section->y() : section->x());
- else
- return (view->orientation() == QmlGraphicsListView::Vertical ? item->y() : item->x());
- }
- int size() const {
- if (section)
- return (view->orientation() == QmlGraphicsListView::Vertical ? item->height()+section->height() : item->width()+section->height());
- else
- return (view->orientation() == QmlGraphicsListView::Vertical ? item->height() : item->width());
- }
- qreal endPosition() const {
- return (view->orientation() == QmlGraphicsListView::Vertical
- ? item->y() + (item->height() > 0 ? item->height() : 1)
- : item->x() + (item->width() > 0 ? item->width() : 1)) - 1;
- }
- void setPosition(qreal pos) {
- if (view->orientation() == QmlGraphicsListView::Vertical) {
- if (section) {
- section->setY(pos);
- pos += section->height();
- }
- item->setY(pos);
- } else {
- if (section) {
- section->setX(pos);
- pos += section->width();
- }
- item->setX(pos);
- }
- }
-
- QmlGraphicsItem *item;
- QmlGraphicsItem *section;
- QmlGraphicsListView *view;
- QmlGraphicsListViewAttached *attached;
- int index;
-};
-
-//----------------------------------------------------------------------------
-
-class QmlGraphicsListViewPrivate : public QmlGraphicsFlickablePrivate, private QmlGraphicsItemChangeListener
-{
- Q_DECLARE_PUBLIC(QmlGraphicsListView)
-
-public:
- QmlGraphicsListViewPrivate()
- : currentItem(0), orient(QmlGraphicsListView::Vertical)
- , visiblePos(0), visibleIndex(0)
- , averageSize(100.0), currentIndex(-1), requestedIndex(-1)
- , highlightRangeStart(0), highlightRangeEnd(0)
- , highlightComponent(0), highlight(0), trackedItem(0)
- , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0)
- , sectionCriteria(0), spacing(0.0)
- , highlightMoveSpeed(400), highlightResizeSpeed(400), highlightRange(QmlGraphicsListView::NoHighlightRange)
- , snapMode(QmlGraphicsListView::NoSnap), overshootDist(0.0)
- , footerComponent(0), footer(0), headerComponent(0), header(0)
- , bufferMode(NoBuffer)
- , ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false)
- , correctFlick(true), inFlickCorrection(false), lazyRelease(false)
- , deferredRelease(false), minExtentDirty(true), maxExtentDirty(true)
- {}
-
- void init();
- void clear();
- FxListItem *createItem(int modelIndex);
- void releaseItem(FxListItem *item);
-
- FxListItem *visibleItem(int modelIndex) const {
- if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) {
- for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) {
- FxListItem *item = visibleItems.at(i);
- if (item->index == modelIndex)
- return item;
- }
- }
- return 0;
- }
-
- FxListItem *firstVisibleItem() const {
- const qreal pos = position();
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItem *item = visibleItems.at(i);
- if (item->index != -1 && item->endPosition() > pos)
- return item;
- }
- return visibleItems.count() ? visibleItems.first() : 0;
- }
-
- FxListItem *nextVisibleItem() const {
- const qreal pos = position();
- bool foundFirst = false;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItem *item = visibleItems.at(i);
- if (item->index != -1) {
- if (foundFirst)
- return item;
- else if (item->position() < pos && item->endPosition() > pos)
- foundFirst = true;
- }
- }
- return 0;
- }
-
- qreal position() const {
- Q_Q(const QmlGraphicsListView);
- return orient == QmlGraphicsListView::Vertical ? q->viewportY() : q->viewportX();
- }
- void setPosition(qreal pos) {
- Q_Q(QmlGraphicsListView);
- if (orient == QmlGraphicsListView::Vertical)
- q->setViewportY(pos);
- else
- q->setViewportX(pos);
- }
- qreal size() const {
- Q_Q(const QmlGraphicsListView);
- return orient == QmlGraphicsListView::Vertical ? q->height() : q->width();
- }
-
- qreal startPosition() const {
- qreal pos = 0;
- if (!visibleItems.isEmpty()) {
- pos = (*visibleItems.constBegin())->position();
- if (visibleIndex > 0)
- pos -= visibleIndex * (averageSize + spacing) - spacing;
- }
- return pos;
- }
-
- qreal endPosition() const {
- qreal pos = 0;
- if (!visibleItems.isEmpty()) {
- int invisibleCount = visibleItems.count() - visibleIndex;
- for (int i = visibleItems.count()-1; i >= 0; --i) {
- if (visibleItems.at(i)->index != -1) {
- invisibleCount = model->count() - visibleItems.at(i)->index - 1;
- break;
- }
- }
- pos = (*(--visibleItems.constEnd()))->endPosition() + invisibleCount * (averageSize + spacing);
- }
- return pos;
- }
-
- qreal positionAt(int modelIndex) const {
- if (FxListItem *item = visibleItem(modelIndex))
- return item->position();
- if (!visibleItems.isEmpty()) {
- if (modelIndex < visibleIndex) {
- int count = visibleIndex - modelIndex;
- return (*visibleItems.constBegin())->position() - count * (averageSize + spacing);
- } else {
- int idx = visibleItems.count() - 1;
- while (idx >= 0 && visibleItems.at(idx)->index == -1)
- --idx;
- if (idx < 0)
- idx = visibleIndex;
- else
- idx = visibleItems.at(idx)->index;
- int count = modelIndex - idx - 1;
- return (*(--visibleItems.constEnd()))->endPosition() + spacing + count * (averageSize + spacing) + 1;
- }
- }
- return 0;
- }
-
- QString sectionAt(int modelIndex) {
- if (FxListItem *item = visibleItem(modelIndex))
- return item->attached->section();
-
- QString section;
- if (sectionCriteria) {
- QString propValue = model->stringValue(modelIndex, sectionCriteria->property());
- section = sectionCriteria->sectionString(propValue);
- }
-
- return section;
- }
-
- bool isValid() const {
- return model && model->count() && model->isValid();
- }
-
- int snapIndex() {
- int index = currentIndex;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItem *item = visibleItems[i];
- if (item->index == -1)
- continue;
- qreal itemTop = item->position();
- if (itemTop >= highlight->position()-item->size()/2 && itemTop < highlight->position()+item->size()/2)
- return item->index;
- }
- return index;
- }
-
- qreal snapPosAt(qreal pos) {
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItem *item = visibleItems[i];
- if (item->index == -1)
- continue;
- qreal itemTop = item->position();
- if (item->index == model->count()-1 || (itemTop+item->size()/2 >= pos))
- return item->position();
- }
- if (visibleItems.count()) {
- qreal firstPos = visibleItems.first()->position();
- qreal endPos = visibleItems.last()->position();
- if (pos < firstPos) {
- return firstPos - qRound((firstPos - pos) / averageSize) * averageSize;
- } else if (pos > endPos)
- return endPos + qRound((pos - endPos) / averageSize) * averageSize;
- }
- return qRound((pos - startPosition()) / averageSize) * averageSize + startPosition();
- }
-
- FxListItem *snapItemAt(qreal pos) {
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItem *item = visibleItems[i];
- if (item->index == -1)
- continue;
- qreal itemTop = item->position();
- if (item->index == model->count()-1 || (itemTop+item->size()/2 >= pos))
- return item;
- }
- if (visibleItems.count() && visibleItems.first()->position() <= pos)
- return visibleItems.first();
- return 0;
- }
-
- int lastVisibleIndex() const {
- int lastIndex = -1;
- for (int i = visibleItems.count()-1; i >= 0; --i) {
- FxListItem *listItem = visibleItems.at(i);
- if (listItem->index != -1) {
- lastIndex = listItem->index;
- break;
- }
- }
- return lastIndex;
- }
-
- // map a model index to visibleItems index.
- // These may differ if removed items are still present in the visible list,
- // e.g. doing a removal animation
- int mapFromModel(int modelIndex) const {
- if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count())
- return -1;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItem *listItem = visibleItems.at(i);
- if (listItem->index == modelIndex)
- return i + visibleIndex;
- if (listItem->index > modelIndex)
- return -1;
- }
- return -1; // Not in visibleList
- }
-
- bool mapRangeFromModel(int &index, int &count) const {
- if (index + count < visibleIndex)
- return false;
-
- int lastIndex = -1;
- for (int i = visibleItems.count()-1; i >= 0; --i) {
- FxListItem *listItem = visibleItems.at(i);
- if (listItem->index != -1) {
- lastIndex = listItem->index;
- break;
- }
- }
-
- if (index > lastIndex)
- return false;
-
- int last = qMin(index + count - 1, lastIndex);
- index = qMax(index, visibleIndex);
- count = last - index + 1;
-
- return true;
- }
-
- void updateViewport() {
- Q_Q(QmlGraphicsListView);
- if (orient == QmlGraphicsListView::Vertical) {
- q->setViewportHeight(endPosition() - startPosition() + 1);
- } else {
- q->setViewportWidth(endPosition() - startPosition() + 1);
- }
- }
-
- void itemGeometryChanged(QmlGraphicsItem *, const QRectF &newGeometry, const QRectF &oldGeometry) {
- if ((orient == QmlGraphicsListView::Vertical && newGeometry.height() != oldGeometry.height())
- || newGeometry.width() != oldGeometry.width()) {
- layout();
- fixupPosition();
- }
- }
-
- // for debugging only
- void checkVisible() const {
- int skip = 0;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItem *listItem = visibleItems.at(i);
- if (listItem->index == -1) {
- ++skip;
- } else if (listItem->index != visibleIndex + i - skip) {
- qFatal("index %d %d %d", visibleIndex, i, listItem->index);
- }
- }
- }
-
- void refill(qreal from, qreal to, bool doBuffer = false);
- void layout();
- void updateUnrequestedIndexes();
- void updateUnrequestedPositions();
- void updateTrackedItem();
- void createHighlight();
- void updateHighlight();
- void createSection(FxListItem *);
- void updateSections();
- void updateCurrentSection();
- void updateCurrent(int);
- void updateAverage();
- void updateHeader();
- void updateFooter();
- void fixupPosition();
- virtual void fixupY();
- virtual void fixupX();
- virtual void flickX(qreal velocity);
- virtual void flickY(qreal velocity);
-
- QGuard<QmlGraphicsVisualModel> model;
- QVariant modelVariant;
- QList<FxListItem*> visibleItems;
- QHash<QmlGraphicsItem*,int> unrequestedItems;
- FxListItem *currentItem;
- QmlGraphicsListView::Orientation orient;
- int visiblePos;
- int visibleIndex;
- qreal averageSize;
- int currentIndex;
- int requestedIndex;
- qreal highlightRangeStart;
- qreal highlightRangeEnd;
- QmlComponent *highlightComponent;
- FxListItem *highlight;
- FxListItem *trackedItem;
- enum MovementReason { Other, SetIndex, Mouse };
- MovementReason moveReason;
- int buffer;
- QmlEaseFollow *highlightPosAnimator;
- QmlEaseFollow *highlightSizeAnimator;
- QmlGraphicsViewSection *sectionCriteria;
- QString currentSection;
- static const int sectionCacheSize = 3;
- QmlGraphicsItem *sectionCache[sectionCacheSize];
- qreal spacing;
- qreal highlightMoveSpeed;
- qreal highlightResizeSpeed;
- QmlGraphicsListView::HighlightRangeMode highlightRange;
- QmlGraphicsListView::SnapMode snapMode;
- qreal overshootDist;
- QmlComponent *footerComponent;
- FxListItem *footer;
- QmlComponent *headerComponent;
- FxListItem *header;
- enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 };
- int bufferMode;
- mutable qreal minExtent;
- mutable qreal maxExtent;
-
- bool ownModel : 1;
- bool wrap : 1;
- bool autoHighlight : 1;
- bool haveHighlightRange : 1;
- bool correctFlick : 1;
- bool inFlickCorrection : 1;
- bool lazyRelease : 1;
- bool deferredRelease : 1;
- mutable bool minExtentDirty : 1;
- mutable bool maxExtentDirty : 1;
-};
-
-void QmlGraphicsListViewPrivate::init()
-{
- Q_Q(QmlGraphicsListView);
- q->setFlag(QGraphicsItem::ItemIsFocusScope);
- addItemChangeListener(this, Geometry);
- QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped()));
- q->setFlickDirection(QmlGraphicsFlickable::VerticalFlick);
- ::memset(sectionCache, 0, sizeof(QmlGraphicsItem*) * sectionCacheSize);
-}
-
-void QmlGraphicsListViewPrivate::clear()
-{
- for (int i = 0; i < visibleItems.count(); ++i)
- releaseItem(visibleItems.at(i));
- visibleItems.clear();
- for (int i = 0; i < sectionCacheSize; ++i) {
- delete sectionCache[i];
- sectionCache[i] = 0;
- }
- visiblePos = header ? header->size() : 0;
- visibleIndex = 0;
- releaseItem(currentItem);
- currentItem = 0;
- createHighlight();
- trackedItem = 0;
- minExtentDirty = true;
- maxExtentDirty = true;
-}
-
-FxListItem *QmlGraphicsListViewPrivate::createItem(int modelIndex)
-{
- Q_Q(QmlGraphicsListView);
- // create object
- requestedIndex = modelIndex;
- FxListItem *listItem = 0;
- if (QmlGraphicsItem *item = model->item(modelIndex, false)) {
- listItem = new FxListItem(item, q);
- listItem->index = modelIndex;
- // initialise attached properties
- if (sectionCriteria) {
- QString propValue = model->stringValue(modelIndex, sectionCriteria->property());
- listItem->attached->m_section = sectionCriteria->sectionString(propValue);
- if (modelIndex > 0) {
- if (FxListItem *item = visibleItem(modelIndex-1))
- listItem->attached->m_prevSection = item->attached->section();
- else
- listItem->attached->m_prevSection = sectionAt(modelIndex-1);
- }
- }
- // complete
- model->completeItem();
- listItem->item->setZValue(1);
- listItem->item->setParent(q->viewport());
- QmlGraphicsItemPrivate *itemPrivate = static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(item));
- itemPrivate->addItemChangeListener(this, QmlGraphicsItemPrivate::Geometry);
- if (sectionCriteria && sectionCriteria->delegate()) {
- if (listItem->attached->m_prevSection != listItem->attached->m_section)
- createSection(listItem);
- }
- unrequestedItems.remove(listItem->item);
- }
- requestedIndex = -1;
-
- return listItem;
-}
-
-void QmlGraphicsListViewPrivate::releaseItem(FxListItem *item)
-{
- Q_Q(QmlGraphicsListView);
- if (!item || !model)
- return;
- if (trackedItem == item) {
- const char *notifier1 = orient == QmlGraphicsListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
- const char *notifier2 = orient == QmlGraphicsListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
- QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
- QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
- trackedItem = 0;
- }
- QmlGraphicsItemPrivate *itemPrivate = static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(item->item));
- itemPrivate->removeItemChangeListener(this, QmlGraphicsItemPrivate::Geometry);
- if (model->release(item->item) == 0) {
- // item was not destroyed, and we no longer reference it.
- unrequestedItems.insert(item->item, model->indexOf(item->item, q));
- }
- if (item->section) {
- int i = 0;
- do {
- if (!sectionCache[i]) {
- sectionCache[i] = item->section;
- sectionCache[i]->setVisible(false);
- item->section = 0;
- break;
- }
- ++i;
- } while (i < sectionCacheSize);
- delete item->section;
- }
- delete item;
-}
-
-void QmlGraphicsListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
-{
- Q_Q(QmlGraphicsListView);
- if (!isValid() || !q->isComponentComplete())
- return;
- qreal bufferFrom = from - buffer;
- qreal bufferTo = to + buffer;
- qreal fillFrom = from;
- qreal fillTo = to;
- if (doBuffer && (bufferMode & BufferAfter))
- fillTo = bufferTo;
- if (doBuffer && (bufferMode & BufferBefore))
- fillFrom = bufferFrom;
-
- int modelIndex = visibleIndex;
- qreal itemEnd = visiblePos-1;
- if (!visibleItems.isEmpty()) {
- visiblePos = (*visibleItems.constBegin())->position();
- itemEnd = (*(--visibleItems.constEnd()))->endPosition() + spacing;
- int i = visibleItems.count() - 1;
- while (i > 0 && visibleItems.at(i)->index == -1)
- --i;
- modelIndex = visibleItems.at(i)->index + 1;
- }
-
- bool changed = false;
- FxListItem *item = 0;
- int pos = itemEnd + 1;
- while (modelIndex < model->count() && pos <= fillTo) {
- //qDebug() << "refill: append item" << modelIndex << "pos" << pos;
- if (!(item = createItem(modelIndex)))
- break;
- item->setPosition(pos);
- pos += item->size() + spacing;
- visibleItems.append(item);
- ++modelIndex;
- changed = true;
- if (doBuffer) // never buffer more than one item per frame
- break;
- }
- while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos > fillFrom) {
- //qDebug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos;
- if (!(item = createItem(visibleIndex-1)))
- break;
- --visibleIndex;
- visiblePos -= item->size() + spacing;
- item->setPosition(visiblePos);
- visibleItems.prepend(item);
- changed = true;
- if (doBuffer) // never buffer more than one item per frame
- break;
- }
-
- if (!lazyRelease || !changed || deferredRelease) { // avoid destroying items in the same frame that we create
- while (visibleItems.count() > 1 && (item = visibleItems.first()) && item->endPosition() < bufferFrom) {
- if (item->attached->delayRemove())
- break;
- //qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endPosition();
- if (item->index != -1)
- visibleIndex++;
- visibleItems.removeFirst();
- releaseItem(item);
- changed = true;
- }
- while (visibleItems.count() > 1 && (item = visibleItems.last()) && item->position() > bufferTo) {
- if (item->attached->delayRemove())
- break;
- //qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1;
- visibleItems.removeLast();
- releaseItem(item);
- changed = true;
- }
- deferredRelease = false;
- } else {
- deferredRelease = true;
- }
- if (changed) {
- minExtentDirty = true;
- maxExtentDirty = true;
- if (visibleItems.count())
- visiblePos = (*visibleItems.constBegin())->position();
- updateAverage();
- if (sectionCriteria)
- updateCurrentSection();
- if (header)
- updateHeader();
- if (footer)
- updateFooter();
- updateViewport();
- updateUnrequestedPositions();
- } else if (!doBuffer && buffer && bufferMode != NoBuffer) {
- refill(from, to, true);
- }
- lazyRelease = false;
-}
-
-void QmlGraphicsListViewPrivate::layout()
-{
- Q_Q(QmlGraphicsListView);
- updateSections();
- if (!visibleItems.isEmpty()) {
- int oldEnd = visibleItems.last()->endPosition();
- int pos = visibleItems.first()->endPosition() + spacing + 1;
- for (int i=1; i < visibleItems.count(); ++i) {
- FxListItem *item = visibleItems.at(i);
- item->setPosition(pos);
- pos += item->size() + spacing;
- }
- // move current item if it is after the visible items.
- if (currentItem && currentIndex > lastVisibleIndex())
- currentItem->setPosition(currentItem->position() + (visibleItems.last()->endPosition() - oldEnd));
- }
- if (!isValid())
- return;
- q->refill();
- minExtentDirty = true;
- maxExtentDirty = true;
- updateHighlight();
- fixupPosition();
- q->refill();
- if (header)
- updateHeader();
- if (footer)
- updateFooter();
- updateViewport();
-}
-
-void QmlGraphicsListViewPrivate::updateUnrequestedIndexes()
-{
- Q_Q(QmlGraphicsListView);
- QHash<QmlGraphicsItem*,int>::iterator it;
- for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it)
- *it = model->indexOf(it.key(), q);
-}
-
-void QmlGraphicsListViewPrivate::updateUnrequestedPositions()
-{
- Q_Q(QmlGraphicsListView);
- if (unrequestedItems.count()) {
- qreal pos = position();
- QHash<QmlGraphicsItem*,int>::const_iterator it;
- for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) {
- QmlGraphicsItem *item = it.key();
- if (orient == QmlGraphicsListView::Vertical) {
- if (item->y() + item->height() > pos && item->y() < pos + q->height())
- item->setY(positionAt(*it));
- } else {
- if (item->x() + item->width() > pos && item->x() < pos + q->width())
- item->setX(positionAt(*it));
- }
- }
- }
-}
-
-void QmlGraphicsListViewPrivate::updateTrackedItem()
-{
- Q_Q(QmlGraphicsListView);
- FxListItem *item = currentItem;
- if (highlight)
- item = highlight;
-
- FxListItem *oldTracked = trackedItem;
-
- const char *notifier1 = orient == QmlGraphicsListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
- const char *notifier2 = orient == QmlGraphicsListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
-
- if (trackedItem && item != trackedItem) {
- QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
- QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
- trackedItem = 0;
- }
-
- if (!trackedItem && item) {
- trackedItem = item;
- QObject::connect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
- QObject::connect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
- }
- if (trackedItem && trackedItem != oldTracked)
- q->trackedPositionChanged();
-}
-
-void QmlGraphicsListViewPrivate::createHighlight()
-{
- Q_Q(QmlGraphicsListView);
- bool changed = false;
- if (highlight) {
- if (trackedItem == highlight)
- trackedItem = 0;
- delete highlight->item;
- delete highlight;
- highlight = 0;
- delete highlightPosAnimator;
- delete highlightSizeAnimator;
- highlightPosAnimator = 0;
- highlightSizeAnimator = 0;
- changed = true;
- }
-
- if (currentItem) {
- QmlGraphicsItem *item = 0;
- if (highlightComponent) {
- QmlContext *highlightContext = new QmlContext(qmlContext(q));
- QObject *nobj = highlightComponent->create(highlightContext);
- if (nobj) {
- highlightContext->setParent(nobj);
- item = qobject_cast<QmlGraphicsItem *>(nobj);
- if (!item)
- delete nobj;
- } else {
- delete highlightContext;
- }
- } else {
- item = new QmlGraphicsItem;
- }
- if (item) {
- item->setParent(q->viewport());
- highlight = new FxListItem(item, q);
- if (orient == QmlGraphicsListView::Vertical)
- highlight->item->setHeight(currentItem->item->height());
- else
- highlight->item->setWidth(currentItem->item->width());
- const QLatin1String posProp(orient == QmlGraphicsListView::Vertical ? "y" : "x");
- highlightPosAnimator = new QmlEaseFollow(q);
- highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp));
- highlightPosAnimator->setVelocity(highlightMoveSpeed);
- highlightPosAnimator->setEnabled(autoHighlight);
- const QLatin1String sizeProp(orient == QmlGraphicsListView::Vertical ? "height" : "width");
- highlightSizeAnimator = new QmlEaseFollow(q);
- highlightSizeAnimator->setVelocity(highlightResizeSpeed);
- highlightSizeAnimator->setTarget(QmlMetaProperty(highlight->item, sizeProp));
- highlightSizeAnimator->setEnabled(autoHighlight);
- changed = true;
- }
- }
- if (changed)
- emit q->highlightChanged();
-}
-
-void QmlGraphicsListViewPrivate::updateHighlight()
-{
- if ((!currentItem && highlight) || (currentItem && !highlight))
- createHighlight();
- if (currentItem && autoHighlight && highlight && !moving) {
- // auto-update highlight
- highlightPosAnimator->setSourceValue(currentItem->position());
- highlightSizeAnimator->setSourceValue(currentItem->size());
- if (orient == QmlGraphicsListView::Vertical) {
- if (highlight->item->width() == 0)
- highlight->item->setWidth(currentItem->item->width());
- } else {
- if (highlight->item->height() == 0)
- highlight->item->setHeight(currentItem->item->height());
- }
- }
- updateTrackedItem();
-}
-
-void QmlGraphicsListViewPrivate::createSection(FxListItem *listItem)
-{
- Q_Q(QmlGraphicsListView);
- if (!sectionCriteria || !sectionCriteria->delegate())
- return;
- if (listItem->attached->m_prevSection != listItem->attached->m_section) {
- if (!listItem->section) {
- int i = sectionCacheSize-1;
- while (i >= 0 && !sectionCache[i])
- --i;
- if (i >= 0) {
- listItem->section = sectionCache[i];
- sectionCache[i] = 0;
- listItem->section->setVisible(true);
- QmlContext *context = QmlEngine::contextForObject(listItem->section)->parentContext();
- context->setContextProperty(QLatin1String("section"), listItem->attached->m_section);
- } else {
- QmlContext *context = new QmlContext(qmlContext(q));
- context->setContextProperty(QLatin1String("section"), listItem->attached->m_section);
- QObject *nobj = sectionCriteria->delegate()->create(context);
- if (nobj) {
- context->setParent(nobj);
- listItem->section = qobject_cast<QmlGraphicsItem *>(nobj);
- if (!listItem->section) {
- delete nobj;
- } else {
- listItem->section->setZValue(1);
- listItem->section->setParent(q->viewport());
- }
- } else {
- delete context;
- }
- }
- }
- } else if (listItem->section) {
- int i = 0;
- do {
- if (!sectionCache[i]) {
- sectionCache[i] = listItem->section;
- sectionCache[i]->setVisible(false);
- listItem->section = 0;
- return;
- }
- ++i;
- } while (i < sectionCacheSize);
- delete listItem->section;
- listItem->section = 0;
- }
-}
-
-void QmlGraphicsListViewPrivate::updateSections()
-{
- if (sectionCriteria) {
- QString prevSection;
- if (visibleIndex > 0)
- prevSection = sectionAt(visibleIndex-1);
- for (int i = 0; i < visibleItems.count(); ++i) {
- if (visibleItems.at(i)->index != -1) {
- QmlGraphicsListViewAttached *attached = visibleItems.at(i)->attached;
- attached->setPrevSection(prevSection);
- createSection(visibleItems.at(i));
- prevSection = attached->section();
- }
- }
- }
-}
-
-void QmlGraphicsListViewPrivate::updateCurrentSection()
-{
- if (!sectionCriteria || visibleItems.isEmpty()) {
- currentSection = QString();
- return;
- }
- int index = 0;
- while (visibleItems.at(index)->endPosition() < position() && index < visibleItems.count())
- ++index;
-
- if (index < visibleItems.count())
- currentSection = visibleItems.at(index)->attached->section();
- else
- currentSection = visibleItems.first()->attached->section();
-}
-
-void QmlGraphicsListViewPrivate::updateCurrent(int modelIndex)
-{
- Q_Q(QmlGraphicsListView);
- if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) {
- if (currentItem) {
- currentItem->attached->setIsCurrentItem(false);
- releaseItem(currentItem);
- currentItem = 0;
- currentIndex = -1;
- updateHighlight();
- emit q->currentIndexChanged();
- }
- return;
- }
-
- if (currentItem && currentIndex == modelIndex) {
- updateHighlight();
- return;
- }
- FxListItem *oldCurrentItem = currentItem;
- currentIndex = modelIndex;
- currentItem = createItem(modelIndex);
- if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item))
- oldCurrentItem->attached->setIsCurrentItem(false);
- if (currentItem) {
- if (modelIndex == visibleIndex - 1) {
- // We can calculate exact postion in this case
- currentItem->setPosition(visibleItems.first()->position() - currentItem->size() - spacing);
- } else {
- // Create current item now and position as best we can.
- // Its position will be corrected when it becomes visible.
- currentItem->setPosition(positionAt(modelIndex));
- }
- currentItem->item->setFocus(true);
- currentItem->attached->setIsCurrentItem(true);
- }
- updateHighlight();
- emit q->currentIndexChanged();
- // Release the old current item
- releaseItem(oldCurrentItem);
-}
-
-void QmlGraphicsListViewPrivate::updateAverage()
-{
- if (!visibleItems.count())
- return;
- qreal sum = 0.0;
- for (int i = 0; i < visibleItems.count(); ++i)
- sum += visibleItems.at(i)->size();
- averageSize = sum / visibleItems.count();
-}
-
-void QmlGraphicsListViewPrivate::updateFooter()
-{
- Q_Q(QmlGraphicsListView);
- if (!footer && footerComponent) {
- QmlGraphicsItem *item = 0;
- QmlContext *context = new QmlContext(qmlContext(q));
- QObject *nobj = footerComponent->create(context);
- if (nobj) {
- context->setParent(nobj);
- item = qobject_cast<QmlGraphicsItem *>(nobj);
- if (!item)
- delete nobj;
- } else {
- delete context;
- }
- if (item) {
- item->setParent(q->viewport());
- item->setZValue(1);
- footer = new FxListItem(item, q);
- }
- }
- if (footer) {
- if (visibleItems.count()) {
- qreal endPos = endPosition();
- if (lastVisibleIndex() == model->count()-1) {
- footer->setPosition(endPos);
- } else {
- qreal visiblePos = position() + q->height();
- if (endPos <= visiblePos || footer->position() < endPos)
- footer->setPosition(endPos);
- }
- } else {
- footer->setPosition(visiblePos);
- }
- }
-}
-
-void QmlGraphicsListViewPrivate::updateHeader()
-{
- Q_Q(QmlGraphicsListView);
- if (!header && headerComponent) {
- QmlGraphicsItem *item = 0;
- QmlContext *context = new QmlContext(qmlContext(q));
- QObject *nobj = headerComponent->create(context);
- if (nobj) {
- context->setParent(nobj);
- item = qobject_cast<QmlGraphicsItem *>(nobj);
- if (!item)
- delete nobj;
- } else {
- delete context;
- }
- if (item) {
- item->setParent(q->viewport());
- item->setZValue(1);
- header = new FxListItem(item, q);
- if (visibleItems.isEmpty())
- visiblePos = header->size();
- }
- }
- if (header) {
- if (visibleItems.count()) {
- qreal startPos = startPosition();
- if (visibleIndex == 0) {
- header->setPosition(startPos - header->size());
- } else {
- if (position() <= startPos || header->position() > startPos - header->size())
- header->setPosition(startPos - header->size());
- }
- } else {
- header->setPosition(0);
- }
- }
-}
-
-void QmlGraphicsListViewPrivate::fixupPosition()
-{
- moveReason = Other;
- if (orient == QmlGraphicsListView::Vertical)
- fixupY();
- else
- fixupX();
-}
-
-void QmlGraphicsListViewPrivate::fixupY()
-{
- Q_Q(QmlGraphicsListView);
- if (orient == QmlGraphicsListView::Horizontal)
- return;
- if (!q->yflick() || _moveY.timeLine())
- return;
-
- int oldDuration = fixupDuration;
- fixupDuration = moveReason == Mouse ? fixupDuration : 0;
-
- if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) {
- if (currentItem && currentItem->position() - position() != highlightRangeStart) {
- qreal pos = currentItem->position() - highlightRangeStart;
- timeline.reset(_moveY);
- if (fixupDuration)
- timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
- _moveY.setValue(-pos);
- vTime = timeline.time();
- }
- } else if (snapMode != QmlGraphicsListView::NoSnap) {
- if (FxListItem *item = snapItemAt(position())) {
- qreal pos = qMin(item->position() - highlightRangeStart, -q->maxYExtent());
- qreal dist = qAbs(_moveY + pos);
- if (dist > 0) {
- timeline.reset(_moveY);
- if (fixupDuration)
- timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
- _moveY.setValue(-pos);
- vTime = timeline.time();
- }
- }
- } else {
- QmlGraphicsFlickablePrivate::fixupY();
- }
- fixupDuration = oldDuration;
-}
-
-void QmlGraphicsListViewPrivate::fixupX()
-{
- Q_Q(QmlGraphicsListView);
- if (orient == QmlGraphicsListView::Vertical)
- return;
- if (!q->xflick() || _moveX.timeLine())
- return;
-
- int oldDuration = fixupDuration;
- fixupDuration = moveReason == Mouse ? fixupDuration : 0;
-
- if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) {
- if (currentItem && currentItem->position() - position() != highlightRangeStart) {
- qreal pos = currentItem->position() - highlightRangeStart;
- timeline.reset(_moveX);
- if (fixupDuration)
- timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
- _moveX.setValue(-pos);
- vTime = timeline.time();
- }
- } else if (snapMode != QmlGraphicsListView::NoSnap) {
- if (FxListItem *item = snapItemAt(position())) {
- qreal pos = qMin(item->position() - highlightRangeStart, -q->maxXExtent());
- qreal dist = qAbs(_moveX + pos);
- if (dist > 0) {
- timeline.reset(_moveX);
- if (fixupDuration)
- timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
- _moveX.setValue(-pos);
- vTime = timeline.time();
- }
- }
- } else {
- QmlGraphicsFlickablePrivate::fixupX();
- }
- fixupDuration = oldDuration;
-}
-
-void QmlGraphicsListViewPrivate::flickX(qreal velocity)
-{
- Q_Q(QmlGraphicsListView);
-
- moveReason = Mouse;
- if ((!haveHighlightRange || highlightRange != QmlGraphicsListView::StrictlyEnforceRange) && snapMode == QmlGraphicsListView::NoSnap) {
- QmlGraphicsFlickablePrivate::flickX(velocity);
- return;
- }
- qreal maxDistance = -1;
- const qreal maxX = q->maxXExtent();
- const qreal minX = q->minXExtent();
- // -ve velocity means list is moving up
- if (velocity > 0) {
- if (snapMode == QmlGraphicsListView::SnapOneItem) {
- if (FxListItem *item = firstVisibleItem())
- maxDistance = qAbs(item->position() + _moveX.value());
- } else if (_moveX.value() < minX) {
- maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0));
- }
- if (snapMode != QmlGraphicsListView::SnapToItem && highlightRange != QmlGraphicsListView::StrictlyEnforceRange)
- flickTargetX = minX;
- } else {
- if (snapMode == QmlGraphicsListView::SnapOneItem) {
- if (FxListItem *item = nextVisibleItem())
- maxDistance = qAbs(item->position() + _moveX.value());
- } else if (_moveX.value() > maxX) {
- maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0);
- }
- if (snapMode != QmlGraphicsListView::SnapToItem && highlightRange != QmlGraphicsListView::StrictlyEnforceRange)
- flickTargetX = maxX;
- }
- if (maxDistance > 0 && (snapMode != QmlGraphicsListView::NoSnap || highlightRange == QmlGraphicsListView::StrictlyEnforceRange)) {
- // These modes require the list to stop exactly on an item boundary.
- // The initial flick will estimate the boundary to stop on.
- // Since list items can have variable sizes, the boundary will be
- // reevaluated and adjusted as we approach the boundary.
- qreal v = velocity;
- if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
- if (v < 0)
- v = -maxVelocity;
- else
- v = maxVelocity;
- }
- if (!flicked) {
- // the initial flick - estimate boundary
- qreal accel = deceleration;
- qreal v2 = v * v;
- qreal maxAccel = v2 / (2.0f * maxDistance);
- if (maxAccel < accel) {
- qreal dist = v2 / (accel * 2.0);
- if (v > 0)
- dist = -dist;
- flickTargetX = -snapPosAt(-(_moveX.value() - highlightRangeStart) + dist) + highlightRangeStart;
- dist = -flickTargetX + _moveX.value();
- accel = v2 / (2.0f * qAbs(dist));
- overshootDist = 0.0;
- } else {
- flickTargetX = velocity > 0 ? minX : maxX;
- overshootDist = overShoot ? 30 : 0;
- }
- timeline.reset(_moveX);
- timeline.accel(_moveX, v, accel, maxDistance + overshootDist);
- timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this));
- flicked = true;
- emit q->flickingChanged();
- emit q->flickStarted();
- correctFlick = true;
- } else {
- // reevaluate the target boundary.
- qreal newtarget = flickTargetX;
- if (snapMode != QmlGraphicsListView::NoSnap || highlightRange == QmlGraphicsListView::StrictlyEnforceRange)
- newtarget = -snapPosAt(-(flickTargetX - highlightRangeStart)) + highlightRangeStart;
- if (velocity < 0 && newtarget < maxX)
- newtarget = maxX;
- else if (velocity > 0 && newtarget > minX)
- newtarget = minX;
- if (newtarget == flickTargetX) // boundary unchanged - nothing to do
- return;
- flickTargetX = newtarget;
- qreal dist = -newtarget + _moveX.value();
- if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) {
- correctFlick = false;
- timeline.reset(_moveX);
- fixupX();
- return;
- }
- timeline.reset(_moveX);
- timeline.accelDistance(_moveX, v, -dist + (v < 0 ? -overshootDist : overshootDist));
- timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this));
- }
- } else {
- correctFlick = false;
- timeline.reset(_moveX);
- fixupX();
- }
-}
-
-void QmlGraphicsListViewPrivate::flickY(qreal velocity)
-{
- Q_Q(QmlGraphicsListView);
-
- moveReason = Mouse;
- if ((!haveHighlightRange || highlightRange != QmlGraphicsListView::StrictlyEnforceRange) && snapMode == QmlGraphicsListView::NoSnap) {
- QmlGraphicsFlickablePrivate::flickY(velocity);
- return;
- }
- qreal maxDistance = -1;
- const qreal maxY = q->maxYExtent();
- const qreal minY = q->minYExtent();
- // -ve velocity means list is moving up
- if (velocity > 0) {
- if (snapMode == QmlGraphicsListView::SnapOneItem) {
- if (FxListItem *item = firstVisibleItem())
- maxDistance = qAbs(item->position() + _moveY.value());
- } else if (_moveY.value() < minY) {
- maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0));
- }
- if (snapMode != QmlGraphicsListView::SnapToItem && highlightRange != QmlGraphicsListView::StrictlyEnforceRange)
- flickTargetY = minY;
- } else {
- if (snapMode == QmlGraphicsListView::SnapOneItem) {
- if (FxListItem *item = nextVisibleItem())
- maxDistance = qAbs(item->position() + _moveY.value());
- } else if (_moveY.value() > maxY) {
- maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0);
- }
- if (snapMode != QmlGraphicsListView::SnapToItem && highlightRange != QmlGraphicsListView::StrictlyEnforceRange)
- flickTargetY = maxY;
- }
- if (maxDistance > 0 && (snapMode != QmlGraphicsListView::NoSnap || highlightRange == QmlGraphicsListView::StrictlyEnforceRange)) {
- // These modes require the list to stop exactly on an item boundary.
- // The initial flick will estimate the boundary to stop on.
- // Since list items can have variable sizes, the boundary will be
- // reevaluated and adjusted as we approach the boundary.
- qreal v = velocity;
- if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
- if (v < 0)
- v = -maxVelocity;
- else
- v = maxVelocity;
- }
- if (!flicked) {
- // the initial flick - estimate boundary
- qreal accel = deceleration;
- qreal v2 = v * v;
- qreal maxAccel = v2 / (2.0f * maxDistance);
- if (maxAccel < accel) {
- qreal dist = v2 / (accel * 2.0);
- if (v > 0)
- dist = -dist;
- flickTargetY = -snapPosAt(-(_moveY.value() - highlightRangeStart) + dist) + highlightRangeStart;
- dist = -flickTargetY + _moveY.value();
- accel = v2 / (2.0f * qAbs(dist));
- overshootDist = 0.0;
- } else {
- flickTargetY = velocity > 0 ? minY : maxY;
- overshootDist = overShoot ? 30 : 0;
- }
- timeline.reset(_moveY);
- timeline.accel(_moveY, v, accel, maxDistance + overshootDist);
- timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this));
- flicked = true;
- emit q->flickingChanged();
- emit q->flickStarted();
- correctFlick = true;
- } else {
- // reevaluate the target boundary.
- qreal newtarget = flickTargetY;
- if (snapMode != QmlGraphicsListView::NoSnap || highlightRange == QmlGraphicsListView::StrictlyEnforceRange)
- newtarget = -snapPosAt(-(flickTargetY - highlightRangeStart)) + highlightRangeStart;
- if (velocity < 0 && newtarget < maxY)
- newtarget = maxY;
- else if (velocity > 0 && newtarget > minY)
- newtarget = minY;
- if (newtarget == flickTargetY) // boundary unchanged - nothing to do
- return;
- flickTargetY = newtarget;
- qreal dist = -newtarget + _moveY.value();
- if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) {
- correctFlick = false;
- timeline.reset(_moveY);
- fixupY();
- return;
- }
- timeline.reset(_moveY);
- timeline.accelDistance(_moveY, v, -dist + (v < 0 ? -overshootDist : overshootDist));
- timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this));
- }
- } else {
- correctFlick = false;
- timeline.reset(_moveY);
- fixupY();
- }
-}
-
-//----------------------------------------------------------------------------
-
-/*!
- \qmlclass ListView QmlGraphicsListView
- \since 4.7
- \inherits Flickable
- \brief The ListView item provides a list view of items provided by a model.
-
- The model is typically provided by a QAbstractListModel "C++ model object",
- but can also be created directly in QML. The items are laid out vertically
- or horizontally and may be flicked to scroll.
-
- The below example creates a very simple vertical list, using a QML model.
- \image trivialListView.png
-
- The user interface defines a delegate to display an item, a highlight,
- and the ListView which uses the above.
-
- \snippet doc/src/snippets/declarative/listview/listview.qml 3
-
- The model is defined as a ListModel using QML:
- \quotefile doc/src/snippets/declarative/listview/dummydata/ContactModel.qml
-
- In this case ListModel is a handy way for us to test our UI. In practice
- the model would be implemented in C++, or perhaps via a SQL data source.
-*/
-
-QmlGraphicsListView::QmlGraphicsListView(QmlGraphicsItem *parent)
- : QmlGraphicsFlickable(*(new QmlGraphicsListViewPrivate), parent)
-{
- Q_D(QmlGraphicsListView);
- d->init();
-}
-
-QmlGraphicsListView::~QmlGraphicsListView()
-{
- Q_D(QmlGraphicsListView);
- d->clear();
- if (d->ownModel)
- delete d->model;
- delete d->header;
- delete d->footer;
-}
-
-/*!
- \qmlattachedproperty bool ListView::isCurrentItem
- This attached property is true if this delegate is the current item; otherwise false.
-
- It is attached to each instance of the delegate.
-
- This property may be used to adjust the appearance of the current item, for example:
-
- \snippet doc/src/snippets/declarative/listview/highlight.qml 0
-*/
-
-/*!
- \qmlattachedproperty ListView ListView::view
- This attached property holds the view that manages this delegate instance.
-
- It is attached to each instance of the delegate.
-*/
-
-/*!
- \qmlattachedproperty string ListView::prevSection
- This attached property holds the section of the previous element.
-
- It is attached to each instance of the delegate.
-
- The section is evaluated using the \l {ListView::section.property}{section} properties.
-*/
-
-/*!
- \qmlattachedproperty string ListView::section
- This attached property holds the section of this element.
-
- It is attached to each instance of the delegate.
-
- The section is evaluated using the \l {ListView::section.property}{section} properties.
-*/
-
-/*!
- \qmlattachedproperty bool ListView::delayRemove
- This attached property holds whether the delegate may be destroyed.
-
- It is attached to each instance of the delegate.
-
- It is sometimes necessary to delay the destruction of an item
- until an animation completes.
-
- The example below ensures that the animation completes before
- the item is removed from the list.
-
- \code
- Component {
- id: myDelegate
- Item {
- id: wrapper
- ListView.onRemove: SequentialAnimation {
- PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: true }
- NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
- PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: false }
- }
- }
- }
- \endcode
-*/
-
-/*!
- \qmlattachedsignal ListView::onAdd()
- This attached handler is called immediately after an item is added to the view.
-*/
-
-/*!
- \qmlattachedsignal ListView::onRemove()
- This attached handler is called immediately before an item is removed from the view.
-*/
-
-/*!
- \qmlproperty model ListView::model
- This property holds the model providing data for the list.
-
- The model provides a set of data that is used to create the items
- for the view. For large or dynamic datasets the model is usually
- provided by a C++ model object. The C++ model object must be a \l
- {QAbstractItemModel} subclass or a simple list.
-
- Models can also be created directly in QML, using a \l{ListModel},
- \l{XmlListModel} or \l{VisualItemModel}.
-
- \sa {qmlmodels}{Data Models}
-*/
-QVariant QmlGraphicsListView::model() const
-{
- Q_D(const QmlGraphicsListView);
- return d->modelVariant;
-}
-
-void QmlGraphicsListView::setModel(const QVariant &model)
-{
- Q_D(QmlGraphicsListView);
- if (d->model) {
- disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
- disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
- disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
- disconnect(d->model, SIGNAL(createdItem(int, QmlGraphicsItem*)), this, SLOT(createdItem(int,QmlGraphicsItem*)));
- disconnect(d->model, SIGNAL(destroyingItem(QmlGraphicsItem*)), this, SLOT(destroyingItem(QmlGraphicsItem*)));
- }
- d->clear();
- d->modelVariant = model;
- QObject *object = qvariant_cast<QObject*>(model);
- QmlGraphicsVisualModel *vim = 0;
- if (object && (vim = qobject_cast<QmlGraphicsVisualModel *>(object))) {
- if (d->ownModel) {
- delete d->model;
- d->ownModel = false;
- }
- d->model = vim;
- } else {
- if (!d->ownModel) {
- d->model = new QmlGraphicsVisualDataModel(qmlContext(this));
- d->ownModel = true;
- }
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model))
- dataModel->setModel(model);
- }
- if (d->model) {
- if (isComponentComplete()) {
- refill();
- if (d->currentIndex >= d->model->count() || d->currentIndex < 0) {
- setCurrentIndex(0);
- } else {
- d->moveReason = QmlGraphicsListViewPrivate::SetIndex;
- d->updateCurrent(d->currentIndex);
- }
- }
- connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
- connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
- connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
- connect(d->model, SIGNAL(createdItem(int, QmlGraphicsItem*)), this, SLOT(createdItem(int,QmlGraphicsItem*)));
- connect(d->model, SIGNAL(destroyingItem(QmlGraphicsItem*)), this, SLOT(destroyingItem(QmlGraphicsItem*)));
- emit countChanged();
- }
-}
-
-/*!
- \qmlproperty component ListView::delegate
-
- The delegate provides a template defining each item instantiated by the view.
- The index is exposed as an accessible \c index property. Properties of the
- model are also available depending upon the type of \l {qmlmodels}{Data Model}.
-
- Note that the ListView will layout the items based on the size of the root item
- in the delegate.
-
- Here is an example delegate:
- \snippet doc/src/snippets/declarative/listview/listview.qml 0
-*/
-QmlComponent *QmlGraphicsListView::delegate() const
-{
- Q_D(const QmlGraphicsListView);
- if (d->model) {
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model))
- return dataModel->delegate();
- }
-
- return 0;
-}
-
-void QmlGraphicsListView::setDelegate(QmlComponent *delegate)
-{
- Q_D(QmlGraphicsListView);
- if (delegate == this->delegate())
- return;
- if (!d->ownModel) {
- d->model = new QmlGraphicsVisualDataModel(qmlContext(this));
- d->ownModel = true;
- }
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) {
- dataModel->setDelegate(delegate);
- if (isComponentComplete()) {
- for (int i = 0; i < d->visibleItems.count(); ++i)
- d->releaseItem(d->visibleItems.at(i));
- d->visibleItems.clear();
- refill();
- d->moveReason = QmlGraphicsListViewPrivate::SetIndex;
- d->updateCurrent(d->currentIndex);
- }
- }
-}
-
-/*!
- \qmlproperty int ListView::currentIndex
- \qmlproperty Item ListView::currentItem
-
- \c currentIndex holds the index of the current item.
- \c currentItem is the current item. Note that the position of the current item
- may only be approximate until it becomes visible in the view.
-*/
-int QmlGraphicsListView::currentIndex() const
-{
- Q_D(const QmlGraphicsListView);
- return d->currentIndex;
-}
-
-void QmlGraphicsListView::setCurrentIndex(int index)
-{
- Q_D(QmlGraphicsListView);
- if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) {
- d->moveReason = QmlGraphicsListViewPrivate::SetIndex;
- cancelFlick();
- d->updateCurrent(index);
- } else {
- d->currentIndex = index;
- }
-}
-
-QmlGraphicsItem *QmlGraphicsListView::currentItem()
-{
- Q_D(QmlGraphicsListView);
- if (!d->currentItem)
- return 0;
- return d->currentItem->item;
-}
-
-/*!
- \qmlproperty Item ListView::highlightItem
-
- \c highlightItem holds the highlight item, which was created
- from the \l highlight component.
-
- The highlightItem is managed by the view unless
- \l highlightFollowsCurrentItem is set to false.
-
- \sa highlight, highlightFollowsCurrentItem
-*/
-QmlGraphicsItem *QmlGraphicsListView::highlightItem()
-{
- Q_D(QmlGraphicsListView);
- if (!d->highlight)
- return 0;
- return d->highlight->item;
-}
-
-/*!
- \qmlproperty int ListView::count
- This property holds the number of items in the view.
-*/
-int QmlGraphicsListView::count() const
-{
- Q_D(const QmlGraphicsListView);
- if (d->model)
- return d->model->count();
- return 0;
-}
-
-/*!
- \qmlproperty component ListView::highlight
- This property holds the component to use as the highlight.
-
- An instance of the highlight component will be created for each list.
- The geometry of the resultant component instance will be managed by the list
- so as to stay with the current item, unless the highlightFollowsCurrentItem
- property is false.
-
- The below example demonstrates how to make a simple highlight
- for a vertical list.
-
- \snippet doc/src/snippets/declarative/listview/listview.qml 1
- \image trivialListView.png
-
- \sa highlightItem, highlightFollowsCurrentItem
-*/
-QmlComponent *QmlGraphicsListView::highlight() const
-{
- Q_D(const QmlGraphicsListView);
- return d->highlightComponent;
-}
-
-void QmlGraphicsListView::setHighlight(QmlComponent *highlight)
-{
- Q_D(QmlGraphicsListView);
- if (highlight != d->highlightComponent) {
- d->highlightComponent = highlight;
- d->createHighlight();
- if (d->currentItem)
- d->updateHighlight();
- }
-}
-
-/*!
- \qmlproperty bool ListView::highlightFollowsCurrentItem
- This property holds whether the highlight is managed by the view.
-
- If highlightFollowsCurrentItem is true, the highlight will be moved smoothly
- to follow the current item. If highlightFollowsCurrentItem is false, the
- highlight will not be moved by the view, and must be implemented
- by the highlight. The following example creates a highlight with
- its motion defined by the spring \l {SpringFollow}:
-
- \snippet doc/src/snippets/declarative/listview/highlight.qml 1
-
- Note that the highlight animation also affects the way that the view
- is scrolled. This is because the view moves to maintain the
- highlight within the preferred highlight range (or visible viewport).
-
- \sa highlight, highlightMoveSpeed
-*/
-bool QmlGraphicsListView::highlightFollowsCurrentItem() const
-{
- Q_D(const QmlGraphicsListView);
- return d->autoHighlight;
-}
-
-void QmlGraphicsListView::setHighlightFollowsCurrentItem(bool autoHighlight)
-{
- Q_D(QmlGraphicsListView);
- if (d->autoHighlight != autoHighlight) {
- d->autoHighlight = autoHighlight;
- if (d->highlightPosAnimator) {
- d->highlightPosAnimator->setEnabled(d->autoHighlight);
- d->highlightSizeAnimator->setEnabled(d->autoHighlight);
- }
- d->updateHighlight();
- }
-}
-
-//###Possibly rename these properties, since they are very useful even without a highlight?
-/*!
- \qmlproperty real ListView::preferredHighlightBegin
- \qmlproperty real ListView::preferredHighlightEnd
- \qmlproperty enumeration ListView::highlightRangeMode
-
- These properties set the preferred range of the highlight (current item)
- within the view.
-
- Note that this is the correct way to influence where the
- current item ends up when the list scrolls. For example, if you want the
- currently selected item to be in the middle of the list, then set the
- highlight range to be where the middle item would go. Then, when the list scrolls,
- the currently selected item will be the item at that spot. This also applies to
- when the currently selected item changes - it will scroll to within the preferred
- highlight range. Furthermore, the behaviour of the current item index will occur
- whether or not a highlight exists.
-
- If highlightRangeMode is set to \e ApplyRange the view will
- attempt to maintain the highlight within the range, however
- the highlight can move outside of the range at the ends of the list
- or due to a mouse interaction.
-
- If highlightRangeMode is set to \e StrictlyEnforceRange the highlight will never
- move outside of the range. This means that the current item will change
- if a keyboard or mouse action would cause the highlight to move
- outside of the range.
-
- The default value is \e NoHighlightRange.
-
- Note that a valid range requires preferredHighlightEnd to be greater
- than or equal to preferredHighlightBegin.
-*/
-qreal QmlGraphicsListView::preferredHighlightBegin() const
-{
- Q_D(const QmlGraphicsListView);
- return d->highlightRangeStart;
-}
-
-void QmlGraphicsListView::setPreferredHighlightBegin(qreal start)
-{
- Q_D(QmlGraphicsListView);
- d->highlightRangeStart = start;
- d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
-}
-
-qreal QmlGraphicsListView::preferredHighlightEnd() const
-{
- Q_D(const QmlGraphicsListView);
- return d->highlightRangeEnd;
-}
-
-void QmlGraphicsListView::setPreferredHighlightEnd(qreal end)
-{
- Q_D(QmlGraphicsListView);
- d->highlightRangeEnd = end;
- d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
-}
-
-QmlGraphicsListView::HighlightRangeMode QmlGraphicsListView::highlightRangeMode() const
-{
- Q_D(const QmlGraphicsListView);
- return d->highlightRange;
-}
-
-void QmlGraphicsListView::setHighlightRangeMode(HighlightRangeMode mode)
-{
- Q_D(QmlGraphicsListView);
- d->highlightRange = mode;
- d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
-}
-
-/*!
- \qmlproperty real ListView::spacing
-
- This property holds the spacing to leave between items.
-*/
-qreal QmlGraphicsListView::spacing() const
-{
- Q_D(const QmlGraphicsListView);
- return d->spacing;
-}
-
-void QmlGraphicsListView::setSpacing(qreal spacing)
-{
- Q_D(QmlGraphicsListView);
- if (spacing != d->spacing) {
- d->spacing = spacing;
- d->layout();
- emit spacingChanged();
- }
-}
-
-/*!
- \qmlproperty enumeration ListView::orientation
- This property holds the orientation of the list.
-
- Possible values are \c Vertical (default) and \c Horizontal.
-
- Vertical Example:
- \image trivialListView.png
- Horizontal Example:
- \image ListViewHorizontal.png
-*/
-QmlGraphicsListView::Orientation QmlGraphicsListView::orientation() const
-{
- Q_D(const QmlGraphicsListView);
- return d->orient;
-}
-
-void QmlGraphicsListView::setOrientation(QmlGraphicsListView::Orientation orientation)
-{
- Q_D(QmlGraphicsListView);
- if (d->orient != orientation) {
- d->orient = orientation;
- if (d->orient == QmlGraphicsListView::Vertical) {
- setViewportWidth(-1);
- setFlickDirection(VerticalFlick);
- } else {
- setViewportHeight(-1);
- setFlickDirection(HorizontalFlick);
- }
- d->clear();
- refill();
- emit orientationChanged();
- d->updateCurrent(d->currentIndex);
- }
-}
-
-/*!
- \qmlproperty bool ListView::keyNavigationWraps
- This property holds whether the list wraps key navigation
-
- If this property is true then key presses to move off of one end of the list will cause the
- current item to jump to the other end.
-*/
-bool QmlGraphicsListView::isWrapEnabled() const
-{
- Q_D(const QmlGraphicsListView);
- return d->wrap;
-}
-
-void QmlGraphicsListView::setWrapEnabled(bool wrap)
-{
- Q_D(QmlGraphicsListView);
- d->wrap = wrap;
-}
-
-/*!
- \qmlproperty int ListView::cacheBuffer
- This property holds the number of off-screen pixels to cache.
-
- This property determines the number of pixels above the top of the list
- and below the bottom of the list to cache. Setting this value can make
- scrolling the list smoother at the expense of additional memory usage.
-*/
-int QmlGraphicsListView::cacheBuffer() const
-{
- Q_D(const QmlGraphicsListView);
- return d->buffer;
-}
-
-void QmlGraphicsListView::setCacheBuffer(int b)
-{
- Q_D(QmlGraphicsListView);
- if (d->buffer != b) {
- d->buffer = b;
- if (isComponentComplete()) {
- d->bufferMode = QmlGraphicsListViewPrivate::BufferBefore | QmlGraphicsListViewPrivate::BufferAfter;
- refill();
- }
- }
-}
-
-/*!
- \qmlproperty string ListView::section.property
- \qmlproperty enumeration ListView::section.criteria
- These properties hold the expression to be evaluated for the section attached property.
-
- section.property hold the name of the property to use to determine
- the section the item is in.
-
- section.criteria holds the criteria to use to get the section. It
- can be either:
- \list
- \o ViewSection.FullString (default) - section is the value of the property.
- \o ViewSection.FirstCharacter - section is the first character of the property value.
- \endlist
-
- Each item in the list has attached properties named \c ListView.section and
- \c ListView.prevSection. These may be used to place a section header for
- related items. The example below assumes that the model is sorted by size of
- pet. The section expression is the size property. If \c ListView.section and
- \c ListView.prevSection differ, the item will display a section header.
-
- \snippet examples/declarative/listview/sections.qml 0
-
- \image ListViewSections.png
-*/
-QmlGraphicsViewSection *QmlGraphicsListView::sectionCriteria()
-{
- Q_D(QmlGraphicsListView);
- if (!d->sectionCriteria)
- d->sectionCriteria = new QmlGraphicsViewSection(this);
- return d->sectionCriteria;
-}
-
-/*!
- \qmlproperty string ListView::currentSection
- This property holds the section that is currently at the beginning of the view.
-*/
-QString QmlGraphicsListView::currentSection() const
-{
- Q_D(const QmlGraphicsListView);
- return d->currentSection;
-}
-
-/*!
- \qmlproperty real ListView::highlightMoveSpeed
- \qmlproperty real ListView::highlightResizeSpeed
- These properties hold the move and resize animation speed of the highlight delegate.
-
- highlightFollowsCurrentItem must be true for these properties
- to have effect.
-
- The default value for these properties is 400 pixels/second.
-
- \sa highlightFollowsCurrentItem
-*/
-qreal QmlGraphicsListView::highlightMoveSpeed() const
-{
- Q_D(const QmlGraphicsListView);\
- return d->highlightMoveSpeed;
-}
-
-void QmlGraphicsListView::setHighlightMoveSpeed(qreal speed)
-{
- Q_D(QmlGraphicsListView);\
- if (d->highlightMoveSpeed != speed) {
- d->highlightMoveSpeed = speed;
- if (d->highlightPosAnimator)
- d->highlightPosAnimator->setVelocity(d->highlightMoveSpeed);
- emit highlightMoveSpeedChanged();
- }
-}
-
-qreal QmlGraphicsListView::highlightResizeSpeed() const
-{
- Q_D(const QmlGraphicsListView);\
- return d->highlightResizeSpeed;
-}
-
-void QmlGraphicsListView::setHighlightResizeSpeed(qreal speed)
-{
- Q_D(QmlGraphicsListView);\
- if (d->highlightResizeSpeed != speed) {
- d->highlightResizeSpeed = speed;
- if (d->highlightSizeAnimator)
- d->highlightSizeAnimator->setVelocity(d->highlightResizeSpeed);
- emit highlightResizeSpeedChanged();
- }
-}
-
-/*!
- \qmlproperty enumeration ListView::snapMode
-
- This property determines where the view will settle following a drag or flick.
- The allowed values are:
-
- \list
- \o NoSnap (default) - the view will stop anywhere within the visible area.
- \o SnapToItem - the view will settle with an item aligned with the start of
- the view.
- \o SnapOneItem - the view will settle no more than one item away from the first
- visible item at the time the mouse button is released. This mode is particularly
- useful for moving one page at a time.
- \endlist
-*/
-QmlGraphicsListView::SnapMode QmlGraphicsListView::snapMode() const
-{
- Q_D(const QmlGraphicsListView);
- return d->snapMode;
-}
-
-void QmlGraphicsListView::setSnapMode(SnapMode mode)
-{
- Q_D(QmlGraphicsListView);
- if (d->snapMode != mode) {
- d->snapMode = mode;
- }
-}
-
-QmlComponent *QmlGraphicsListView::footer() const
-{
- Q_D(const QmlGraphicsListView);
- return d->footerComponent;
-}
-
-void QmlGraphicsListView::setFooter(QmlComponent *footer)
-{
- Q_D(QmlGraphicsListView);
- if (d->footerComponent != footer) {
- if (d->footer) {
- delete d->footer;
- d->footer = 0;
- }
- d->footerComponent = footer;
- d->minExtentDirty = true;
- d->maxExtentDirty = true;
- d->updateFooter();
- d->updateViewport();
- }
-}
-
-QmlComponent *QmlGraphicsListView::header() const
-{
- Q_D(const QmlGraphicsListView);
- return d->headerComponent;
-}
-
-void QmlGraphicsListView::setHeader(QmlComponent *header)
-{
- Q_D(QmlGraphicsListView);
- if (d->headerComponent != header) {
- if (d->header) {
- delete d->header;
- d->header = 0;
- }
- d->headerComponent = header;
- d->minExtentDirty = true;
- d->maxExtentDirty = true;
- d->updateHeader();
- d->updateFooter();
- d->updateViewport();
- }
-}
-
-void QmlGraphicsListView::viewportMoved()
-{
- Q_D(QmlGraphicsListView);
- QmlGraphicsFlickable::viewportMoved();
- d->lazyRelease = true;
- refill();
- if (isFlicking() || d->moving)
- d->moveReason = QmlGraphicsListViewPrivate::Mouse;
- if (d->moveReason != QmlGraphicsListViewPrivate::SetIndex) {
- if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
- // reposition highlight
- qreal pos = d->highlight->position();
- if (pos > d->position() + d->highlightRangeEnd - 1 - d->highlight->size())
- pos = d->position() + d->highlightRangeEnd - 1 - d->highlight->size();
- if (pos < d->position() + d->highlightRangeStart)
- pos = d->position() + d->highlightRangeStart;
- d->highlight->setPosition(pos);
-
- // update current index
- int idx = d->snapIndex();
- if (idx >= 0 && idx != d->currentIndex)
- d->updateCurrent(idx);
- }
- }
-
- if (d->flicked && d->correctFlick && !d->inFlickCorrection) {
- d->inFlickCorrection = true;
- // Near an end and it seems that the extent has changed?
- // Recalculate the flick so that we don't end up in an odd position.
- if (yflick()) {
- if (d->velocityY > 0) {
- const qreal minY = minYExtent();
- if ((minY - d->_moveY.value() < height()/2 || d->flickTargetY - d->_moveY.value() < height()/2)
- && minY != d->flickTargetY)
- d->flickY(-d->verticalVelocity.value());
- d->bufferMode = QmlGraphicsListViewPrivate::BufferBefore;
- } else if (d->velocityY < 0) {
- const qreal maxY = maxYExtent();
- if ((d->_moveY.value() - maxY < height()/2 || d->_moveY.value() - d->flickTargetY < height()/2)
- && maxY != d->flickTargetY)
- d->flickY(-d->verticalVelocity.value());
- d->bufferMode = QmlGraphicsListViewPrivate::BufferAfter;
- }
- }
-
- if (xflick()) {
- if (d->velocityX > 0) {
- const qreal minX = minXExtent();
- if ((minX - d->_moveX.value() < height()/2 || d->flickTargetX - d->_moveX.value() < height()/2)
- && minX != d->flickTargetX)
- d->flickX(-d->horizontalVelocity.value());
- d->bufferMode = QmlGraphicsListViewPrivate::BufferBefore;
- } else if (d->velocityX < 0) {
- const qreal maxX = maxXExtent();
- if ((d->_moveX.value() - maxX < height()/2 || d->_moveX.value() - d->flickTargetX < height()/2)
- && maxX != d->flickTargetX)
- d->flickX(-d->horizontalVelocity.value());
- d->bufferMode = QmlGraphicsListViewPrivate::BufferAfter;
- }
- }
- d->inFlickCorrection = false;
- }
-}
-
-qreal QmlGraphicsListView::minYExtent() const
-{
- Q_D(const QmlGraphicsListView);
- if (d->orient == QmlGraphicsListView::Horizontal)
- return QmlGraphicsFlickable::minYExtent();
- if (d->minExtentDirty) {
- d->minExtent = -d->startPosition();
- if (d->header && d->visibleItems.count())
- d->minExtent += d->header->size();
- if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
- d->minExtent += d->highlightRangeStart;
- d->minExtentDirty = false;
- }
-
- return d->minExtent;
-}
-
-qreal QmlGraphicsListView::maxYExtent() const
-{
- Q_D(const QmlGraphicsListView);
- if (d->orient == QmlGraphicsListView::Horizontal)
- return height();
- if (d->maxExtentDirty) {
- if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
- d->maxExtent = -(d->positionAt(count()-1) - d->highlightRangeEnd);
- else
- d->maxExtent = -(d->endPosition() - height() + 1);
- if (d->footer)
- d->maxExtent -= d->footer->size();
- qreal minY = minYExtent();
- if (d->maxExtent > minY)
- d->maxExtent = minY;
- d->maxExtentDirty = false;
- }
- return d->maxExtent;
-}
-
-qreal QmlGraphicsListView::minXExtent() const
-{
- Q_D(const QmlGraphicsListView);
- if (d->orient == QmlGraphicsListView::Vertical)
- return QmlGraphicsFlickable::minXExtent();
- if (d->minExtentDirty) {
- d->minExtent = -d->startPosition();
- if (d->header)
- d->minExtent += d->header->size();
- if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
- d->minExtent += d->highlightRangeStart;
- d->minExtentDirty = false;
- }
-
- return d->minExtent;
-}
-
-qreal QmlGraphicsListView::maxXExtent() const
-{
- Q_D(const QmlGraphicsListView);
- if (d->orient == QmlGraphicsListView::Vertical)
- return width();
- if (d->maxExtentDirty) {
- if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
- d->maxExtent = -(d->positionAt(count()-1) - d->highlightRangeEnd);
- else
- d->maxExtent = -(d->endPosition() - width() + 1);
- if (d->footer)
- d->maxExtent -= d->footer->size();
- qreal minX = minXExtent();
- if (d->maxExtent > minX)
- d->maxExtent = minX;
- d->maxExtentDirty = false;
- }
-
- return d->maxExtent;
-}
-
-void QmlGraphicsListView::keyPressEvent(QKeyEvent *event)
-{
- Q_D(QmlGraphicsListView);
- QmlGraphicsFlickable::keyPressEvent(event);
- if (event->isAccepted())
- return;
-
- if (d->model && d->model->count() && d->interactive) {
- if ((d->orient == QmlGraphicsListView::Horizontal && event->key() == Qt::Key_Left)
- || (d->orient == QmlGraphicsListView::Vertical && event->key() == Qt::Key_Up)) {
- if (currentIndex() > 0 || (d->wrap && !event->isAutoRepeat())) {
- decrementCurrentIndex();
- event->accept();
- return;
- } else if (d->wrap) {
- event->accept();
- return;
- }
- } else if ((d->orient == QmlGraphicsListView::Horizontal && event->key() == Qt::Key_Right)
- || (d->orient == QmlGraphicsListView::Vertical && event->key() == Qt::Key_Down)) {
- if (currentIndex() < d->model->count() - 1 || (d->wrap && !event->isAutoRepeat())) {
- incrementCurrentIndex();
- event->accept();
- return;
- } else if (d->wrap) {
- event->accept();
- return;
- }
- }
- }
- event->ignore();
-}
-
-/*!
- \qmlmethod ListView::incrementCurrentIndex()
-
- Increments the current index. The current index will wrap
- if keyNavigationWraps is true and it is currently at the end.
-*/
-void QmlGraphicsListView::incrementCurrentIndex()
-{
- Q_D(QmlGraphicsListView);
- if (currentIndex() < d->model->count() - 1 || d->wrap) {
- d->moveReason = QmlGraphicsListViewPrivate::SetIndex;
- int index = currentIndex()+1;
- cancelFlick();
- d->updateCurrent(index < d->model->count() ? index : 0);
- }
-}
-
-/*!
- \qmlmethod ListView::decrementCurrentIndex()
-
- Decrements the current index. The current index will wrap
- if keyNavigationWraps is true and it is currently at the beginning.
-*/
-void QmlGraphicsListView::decrementCurrentIndex()
-{
- Q_D(QmlGraphicsListView);
- if (currentIndex() > 0 || d->wrap) {
- d->moveReason = QmlGraphicsListViewPrivate::SetIndex;
- int index = currentIndex()-1;
- cancelFlick();
- d->updateCurrent(index >= 0 ? index : d->model->count()-1);
- }
-}
-
-/*!
- \qmlmethod ListView::positionViewAtIndex(int index)
-
- Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view.
- If positioning the view at the index would cause empty space to be displayed at
- the end of the view, the view will be positioned at the end.
-*/
-void QmlGraphicsListView::positionViewAtIndex(int index)
-{
- Q_D(QmlGraphicsListView);
- if (!d->isValid() || index < 0 || index >= d->model->count())
- return;
-
- qreal maxExtent = d->orient == QmlGraphicsListView::Vertical ? -maxYExtent() : -maxXExtent();
- FxListItem *item = d->visibleItem(index);
- if (item) {
- // Already created - just move to top of view
- int pos = qMin(item->position(), maxExtent);
- d->setPosition(pos);
- } else {
- int pos = d->positionAt(index);
- // save the currently visible items in case any of them end up visible again
- QList<FxListItem*> oldVisible = d->visibleItems;
- d->visibleItems.clear();
- d->visiblePos = pos;
- d->visibleIndex = index;
- d->setPosition(pos);
- // setPosition() will cause refill. Adjust if we have moved beyond range.
- if (d->position() > maxExtent)
- d->setPosition(maxExtent);
- // now release the reference to all the old visible items.
- for (int i = 0; i < oldVisible.count(); ++i)
- d->releaseItem(oldVisible.at(i));
- }
- d->fixupPosition();
-}
-
-
-void QmlGraphicsListView::componentComplete()
-{
- Q_D(QmlGraphicsListView);
- QmlGraphicsFlickable::componentComplete();
- refill();
- d->moveReason = QmlGraphicsListViewPrivate::SetIndex;
- if (d->currentIndex < 0)
- d->updateCurrent(0);
- else
- d->updateCurrent(d->currentIndex);
- d->fixupPosition();
-}
-
-void QmlGraphicsListView::refill()
-{
- Q_D(QmlGraphicsListView);
- d->refill(d->position(), d->position()+d->size()-1);
-}
-
-void QmlGraphicsListView::trackedPositionChanged()
-{
- Q_D(QmlGraphicsListView);
- if (!d->trackedItem || !d->currentItem)
- return;
- if (!isFlicking() && !d->moving && d->moveReason == QmlGraphicsListViewPrivate::SetIndex) {
- const qreal trackedPos = d->trackedItem->position();
- const qreal viewPos = d->position();
- if (d->haveHighlightRange) {
- if (d->highlightRange == StrictlyEnforceRange) {
- qreal pos = viewPos;
- if (trackedPos > pos + d->highlightRangeEnd - d->trackedItem->size())
- pos = trackedPos - d->highlightRangeEnd + d->trackedItem->size();
- if (trackedPos < pos + d->highlightRangeStart)
- pos = trackedPos - d->highlightRangeStart;
- d->setPosition(pos);
- } else {
- qreal pos = viewPos;
- if (trackedPos < d->startPosition() + d->highlightRangeStart) {
- pos = d->startPosition();
- } else if (d->trackedItem->endPosition() > d->endPosition() - d->size() + d->highlightRangeEnd) {
- pos = d->endPosition() - d->size();
- if (pos < d->startPosition())
- pos = d->startPosition();
- } else {
- if (trackedPos < viewPos + d->highlightRangeStart) {
- pos = trackedPos - d->highlightRangeStart;
- } else if (trackedPos > viewPos + d->highlightRangeEnd - d->trackedItem->size()) {
- pos = trackedPos - d->highlightRangeEnd + d->trackedItem->size();
- }
- }
- d->setPosition(pos);
- }
- } else {
- if (trackedPos < viewPos && d->currentItem->position() < viewPos) {
- d->setPosition(d->currentItem->position() < trackedPos ? trackedPos : d->currentItem->position());
- } else if (d->trackedItem->endPosition() > viewPos + d->size()
- && d->currentItem->endPosition() > viewPos + d->size()) {
- qreal pos;
- if (d->trackedItem->endPosition() < d->currentItem->endPosition()) {
- pos = d->trackedItem->endPosition() - d->size();
- if (d->trackedItem->size() > d->size())
- pos = trackedPos;
- } else {
- pos = d->currentItem->endPosition() - d->size();
- if (d->currentItem->size() > d->size())
- pos = d->currentItem->position();
- }
- d->setPosition(pos);
- }
- }
- }
-}
-
-void QmlGraphicsListView::itemsInserted(int modelIndex, int count)
-{
- Q_D(QmlGraphicsListView);
- d->updateUnrequestedIndexes();
- d->moveReason = QmlGraphicsListViewPrivate::Other;
- if (!d->visibleItems.count() || d->model->count() <= 1) {
- d->layout();
- d->updateCurrent(qMax(0, qMin(d->currentIndex, d->model->count()-1)));
- emit countChanged();
- return;
- }
-
- int overlapCount = count;
- if (!d->mapRangeFromModel(modelIndex, overlapCount)) {
- int i = d->visibleItems.count() - 1;
- while (i > 0 && d->visibleItems.at(i)->index == -1)
- --i;
- if (d->visibleItems.at(i)->index + 1 == modelIndex) {
- // Special case of appending an item to the model.
- modelIndex = d->visibleIndex + d->visibleItems.count();
- } else {
- if (modelIndex < d->visibleIndex) {
- // Insert before visible items
- d->visibleIndex += count;
- for (int i = 0; i < d->visibleItems.count(); ++i) {
- FxListItem *listItem = d->visibleItems.at(i);
- if (listItem->index != -1 && listItem->index >= modelIndex)
- listItem->index += count;
- }
- }
- if (d->currentIndex >= modelIndex) {
- // adjust current item index
- d->currentIndex += count;
- if (d->currentItem)
- d->currentItem->index = d->currentIndex;
- }
- d->layout();
- emit countChanged();
- return;
- }
- }
-
- // At least some of the added items will be visible
-
- int index = modelIndex - d->visibleIndex;
- // index can be the next item past the end of the visible items list (i.e. appended)
- int pos = index < d->visibleItems.count() ? d->visibleItems.at(index)->position()
- : d->visibleItems.at(index-1)->endPosition()+d->spacing+1;
- int initialPos = pos;
- int diff = 0;
- QList<FxListItem*> added;
- bool addedVisible = false;
- FxListItem *firstVisible = d->firstVisibleItem();
- if (firstVisible && pos < firstVisible->position()) {
- // Insert items before the visible item.
- int insertionIdx = index;
- int i = 0;
- int from = d->position() - d->buffer;
- for (i = count-1; i >= 0 && pos > from; --i) {
- addedVisible = true;
- FxListItem *item = d->createItem(modelIndex + i);
- d->visibleItems.insert(insertionIdx, item);
- pos -= item->size() + d->spacing;
- item->setPosition(pos);
- index++;
- }
- if (i >= 0) {
- // If we didn't insert all our new items - anything
- // before the current index is not visible - remove it.
- while (insertionIdx--) {
- FxListItem *item = d->visibleItems.takeFirst();
- if (item->index != -1)
- d->visibleIndex++;
- d->releaseItem(item);
- }
- } else {
- // adjust pos of items before inserted items.
- for (int i = insertionIdx-1; i >= 0; i--) {
- FxListItem *listItem = d->visibleItems.at(i);
- listItem->setPosition(listItem->position() - (initialPos - pos));
- }
- }
- } else {
- int i = 0;
- int to = d->buffer+d->position()+d->size()-1;
- for (i = 0; i < count && pos <= to; ++i) {
- addedVisible = true;
- FxListItem *item = d->createItem(modelIndex + i);
- d->visibleItems.insert(index, item);
- item->setPosition(pos);
- added.append(item);
- pos += item->size() + d->spacing;
- ++index;
- }
- if (i != count) {
- // We didn't insert all our new items, which means anything
- // beyond the current index is not visible - remove it.
- while (d->visibleItems.count() > index)
- d->releaseItem(d->visibleItems.takeLast());
- }
- diff = pos - initialPos;
- }
- if (d->currentIndex >= modelIndex) {
- // adjust current item index
- d->currentIndex += count;
- if (d->currentItem) {
- d->currentItem->index = d->currentIndex;
- d->currentItem->setPosition(d->currentItem->position() + diff);
- }
- }
- // Update the indexes of the following visible items.
- for (; index < d->visibleItems.count(); ++index) {
- FxListItem *listItem = d->visibleItems.at(index);
- if (d->currentItem && listItem->item != d->currentItem->item)
- listItem->setPosition(listItem->position() + diff);
- if (listItem->index != -1)
- listItem->index += count;
- }
- // everything is in order now - emit add() signal
- for (int j = 0; j < added.count(); ++j)
- added.at(j)->attached->emitAdd();
-
- if (addedVisible)
- d->layout();
- emit countChanged();
-}
-
-void QmlGraphicsListView::itemsRemoved(int modelIndex, int count)
-{
- Q_D(QmlGraphicsListView);
- d->moveReason = QmlGraphicsListViewPrivate::Other;
- d->updateUnrequestedIndexes();
-
- FxListItem *firstVisible = d->firstVisibleItem();
- int preRemovedSize = 0;
- bool removedVisible = false;
- // Remove the items from the visible list, skipping anything already marked for removal
- QList<FxListItem*>::Iterator it = d->visibleItems.begin();
- while (it != d->visibleItems.end()) {
- FxListItem *item = *it;
- if (item->index == -1 || item->index < modelIndex) {
- // already removed, or before removed items
- ++it;
- } else if (item->index >= modelIndex + count) {
- // after removed items
- item->index -= count;
- ++it;
- } else {
- // removed item
- removedVisible = true;
- item->attached->emitRemove();
- if (item->attached->delayRemove()) {
- item->index = -1;
- connect(item->attached, SIGNAL(delayRemoveChanged()), this, SLOT(destroyRemoved()), Qt::QueuedConnection);
- ++it;
- } else {
- if (item == firstVisible)
- firstVisible = 0;
- if (firstVisible && item->position() < firstVisible->position())
- preRemovedSize += item->size();
- it = d->visibleItems.erase(it);
- d->releaseItem(item);
- }
- }
- }
-
- if (firstVisible && d->visibleItems.first() != firstVisible)
- d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + preRemovedSize);
-
- // fix current
- if (d->currentIndex >= modelIndex + count) {
- d->currentIndex -= count;
- if (d->currentItem)
- d->currentItem->index -= count;
- } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
- // current item has been removed.
- d->currentItem->attached->setIsCurrentItem(false);
- d->releaseItem(d->currentItem);
- d->currentItem = 0;
- d->currentIndex = -1;
- d->updateCurrent(qMin(modelIndex, d->model->count()-1));
- }
-
- // update visibleIndex
- for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
- if ((*it)->index != -1) {
- d->visibleIndex = (*it)->index;
- break;
- }
- }
-
- if (removedVisible) {
- if (d->visibleItems.isEmpty()) {
- d->visibleIndex = 0;
- d->visiblePos = d->header ? d->header->size() : 0;
- d->timeline.clear();
- d->setPosition(0);
- if (d->model->count() == 0)
- update();
- else
- refill();
- } else {
- // Correct the positioning of the items
- d->layout();
- }
- }
-
- emit countChanged();
-}
-
-void QmlGraphicsListView::destroyRemoved()
-{
- Q_D(QmlGraphicsListView);
- for (QList<FxListItem*>::Iterator it = d->visibleItems.begin();
- it != d->visibleItems.end();) {
- FxListItem *listItem = *it;
- if (listItem->index == -1 && listItem->attached->delayRemove() == false) {
- d->releaseItem(listItem);
- it = d->visibleItems.erase(it);
- } else {
- ++it;
- }
- }
-
- // Correct the positioning of the items
- d->layout();
-}
-
-void QmlGraphicsListView::itemsMoved(int from, int to, int count)
-{
- Q_D(QmlGraphicsListView);
- d->updateUnrequestedIndexes();
-
- if (d->visibleItems.isEmpty()) {
- refill();
- return;
- }
-
- d->moveReason = QmlGraphicsListViewPrivate::Other;
- FxListItem *firstVisible = d->firstVisibleItem();
- qreal firstItemPos = firstVisible->position();
- QHash<int,FxListItem*> moved;
- int moveBy = 0;
-
- QList<FxListItem*>::Iterator it = d->visibleItems.begin();
- while (it != d->visibleItems.end()) {
- FxListItem *item = *it;
- if (item->index >= from && item->index < from + count) {
- // take the items that are moving
- item->index += (to-from);
- moved.insert(item->index, item);
- if (item->position() < firstItemPos)
- moveBy += item->size();
- it = d->visibleItems.erase(it);
- } else {
- // move everything after the moved items.
- if (item->index > from && item->index != -1)
- item->index -= count;
- ++it;
- }
- }
-
- int remaining = count;
- int endIndex = d->visibleIndex;
- it = d->visibleItems.begin();
- while (it != d->visibleItems.end()) {
- FxListItem *item = *it;
- if (remaining && item->index >= to && item->index < to + count) {
- // place items in the target position, reusing any existing items
- FxListItem *movedItem = moved.take(item->index);
- if (!movedItem)
- movedItem = d->createItem(item->index);
- if (item->index <= firstVisible->index)
- moveBy -= movedItem->size();
- it = d->visibleItems.insert(it, movedItem);
- ++it;
- --remaining;
- } else {
- if (item->index != -1) {
- if (item->index >= to) {
- // update everything after the moved items.
- item->index += count;
- }
- endIndex = item->index;
- }
- ++it;
- }
- }
-
- // If we have moved items to the end of the visible items
- // then add any existing moved items that we have
- while (FxListItem *item = moved.take(endIndex+1)) {
- d->visibleItems.append(item);
- ++endIndex;
- }
-
- // update visibleIndex
- for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
- if ((*it)->index != -1) {
- d->visibleIndex = (*it)->index;
- break;
- }
- }
-
- // Fix current index
- if (d->currentIndex >= 0 && d->currentItem) {
- int oldCurrent = d->currentIndex;
- d->currentIndex = d->model->indexOf(d->currentItem->item, this);
- if (oldCurrent != d->currentIndex) {
- d->currentItem->index = d->currentIndex;
- emit currentIndexChanged();
- }
- }
-
- // Whatever moved items remain are no longer visible items.
- while (moved.count()) {
- int idx = moved.begin().key();
- FxListItem *item = moved.take(idx);
- if (item->item == d->currentItem->item)
- item->setPosition(d->positionAt(idx));
- d->releaseItem(item);
- }
-
- // Ensure we don't cause an ugly list scroll.
- d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + moveBy);
-
- d->layout();
-}
-
-void QmlGraphicsListView::createdItem(int index, QmlGraphicsItem *item)
-{
- Q_D(QmlGraphicsListView);
- if (d->requestedIndex != index) {
- item->setParentItem(viewport());
- d->unrequestedItems.insert(item, index);
- if (d->orient == QmlGraphicsListView::Vertical)
- item->setY(d->positionAt(index));
- else
- item->setX(d->positionAt(index));
- }
-}
-
-void QmlGraphicsListView::destroyingItem(QmlGraphicsItem *item)
-{
- Q_D(QmlGraphicsListView);
- d->unrequestedItems.remove(item);
-}
-
-void QmlGraphicsListView::animStopped()
-{
- Q_D(QmlGraphicsListView);
- d->moveReason = QmlGraphicsListViewPrivate::Other;
- d->bufferMode = QmlGraphicsListViewPrivate::NoBuffer;
-}
-
-QmlGraphicsListViewAttached *QmlGraphicsListView::qmlAttachedProperties(QObject *obj)
-{
- return new QmlGraphicsListViewAttached(obj);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview_p.h b/src/declarative/graphicsitems/qmlgraphicslistview_p.h
deleted file mode 100644
index c5b4aab..0000000
--- a/src/declarative/graphicsitems/qmlgraphicslistview_p.h
+++ /dev/null
@@ -1,305 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSLISTVIEW_H
-#define QMLGRAPHICSLISTVIEW_H
-
-#include "qmlgraphicsflickable_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsViewSection : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY changed)
- Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY changed)
- Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
- Q_ENUMS(SectionCriteria)
-public:
- QmlGraphicsViewSection(QObject *parent=0) : QObject(parent), m_criteria(FullString), m_delegate(0) {}
-
- QString property() const { return m_property; }
- void setProperty(const QString &);
-
- enum SectionCriteria { FullString, FirstCharacter };
- SectionCriteria criteria() const { return m_criteria; }
- void setCriteria(SectionCriteria);
-
- QmlComponent *delegate() const { return m_delegate; }
- void setDelegate(QmlComponent *delegate);
-
- QString sectionString(const QString &value);
-
-Q_SIGNALS:
- void changed();
- void delegateChanged();
-
-private:
- QString m_property;
- SectionCriteria m_criteria;
- QmlComponent *m_delegate;
-};
-
-
-class QmlGraphicsVisualModel;
-class QmlGraphicsListViewAttached;
-class QmlGraphicsListViewPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsListView : public QmlGraphicsFlickable
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsListView)
-
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
- Q_PROPERTY(QmlGraphicsItem *currentItem READ currentItem NOTIFY currentIndexChanged)
- Q_PROPERTY(int count READ count NOTIFY countChanged)
-
- Q_PROPERTY(QmlComponent *highlight READ highlight WRITE setHighlight)
- Q_PROPERTY(QmlGraphicsItem *highlightItem READ highlightItem NOTIFY highlightChanged)
- Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
- Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
- Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
-
- Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin)
- Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd)
- Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode)
-
- Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
- Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
- Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
- Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
- Q_PROPERTY(QmlGraphicsViewSection *section READ sectionCriteria CONSTANT)
- Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
-
- Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode)
-
- Q_PROPERTY(QmlComponent *header READ header WRITE setHeader)
- Q_PROPERTY(QmlComponent *footer READ footer WRITE setFooter)
-
- Q_ENUMS(HighlightRangeMode)
- Q_ENUMS(Orientation)
- Q_ENUMS(SnapMode)
- Q_CLASSINFO("DefaultProperty", "data")
-
-public:
- QmlGraphicsListView(QmlGraphicsItem *parent=0);
- ~QmlGraphicsListView();
-
- QVariant model() const;
- void setModel(const QVariant &);
-
- QmlComponent *delegate() const;
- void setDelegate(QmlComponent *);
-
- int currentIndex() const;
- void setCurrentIndex(int idx);
-
- QmlGraphicsItem *currentItem();
- QmlGraphicsItem *highlightItem();
- int count() const;
-
- QmlComponent *highlight() const;
- void setHighlight(QmlComponent *highlight);
-
- bool highlightFollowsCurrentItem() const;
- void setHighlightFollowsCurrentItem(bool);
-
- enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
- HighlightRangeMode highlightRangeMode() const;
- void setHighlightRangeMode(HighlightRangeMode mode);
-
- qreal preferredHighlightBegin() const;
- void setPreferredHighlightBegin(qreal);
-
- qreal preferredHighlightEnd() const;
- void setPreferredHighlightEnd(qreal);
-
- qreal spacing() const;
- void setSpacing(qreal spacing);
-
- enum Orientation { Horizontal = Qt::Horizontal, Vertical = Qt::Vertical };
- Orientation orientation() const;
- void setOrientation(Orientation);
-
- bool isWrapEnabled() const;
- void setWrapEnabled(bool);
-
- int cacheBuffer() const;
- void setCacheBuffer(int);
-
- QmlGraphicsViewSection *sectionCriteria();
- QString currentSection() const;
-
- qreal highlightMoveSpeed() const;
- void setHighlightMoveSpeed(qreal);
-
- qreal highlightResizeSpeed() const;
- void setHighlightResizeSpeed(qreal);
-
- enum SnapMode { NoSnap, SnapToItem, SnapOneItem };
- SnapMode snapMode() const;
- void setSnapMode(SnapMode mode);
-
- QmlComponent *footer() const;
- void setFooter(QmlComponent *);
-
- QmlComponent *header() const;
- void setHeader(QmlComponent *);
-
- static QmlGraphicsListViewAttached *qmlAttachedProperties(QObject *);
-
-public Q_SLOTS:
- void incrementCurrentIndex();
- void decrementCurrentIndex();
- void positionViewAtIndex(int index);
-
-Q_SIGNALS:
- void countChanged();
- void spacingChanged();
- void orientationChanged();
- void currentIndexChanged();
- void currentSectionChanged();
- void highlightMoveSpeedChanged();
- void highlightResizeSpeedChanged();
- void highlightChanged();
-
-protected:
- virtual void viewportMoved();
- virtual qreal minYExtent() const;
- virtual qreal maxYExtent() const;
- virtual qreal minXExtent() const;
- virtual qreal maxXExtent() const;
- virtual void keyPressEvent(QKeyEvent *);
- virtual void componentComplete();
-
-private Q_SLOTS:
- void refill();
- void trackedPositionChanged();
- void itemsInserted(int index, int count);
- void itemsRemoved(int index, int count);
- void itemsMoved(int from, int to, int count);
- void destroyRemoved();
- void createdItem(int index, QmlGraphicsItem *item);
- void destroyingItem(QmlGraphicsItem *item);
- void animStopped();
-};
-
-class QmlGraphicsListViewAttached : public QObject
-{
- Q_OBJECT
-public:
- QmlGraphicsListViewAttached(QObject *parent)
- : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {}
- ~QmlGraphicsListViewAttached() {}
-
- Q_PROPERTY(QmlGraphicsListView *view READ view CONSTANT)
- QmlGraphicsListView *view() { return m_view; }
-
- Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
- bool isCurrentItem() const { return m_isCurrent; }
- void setIsCurrentItem(bool c) {
- if (m_isCurrent != c) {
- m_isCurrent = c;
- emit currentItemChanged();
- }
- }
-
- Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged)
- QString prevSection() const { return m_prevSection; }
- void setPrevSection(const QString &sect) {
- if (m_prevSection != sect) {
- m_prevSection = sect;
- emit prevSectionChanged();
- }
- }
-
- Q_PROPERTY(QString section READ section NOTIFY sectionChanged)
- QString section() const { return m_section; }
- void setSection(const QString &sect) {
- if (m_section != sect) {
- m_section = sect;
- emit sectionChanged();
- }
- }
-
- Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
- bool delayRemove() const { return m_delayRemove; }
- void setDelayRemove(bool delay) {
- if (m_delayRemove != delay) {
- m_delayRemove = delay;
- emit delayRemoveChanged();
- }
- }
-
- void emitAdd() { emit add(); }
- void emitRemove() { emit remove(); }
-
-Q_SIGNALS:
- void currentItemChanged();
- void sectionChanged();
- void prevSectionChanged();
- void delayRemoveChanged();
- void add();
- void remove();
-
-public:
- QmlGraphicsListView *m_view;
- bool m_isCurrent;
- mutable QString m_section;
- QString m_prevSection;
- bool m_delayRemove;
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPEINFO(QmlGraphicsListView, QML_HAS_ATTACHED_PROPERTIES)
-QML_DECLARE_TYPE(QmlGraphicsListView)
-QML_DECLARE_TYPE(QmlGraphicsViewSection)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
deleted file mode 100644
index b9780f2..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp
+++ /dev/null
@@ -1,488 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsloader_p_p.h"
-
-#include <qmlengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QmlGraphicsLoaderPrivate::QmlGraphicsLoaderPrivate()
- : item(0), component(0), ownComponent(false)
- , resizeMode(QmlGraphicsLoader::SizeLoaderToItem)
-{
-}
-
-QmlGraphicsLoaderPrivate::~QmlGraphicsLoaderPrivate()
-{
-}
-
-void QmlGraphicsLoaderPrivate::itemGeometryChanged(QmlGraphicsItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- if (resizeItem == item && resizeMode == QmlGraphicsLoader::SizeLoaderToItem) {
- _q_updateSize();
- }
- QmlGraphicsItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry);
-}
-
-void QmlGraphicsLoaderPrivate::clear()
-{
- if (ownComponent) {
- delete component;
- component = 0;
- ownComponent = false;
- }
- source = QUrl();
-
- if (item) {
- if (QmlGraphicsItem *qmlItem = qobject_cast<QmlGraphicsItem*>(item)) {
- if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem) {
- QmlGraphicsItemPrivate *p =
- static_cast<QmlGraphicsItemPrivate *>(QGraphicsItemPrivate::get(qmlItem));
- p->removeItemChangeListener(this, QmlGraphicsItemPrivate::Geometry);
- }
- }
-
- // We can't delete immediately because our item may have triggered
- // the Loader to load a different item.
- item->setVisible(false);
- item->setParentItem(0);
- item->deleteLater();
- item = 0;
- }
-}
-
-void QmlGraphicsLoaderPrivate::initResize()
-{
- Q_Q(QmlGraphicsLoader);
- if (QmlGraphicsItem *qmlItem = qobject_cast<QmlGraphicsItem*>(item)) {
- if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem) {
- QmlGraphicsItemPrivate *p =
- static_cast<QmlGraphicsItemPrivate *>(QGraphicsItemPrivate::get(qmlItem));
- p->addItemChangeListener(this, QmlGraphicsItemPrivate::Geometry);
- }
- } else if (item && item->isWidget()) {
- QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item);
- if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem) {
- widget->installEventFilter(q);
- }
- }
- _q_updateSize();
-}
-
-/*!
- \qmlclass Loader QmlGraphicsLoader
- \since 4.7
- \inherits Item
-
- \brief The Loader item allows dynamically loading an Item-based
- subtree from a QML URL or Component.
-
- Loader instantiates an item from a component. The component to
- instantiate may be specified directly by the \c sourceComponent
- property, or loaded from a URL via the \c source property.
-
- It is also an effective means of delaying the creation of a component
- until it is required:
- \code
- Loader { id: pageLoader }
- Rectangle {
- MouseArea { anchors.fill: parent; onClicked: pageLoader.source = "Page1.qml" }
- }
- \endcode
-
- If the Loader source is changed, any previous items instantiated
- will be destroyed. Setting \c source to an empty string
- will destroy the currently instantiated items, freeing resources
- and leaving the Loader empty. For example:
-
- \code
- pageLoader.source = ""
- \endcode
-
- unloads "Page1.qml" and frees resources consumed by it.
-
- \sa {dynamic-object-creation}{Dynamic Object Creation}
-*/
-
-/*!
- \internal
- \class QmlGraphicsLoader
- \qmlclass Loader
- */
-
-/*!
- Create a new QmlGraphicsLoader instance.
- */
-QmlGraphicsLoader::QmlGraphicsLoader(QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsLoaderPrivate), parent)
-{
-}
-
-/*!
- Destroy the loader instance.
- */
-QmlGraphicsLoader::~QmlGraphicsLoader()
-{
-}
-
-/*!
- \qmlproperty url Loader::source
- This property holds the URL of the QML component to
- instantiate.
-
- \sa sourceComponent, status, progress
-*/
-QUrl QmlGraphicsLoader::source() const
-{
- Q_D(const QmlGraphicsLoader);
- return d->source;
-}
-
-void QmlGraphicsLoader::setSource(const QUrl &url)
-{
- Q_D(QmlGraphicsLoader);
- if (d->source == url)
- return;
-
- d->clear();
-
- d->source = url;
- if (d->source.isEmpty()) {
- emit sourceChanged();
- emit statusChanged();
- emit progressChanged();
- emit itemChanged();
- return;
- }
-
- d->component = new QmlComponent(qmlEngine(this), d->source, this);
- d->ownComponent = true;
- if (!d->component->isLoading()) {
- d->_q_sourceLoaded();
- } else {
- connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)),
- this, SLOT(_q_sourceLoaded()));
- connect(d->component, SIGNAL(progressChanged(qreal)),
- this, SIGNAL(progressChanged()));
- emit statusChanged();
- emit progressChanged();
- emit sourceChanged();
- emit itemChanged();
- }
-}
-
-/*!
- \qmlproperty Component Loader::sourceComponent
- The sourceComponent property holds the \l{Component} to instantiate.
-
- \qml
- Item {
- Component {
- id: redSquare
- Rectangle { color: "red"; width: 10; height: 10 }
- }
-
- Loader { sourceComponent: redSquare }
- Loader { sourceComponent: redSquare; x: 10 }
- }
- \endqml
-
- \sa source, progress
-*/
-
-QmlComponent *QmlGraphicsLoader::sourceComponent() const
-{
- Q_D(const QmlGraphicsLoader);
- return d->component;
-}
-
-void QmlGraphicsLoader::setSourceComponent(QmlComponent *comp)
-{
- Q_D(QmlGraphicsLoader);
- if (comp == d->component)
- return;
-
- d->clear();
-
- d->component = comp;
- d->ownComponent = false;
- if (!d->component) {
- emit sourceChanged();
- emit statusChanged();
- emit progressChanged();
- emit itemChanged();
- return;
- }
-
- if (!d->component->isLoading()) {
- d->_q_sourceLoaded();
- } else {
- connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)),
- this, SLOT(_q_sourceLoaded()));
- connect(d->component, SIGNAL(progressChanged(qreal)),
- this, SIGNAL(progressChanged()));
- emit progressChanged();
- emit sourceChanged();
- emit statusChanged();
- emit itemChanged();
- }
-}
-
-void QmlGraphicsLoaderPrivate::_q_sourceLoaded()
-{
- Q_Q(QmlGraphicsLoader);
-
- if (component) {
- QmlContext *ctxt = new QmlContext(qmlContext(q));
- ctxt->addDefaultObject(q);
-
- if (!component->errors().isEmpty()) {
- qWarning() << component->errors();
- emit q->sourceChanged();
- emit q->statusChanged();
- emit q->progressChanged();
- return;
- }
-
- QObject *obj = component->create(ctxt);
- if (obj) {
- ctxt->setParent(obj);
- item = qobject_cast<QGraphicsObject *>(obj);
- if (item) {
- if (QmlGraphicsItem* qmlItem = qobject_cast<QmlGraphicsItem *>(item)) {
- qmlItem->setParentItem(q);
- } else {
- item->setParentItem(q);
- item->setParent(q);
- }
-// item->setFocus(true);
- initResize();
- }
- } else {
- delete obj;
- delete ctxt;
- source = QUrl();
- }
- emit q->sourceChanged();
- emit q->statusChanged();
- emit q->progressChanged();
- emit q->itemChanged();
- }
-}
-
-/*!
- \qmlproperty enum Loader::status
-
- This property holds the status of QML loading. It can be one of:
- \list
- \o Null - no QML source has been set
- \o Ready - the QML source has been loaded
- \o Loading - the QML source is currently being loaded
- \o Error - an error occurred while loading the QML source
- \endlist
-
- \sa progress
-*/
-
-QmlGraphicsLoader::Status QmlGraphicsLoader::status() const
-{
- Q_D(const QmlGraphicsLoader);
-
- if (d->component)
- return static_cast<QmlGraphicsLoader::Status>(d->component->status());
-
- if (d->item)
- return Ready;
-
- return d->source.isEmpty() ? Null : Error;
-}
-
-/*!
- \qmlproperty real Loader::progress
-
- This property holds the progress of QML data loading, from 0.0 (nothing loaded)
- to 1.0 (finished).
-
- \sa status
-*/
-qreal QmlGraphicsLoader::progress() const
-{
- Q_D(const QmlGraphicsLoader);
-
- if (d->item)
- return 1.0;
-
- if (d->component)
- return d->component->progress();
-
- return 0.0;
-}
-
-/*!
- \qmlproperty enum Loader::resizeMode
-
- This property determines how the Loader or item are resized:
- \list
- \o NoResize - no item will be resized
- \o SizeLoaderToItem - the Loader will be sized to the size of the item, unless the size of the Loader has been otherwise specified.
- \o SizeItemToLoader - the item will be sized to the size of the Loader.
- \endlist
-
- Note that changing from SizeItemToLoader to SizeLoaderToItem
- after the component is loaded will not return the item or Loader
- to it's original size. This is due to the item size being adjusted
- to the Loader size, thereby losing the original size of the item.
- Future changes to the item's size will affect the loader, however.
-
- The default resizeMode is SizeLoaderToItem.
-*/
-QmlGraphicsLoader::ResizeMode QmlGraphicsLoader::resizeMode() const
-{
- Q_D(const QmlGraphicsLoader);
- return d->resizeMode;
-}
-
-void QmlGraphicsLoader::setResizeMode(ResizeMode mode)
-{
- Q_D(QmlGraphicsLoader);
- if (mode == d->resizeMode)
- return;
-
- if (QmlGraphicsItem *qmlItem = qobject_cast<QmlGraphicsItem*>(d->item)) {
- if (d->resizeMode == SizeLoaderToItem) {
- QmlGraphicsItemPrivate *p =
- static_cast<QmlGraphicsItemPrivate *>(QGraphicsItemPrivate::get(qmlItem));
- p->removeItemChangeListener(d, QmlGraphicsItemPrivate::Geometry);
- }
- } else if (d->item && d->item->isWidget()) {
- if (d->resizeMode == SizeLoaderToItem)
- d->item->removeEventFilter(this);
- }
-
- d->resizeMode = mode;
- emit resizeModeChanged();
- d->initResize();
-}
-
-void QmlGraphicsLoaderPrivate::_q_updateSize()
-{
- Q_Q(QmlGraphicsLoader);
- if (!item)
- return;
- if (QmlGraphicsItem *qmlItem = qobject_cast<QmlGraphicsItem*>(item)) {
- if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem) {
- q->setWidth(qmlItem->width());
- q->setHeight(qmlItem->height());
- } else if (resizeMode == QmlGraphicsLoader::SizeItemToLoader) {
- qmlItem->setWidth(q->width());
- qmlItem->setHeight(q->height());
- }
- } else if (item && item->isWidget()) {
- QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item);
- if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem) {
- QSizeF newSize = widget->size();
- if (newSize.isValid()) {
- q->setWidth(newSize.width());
- q->setHeight(newSize.height());
- }
- } else if (resizeMode == QmlGraphicsLoader::SizeItemToLoader) {
- QSizeF oldSize = widget->size();
- QSizeF newSize = oldSize;
- if (q->heightValid())
- newSize.setHeight(q->height());
- if (q->widthValid())
- newSize.setWidth(q->width());
- if (oldSize != newSize)
- widget->resize(newSize);
- }
- }
-}
-
-/*!
- \qmlproperty Item Loader::item
- This property holds the top-level item created from source.
-*/
-QGraphicsObject *QmlGraphicsLoader::item() const
-{
- Q_D(const QmlGraphicsLoader);
- return d->item;
-}
-
-void QmlGraphicsLoader::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- Q_D(QmlGraphicsLoader);
- if (newGeometry != oldGeometry) {
- if (d->resizeMode == SizeItemToLoader) {
- d->_q_updateSize();
- }
- }
- QmlGraphicsItem::geometryChanged(newGeometry, oldGeometry);
-}
-
-QVariant QmlGraphicsLoader::itemChange(GraphicsItemChange change, const QVariant &value)
-{
- Q_D(QmlGraphicsLoader);
- if (change == ItemSceneHasChanged) {
- if (d->item && d->item->isWidget()) {
- if (d->resizeMode == SizeLoaderToItem) {
- d->item->removeEventFilter(this);
- d->item->installEventFilter(this);
- }
- }
- }
- return QmlGraphicsItem::itemChange(change, value);
-}
-
-bool QmlGraphicsLoader::eventFilter(QObject *watched, QEvent *e)
-{
- Q_D(QmlGraphicsLoader);
- if (watched == d->item && e->type() == QEvent::GraphicsSceneResize) {
- if (d->item && d->item->isWidget() && d->resizeMode == SizeLoaderToItem) {
- d->_q_updateSize();
- }
- }
- return QmlGraphicsItem::eventFilter(watched, e);
-}
-
-#include <moc_qmlgraphicsloader_p.cpp>
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p.h
deleted file mode 100644
index 0ab67ac..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsloader_p.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSLOADER_H
-#define QMLGRAPHICSLOADER_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsLoaderPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsLoader : public QmlGraphicsItem
-{
- Q_OBJECT
- Q_ENUMS(Status)
- Q_ENUMS(ResizeMode)
-
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(QmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent NOTIFY sourceChanged)
- Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode NOTIFY resizeModeChanged)
- Q_PROPERTY(QGraphicsObject *item READ item NOTIFY itemChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
-
-public:
- QmlGraphicsLoader(QmlGraphicsItem *parent=0);
- virtual ~QmlGraphicsLoader();
-
- QUrl source() const;
- void setSource(const QUrl &);
-
- QmlComponent *sourceComponent() const;
- void setSourceComponent(QmlComponent *);
-
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
- qreal progress() const;
-
- enum ResizeMode { NoResize, SizeLoaderToItem, SizeItemToLoader };
- ResizeMode resizeMode() const;
- void setResizeMode(ResizeMode mode);
-
- QGraphicsObject *item() const;
-
-Q_SIGNALS:
- void itemChanged();
- void sourceChanged();
- void statusChanged();
- void progressChanged();
- void resizeModeChanged();
-
-protected:
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
- QVariant itemChange(GraphicsItemChange change, const QVariant &value);
- bool eventFilter(QObject *watched, QEvent *e);
-private:
- Q_DISABLE_COPY(QmlGraphicsLoader)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsLoader)
- Q_PRIVATE_SLOT(d_func(), void _q_sourceLoaded())
- Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsLoader)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSLOADER_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h
deleted file mode 100644
index 61dab58..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSLOADER_P_H
-#define QMLGRAPHICSLOADER_P_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 "qmlgraphicsloader_p.h"
-
-#include "qmlgraphicsitem_p.h"
-#include "qmlgraphicsitemchangelistener_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlContext;
-class QmlGraphicsLoaderPrivate : public QmlGraphicsItemPrivate, public QmlGraphicsItemChangeListener
-{
- Q_DECLARE_PUBLIC(QmlGraphicsLoader)
-
-public:
- QmlGraphicsLoaderPrivate();
- ~QmlGraphicsLoaderPrivate();
-
- void itemGeometryChanged(QmlGraphicsItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
- void clear();
- void initResize();
-
- QUrl source;
- QGraphicsObject *item;
- QmlComponent *component;
- bool ownComponent : 1;
- QmlGraphicsLoader::ResizeMode resizeMode;
-
- void _q_sourceLoaded();
- void _q_updateSize();
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLGRAPHICSLOADER_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsmousearea.cpp b/src/declarative/graphicsitems/qmlgraphicsmousearea.cpp
deleted file mode 100644
index 07354f4..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsmousearea.cpp
+++ /dev/null
@@ -1,685 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsmousearea_p.h"
-#include "qmlgraphicsmousearea_p_p.h"
-
-#include "qmlgraphicsevents_p_p.h"
-
-#include <QGraphicsSceneMouseEvent>
-
-QT_BEGIN_NAMESPACE
-static const int PressAndHoldDelay = 800;
-
-QmlGraphicsDrag::QmlGraphicsDrag(QObject *parent)
-: QObject(parent), _target(0), _axis(XandYAxis), _xmin(0), _xmax(0), _ymin(0), _ymax(0)
-{
-}
-
-QmlGraphicsDrag::~QmlGraphicsDrag()
-{
-}
-
-QmlGraphicsItem *QmlGraphicsDrag::target() const
-{
- return _target;
-}
-
-void QmlGraphicsDrag::setTarget(QmlGraphicsItem *t)
-{
- if (_target == t)
- return;
- _target = t;
- emit targetChanged();
-}
-
-QmlGraphicsDrag::Axis QmlGraphicsDrag::axis() const
-{
- return _axis;
-}
-
-void QmlGraphicsDrag::setAxis(QmlGraphicsDrag::Axis a)
-{
- if (_axis == a)
- return;
- _axis = a;
- emit axisChanged();
-}
-
-qreal QmlGraphicsDrag::xmin() const
-{
- return _xmin;
-}
-
-void QmlGraphicsDrag::setXmin(qreal m)
-{
- if (_xmin == m)
- return;
- _xmin = m;
- emit minimumXChanged();
-}
-
-qreal QmlGraphicsDrag::xmax() const
-{
- return _xmax;
-}
-
-void QmlGraphicsDrag::setXmax(qreal m)
-{
- if (_xmax == m)
- return;
- _xmax = m;
- emit maximumXChanged();
-}
-
-qreal QmlGraphicsDrag::ymin() const
-{
- return _ymin;
-}
-
-void QmlGraphicsDrag::setYmin(qreal m)
-{
- if (_ymin == m)
- return;
- _ymin = m;
- emit minimumYChanged();
-}
-
-qreal QmlGraphicsDrag::ymax() const
-{
- return _ymax;
-}
-
-void QmlGraphicsDrag::setYmax(qreal m)
-{
- if (_ymax == m)
- return;
- _ymax = m;
- emit maximumYChanged();
-}
-
-QmlGraphicsMouseAreaPrivate::~QmlGraphicsMouseAreaPrivate()
-{
- delete drag;
-}
-
-
-/*!
- \qmlclass MouseRegion QmlGraphicsMouseRegion
- \since 4.7
- \brief The MouseArea item enables simple mouse handling.
- \inherits Item
-
- A MouseArea is typically used in conjunction with a visible item,
- where the MouseArea effectively 'proxies' mouse handling for that
- item. For example, we can put a MouseArea in a Rectangle that changes
- the Rectangle color to red when clicked:
- \snippet doc/src/snippets/declarative/mouseregion.qml 0
-
- Many MouseArea signals pass a \l {MouseEvent}{mouse} parameter that contains
- additional information about the mouse event, such as the position, button,
- and any key modifiers.
-
- Below we have the previous
- example extended so as to give a different color when you right click.
- \snippet doc/src/snippets/declarative/mouseregion.qml 1
-
- For basic key handling, see the \l {Keys}{Keys attached property}.
-
- MouseArea is an invisible item: it is never painted.
-
- \sa MouseEvent
-*/
-
-/*!
- \qmlsignal MouseArea::onEntered()
-
- This handler is called when the mouse enters the mouse region.
-
- By default the onEntered handler is only called while a button is
- pressed. Setting hoverEnabled to true enables handling of
- onExited when no mouse button is pressed.
-
- \sa hoverEnabled
-*/
-
-/*!
- \qmlsignal MouseArea::onExited()
-
- This handler is called when the mouse exists the mouse region.
-
- By default the onExited handler is only called while a button is
- pressed. Setting hoverEnabled to true enables handling of
- onExited when no mouse button is pressed.
-
- \sa hoverEnabled
-*/
-
-/*!
- \qmlsignal MouseArea::onPositionChanged(MouseEvent mouse)
-
- This handler is called when the mouse position changes.
-
- The \l {MouseEvent}{mouse} parameter provides information about the mouse, including the x and y
- position, and any buttons currently pressed.
-
- The \e accepted property of the MouseEvent parameter is ignored in this handler.
-
- By default the onPositionChanged handler is only called while a button is
- pressed. Setting hoverEnabled to true enables handling of
- onPositionChanged when no mouse button is pressed.
-*/
-
-/*!
- \qmlsignal MouseArea::onClicked(mouse)
-
- This handler is called when there is a click. A click is defined as a press followed by a release,
- both inside the MouseArea (pressing, moving outside the MouseArea, and then moving back inside and
- releasing is also considered a click).
-
- The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
- position of the release of the click, and whether the click wasHeld.
-
- The \e accepted property of the MouseEvent parameter is ignored in this handler.
-*/
-
-/*!
- \qmlsignal MouseArea::onPressed(mouse)
-
- This handler is called when there is a press.
- The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
- position and which button was pressed.
-
- The \e accepted property of the MouseEvent parameter determines whether this MouseArea
- will handle the press and all future mouse events until release. The default is to accept
- the event and not allow other MouseArea beneath this one to handle the event. If \e accepted
- is set to false, no further events will be sent to this MouseArea until the button is next
- pressed.
-*/
-
-/*!
- \qmlsignal MouseArea::onReleased(mouse)
-
- This handler is called when there is a release.
- The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
- position of the release of the click, and whether the click wasHeld.
-
- The \e accepted property of the MouseEvent parameter is ignored in this handler.
-*/
-
-/*!
- \qmlsignal MouseArea::onPressAndHold(mouse)
-
- This handler is called when there is a long press (currently 800ms).
- The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
- position of the press, and which button is pressed.
-
- The \e accepted property of the MouseEvent parameter is ignored in this handler.
-*/
-
-/*!
- \qmlsignal MouseArea::onDoubleClicked(mouse)
-
- This handler is called when there is a double-click (a press followed by a release followed by a press).
- The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
- position of the release of the click, and whether the click wasHeld.
-
- The \e accepted property of the MouseEvent parameter is ignored in this handler.
-*/
-
-/*!
- \internal
- \class QmlGraphicsMouseArea
- \brief The QmlGraphicsMouseArea class provides a simple mouse handling abstraction for use within Qml.
-
- \ingroup group_coreitems
-
- All QmlGraphicsItem derived classes can do mouse handling but the QmlGraphicsMouseArea class exposes mouse
- handling data as properties and tracks flicking and dragging of the mouse.
-
- A QmlGraphicsMouseArea object can be instantiated in Qml using the tag \l MouseArea.
- */
-QmlGraphicsMouseArea::QmlGraphicsMouseArea(QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsMouseAreaPrivate), parent)
-{
- Q_D(QmlGraphicsMouseArea);
- d->init();
-}
-
-QmlGraphicsMouseArea::~QmlGraphicsMouseArea()
-{
-}
-
-/*!
- \qmlproperty real MouseArea::mouseX
- \qmlproperty real MouseArea::mouseY
- These properties hold the coordinates of the mouse.
-
- If the hoverEnabled property is false then these properties will only be valid
- while a button is pressed, and will remain valid as long as the button is held
- even if the mouse is moved outside the region.
-
- If hoverEnabled is true then these properties will be valid:
- \list
- \i when no button is pressed, but the mouse is within the MouseArea (containsMouse is true).
- \i if a button is pressed and held, even if it has since moved out of the region.
- \endlist
-
- The coordinates are relative to the MouseArea.
-*/
-qreal QmlGraphicsMouseArea::mouseX() const
-{
- Q_D(const QmlGraphicsMouseArea);
- return d->lastPos.x();
-}
-
-qreal QmlGraphicsMouseArea::mouseY() const
-{
- Q_D(const QmlGraphicsMouseArea);
- return d->lastPos.y();
-}
-
-/*!
- \qmlproperty bool MouseArea::enabled
- This property holds whether the item accepts mouse events.
-*/
-bool QmlGraphicsMouseArea::isEnabled() const
-{
- Q_D(const QmlGraphicsMouseArea);
- return d->absorb;
-}
-
-void QmlGraphicsMouseArea::setEnabled(bool a)
-{
- Q_D(QmlGraphicsMouseArea);
- if (a != d->absorb) {
- d->absorb = a;
- emit enabledChanged();
- }
-}
-/*!
- \qmlproperty MouseButtons MouseArea::pressedButtons
- This property holds the mouse buttons currently pressed.
-
- It contains a bitwise combination of:
- \list
- \o Qt.LeftButton
- \o Qt.RightButton
- \o Qt.MidButton
- \endlist
-
- The code below displays "right" when the right mouse buttons is pressed:
- \code
- Text {
- text: mr.pressedButtons & Qt.RightButton ? "right" : ""
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- MouseArea {
- id: mr
- acceptedButtons: Qt.LeftButton | Qt.RightButton
- anchors.fill: parent
- }
- }
- \endcode
-
- \sa acceptedButtons
-*/
-Qt::MouseButtons QmlGraphicsMouseArea::pressedButtons() const
-{
- Q_D(const QmlGraphicsMouseArea);
- return d->lastButtons;
-}
-
-void QmlGraphicsMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsMouseArea);
- d->moved = false;
- if (!d->absorb)
- QmlGraphicsItem::mousePressEvent(event);
- else {
- d->longPress = false;
- d->saveEvent(event);
- if (d->drag) {
- d->dragX = drag()->axis() & QmlGraphicsDrag::XAxis;
- d->dragY = drag()->axis() & QmlGraphicsDrag::YAxis;
- }
- d->dragged = false;
- setHovered(true);
- d->start = event->pos();
- d->startScene = event->scenePos();
- // we should only start timer if pressAndHold is connected to.
- if (d->isConnected("pressAndHold(QmlGraphicsMouseEvent*)"))
- d->pressAndHoldTimer.start(PressAndHoldDelay, this);
- setKeepMouseGrab(false);
- event->setAccepted(setPressed(true));
- }
-}
-
-void QmlGraphicsMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsMouseArea);
- if (!d->absorb) {
- QmlGraphicsItem::mouseMoveEvent(event);
- return;
- }
-
- d->saveEvent(event);
-
- // ### we should skip this if these signals aren't used
- // ### can GV handle this for us?
- bool contains = boundingRect().contains(d->lastPos);
- if (d->hovered && !contains)
- setHovered(false);
- else if (!d->hovered && contains)
- setHovered(true);
-
- if (d->drag && d->drag->target()) {
- if (!d->moved) {
- if (d->dragX) d->startX = drag()->target()->x();
- if (d->dragY) d->startY = drag()->target()->y();
- }
-
- QPointF startLocalPos;
- QPointF curLocalPos;
- if (drag()->target()->parent()) {
- startLocalPos = drag()->target()->parentItem()->mapFromScene(d->startScene);
- curLocalPos = drag()->target()->parentItem()->mapFromScene(event->scenePos());
- } else {
- startLocalPos = d->startScene;
- curLocalPos = event->scenePos();
- }
-
- const int dragThreshold = QApplication::startDragDistance();
- qreal dx = qAbs(curLocalPos.x() - startLocalPos.x());
- qreal dy = qAbs(curLocalPos.y() - startLocalPos.y());
- if ((d->dragX && !(dx < dragThreshold)) || (d->dragY && !(dy < dragThreshold)))
- d->dragged = true;
- if (!keepMouseGrab()) {
- if ((!d->dragY && dy < dragThreshold && d->dragX && dx > dragThreshold)
- || (!d->dragX && dx < dragThreshold && d->dragY && dy > dragThreshold)
- || (d->dragX && d->dragY)) {
- setKeepMouseGrab(true);
- }
- }
-
- if (d->dragX) {
- qreal x = (curLocalPos.x() - startLocalPos.x()) + d->startX;
- if (x < drag()->xmin())
- x = drag()->xmin();
- else if (x > drag()->xmax())
- x = drag()->xmax();
- drag()->target()->setX(x);
- }
- if (d->dragY) {
- qreal y = (curLocalPos.y() - startLocalPos.y()) + d->startY;
- if (y < drag()->ymin())
- y = drag()->ymin();
- else if (y > drag()->ymax())
- y = drag()->ymax();
- drag()->target()->setY(y);
- }
- }
- d->moved = true;
- QmlGraphicsMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
- emit positionChanged(&me);
-}
-
-
-void QmlGraphicsMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsMouseArea);
- if (!d->absorb) {
- QmlGraphicsItem::mouseReleaseEvent(event);
- } else {
- d->saveEvent(event);
- setPressed(false);
- // If we don't accept hover, we need to reset containsMouse.
- if (!acceptHoverEvents())
- setHovered(false);
- setKeepMouseGrab(false);
- }
-}
-
-void QmlGraphicsMouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsMouseArea);
- if (!d->absorb) {
- QmlGraphicsItem::mouseDoubleClickEvent(event);
- } else {
- QmlGraphicsItem::mouseDoubleClickEvent(event);
- if (event->isAccepted()) {
- // Only deliver the event if we have accepted the press.
- d->saveEvent(event);
- QmlGraphicsMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false);
- emit this->doubleClicked(&me);
- }
- }
-}
-
-void QmlGraphicsMouseArea::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_D(QmlGraphicsMouseArea);
- if (!d->absorb)
- QmlGraphicsItem::hoverEnterEvent(event);
- else
- setHovered(true);
-}
-
-void QmlGraphicsMouseArea::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_D(QmlGraphicsMouseArea);
- if (!d->absorb) {
- QmlGraphicsItem::hoverEnterEvent(event);
- } else {
- d->lastPos = event->pos();
- QmlGraphicsMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, d->lastButtons, d->lastModifiers, false, d->longPress);
- emit positionChanged(&me);
- }
-}
-
-void QmlGraphicsMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_D(QmlGraphicsMouseArea);
- if (!d->absorb)
- QmlGraphicsItem::hoverLeaveEvent(event);
- else
- setHovered(false);
-}
-
-bool QmlGraphicsMouseArea::sceneEvent(QEvent *event)
-{
- bool rv = QmlGraphicsItem::sceneEvent(event);
- if (event->type() == QEvent::UngrabMouse) {
- Q_D(QmlGraphicsMouseArea);
- if (d->pressed) {
- // if our mouse grab has been removed (probably by Flickable), fix our
- // state
- d->pressed = false;
- setKeepMouseGrab(false);
- emit pressedChanged();
- //emit hoveredChanged();
- }
- }
- return rv;
-}
-
-void QmlGraphicsMouseArea::timerEvent(QTimerEvent *event)
-{
- Q_D(QmlGraphicsMouseArea);
- if (event->timerId() == d->pressAndHoldTimer.timerId()) {
- d->pressAndHoldTimer.stop();
- if (d->pressed && d->dragged == false && d->hovered == true) {
- d->longPress = true;
- QmlGraphicsMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
- emit pressAndHold(&me);
- }
- }
-}
-
-/*!
- \qmlproperty bool MouseArea::hoverEnabled
- This property holds whether hover events are handled.
-
- By default, mouse events are only handled in response to a button event, or when a button is
- pressed. Hover enables handling of all mouse events even when no mouse button is
- pressed.
-
- This property affects the containsMouse property and the onEntered, onExited and onPositionChanged signals.
-*/
-
-/*!
- \qmlproperty bool MouseArea::containsMouse
- This property holds whether the mouse is currently inside the mouse region.
-
- \warning This property is not updated if the region moves under the mouse: \e containsMouse will not change.
- In addition, if hoverEnabled is false, containsMouse will only be valid when the mouse is pressed.
-*/
-bool QmlGraphicsMouseArea::hovered() const
-{
- Q_D(const QmlGraphicsMouseArea);
- return d->hovered;
-}
-
-/*!
- \qmlproperty bool MouseArea::pressed
- This property holds whether the mouse region is currently pressed.
-*/
-bool QmlGraphicsMouseArea::pressed() const
-{
- Q_D(const QmlGraphicsMouseArea);
- return d->pressed;
-}
-
-void QmlGraphicsMouseArea::setHovered(bool h)
-{
- Q_D(QmlGraphicsMouseArea);
- if (d->hovered != h) {
- d->hovered = h;
- emit hoveredChanged();
- d->hovered ? emit entered() : emit exited();
- }
-}
-
-/*!
- \qmlproperty Qt::MouseButtons MouseArea::acceptedButtons
- This property holds the mouse buttons that the mouse region reacts to.
-
- The available buttons are:
- \list
- \o Qt.LeftButton
- \o Qt.RightButton
- \o Qt.MidButton
- \endlist
-
- To accept more than one button the flags can be combined with the
- "|" (or) operator:
-
- \code
- MouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton }
- \endcode
-
- The default is to accept the Left button.
-*/
-Qt::MouseButtons QmlGraphicsMouseArea::acceptedButtons() const
-{
- return acceptedMouseButtons();
-}
-
-void QmlGraphicsMouseArea::setAcceptedButtons(Qt::MouseButtons buttons)
-{
- if (buttons != acceptedMouseButtons()) {
- setAcceptedMouseButtons(buttons);
- emit acceptedButtonsChanged();
- }
-}
-
-bool QmlGraphicsMouseArea::setPressed(bool p)
-{
- Q_D(QmlGraphicsMouseArea);
- bool isclick = d->pressed == true && p == false && d->dragged == false && d->hovered == true;
-
- if (d->pressed != p) {
- d->pressed = p;
- QmlGraphicsMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress);
- if (d->pressed) {
- emit positionChanged(&me);
- emit pressed(&me);
- } else {
- emit released(&me);
- if (isclick)
- emit clicked(&me);
- }
-
- emit pressedChanged();
- return me.isAccepted();
- }
- return false;
-}
-
-QmlGraphicsDrag *QmlGraphicsMouseArea::drag()
-{
- Q_D(QmlGraphicsMouseArea);
- if (!d->drag)
- d->drag = new QmlGraphicsDrag;
- return d->drag;
-}
-
-/*!
- \qmlproperty Item MouseArea::drag.target
- \qmlproperty Axis MouseArea::drag.axis
- \qmlproperty real MouseArea::drag.minimumX
- \qmlproperty real MouseArea::drag.maximumX
- \qmlproperty real MouseArea::drag.minimumY
- \qmlproperty real MouseArea::drag.maximumY
-
- drag provides a convenient way to make an item draggable.
-
- \list
- \i \c target specifies the item to drag.
- \i \c axis specifies whether dragging can be done horizontally (XAxis), vertically (YAxis), or both (XandYAxis)
- \i the minimum and maximum properties limit how far the target can be dragged along the corresponding axes.
- \endlist
-
- The following example uses drag to reduce the opacity of an image as it moves to the right:
- \snippet doc/src/snippets/declarative/drag.qml 0
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsmousearea_p.h b/src/declarative/graphicsitems/qmlgraphicsmousearea_p.h
deleted file mode 100644
index 2e2f8c9..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsmousearea_p.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSMOUSEAREA_H
-#define QMLGRAPHICSMOUSEAREA_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsDrag : public QObject
-{
- Q_OBJECT
-
- Q_ENUMS(Axis)
- Q_PROPERTY(QmlGraphicsItem *target READ target WRITE setTarget NOTIFY targetChanged)
- Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
- Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
- Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
- Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
- Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
- //### consider drag and drop
-
-public:
- QmlGraphicsDrag(QObject *parent=0);
- ~QmlGraphicsDrag();
-
- QmlGraphicsItem *target() const;
- void setTarget(QmlGraphicsItem *);
-
- enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
- Axis axis() const;
- void setAxis(Axis);
-
- qreal xmin() const;
- void setXmin(qreal);
- qreal xmax() const;
- void setXmax(qreal);
- qreal ymin() const;
- void setYmin(qreal);
- qreal ymax() const;
- void setYmax(qreal);
-
-Q_SIGNALS:
- void targetChanged();
- void axisChanged();
- void minimumXChanged();
- void maximumXChanged();
- void minimumYChanged();
- void maximumYChanged();
-
-private:
- QmlGraphicsItem *_target;
- Axis _axis;
- qreal _xmin;
- qreal _xmax;
- qreal _ymin;
- qreal _ymax;
- Q_DISABLE_COPY(QmlGraphicsDrag)
-};
-
-class QmlGraphicsMouseEvent;
-class QmlGraphicsMouseAreaPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsMouseArea : public QmlGraphicsItem
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal mouseX READ mouseX NOTIFY positionChanged)
- Q_PROPERTY(qreal mouseY READ mouseY NOTIFY positionChanged)
- Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
- Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
- Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
- Q_PROPERTY(bool hoverEnabled READ acceptHoverEvents WRITE setAcceptHoverEvents)
- Q_PROPERTY(QmlGraphicsDrag *drag READ drag CONSTANT) //### add flicking to QmlGraphicsDrag or add a QmlGraphicsFlick ???
-
-public:
- QmlGraphicsMouseArea(QmlGraphicsItem *parent=0);
- ~QmlGraphicsMouseArea();
-
- qreal mouseX() const;
- qreal mouseY() const;
-
- bool isEnabled() const;
- void setEnabled(bool);
-
- bool hovered() const;
- bool pressed() const;
-
- Qt::MouseButtons pressedButtons() const;
-
- Qt::MouseButtons acceptedButtons() const;
- void setAcceptedButtons(Qt::MouseButtons buttons);
-
- QmlGraphicsDrag *drag();
-
-Q_SIGNALS:
- void hoveredChanged();
- void pressedChanged();
- void enabledChanged();
- void acceptedButtonsChanged();
- void positionChanged(QmlGraphicsMouseEvent *mouse);
-
- void pressed(QmlGraphicsMouseEvent *mouse);
- void pressAndHold(QmlGraphicsMouseEvent *mouse);
- void released(QmlGraphicsMouseEvent *mouse);
- void clicked(QmlGraphicsMouseEvent *mouse);
- void doubleClicked(QmlGraphicsMouseEvent *mouse);
- void entered();
- void exited();
-
-protected:
- void setHovered(bool);
- bool setPressed(bool);
-
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
- void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
- void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
- bool sceneEvent(QEvent *);
- void timerEvent(QTimerEvent *event);
-
-private:
- void handlePress();
- void handleRelease();
-
-private:
- Q_DISABLE_COPY(QmlGraphicsMouseArea)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsMouseArea)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsDrag)
-QML_DECLARE_TYPE(QmlGraphicsMouseArea)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSMOUSEAREA_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsmousearea_p_p.h b/src/declarative/graphicsitems/qmlgraphicsmousearea_p_p.h
deleted file mode 100644
index fadb430..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsmousearea_p_p.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSMOUSEREGION_P_H
-#define QMLGRAPHICSMOUSEREGION_P_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 "qmlgraphicsitem_p.h"
-
-#include <qdatetime.h>
-#include <qbasictimer.h>
-#include <qgraphicssceneevent.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsMouseAreaPrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsMouseArea)
-
-public:
- QmlGraphicsMouseAreaPrivate()
- : absorb(true), hovered(false), pressed(false), longPress(false), drag(0)
- {
- }
-
- ~QmlGraphicsMouseAreaPrivate();
-
- void init()
- {
- Q_Q(QmlGraphicsMouseArea);
- q->setAcceptedMouseButtons(Qt::LeftButton);
- }
-
- void saveEvent(QGraphicsSceneMouseEvent *event) {
- lastPos = event->pos();
- lastButton = event->button();
- lastButtons = event->buttons();
- lastModifiers = event->modifiers();
- }
-
- bool isConnected(const char *signal) {
- Q_Q(QmlGraphicsMouseArea);
- int idx = QObjectPrivate::get(q)->signalIndex(signal);
- return QObjectPrivate::get(q)->isSignalConnected(idx);
- }
-
- bool absorb : 1;
- bool hovered : 1;
- bool pressed : 1;
- bool longPress : 1;
- bool moved : 1;
- bool dragX : 1;
- bool dragY : 1;
- bool dragged : 1;
- QmlGraphicsDrag *drag;
- QPointF start;
- QPointF startScene;
- qreal startX;
- qreal startY;
- QPointF lastPos;
- Qt::MouseButton lastButton;
- Qt::MouseButtons lastButtons;
- Qt::KeyboardModifiers lastModifiers;
- QBasicTimer pressAndHoldTimer;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLGRAPHICSMOUSEREGION_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp
deleted file mode 100644
index 3daa0c6..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp
+++ /dev/null
@@ -1,466 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicspainteditem_p.h"
-#include "qmlgraphicspainteditem_p_p.h"
-
-#include <QDebug>
-#include <QPen>
-#include <QFile>
-#include <QEvent>
-#include <QApplication>
-#include <QGraphicsSceneMouseEvent>
-#include <QPainter>
-#include <QPaintEngine>
-#include <qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlGraphicsPaintedItem
- \brief The QmlGraphicsPaintedItem class is an abstract base class for QmlView items that want cached painting.
- \internal
-
- This is a convenience class for implementing items that paint their contents
- using a QPainter. The contents of the item are cached behind the scenes.
- The dirtyCache() function should be called if the contents change to
- ensure the cache is refreshed the next time painting occurs.
-
- To subclass QmlGraphicsPaintedItem, you must reimplement drawContents() to draw
- the contents of the item.
-*/
-
-/*!
- \fn void QmlGraphicsPaintedItem::drawContents(QPainter *painter, const QRect &rect)
-
- This function is called when the cache needs to be refreshed. When
- sub-classing QmlGraphicsPaintedItem this function should be implemented so as to
- paint the contents of the item using the given \a painter for the
- area of the contents specified by \a rect.
-*/
-
-/*!
- \property QmlGraphicsPaintedItem::contentsSize
- \brief The size of the contents
-
- The contents size is the size of the item in regards to how it is painted
- using the drawContents() function. This is distinct from the size of the
- item in regards to height() and width().
-*/
-
-// XXX bug in WebKit - can call repaintRequested and other cache-changing functions from within render!
-static int inpaint=0;
-static int inpaint_clearcache=0;
-
-/*!
- Marks areas of the cache that intersect with the given \a rect as dirty and
- in need of being refreshed.
-
- \sa clearCache()
-*/
-void QmlGraphicsPaintedItem::dirtyCache(const QRect& rect)
-{
- Q_D(QmlGraphicsPaintedItem);
- QRect srect(qCeil(rect.x()*d->contentsScale),
- qCeil(rect.y()*d->contentsScale),
- qCeil(rect.width()*d->contentsScale),
- qCeil(rect.height()*d->contentsScale));
- for (int i=0; i < d->imagecache.count(); ) {
- QmlGraphicsPaintedItemPrivate::ImageCacheItem *c = d->imagecache[i];
- QRect isect = (c->area & srect) | c->dirty;
- if (isect == c->area && !inpaint) {
- delete d->imagecache.takeAt(i);
- } else {
- c->dirty = isect;
- ++i;
- }
- }
-}
-
-/*!
- Marks the entirety of the contents cache as dirty.
-
- \sa dirtyCache()
-*/
-void QmlGraphicsPaintedItem::clearCache()
-{
- if (inpaint) {
- inpaint_clearcache=1;
- return;
- }
- Q_D(QmlGraphicsPaintedItem);
- qDeleteAll(d->imagecache);
- d->imagecache.clear();
-}
-
-/*!
- Returns the size of the contents.
-
- \sa setContentsSize()
-*/
-QSize QmlGraphicsPaintedItem::contentsSize() const
-{
- Q_D(const QmlGraphicsPaintedItem);
- return d->contentsSize;
-}
-
-/*!
- Sets the size of the contents to the given \a size.
-
- \sa contentsSize()
-*/
-void QmlGraphicsPaintedItem::setContentsSize(const QSize &size)
-{
- Q_D(QmlGraphicsPaintedItem);
- if (d->contentsSize == size) return;
- d->contentsSize = size;
- setImplicitWidth(size.width()*d->contentsScale);
- setImplicitHeight(size.height()*d->contentsScale);
- clearCache();
- update();
- emit contentsSizeChanged();
-}
-
-qreal QmlGraphicsPaintedItem::contentsScale() const
-{
- Q_D(const QmlGraphicsPaintedItem);
- return d->contentsScale;
-}
-
-void QmlGraphicsPaintedItem::setContentsScale(qreal scale)
-{
- Q_D(QmlGraphicsPaintedItem);
- if (d->contentsScale == scale) return;
- d->contentsScale = scale;
- setImplicitWidth(d->contentsSize.width()*scale);
- setImplicitHeight(d->contentsSize.height()*scale);
- clearCache();
- update();
- emit contentsScaleChanged();
-}
-
-
-/*!
- Constructs a new QmlGraphicsPaintedItem with the given \a parent.
-*/
-QmlGraphicsPaintedItem::QmlGraphicsPaintedItem(QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsPaintedItemPrivate), parent)
-{
- init();
-}
-
-/*!
- \internal
- Constructs a new QmlGraphicsPaintedItem with the given \a parent and
- initialized private data member \a dd.
-*/
-QmlGraphicsPaintedItem::QmlGraphicsPaintedItem(QmlGraphicsPaintedItemPrivate &dd, QmlGraphicsItem *parent)
- : QmlGraphicsItem(dd, parent)
-{
- init();
-}
-
-/*!
- Destroys the image item.
-*/
-QmlGraphicsPaintedItem::~QmlGraphicsPaintedItem()
-{
- clearCache();
-}
-
-/*!
- \internal
-*/
-void QmlGraphicsPaintedItem::init()
-{
- connect(this,SIGNAL(widthChanged()),this,SLOT(clearCache()));
- connect(this,SIGNAL(heightChanged()),this,SLOT(clearCache()));
- connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache()));
-}
-
-void QmlGraphicsPaintedItem::setCacheFrozen(bool frozen)
-{
- Q_D(QmlGraphicsPaintedItem);
- if (d->cachefrozen == frozen)
- return;
- d->cachefrozen = frozen;
- // XXX clear cache?
-}
-
-/*!
- \reimp
-*/
-void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
-{
- Q_D(QmlGraphicsPaintedItem);
- const QRect content(0,0,qCeil(d->contentsSize.width()*d->contentsScale),
- qCeil(d->contentsSize.height()*d->contentsScale));
- if (content.width() <= 0 || content.height() <= 0)
- return;
-
- ++inpaint;
-
- const QTransform &x = p->deviceTransform();
- QTransform xinv = x.inverted();
- QRegion effectiveClip;
- QRegion sysClip = p->paintEngine()->systemClip();
- if (xinv.type() <= QTransform::TxScale && sysClip.numRects() < 5) {
- // simple transform, region gets no more complicated...
- effectiveClip = xinv.map(sysClip);
- } else {
- // do not make complicated regions...
- effectiveClip = xinv.mapRect(sysClip.boundingRect());
- }
-
- QRegion topaint = p->clipRegion();
- if (topaint.isEmpty()) {
- if (effectiveClip.isEmpty())
- topaint = QRect(0,0,p->device()->width(),p->device()->height());
- else
- topaint = effectiveClip;
- } else if (!effectiveClip.isEmpty()) {
- topaint &= effectiveClip;
- }
-
- topaint &= content;
- QRegion uncached(content);
- p->setRenderHints(QPainter::SmoothPixmapTransform, d->smooth);
-
- int cachesize=0;
- for (int i=0; i<d->imagecache.count(); ++i) {
- QRect area = d->imagecache[i]->area;
- if (topaint.contains(area)) {
- QRectF target(area.x(), area.y(), area.width(), area.height());
- if (!d->cachefrozen) {
- if (!d->imagecache[i]->dirty.isNull() && topaint.contains(d->imagecache[i]->dirty)) {
- QPainter qp(&d->imagecache[i]->image);
- qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache);
- qp.translate(-area.x(), -area.y());
- qp.scale(d->contentsScale,d->contentsScale);
- QRect clip = d->imagecache[i]->dirty;
- QRect sclip(qFloor(clip.x()/d->contentsScale),
- qFloor(clip.y()/d->contentsScale),
- qCeil(clip.width()/d->contentsScale+clip.x()/d->contentsScale-qFloor(clip.x()/d->contentsScale)),
- qCeil(clip.height()/d->contentsScale+clip.y()/d->contentsScale-qFloor(clip.y()/d->contentsScale)));
- qp.setClipRect(sclip);
- if (d->fillColor.isValid()){
- if(d->fillColor.alpha() < 255){
- // ### Might not work outside of raster paintengine
- QPainter::CompositionMode prev = qp.compositionMode();
- qp.setCompositionMode(QPainter::CompositionMode_Source);
- qp.fillRect(sclip,d->fillColor);
- qp.setCompositionMode(prev);
- }else{
- qp.fillRect(sclip,d->fillColor);
- }
- }
- drawContents(&qp, sclip);
- d->imagecache[i]->dirty = QRect();
- }
- }
- p->drawPixmap(target.toRect(), d->imagecache[i]->image);
- topaint -= area;
- d->imagecache[i]->age=0;
- } else {
- d->imagecache[i]->age++;
- }
- cachesize += area.width()*area.height();
- uncached -= area;
- }
-
- if (!topaint.isEmpty()) {
- if (!d->cachefrozen) {
- // Find a sensible larger area, otherwise will paint lots of tiny images.
- QRect biggerrect = topaint.boundingRect().adjusted(-64,-64,128,128);
- cachesize += biggerrect.width() * biggerrect.height();
- while (d->imagecache.count() && cachesize > d->max_imagecache_size) {
- int oldest=-1;
- int age=-1;
- for (int i=0; i<d->imagecache.count(); ++i) {
- int a = d->imagecache[i]->age;
- if (a > age) {
- oldest = i;
- age = a;
- }
- }
- cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
- uncached += d->imagecache[oldest]->area;
- delete d->imagecache.takeAt(oldest);
- }
- const QRegion bigger = QRegion(biggerrect) & uncached;
- const QVector<QRect> rects = bigger.rects();
- for (int i = 0; i < rects.count(); ++i) {
- const QRect &r = rects.at(i);
- QPixmap img(r.size());
- if (d->fillColor.isValid())
- img.fill(d->fillColor);
- {
- QPainter qp(&img);
- qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache);
-
- qp.translate(-r.x(),-r.y());
- qp.scale(d->contentsScale,d->contentsScale);
- QRect sclip(qFloor(r.x()/d->contentsScale),
- qFloor(r.y()/d->contentsScale),
- qCeil(r.width()/d->contentsScale+r.x()/d->contentsScale-qFloor(r.x()/d->contentsScale)),
- qCeil(r.height()/d->contentsScale+r.y()/d->contentsScale-qFloor(r.y()/d->contentsScale)));
- drawContents(&qp, sclip);
- }
- QmlGraphicsPaintedItemPrivate::ImageCacheItem *newitem = new QmlGraphicsPaintedItemPrivate::ImageCacheItem;
- newitem->area = r;
- newitem->image = img;
- d->imagecache.append(newitem);
- p->drawPixmap(r, newitem->image);
- }
- } else {
- const QVector<QRect> rects = uncached.rects();
- for (int i = 0; i < rects.count(); ++i)
- p->fillRect(rects.at(i), Qt::lightGray);
- }
- }
-
- if (inpaint_clearcache) {
- clearCache();
- inpaint_clearcache = 0;
- }
-
- --inpaint;
-}
-
-/*!
- \qmlproperty int PaintedItem::pixelCacheSize
-
- This property holds the maximum number of pixels of image cache to
- allow. The default is 0.1 megapixels. The cache will not be larger
- than the (unscaled) size of the WebView.
-*/
-/*!
- \property QmlGraphicsPaintedItem::pixelCacheSize
-
- The maximum number of pixels of image cache to allow. The default
- is 0.1 megapixels. The cache will not be larger than the (unscaled)
- size of the QmlGraphicsPaintedItem.
-*/
-int QmlGraphicsPaintedItem::pixelCacheSize() const
-{
- Q_D(const QmlGraphicsPaintedItem);
- return d->max_imagecache_size;
-}
-
-void QmlGraphicsPaintedItem::setPixelCacheSize(int pixels)
-{
- Q_D(QmlGraphicsPaintedItem);
- if (pixels < d->max_imagecache_size) {
- int cachesize=0;
- for (int i=0; i<d->imagecache.count(); ++i) {
- QRect area = d->imagecache[i]->area;
- cachesize += area.width()*area.height();
- }
- while (d->imagecache.count() && cachesize > pixels) {
- int oldest=-1;
- int age=-1;
- for (int i=0; i<d->imagecache.count(); ++i) {
- int a = d->imagecache[i]->age;
- if (a > age) {
- oldest = i;
- age = a;
- }
- }
- cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
- delete d->imagecache.takeAt(oldest);
- }
- }
- d->max_imagecache_size = pixels;
-}
-
-
-
-/*!
- \property QmlGraphicsPaintedItem::fillColor
-
- The color to be used to fill the item prior to calling drawContents().
- By default, this is Qt::transparent.
-
- Performance improvements can be achieved if subclasses call this with either an
- invalid color (QColor()), or an appropriate solid color.
-*/
-void QmlGraphicsPaintedItem::setFillColor(const QColor& c)
-{
- Q_D(QmlGraphicsPaintedItem);
- if (d->fillColor == c)
- return;
- d->fillColor = c;
- emit fillColorChanged();
- update();
-}
-
-QColor QmlGraphicsPaintedItem::fillColor() const
-{
- Q_D(const QmlGraphicsPaintedItem);
- return d->fillColor;
-}
-
-/*!
- \qmlproperty bool PaintedItem::smoothCache
-
- Controls whether the cached tiles of which the item is composed are
- rendered smoothly when they are generated.
-
- This is in addition toe Item::smooth, which controls the smooth painting of
- the already-painted cached tiles under transformation.
-*/
-bool QmlGraphicsPaintedItem::smoothCache() const
-{
- Q_D(const QmlGraphicsPaintedItem);
- return d->smoothCache;
-}
-
-void QmlGraphicsPaintedItem::setSmoothCache(bool on)
-{
- Q_D(QmlGraphicsPaintedItem);
- if (d->smoothCache != on) {
- d->smoothCache = on;
- clearCache();
- }
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h
deleted file mode 100644
index f2f9be0..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSIMAGEITEM_H
-#define QMLGRAPHICSIMAGEITEM_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsPaintedItemPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsPaintedItem : public QmlGraphicsItem
-{
- Q_OBJECT
-
- Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize NOTIFY contentsSizeChanged)
- Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
- Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize)
- Q_PROPERTY(bool smoothCache READ smoothCache WRITE setSmoothCache)
- Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged)
-
-
-public:
- QmlGraphicsPaintedItem(QmlGraphicsItem *parent=0);
- ~QmlGraphicsPaintedItem();
-
- QSize contentsSize() const;
- void setContentsSize(const QSize &);
-
- qreal contentsScale() const;
- void setContentsScale(qreal);
-
- int pixelCacheSize() const;
- void setPixelCacheSize(int pixels);
-
- bool smoothCache() const;
- void setSmoothCache(bool on);
-
- QColor fillColor() const;
- void setFillColor(const QColor&);
-
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
-
-protected:
- QmlGraphicsPaintedItem(QmlGraphicsPaintedItemPrivate &dd, QmlGraphicsItem *parent);
-
- virtual void drawContents(QPainter *p, const QRect &) = 0;
-
- void setCacheFrozen(bool);
-
-Q_SIGNALS:
- void fillColorChanged();
- void contentsSizeChanged();
- void contentsScaleChanged();
-
-protected Q_SLOTS:
- void dirtyCache(const QRect &);
- void clearCache();
-
-private:
- void init();
- Q_DISABLE_COPY(QmlGraphicsPaintedItem)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsPaintedItem)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsPaintedItem)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h b/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h
deleted file mode 100644
index 7d49914..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSIMAGEITEM_P_H
-#define QMLGRAPHICSIMAGEITEM_P_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 "qmlgraphicsitem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsPaintedItemPrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsPaintedItem)
-
-public:
- QmlGraphicsPaintedItemPrivate()
- : max_imagecache_size(100000), contentsScale(1.0), fillColor(Qt::transparent), cachefrozen(false), smoothCache(true)
- {
- }
-
- struct ImageCacheItem {
- ImageCacheItem() : age(0) {}
- ~ImageCacheItem() { }
- int age;
- QRect area;
- QRect dirty; // one dirty area (allows optimization of common cases)
- QPixmap image;
- };
-
- QList<ImageCacheItem*> imagecache;
-
- int max_imagecache_size;
- QSize contentsSize;
- qreal contentsScale;
- QColor fillColor;
- bool cachefrozen;
- bool smoothCache;
-};
-
-QT_END_NAMESPACE
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
deleted file mode 100644
index 93127bc..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
+++ /dev/null
@@ -1,1295 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsparticles_p.h"
-
-#include "qmlgraphicsitem_p.h"
-
-#include <qmlpixmapcache_p.h>
-#include <qfxperf_p_p.h>
-#include <qmlanimation_p_p.h>
-
-#include <QNetworkReply>
-#include <QPainter>
-#include <QtGui/qdrawutil.h>
-#include <QVarLengthArray>
-
-#include <stdlib.h>
-#include <math.h>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#define M_PI_2 (M_PI / 2.)
-#endif
-#ifndef INT_MAX
-#define INT_MAX 2147483647
-#endif
-
-QT_BEGIN_NAMESPACE
-#define PI_SQR 9.8696044
-// parabolic approximation
-inline qreal fastSin(qreal theta)
-{
- const qreal b = 4 / M_PI;
- const qreal c = -4 / PI_SQR;
-
- qreal y = b * theta + c * theta * qAbs(theta);
- return y;
-}
-
-inline qreal fastCos(qreal theta)
-{
- theta += M_PI_2;
- if (theta > M_PI)
- theta -= 2 * M_PI;
-
- return fastSin(theta);
-}
-
-class QmlGraphicsParticle
-{
-public:
- QmlGraphicsParticle(int time) : lifeSpan(1000), fadeOutAge(800)
- , opacity(0), birthTime(time), x_velocity(0), y_velocity(0)
- , state(FadeIn), data(0)
- {
- }
-
- int lifeSpan;
- int fadeOutAge;
- qreal x;
- qreal y;
- qreal opacity;
- int birthTime;
- qreal x_velocity;
- qreal y_velocity;
- enum State { FadeIn, Solid, FadeOut };
- State state;
- void *data;
-};
-
-//---------------------------------------------------------------------------
-
-/*!
- \class QmlGraphicsParticleMotion
- \ingroup group_effects
- \brief The QmlGraphicsParticleMotion class is the base class for particle motion.
- \internal
-
- This class causes the particles to remain static.
-*/
-
-/*!
- Constructs a QmlGraphicsParticleMotion with parent object \a parent.
-*/
-QmlGraphicsParticleMotion::QmlGraphicsParticleMotion(QObject *parent) :
- QObject(parent)
-{
-}
-
-/*!
- Move the \a particle to its new position. \a interval is the number of
- milliseconds elapsed since it was last moved.
-*/
-void QmlGraphicsParticleMotion::advance(QmlGraphicsParticle &particle, int interval)
-{
- Q_UNUSED(particle);
- Q_UNUSED(interval);
-}
-
-/*!
- The \a particle has just been created. Some motion strategies require
- additional state information. This can be allocated by this function.
-*/
-void QmlGraphicsParticleMotion::created(QmlGraphicsParticle &particle)
-{
- Q_UNUSED(particle);
-}
-
-/*!
- The \a particle is about to be destroyed. Any additional memory
- that has been allocated for the particle should be freed.
-*/
-void QmlGraphicsParticleMotion::destroy(QmlGraphicsParticle &particle)
-{
- Q_UNUSED(particle);
-}
-
-/*!
- \qmlclass ParticleMotionLinear
- \since 4.7
- \brief The ParticleMotionLinear object moves particles linearly.
-
- \sa Particles
-*/
-
-/*!
- \internal
- \class QmlGraphicsParticleMotionLinear
- \ingroup group_effects
- \brief The QmlGraphicsParticleMotionLinear class moves the particles linearly.
-*/
-
-void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interval)
-{
- p.x += interval * p.x_velocity;
- p.y += interval * p.y_velocity;
-}
-
-/*!
- \qmlclass ParticleMotionGravity
- \since 4.7
- \brief The ParticleMotionGravity object moves particles towards a point.
-
- \sa Particles
-*/
-
-/*!
- \internal
- \class QmlGraphicsParticleMotionGravity
- \ingroup group_effects
- \brief The QmlGraphicsParticleMotionGravity class moves the particles towards a point.
-*/
-
-/*!
- \qmlproperty qreal ParticleMotionGravity::xattractor
- \qmlproperty qreal ParticleMotionGravity::yattractor
- These properties hold the x and y coordinates of the point attracting the particles.
-*/
-
-/*!
- \qmlproperty qreal ParticleMotionGravity::acceleration
- This property holds the acceleration to apply to the particles.
-*/
-
-/*!
- \property QmlGraphicsParticleMotionGravity::xattractor
- \brief the x coordinate of the point attracting the particles.
-*/
-
-/*!
- \property QmlGraphicsParticleMotionGravity::yattractor
- \brief the y coordinate of the point attracting the particles.
-*/
-
-/*!
- \property QmlGraphicsParticleMotionGravity::acceleration
- \brief the acceleration to apply to the particles.
-*/
-
-void QmlGraphicsParticleMotionGravity::setXAttractor(qreal x)
-{
- if (qFuzzyCompare(x, _xAttr))
- return;
- _xAttr = x;
- emit xattractorChanged();
-}
-
-void QmlGraphicsParticleMotionGravity::setYAttractor(qreal y)
-{
- if (qFuzzyCompare(y, _yAttr))
- return;
- _yAttr = y;
- emit yattractorChanged();
-}
-
-void QmlGraphicsParticleMotionGravity::setAcceleration(qreal accel)
-{
- qreal scaledAccel = accel/1000000.0;
- if (qFuzzyCompare(scaledAccel, _accel))
- return;
- _accel = scaledAccel;
- emit accelerationChanged();
-}
-
-void QmlGraphicsParticleMotionGravity::advance(QmlGraphicsParticle &p, int interval)
-{
- qreal xdiff = p.x - _xAttr;
- qreal ydiff = p.y - _yAttr;
-
- qreal xcomp = xdiff / (xdiff + ydiff);
- qreal ycomp = ydiff / (xdiff + ydiff);
-
- p.x_velocity += xcomp * _accel * interval;
- p.y_velocity += ycomp * _accel * interval;
-
- p.x += interval * p.x_velocity;
- p.y += interval * p.y_velocity;
-}
-
-/*!
- \qmlclass ParticleMotionWander
- \since 4.7
- \brief The ParticleMotionWander object moves particles in a somewhat random fashion.
-
- The particles will continue roughly in the original direction, however will randomly
- drift to each side.
-
- The code below produces an effect similar to falling snow.
-
- \qml
-Rectangle {
- width: 240
- height: 320
- color: "black"
-
- Particles {
- y: 0
- width: parent.width
- height: 30
- source: "star.png"
- lifeSpan: 5000
- count: 50
- angle: 70
- angleDeviation: 36
- velocity: 30
- velocityDeviation: 10
- ParticleMotionWander {
- xvariance: 30
- pace: 100
- }
- }
-}
- \endqml
-
- \sa Particles
-*/
-
-/*!
- \internal
- \class QmlGraphicsParticleMotionWander
- \ingroup group_effects
- \brief The QmlGraphicsParticleMotionWander class moves particles in a somewhat random fashion.
-
- The particles will continue roughly in the original direction, however will randomly
- drift to each side.
-*/
-
-/*!
- \qmlproperty qreal QmlGraphicsParticleMotionWander::xvariance
- \qmlproperty qreal QmlGraphicsParticleMotionWander::yvariance
-
- These properties set the amount to wander in the x and y directions.
-*/
-
-/*!
- \qmlproperty qreal QmlGraphicsParticleMotionWander::pace
- This property holds how quickly the paricles will move from side to side.
-*/
-
-void QmlGraphicsParticleMotionWander::advance(QmlGraphicsParticle &p, int interval)
-{
- if (!particles)
- particles = qobject_cast<QmlGraphicsParticles*>(parent());
- if (particles) {
- Data *d = (Data*)p.data;
- if (_xvariance != 0.) {
- qreal xdiff = p.x_velocity - d->x_targetV;
- if ((xdiff > d->x_peak && d->x_var > 0.0) || (xdiff < -d->x_peak && d->x_var < 0.0)) {
- d->x_var = -d->x_var;
- d->x_peak = _xvariance + _xvariance * qreal(qrand()) / RAND_MAX;
- }
- p.x_velocity += d->x_var * interval;
- }
- p.x += interval * p.x_velocity;
-
- if (_yvariance != 0.) {
- qreal ydiff = p.y_velocity - d->y_targetV;
- if ((ydiff > d->y_peak && d->y_var > 0.0) || (ydiff < -d->y_peak && d->y_var < 0.0)) {
- d->y_var = -d->y_var;
- d->y_peak = _yvariance + _yvariance * qreal(qrand()) / RAND_MAX;
- }
- p.y_velocity += d->y_var * interval;
- }
- p.y += interval * p.y_velocity;
- }
-}
-
-void QmlGraphicsParticleMotionWander::created(QmlGraphicsParticle &p)
-{
- if (!p.data) {
- Data *d = new Data;
- p.data = (void*)d;
- d->x_targetV = p.x_velocity;
- d->y_targetV = p.y_velocity;
- d->x_peak = _xvariance;
- d->y_peak = _yvariance;
- d->x_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0;
- d->y_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0;
- }
-}
-
-void QmlGraphicsParticleMotionWander::destroy(QmlGraphicsParticle &p)
-{
- if (p.data)
- delete (Data*)p.data;
-}
-
-void QmlGraphicsParticleMotionWander::setXVariance(qreal var)
-{
- qreal scaledVar = var / 1000.0;
- if (qFuzzyCompare(scaledVar, _xvariance))
- return;
- _xvariance = scaledVar;
- emit xvarianceChanged();
-}
-
-void QmlGraphicsParticleMotionWander::setYVariance(qreal var)
-{
- qreal scaledVar = var / 1000.0;
- if (qFuzzyCompare(scaledVar, _yvariance))
- return;
- _yvariance = scaledVar;
- emit yvarianceChanged();
-}
-
-void QmlGraphicsParticleMotionWander::setPace(qreal pace)
-{
- qreal scaledPace = pace / 1000.0;
- if (qFuzzyCompare(scaledPace, _pace))
- return;
- _pace = scaledPace;
- emit paceChanged();
-}
-
-//---------------------------------------------------------------------------
-class QmlGraphicsParticlesPainter : public QmlGraphicsItem
-{
-public:
- QmlGraphicsParticlesPainter(QmlGraphicsParticlesPrivate *p, QmlGraphicsItem* parent)
- : QmlGraphicsItem(parent), d(p)
- {
- setFlag(QGraphicsItem::ItemHasNoContents, false);
- maxX = minX = maxY = minY = 0;
- }
-
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
-
- void updateSize();
-
- qreal maxX;
- qreal minX;
- qreal maxY;
- qreal minY;
- QmlGraphicsParticlesPrivate* d;
-};
-
-//---------------------------------------------------------------------------
-class QmlGraphicsParticlesPrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsParticles)
-public:
- QmlGraphicsParticlesPrivate()
- : count(1), emissionRate(-1), emissionVariance(0.5), lifeSpan(1000)
- , lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300)
- , angle(0), angleDev(0), velocity(0), velocityDev(0), emissionCarry(0.)
- , addParticleTime(0), addParticleCount(0), lastAdvTime(0)
- , motion(0), pendingPixmapCache(false), clock(this)
- {
- }
-
- ~QmlGraphicsParticlesPrivate()
- {
- }
-
- void init()
- {
- Q_Q(QmlGraphicsParticles);
- paintItem = new QmlGraphicsParticlesPainter(this, q);
- }
-
- void tick(int time);
- void createParticle(int time);
- void updateOpacity(QmlGraphicsParticle &p, int age);
-
- QUrl url;
- QPixmap image;
- int count;
- int emissionRate;
- qreal emissionVariance;
- int lifeSpan;
- int lifeSpanDev;
- int fadeInDur;
- int fadeOutDur;
- qreal angle;
- qreal angleDev;
- qreal velocity;
- qreal velocityDev;
- qreal emissionCarry;
- int addParticleTime;
- int addParticleCount;
- int lastAdvTime;
- QmlGraphicsParticleMotion *motion;
- QmlGraphicsParticlesPainter *paintItem;
-
- bool pendingPixmapCache;
-
- QList<QPair<int, int> > bursts;//countLeft, emissionRate pairs
- QList<QmlGraphicsParticle> particles;
- QTickAnimationProxy<QmlGraphicsParticlesPrivate, &QmlGraphicsParticlesPrivate::tick> clock;
-
-};
-
-void QmlGraphicsParticlesPrivate::tick(int time)
-{
- Q_Q(QmlGraphicsParticles);
- if (!motion)
- motion = new QmlGraphicsParticleMotionLinear(q);
-
- int oldCount = particles.count();
- int removed = 0;
- int interval = time - lastAdvTime;
- for (int i = 0; i < particles.count(); ) {
- QmlGraphicsParticle &particle = particles[i];
- int age = time - particle.birthTime;
- if (age >= particle.lifeSpan) {
- QmlGraphicsParticle part = particles.takeAt(i);
- motion->destroy(part);
- ++removed;
- } else {
- updateOpacity(particle, age);
- motion->advance(particle, interval);
- ++i;
- }
- }
-
- if(emissionRate == -1)//Otherwise leave emission to the emission rate
- while(removed-- && ((count == -1) || particles.count() < count))
- createParticle(time);
-
- if (!addParticleTime)
- addParticleTime = time;
-
- //Possibly emit new particles
- if (((count == -1) || particles.count() < count) && emissionRate
- && !(count==-1 && emissionRate==-1)) {
- int emissionCount = -1;
- if (emissionRate != -1){
- qreal variance = 1.;
- if (emissionVariance > 0.){
- variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.);
- }
- qreal emission = emissionRate * (qreal(interval)/1000.);
- emission = emission * variance + emissionCarry;
- double tmpDbl;
- emissionCarry = modf(emission, &tmpDbl);
- emissionCount = (int)tmpDbl;
- emissionCount = qMax(0,emissionCount);
- }
- while(((count == -1) || particles.count() < count) &&
- (emissionRate==-1 || emissionCount--))
- createParticle(time);
- }
-
- //Deal with emissions from requested bursts
- for(int i=0; i<bursts.size(); i++){
- int emission = 0;
- if(bursts[i].second == -1){
- emission = bursts[i].first;
- }else{
- qreal variance = 1.;
- if (emissionVariance > 0.){
- variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.);
- }
- qreal workingEmission = bursts[i].second * (qreal(interval)/1000.);
- workingEmission *= variance;
- emission = (int)workingEmission;
- emission = qMax(emission, 0);
- }
- emission = qMin(emission, bursts[i].first);
- bursts[i].first -= emission;
- while(emission--)
- createParticle(time);
- }
- for(int i=bursts.size()-1; i>=0; i--)
- if(bursts[i].first <= 0)
- bursts.removeAt(i);
-
- lastAdvTime = time;
- paintItem->updateSize();
- paintItem->update();
- if (!(oldCount || particles.count()) && (!count || !emissionRate) && bursts.isEmpty()) {
- lastAdvTime = 0;
- clock.stop();
- }
-}
-
-void QmlGraphicsParticlesPrivate::createParticle(int time)
-{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::CreateParticle> x;
-#endif
- Q_Q(QmlGraphicsParticles);
- QmlGraphicsParticle p(time);
- p.x = q->x() + q->width() * qreal(qrand()) / RAND_MAX - image.width()/2.0;
- p.y = q->y() + q->height() * qreal(qrand()) / RAND_MAX - image.height()/2.0;
- p.lifeSpan = lifeSpan;
- if (lifeSpanDev)
- p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(qrand()) / RAND_MAX);
- p.fadeOutAge = p.lifeSpan - fadeOutDur;
- if (fadeInDur == 0.) {
- p.state= QmlGraphicsParticle::Solid;
- p.opacity = 1.0;
- }
- qreal a = angle;
- if (angleDev)
- a += angleDev/2 - angleDev * qreal(qrand()) / RAND_MAX;
- if (a > M_PI)
- a = a - 2 * M_PI;
- qreal v = velocity;
- if (velocityDev)
- v += velocityDev/2 - velocityDev * qreal(qrand()) / RAND_MAX;
- p.x_velocity = v * fastCos(a);
- p.y_velocity = v * fastSin(a);
- particles.append(p);
- motion->created(particles.last());
-}
-
-void QmlGraphicsParticlesPrivate::updateOpacity(QmlGraphicsParticle &p, int age)
-{
- switch (p.state) {
- case QmlGraphicsParticle::FadeIn:
- if (age <= fadeInDur) {
- p.opacity = qreal(age) / fadeInDur;
- break;
- } else {
- p.opacity = 1.0;
- p.state = QmlGraphicsParticle::Solid;
- // Fall through
- }
- case QmlGraphicsParticle::Solid:
- if (age <= p.fadeOutAge) {
- break;
- } else {
- p.state = QmlGraphicsParticle::FadeOut;
- // Fall through
- }
- case QmlGraphicsParticle::FadeOut:
- p.opacity = qreal(p.lifeSpan - age) / fadeOutDur;
- break;
- }
-}
-
-/*!
- \qmlclass Particles
- \since 4.7
- \brief The Particles object generates and moves particles.
- \inherits Item
-
- This element provides preliminary support for particles in QML,
- and may be heavily changed or removed in later versions.
-
- The particles created by this object cannot be dealt with
- directly, they can only be controlled through the parameters of
- the Particles object. The particles are all the same pixmap,
- specified by the user.
-
- The particles are painted relative to the parent of the Particles
- object. Moving the Particles object will not move the particles
- already emitted.
-
- The below example creates two differently behaving particle
- sources. The top one has particles falling from the top like
- snow, the lower one has particles expelled up like a fountain.
-
- \qml
-Rectangle {
- width: 240
- height: 320
- color: "black"
- Particles {
- y: 0
- width: parent.width
- height: 30
- source: "star.png"
- lifeSpan: 5000
- count: 50
- angle: 70
- angleDeviation: 36
- velocity: 30
- velocityDeviation: 10
- ParticleMotionWander {
- xvariance: 30
- pace: 100
- }
- }
- Particles {
- y: 300
- x: 120
- width: 1
- height: 1
- source: "star.png"
- lifeSpan: 5000
- count: 200
- angle: 270
- angleDeviation: 45
- velocity: 50
- velocityDeviation: 30
- ParticleMotionGravity {
- yattractor: 1000
- xattractor: 0
- acceleration: 25
- }
- }
-}
- \endqml
- \image particles.gif
-*/
-
-/*!
- \internal
- \class QmlGraphicsParticles
- \ingroup group_effects
- \brief The QmlGraphicsParticles class generates and moves particles.
-*/
-
-QmlGraphicsParticles::QmlGraphicsParticles(QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsParticlesPrivate), parent)
-{
- Q_D(QmlGraphicsParticles);
- d->init();
-}
-
-QmlGraphicsParticles::~QmlGraphicsParticles()
-{
- Q_D(QmlGraphicsParticles);
- if (d->pendingPixmapCache)
- QmlPixmapCache::cancel(d->url, this);
-}
-
-/*!
- \qmlproperty string Particles::source
- This property holds the URL of the particle image.
-*/
-
-/*!
- \property QmlGraphicsParticles::source
- \brief the URL of the particle image.
-*/
-QUrl QmlGraphicsParticles::source() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->url;
-}
-
-void QmlGraphicsParticles::imageLoaded()
-{
- Q_D(QmlGraphicsParticles);
- d->pendingPixmapCache = false;
- QmlPixmapCache::get(d->url, &d->image);
- d->paintItem->updateSize();
- d->paintItem->update();
-}
-
-void QmlGraphicsParticles::setSource(const QUrl &name)
-{
- Q_D(QmlGraphicsParticles);
-
- if ((d->url.isEmpty() == name.isEmpty()) && name == d->url)
- return;
-
- if (d->pendingPixmapCache) {
- QmlPixmapCache::cancel(d->url, this);
- d->pendingPixmapCache = false;
- }
- if (name.isEmpty()) {
- d->url = name;
- d->image = QPixmap();
- d->paintItem->updateSize();
- d->paintItem->update();
- } else {
- d->url = name;
- Q_ASSERT(!name.isRelative());
- QmlPixmapReply::Status status = QmlPixmapCache::get(d->url, &d->image);
- if (status != QmlPixmapReply::Ready && status != QmlPixmapReply::Error) {
- QmlPixmapReply *reply = QmlPixmapCache::request(qmlEngine(this), d->url);
- connect(reply, SIGNAL(finished()), this, SLOT(imageLoaded()));
- d->pendingPixmapCache = true;
- } else {
- //### unify with imageLoaded
- d->paintItem->updateSize();
- d->paintItem->update();
- }
- }
- emit sourceChanged();
-}
-
-/*!
- \qmlproperty int Particles::count
- This property holds the maximum number of particles
-
- The particles element emits particles until it has count active
- particles. When this number is reached, new particles are not emitted until
- some of the current particles reach theend of their lifespan.
-
- If count is -1 then there is no maximum number of active particles, and
- particles will be constantly emitted at the rate specified by emissionRate.
-
- If both count and emissionRate are set to -1, nothing will be emitted.
-
-*/
-
-/*!
- \property QmlGraphicsParticles::count
- \brief the maximum number of particles
-*/
-int QmlGraphicsParticles::count() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->count;
-}
-
-void QmlGraphicsParticles::setCount(int cnt)
-{
- Q_D(QmlGraphicsParticles);
- if (cnt == d->count)
- return;
-
- int oldCount = d->count;
- d->count = cnt;
- d->addParticleTime = 0;
- d->addParticleCount = d->particles.count();
- if (!oldCount && d->clock.state() != QAbstractAnimation::Running && d->count && d->emissionRate) {
- d->clock.start();
- }
- d->paintItem->updateSize();
- d->paintItem->update();
- emit countChanged();
-}
-
-
-/*!
- \qmlproperty int Particles::emissionRate
- This property holds the target number of particles to emit every second.
-
- The particles element will emit up to emissionRate particles every
- second. Fewer particles may be emitted per second if the maximum number of
- particles has been reached.
-
- If emissionRate is set to -1 there is no limit to the number of
- particles emitted per second, and particles will be instantly emitted to
- reach the maximum number of particles specified by count.
-
- The default value for emissionRate is -1.
-
- If both count and emissionRate are set to -1, nothing will be emitted.
-*/
-
-/*!
- \property QmlGraphicsParticles::emissionRate
- \brief the emission rate of particles
-*/
-int QmlGraphicsParticles::emissionRate() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->emissionRate;
-}
-void QmlGraphicsParticles::setEmissionRate(int er)
-{
- Q_D(QmlGraphicsParticles);
- if(er == d->emissionRate)
- return;
- d->emissionRate = er;
- if (d->clock.state() != QAbstractAnimation::Running && d->count && d->emissionRate) {
- d->clock.start();
- }
- emit emissionRateChanged();
-}
-
-/*!
- \qmlproperty qreal Particles::emissionVariance
- This property holds how inconsistent the rate of particle emissions are.
- It is a number between 0 (no variance) and 1 (some variance).
-
- The expected number of particles emitted per second is emissionRate. If
- emissionVariance is 0 then particles will be emitted consistently throughout
- each second to reach that number. If emissionVariance is greater than 0 the
- rate of particle emission will vary randomly throughout the second, with the
- consequence that the actual number of particles emitted in one second will
- vary randomly as well.
-
- emissionVariance is the maximum deviation from emitting
- emissionRate particles per second. An emissionVariance of 0 means you should
- get exactly emissionRate particles emitted per second,
- and an emissionVariance of 1 means you will get between zero and two times
- emissionRate particles per second, but you should get emissionRate particles
- per second on average.
-
- Note that even with an emissionVariance of 0 there may be some variance due
- to performance and hardware constraints.
-
- The default value of emissionVariance is 0.5
-*/
-
-/*!
- \property QmlGraphicsParticles::emissionVariance
- \brief how much the particle emission amounts vary per tick
-*/
-
-qreal QmlGraphicsParticles::emissionVariance() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->emissionVariance;
-}
-
-void QmlGraphicsParticles::setEmissionVariance(qreal ev)
-{
- Q_D(QmlGraphicsParticles);
- if(d->emissionVariance == ev)
- return;
- d->emissionVariance = ev;
- emit emissionVarianceChanged();
-}
-
-/*!
- \qmlproperty int Particles::lifeSpan
- \qmlproperty int Particles::lifeSpanDeviation
-
- These properties describe the life span of each particle.
-
- The default lifespan for a particle is 1000ms.
-
- lifeSpanDeviation randomly varies the lifeSpan up to the specified variation. For
- example, the following creates particles whose lifeSpan will vary
- from 150ms to 250ms:
-
- \qml
-Particles {
- source: "star.png"
- lifeSpan: 200
- lifeSpanDeviation: 100
-}
- \endqml
-*/
-
-/*!
- \property QmlGraphicsParticles::lifeSpan
- \brief the life span of each particle.
-
- Default value is 1000ms.
-
- \sa QmlGraphicsParticles::lifeSpanDeviation
-*/
-int QmlGraphicsParticles::lifeSpan() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->lifeSpan;
-}
-
-void QmlGraphicsParticles::setLifeSpan(int ls)
-{
- Q_D(QmlGraphicsParticles);
- if(d->lifeSpan == ls)
- return;
- d->lifeSpan = ls;
- emit lifeSpanChanged();
-}
-
-/*!
- \property QmlGraphicsParticles::lifeSpanDeviation
- \brief the maximum possible deviation from the set lifeSpan.
-
- Randomly varies the lifeSpan up to the specified variation. For
- example, the following creates particles whose lifeSpan will vary
- from 150ms to 250ms:
-
-\qml
-Particles {
- source: "star.png"
- lifeSpan: 200
- lifeSpanDeviation: 100
-}
-\endqml
-
- \sa QmlGraphicsParticles::lifeSpan
-*/
-int QmlGraphicsParticles::lifeSpanDeviation() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->lifeSpanDev;
-}
-
-void QmlGraphicsParticles::setLifeSpanDeviation(int dev)
-{
- Q_D(QmlGraphicsParticles);
- if(d->lifeSpanDev == dev)
- return;
- d->lifeSpanDev = dev;
- emit lifeSpanDeviationChanged();
-}
-
-/*!
- \qmlproperty int Particles::fadeInDuration
- \qmlproperty int Particles::fadeOutDuration
- These properties hold the time taken to fade the particles in and out.
-
- By default fade in is 200ms and fade out is 300ms.
-*/
-
-/*!
- \property QmlGraphicsParticles::fadeInDuration
- \brief the time taken to fade in the particles.
-
- Default value is 200ms.
-*/
-int QmlGraphicsParticles::fadeInDuration() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->fadeInDur;
-}
-
-void QmlGraphicsParticles::setFadeInDuration(int dur)
-{
- Q_D(QmlGraphicsParticles);
- if (dur < 0.0 || dur == d->fadeInDur)
- return;
- d->fadeInDur = dur;
- emit fadeInDurationChanged();
-}
-
-/*!
- \property QmlGraphicsParticles::fadeOutDuration
- \brief the time taken to fade out the particles.
-
- Default value is 300ms.
-*/
-int QmlGraphicsParticles::fadeOutDuration() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->fadeOutDur;
-}
-
-void QmlGraphicsParticles::setFadeOutDuration(int dur)
-{
- Q_D(QmlGraphicsParticles);
- if (dur < 0.0 || d->fadeOutDur == dur)
- return;
- d->fadeOutDur = dur;
- emit fadeOutDurationChanged();
-}
-
-/*!
- \qmlproperty real Particles::angle
- \qmlproperty real Particles::angleDeviation
-
- These properties control particle direction.
-
- angleDeviation randomly varies the direction up to the specified variation. For
- example, the following creates particles whose initial direction will
- vary from 15 degrees to 105 degrees:
-
- \qml
-Particles {
- source: "star.png"
- angle: 60
- angleDeviation: 90
-}
- \endqml
-*/
-
-/*!
- \property QmlGraphicsParticles::angle
- \brief the initial angle of direction.
-
- \sa QmlGraphicsParticles::angleDeviation
-*/
-qreal QmlGraphicsParticles::angle() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->angle * 180.0 / M_PI;
-}
-
-void QmlGraphicsParticles::setAngle(qreal angle)
-{
- Q_D(QmlGraphicsParticles);
- qreal radAngle = angle * M_PI / 180.0;
- if(radAngle == d->angle)
- return;
- d->angle = radAngle;
- emit angleChanged();
-}
-
-/*!
- \property QmlGraphicsParticles::angleDeviation
- \brief the maximum possible deviation from the set angle.
-
- Randomly varies the direction up to the specified variation. For
- example, the following creates particles whose initial direction will
- vary from 15 degrees to 105 degrees:
-
-\qml
-Particles {
- source: "star.png"
- angle: 60
- angleDeviation: 90
-}
-\endqml
-
- \sa QmlGraphicsParticles::angle
-*/
-qreal QmlGraphicsParticles::angleDeviation() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->angleDev * 180.0 / M_PI;
-}
-
-void QmlGraphicsParticles::setAngleDeviation(qreal dev)
-{
- Q_D(QmlGraphicsParticles);
- qreal radDev = dev * M_PI / 180.0;
- if(radDev == d->angleDev)
- return;
- d->angleDev = radDev;
- emit angleDeviationChanged();
-}
-
-/*!
- \qmlproperty real Particles::velocity
- \qmlproperty real Particles::velocityDeviation
-
- These properties control the velocity of the particles.
-
- velocityDeviation randomly varies the velocity up to the specified variation. For
- example, the following creates particles whose initial velocity will
- vary from 40 to 60.
-
- \qml
-Particles {
- source: "star.png"
- velocity: 50
- velocityDeviation: 20
-}
- \endqml
-*/
-
-/*!
- \property QmlGraphicsParticles::velocity
- \brief the initial velocity of the particles.
-
- \sa QmlGraphicsParticles::velocityDeviation
-*/
-qreal QmlGraphicsParticles::velocity() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->velocity * 1000.0;
-}
-
-void QmlGraphicsParticles::setVelocity(qreal velocity)
-{
- Q_D(QmlGraphicsParticles);
- qreal realVel = velocity / 1000.0;
- if(realVel == d->velocity)
- return;
- d->velocity = realVel;
- emit velocityChanged();
-}
-
-/*!
- \property QmlGraphicsParticles::velocityDeviation
- \brief the maximum possible deviation from the set velocity.
-
- Randomly varies the velocity up to the specified variation. For
- example, the following creates particles whose initial velocity will
- vary from 40 to 60.
-
-\qml
-Particles {
- source: "star.png"
- velocity: 50
- velocityDeviation: 20
-}
-\endqml
-
- \sa QmlGraphicsParticles::velocity
-*/
-qreal QmlGraphicsParticles::velocityDeviation() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->velocityDev * 1000.0;
-}
-
-void QmlGraphicsParticles::setVelocityDeviation(qreal velocity)
-{
- Q_D(QmlGraphicsParticles);
- qreal realDev = velocity / 1000.0;
- if(realDev == d->velocityDev)
- return;
- d->velocityDev = realDev;
- emit velocityDeviationChanged();
-}
-
-/*!
- \qmlproperty ParticleMotion Particles::motion
- This property sets the type of motion to apply to the particles.
-
- When a particle is created it will have an initial direction and velocity.
- The motion of the particle during its lifeSpan is then influenced by the
- motion property.
-
- Default motion is ParticleMotionLinear.
-*/
-
-/*!
- \property QmlGraphicsParticles::motion
- \brief sets the type of motion to apply to the particles.
-
- When a particle is created it will have an initial direction and velocity.
- The motion of the particle during its lifeSpan is then influenced by the
- motion property.
-
- Default motion is QmlGraphicsParticleMotionLinear.
-*/
-QmlGraphicsParticleMotion *QmlGraphicsParticles::motion() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->motion;
-}
-
-void QmlGraphicsParticles::setMotion(QmlGraphicsParticleMotion *motion)
-{
- Q_D(QmlGraphicsParticles);
- if (motion == d->motion)
- return;
- d->motion = motion;
- emit motionChanged();
-}
-
-/*!
- \qmlmethod Particles::burst(int count, int emissionRate)
-
- Initiates a burst of particles.
-
- This method takes two arguments. The first argument is the number
- of particles to emit and the second argument is the emissionRate for the
- burst. If the second argument is omitted, it is treated as -1. The burst
- of particles has a separate emissionRate and count to the normal emission of
- particles. The burst uses the same values as normal emission for all other
- properties, including emissionVariance.
-
- The normal emission of particles will continue during the burst, however
- the particles created by the burst count towards the maximum number used by
- normal emission. To avoid this behavior, use two Particles elements.
-
-*/
-void QmlGraphicsParticles::burst(int count, int emissionRate)
-{
- Q_D(QmlGraphicsParticles);
- d->bursts << qMakePair(count, emissionRate);
- if (d->clock.state() != QAbstractAnimation::Running)
- d->clock.start();
-}
-
-void QmlGraphicsParticlesPainter::updateSize()
-{
- if (!isComponentComplete())
- return;
-
- const int parentX = parentItem()->x();
- const int parentY = parentItem()->y();
- for (int i = 0; i < d->particles.count(); ++i) {
- const QmlGraphicsParticle &particle = d->particles.at(i);
- if(particle.x > maxX)
- maxX = particle.x;
- if(particle.x < minX)
- minX = particle.x;
- if(particle.y > maxY)
- maxY = particle.y;
- if(particle.y < minY)
- minY = particle.y;
- }
-
- int myWidth = (int)(maxX-minX+0.5)+d->image.width();
- int myX = (int)(minX - parentX);
- int myHeight = (int)(maxY-minY+0.5)+d->image.height();
- int myY = (int)(minY - parentY);
- setWidth(myWidth);
- setHeight(myHeight);
- setX(myX);
- setY(myY);
-}
-
-void QmlGraphicsParticles::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
-{
- Q_UNUSED(p);
- //painting is done by the ParticlesPainter, so it can have the right size
-}
-
-void QmlGraphicsParticlesPainter::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
-{
- if (d->image.isNull() || d->particles.isEmpty())
- return;
-
- const int myX = x() + parentItem()->x();
- const int myY = y() + parentItem()->y();
-
- QVarLengthArray<QDrawPixmaps::Data, 256> pixmapData;
- pixmapData.resize(d->particles.count());
-
- const QRectF sourceRect = d->image.rect();
- qreal halfPWidth = sourceRect.width()/2.;
- qreal halfPHeight = sourceRect.height()/2.;
- for (int i = 0; i < d->particles.count(); ++i) {
- const QmlGraphicsParticle &particle = d->particles.at(i);
- pixmapData[i].point = QPointF(particle.x - myX + halfPWidth, particle.y - myY + halfPHeight);
- pixmapData[i].opacity = particle.opacity;
-
- //these never change
- pixmapData[i].rotation = 0;
- pixmapData[i].scaleX = 1;
- pixmapData[i].scaleY = 1;
- pixmapData[i].source = sourceRect;
- }
- qDrawPixmaps(p, pixmapData.data(), d->particles.count(), d->image);
-}
-
-void QmlGraphicsParticles::componentComplete()
-{
- Q_D(QmlGraphicsParticles);
- QmlGraphicsItem::componentComplete();
- if (d->count) {
- d->paintItem->updateSize();
- d->clock.start();
- }
- if (d->lifeSpanDev > d->lifeSpan)
- d->lifeSpanDev = d->lifeSpan;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles_p.h b/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
deleted file mode 100644
index 8e66335..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSPARTICLES_H
-#define QMLGRAPHICSPARTICLES_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsParticle;
-class QmlGraphicsParticles;
-class Q_DECLARATIVE_EXPORT QmlGraphicsParticleMotion : public QObject
-{
- Q_OBJECT
-public:
- QmlGraphicsParticleMotion(QObject *parent=0);
-
- virtual void advance(QmlGraphicsParticle &, int interval);
- virtual void created(QmlGraphicsParticle &);
- virtual void destroy(QmlGraphicsParticle &);
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsParticleMotionLinear : public QmlGraphicsParticleMotion
-{
- Q_OBJECT
-public:
- QmlGraphicsParticleMotionLinear(QObject *parent=0)
- : QmlGraphicsParticleMotion(parent) {}
-
- virtual void advance(QmlGraphicsParticle &, int interval);
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsParticleMotionGravity : public QmlGraphicsParticleMotion
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal xattractor READ xAttractor WRITE setXAttractor NOTIFY xattractorChanged)
- Q_PROPERTY(qreal yattractor READ yAttractor WRITE setYAttractor NOTIFY yattractorChanged)
- Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
-public:
- QmlGraphicsParticleMotionGravity(QObject *parent=0)
- : QmlGraphicsParticleMotion(parent), _xAttr(0.0), _yAttr(0.0), _accel(0.00005) {}
-
- qreal xAttractor() const { return _xAttr; }
- void setXAttractor(qreal x);
-
- qreal yAttractor() const { return _yAttr; }
- void setYAttractor(qreal y);
-
- qreal acceleration() const { return _accel * 1000000; }
- void setAcceleration(qreal accel);
-
- virtual void advance(QmlGraphicsParticle &, int interval);
-
-Q_SIGNALS:
- void xattractorChanged();
- void yattractorChanged();
- void accelerationChanged();
-
-private:
- qreal _xAttr;
- qreal _yAttr;
- qreal _accel;
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsParticleMotionWander : public QmlGraphicsParticleMotion
-{
- Q_OBJECT
-public:
- QmlGraphicsParticleMotionWander()
- : QmlGraphicsParticleMotion(), particles(0), _xvariance(0), _yvariance(0) {}
-
- virtual void advance(QmlGraphicsParticle &, int interval);
- virtual void created(QmlGraphicsParticle &);
- virtual void destroy(QmlGraphicsParticle &);
-
- struct Data {
- qreal x_targetV;
- qreal y_targetV;
- qreal x_peak;
- qreal y_peak;
- qreal x_var;
- qreal y_var;
- };
-
- Q_PROPERTY(qreal xvariance READ xVariance WRITE setXVariance NOTIFY xvarianceChanged)
- qreal xVariance() const { return _xvariance * 1000.0; }
- void setXVariance(qreal var);
-
- Q_PROPERTY(qreal yvariance READ yVariance WRITE setYVariance NOTIFY yvarianceChanged)
- qreal yVariance() const { return _yvariance * 1000.0; }
- void setYVariance(qreal var);
-
- Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged)
- qreal pace() const { return _pace * 1000.0; }
- void setPace(qreal pace);
-
-Q_SIGNALS:
- void xvarianceChanged();
- void yvarianceChanged();
- void paceChanged();
-
-private:
- QmlGraphicsParticles *particles;
- qreal _xvariance;
- qreal _yvariance;
- qreal _pace;
-};
-
-class QmlGraphicsParticlesPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsParticles : public QmlGraphicsItem
-{
- Q_OBJECT
-
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
- Q_PROPERTY(int emissionRate READ emissionRate WRITE setEmissionRate NOTIFY emissionRateChanged)
- Q_PROPERTY(qreal emissionVariance READ emissionVariance WRITE setEmissionVariance NOTIFY emissionVarianceChanged)
- Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan NOTIFY lifeSpanChanged)
- Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation NOTIFY lifeSpanDeviationChanged)
- Q_PROPERTY(int fadeInDuration READ fadeInDuration WRITE setFadeInDuration NOTIFY fadeInDurationChanged)
- Q_PROPERTY(int fadeOutDuration READ fadeOutDuration WRITE setFadeOutDuration NOTIFY fadeOutDurationChanged)
- Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
- Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation NOTIFY angleDeviationChanged)
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
- Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation NOTIFY velocityDeviationChanged)
- Q_PROPERTY(QmlGraphicsParticleMotion *motion READ motion WRITE setMotion NOTIFY motionChanged)
- Q_CLASSINFO("DefaultProperty", "motion")
-
-public:
- QmlGraphicsParticles(QmlGraphicsItem *parent=0);
- ~QmlGraphicsParticles();
-
- QUrl source() const;
- void setSource(const QUrl &);
-
- int count() const;
- void setCount(int cnt);
-
- int emissionRate() const;
- void setEmissionRate(int);
-
- qreal emissionVariance() const;
- void setEmissionVariance(qreal);
-
- int lifeSpan() const;
- void setLifeSpan(int);
-
- int lifeSpanDeviation() const;
- void setLifeSpanDeviation(int);
-
- int fadeInDuration() const;
- void setFadeInDuration(int);
-
- int fadeOutDuration() const;
- void setFadeOutDuration(int);
-
- qreal angle() const;
- void setAngle(qreal);
-
- qreal angleDeviation() const;
- void setAngleDeviation(qreal);
-
- qreal velocity() const;
- void setVelocity(qreal);
-
- qreal velocityDeviation() const;
- void setVelocityDeviation(qreal);
-
- QmlGraphicsParticleMotion *motion() const;
- void setMotion(QmlGraphicsParticleMotion *);
-
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
-
-public Q_SLOTS:
- void burst(int count, int emissionRate=-1);
-
-protected:
- virtual void componentComplete();
-
-Q_SIGNALS:
- void sourceChanged();
- void countChanged();
- void emissionRateChanged();
- void emissionVarianceChanged();
- void lifeSpanChanged();
- void lifeSpanDeviationChanged();
- void fadeInDurationChanged();
- void fadeOutDurationChanged();
- void angleChanged();
- void angleDeviationChanged();
- void velocityChanged();
- void velocityDeviationChanged();
- void emittingChanged();
- void motionChanged();
-
-private Q_SLOTS:
- void imageLoaded();
-
-private:
- Q_DISABLE_COPY(QmlGraphicsParticles)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsParticles)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsParticleMotion)
-QML_DECLARE_TYPE(QmlGraphicsParticleMotionLinear)
-QML_DECLARE_TYPE(QmlGraphicsParticleMotionGravity)
-QML_DECLARE_TYPE(QmlGraphicsParticleMotionWander)
-QML_DECLARE_TYPE(QmlGraphicsParticles)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicspath.cpp b/src/declarative/graphicsitems/qmlgraphicspath.cpp
deleted file mode 100644
index 0da246f..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspath.cpp
+++ /dev/null
@@ -1,849 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicspath_p.h"
-#include "qmlgraphicspath_p_p.h"
-
-#include <qfxperf_p_p.h>
-
-#include <QSet>
-
-#include <private/qbezier_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass PathElement QmlGraphicsPathElement
- \since 4.7
- \brief PathElement is the base path type.
-
- This type is the base for all path types. It cannot
- be instantiated.
-
- \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic
-*/
-
-/*!
- \internal
- \class QmlGraphicsPathElement
- \ingroup group_utility
-*/
-
-/*!
- \qmlclass Path QmlGraphicsPath
- \since 4.7
- \brief A Path object defines a path for use by \l PathView.
-
- A Path is composed of one or more path segments - PathLine, PathQuad,
- PathCubic.
-
- The spacing of the items along the Path can be adjusted via a
- PathPercent object.
-
- PathAttribute allows named attributes with values to be defined
- along the path.
-
- \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic
-*/
-
-/*!
- \internal
- \class QmlGraphicsPath
- \ingroup group_utility
- \brief The QmlGraphicsPath class defines a path.
- \sa QmlGraphicsPathView
-*/
-QmlGraphicsPath::QmlGraphicsPath(QObject *parent)
- : QObject(*(new QmlGraphicsPathPrivate), parent)
-{
-}
-
-QmlGraphicsPath::~QmlGraphicsPath()
-{
-}
-
-/*!
- \qmlproperty real Path::startX
- \qmlproperty real Path::startY
- These properties hold the starting position of the path.
-*/
-qreal QmlGraphicsPath::startX() const
-{
- Q_D(const QmlGraphicsPath);
- return d->startX;
-}
-
-void QmlGraphicsPath::setStartX(qreal x)
-{
- Q_D(QmlGraphicsPath);
- d->startX = x;
-}
-
-qreal QmlGraphicsPath::startY() const
-{
- Q_D(const QmlGraphicsPath);
- return d->startY;
-}
-
-void QmlGraphicsPath::setStartY(qreal y)
-{
- Q_D(QmlGraphicsPath);
- d->startY = y;
-}
-
-/*!
- \qmlproperty bool Path::closed
- This property holds whether the start and end of the path are identical.
-*/
-bool QmlGraphicsPath::isClosed() const
-{
- Q_D(const QmlGraphicsPath);
- return d->closed;
-}
-
-/*!
- \qmlproperty list<PathElement> Path::pathElements
- This property holds the objects composing the path.
-
- \default
-
- A path can contain the following path objects:
- \list
- \i \l PathLine - a straight line to a given position.
- \i \l PathQuad - a quadratic Bezier curve to a given position with a control point.
- \i \l PathCubic - a cubic Bezier curve to a given position with two control points.
- \i \l PathAttribute - an attribute at a given position in the path.
- \i \l PathPercent - a way to spread out items along various segments of the path.
- \endlist
-
- \snippet doc/src/snippets/declarative/pathview/pathattributes.qml 2
-*/
-
-QmlListProperty<QmlGraphicsPathElement> QmlGraphicsPath::pathElements()
-{
- Q_D(QmlGraphicsPath);
- return QmlListProperty<QmlGraphicsPathElement>(this, d->_pathElements);
-}
-
-void QmlGraphicsPath::interpolate(int idx, const QString &name, qreal value)
-{
- Q_D(QmlGraphicsPath);
- if (!idx)
- return;
-
- qreal lastValue = 0;
- qreal lastPercent = 0;
- int search = idx - 1;
- while(search >= 0) {
- const AttributePoint &point = d->_attributePoints.at(search);
- if (point.values.contains(name)) {
- lastValue = point.values.value(name);
- lastPercent = point.origpercent;
- break;
- }
- --search;
- }
-
- ++search;
-
- const AttributePoint &curPoint = d->_attributePoints.at(idx);
-
- for (int ii = search; ii < idx; ++ii) {
- AttributePoint &point = d->_attributePoints[ii];
-
- qreal val = lastValue + (value - lastValue) * (point.origpercent - lastPercent) / (curPoint.origpercent - lastPercent);
- point.values.insert(name, val);
- }
-}
-
-void QmlGraphicsPath::endpoint(const QString &name)
-{
- Q_D(QmlGraphicsPath);
- const AttributePoint &first = d->_attributePoints.first();
- qreal val = first.values.value(name);
- for (int ii = d->_attributePoints.count() - 1; ii >= 0; ii--) {
- const AttributePoint &point = d->_attributePoints.at(ii);
- if (point.values.contains(name)) {
- for (int jj = ii + 1; jj < d->_attributePoints.count(); ++jj) {
- AttributePoint &setPoint = d->_attributePoints[jj];
- setPoint.values.insert(name, val);
- }
- return;
- }
- }
-}
-
-void QmlGraphicsPath::processPath()
-{
- Q_D(QmlGraphicsPath);
-
- d->_pointCache.clear();
- d->_attributePoints.clear();
- d->_path = QPainterPath();
-
- AttributePoint first;
- for (int ii = 0; ii < d->_attributes.count(); ++ii)
- first.values[d->_attributes.at(ii)] = 0;
- d->_attributePoints << first;
-
- d->_path.moveTo(d->startX, d->startY);
-
- QmlGraphicsCurve *lastCurve = 0;
- foreach (QmlGraphicsPathElement *pathElement, d->_pathElements) {
- if (QmlGraphicsCurve *curve = qobject_cast<QmlGraphicsCurve *>(pathElement)) {
- curve->addToPath(d->_path);
- AttributePoint p;
- p.origpercent = d->_path.length();
- d->_attributePoints << p;
- lastCurve = curve;
- } else if (QmlGraphicsPathAttribute *attribute = qobject_cast<QmlGraphicsPathAttribute *>(pathElement)) {
- AttributePoint &point = d->_attributePoints.last();
- point.values[attribute->name()] = attribute->value();
- interpolate(d->_attributePoints.count() - 1, attribute->name(), attribute->value());
- } else if (QmlGraphicsPathPercent *percent = qobject_cast<QmlGraphicsPathPercent *>(pathElement)) {
- AttributePoint &point = d->_attributePoints.last();
- point.values[QLatin1String("_qfx_percent")] = percent->value();
- interpolate(d->_attributePoints.count() - 1, QLatin1String("_qfx_percent"), percent->value());
- }
- }
-
- // Fixup end points
- const AttributePoint &last = d->_attributePoints.last();
- for (int ii = 0; ii < d->_attributes.count(); ++ii) {
- if (!last.values.contains(d->_attributes.at(ii)))
- endpoint(d->_attributes.at(ii));
- }
-
- // Adjust percent
- qreal length = d->_path.length();
- qreal prevpercent = 0;
- qreal prevorigpercent = 0;
- for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
- const AttributePoint &point = d->_attributePoints.at(ii);
- if (point.values.contains(QLatin1String("_qfx_percent"))) { //special string for QmlGraphicsPathPercent
- if ( ii > 0) {
- qreal scale = (d->_attributePoints[ii].origpercent/length - prevorigpercent) /
- (point.values.value(QLatin1String("_qfx_percent"))-prevpercent);
- d->_attributePoints[ii].scale = scale;
- }
- d->_attributePoints[ii].origpercent /= length;
- d->_attributePoints[ii].percent = point.values.value(QLatin1String("_qfx_percent"));
- prevorigpercent = d->_attributePoints[ii].origpercent;
- prevpercent = d->_attributePoints[ii].percent;
- } else {
- d->_attributePoints[ii].origpercent /= length;
- d->_attributePoints[ii].percent = d->_attributePoints[ii].origpercent;
- }
- }
-
- d->closed = lastCurve && d->startX == lastCurve->x() && d->startY == lastCurve->y();
-
- emit changed();
-}
-
-void QmlGraphicsPath::componentComplete()
-{
- Q_D(QmlGraphicsPath);
- QSet<QString> attrs;
- // First gather up all the attributes
- foreach (QmlGraphicsPathElement *pathElement, d->_pathElements) {
- if (QmlGraphicsPathAttribute *attribute =
- qobject_cast<QmlGraphicsPathAttribute *>(pathElement))
- attrs.insert(attribute->name());
- }
- d->_attributes = attrs.toList();
-
- processPath();
-
- foreach (QmlGraphicsPathElement *pathElement, d->_pathElements)
- connect(pathElement, SIGNAL(changed()), this, SLOT(processPath()));
-}
-
-QPainterPath QmlGraphicsPath::path() const
-{
- Q_D(const QmlGraphicsPath);
- return d->_path;
-}
-
-QStringList QmlGraphicsPath::attributes() const
-{
- Q_D(const QmlGraphicsPath);
- return d->_attributes;
-}
-#include <QTime>
-
-static inline QBezier nextBezier(const QPainterPath &path, int *from, qreal *bezLength)
-{
- const int lastElement = path.elementCount() - 1;
- for (int i=*from; i <= lastElement; ++i) {
- const QPainterPath::Element &e = path.elementAt(i);
-
- switch (e.type) {
- case QPainterPath::MoveToElement:
- break;
- case QPainterPath::LineToElement:
- {
- QLineF line(path.elementAt(i-1), e);
- *bezLength = line.length();
- QPointF a = path.elementAt(i-1);
- QPointF delta = e - a;
- *from = i+1;
- return QBezier::fromPoints(a, a + delta / 3, a + 2 * delta / 3, e);
- }
- case QPainterPath::CurveToElement:
- {
- QBezier b = QBezier::fromPoints(path.elementAt(i-1),
- e,
- path.elementAt(i+1),
- path.elementAt(i+2));
- *bezLength = b.length();
- *from = i+3;
- return b;
- }
- default:
- break;
- }
- }
- *from = lastElement;
- *bezLength = 0;
- return QBezier();
-}
-
-void QmlGraphicsPath::createPointCache() const
-{
- Q_D(const QmlGraphicsPath);
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::QmlGraphicsPathViewPathCache> pc;
-#endif
- qreal pathLength = d->_path.length();
- const int points = int(pathLength*2);
- const int lastElement = d->_path.elementCount() - 1;
- d->_pointCache.resize(points+1);
-
- int currElement = 0;
- qreal bezLength = 0;
- QBezier currBez = nextBezier(d->_path, &currElement, &bezLength);
- qreal currLength = bezLength;
- qreal epc = currLength / pathLength;
-
- for (int i = 0; i < d->_pointCache.size(); i++) {
- //find which set we are in
- qreal prevPercent = 0;
- qreal prevOrigPercent = 0;
- for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
- qreal percent = qreal(i)/points;
- const AttributePoint &point = d->_attributePoints.at(ii);
- if (percent < point.percent || ii == d->_attributePoints.count() - 1) { //### || is special case for very last item
- qreal elementPercent = (percent - prevPercent);
-
- qreal spc = prevOrigPercent + elementPercent * point.scale;
-
- while (spc > epc) {
- if (currElement > lastElement)
- break;
- currBez = nextBezier(d->_path, &currElement, &bezLength);
- if (bezLength == 0.0) {
- currLength = pathLength;
- epc = 1.0;
- break;
- }
- currLength += bezLength;
- epc = currLength / pathLength;
- }
- qreal realT = (pathLength * spc - (currLength - bezLength)) / bezLength;
- d->_pointCache[i] = currBez.pointAt(qBound(qreal(0), realT, qreal(1)));
- break;
- }
- prevOrigPercent = point.origpercent;
- prevPercent = point.percent;
- }
- }
-}
-
-QPointF QmlGraphicsPath::pointAt(qreal p) const
-{
- Q_D(const QmlGraphicsPath);
- if (d->_pointCache.isEmpty()) {
- createPointCache();
- }
- int idx = qRound(p*d->_pointCache.size());
- if (idx >= d->_pointCache.size())
- idx = d->_pointCache.size() - 1;
- else if (idx < 0)
- idx = 0;
- return d->_pointCache.at(idx);
-}
-
-qreal QmlGraphicsPath::attributeAt(const QString &name, qreal percent) const
-{
- Q_D(const QmlGraphicsPath);
- if (percent < 0 || percent > 1)
- return 0;
-
- for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
- const AttributePoint &point = d->_attributePoints.at(ii);
-
- if (point.percent == percent) {
- return point.values.value(name);
- } else if (point.percent > percent) {
- qreal lastValue =
- ii?(d->_attributePoints.at(ii - 1).values.value(name)):0;
- qreal lastPercent =
- ii?(d->_attributePoints.at(ii - 1).percent):0;
- qreal curValue = point.values.value(name);
- qreal curPercent = point.percent;
-
- return lastValue + (curValue - lastValue) * (percent - lastPercent) / (curPercent - lastPercent);
- }
- }
-
- return 0;
-}
-
-/****************************************************************************/
-
-qreal QmlGraphicsCurve::x() const
-{
- return _x;
-}
-
-void QmlGraphicsCurve::setX(qreal x)
-{
- if (_x != x) {
- _x = x;
- emit changed();
- }
-}
-
-qreal QmlGraphicsCurve::y() const
-{
- return _y;
-}
-
-void QmlGraphicsCurve::setY(qreal y)
-{
- if (_y != y) {
- _y = y;
- emit changed();
- }
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathAttribute QmlGraphicsPathAttribute
- \since 4.7
- \brief The PathAttribute allows setting an attribute at a given position in a Path.
-
- The PathAttribute object allows attibutes consisting of a name and
- a value to be specified for the endpoints of path segments. The
- attributes are exposed to the delegate as
- \l{qmlintroduction.html#attached-properties} {Attached Properties}.
- The value of an attribute at any particular point is interpolated
- from the PathAttributes bounding the point.
-
- The example below shows a path with the items scaled to 30% with
- opacity 50% at the top of the path and scaled 100% with opacity
- 100% at the bottom. Note the use of the PathView.scale and
- PathView.opacity attached properties to set the scale and opacity
- of the delegate.
-
- \table
- \row
- \o \image declarative-pathattribute.png
- \o
- \snippet doc/src/snippets/declarative/pathview/pathattributes.qml 0
- \endtable
-
- \sa Path
-*/
-
-/*!
- \internal
- \class QmlGraphicsPathAttribute
- \ingroup group_utility
- \brief The QmlGraphicsPathAttribute class allows to set the value of an attribute at a given position in the path.
-
- \sa QmlGraphicsPath
-*/
-
-
-/*!
- \qmlproperty string PathAttribute::name
- the name of the attribute to change.
-*/
-
-/*!
- the name of the attribute to change.
-*/
-
-QString QmlGraphicsPathAttribute::name() const
-{
- return _name;
-}
-
-void QmlGraphicsPathAttribute::setName(const QString &name)
-{
- _name = name;
-}
-
-/*!
- \qmlproperty string PathAttribute::value
- the new value of the attribute.
-*/
-
-/*!
- the new value of the attribute.
-*/
-qreal QmlGraphicsPathAttribute::value() const
-{
- return _value;
-}
-
-void QmlGraphicsPathAttribute::setValue(qreal value)
-{
- if (_value != value) {
- _value = value;
- emit changed();
- }
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathLine QmlGraphicsPathLine
- \since 4.7
- \brief The PathLine defines a straight line.
-
- The example below creates a path consisting of a straight line from
- 0,100 to 200,100:
-
- \qml
- Path {
- startX: 0; startY: 100
- PathLine { x: 200; y: 100 }
- }
- \endqml
-
- \sa Path, PathQuad, PathCubic
-*/
-
-/*!
- \internal
- \class QmlGraphicsPathLine
- \ingroup group_utility
- \brief The QmlGraphicsPathLine class defines a straight line.
-
- \sa QmlGraphicsPath
-*/
-
-/*!
- \qmlproperty real PathLine::x
- \qmlproperty real PathLine::y
-
- Defines the end point of the line.
-*/
-
-void QmlGraphicsPathLine::addToPath(QPainterPath &path)
-{
- path.lineTo(x(), y());
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathQuad QmlGraphicsPathQuad
- \since 4.7
- \brief The PathQuad defines a quadratic Bezier curve with a control point.
-
- The following QML produces the path shown below:
- \table
- \row
- \o \image declarative-pathquad.png
- \o
- \qml
- Path {
- startX: 0; startY: 0
- PathQuad x: 200; y: 0; controlX: 100; controlY: 150 }
- }
- \endqml
- \endtable
-
- \sa Path, PathCubic, PathLine
-*/
-
-/*!
- \internal
- \class QmlGraphicsPathQuad
- \ingroup group_utility
- \brief The QmlGraphicsPathQuad class defines a quadratic Bezier curve with a control point.
-
- \sa QmlGraphicsPath
-*/
-
-
-/*!
- \qmlproperty real PathQuad::x
- \qmlproperty real PathQuad::y
-
- Defines the end point of the curve.
-*/
-
-/*!
- \qmlproperty real PathQuad::controlX
- \qmlproperty real PathQuad::controlY
-
- Defines the position of the control point.
-*/
-
-/*!
- the x position of the control point.
-*/
-qreal QmlGraphicsPathQuad::controlX() const
-{
- return _controlX;
-}
-
-void QmlGraphicsPathQuad::setControlX(qreal x)
-{
- if (_controlX != x) {
- _controlX = x;
- emit changed();
- }
-}
-
-
-/*!
- the y position of the control point.
-*/
-qreal QmlGraphicsPathQuad::controlY() const
-{
- return _controlY;
-}
-
-void QmlGraphicsPathQuad::setControlY(qreal y)
-{
- if (_controlY != y) {
- _controlY = y;
- emit changed();
- }
-}
-
-void QmlGraphicsPathQuad::addToPath(QPainterPath &path)
-{
- path.quadTo(controlX(), controlY(), x(), y());
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathCubic QmlGraphicsPathCubic
- \since 4.7
- \brief The PathCubic defines a cubic Bezier curve with two control points.
-
- The following QML produces the path shown below:
- \table
- \row
- \o \image declarative-pathcubic.png
- \o
- \qml
- Path {
- startX: 20; startY: 0
- PathCubic {
- x: 180; y: 0; control1X: -10; control1Y: 90
- control2X: 210; control2Y: 90
- }
- }
- \endqml
- \endtable
-
- \sa Path, PathQuad, PathLine
-*/
-
-/*!
- \internal
- \class QmlGraphicsPathCubic
- \ingroup group_utility
- \brief The QmlGraphicsPathCubic class defines a cubic Bezier curve with two control points.
-
- \sa QmlGraphicsPath
-*/
-
-/*!
- \qmlproperty real PathCubic::x
- \qmlproperty real PathCubic::y
-
- Defines the end point of the curve.
-*/
-
-/*!
- \qmlproperty real PathCubic::control1X
- \qmlproperty real PathCubic::control1Y
-
- Defines the position of the first control point.
-*/
-qreal QmlGraphicsPathCubic::control1X() const
-{
- return _control1X;
-}
-
-void QmlGraphicsPathCubic::setControl1X(qreal x)
-{
- if (_control1X != x) {
- _control1X = x;
- emit changed();
- }
-}
-
-qreal QmlGraphicsPathCubic::control1Y() const
-{
- return _control1Y;
-}
-
-void QmlGraphicsPathCubic::setControl1Y(qreal y)
-{
- if (_control1Y != y) {
- _control1Y = y;
- emit changed();
- }
-}
-
-/*!
- \qmlproperty real PathCubic::control2X
- \qmlproperty real PathCubic::control2Y
-
- Defines the position of the second control point.
-*/
-qreal QmlGraphicsPathCubic::control2X() const
-{
- return _control2X;
-}
-
-void QmlGraphicsPathCubic::setControl2X(qreal x)
-{
- if (_control2X != x) {
- _control2X = x;
- emit changed();
- }
-}
-
-qreal QmlGraphicsPathCubic::control2Y() const
-{
- return _control2Y;
-}
-
-void QmlGraphicsPathCubic::setControl2Y(qreal y)
-{
- if (_control2Y != y) {
- _control2Y = y;
- emit changed();
- }
-}
-
-void QmlGraphicsPathCubic::addToPath(QPainterPath &path)
-{
- path.cubicTo(control1X(), control1Y(), control2X(), control2Y(), x(), y());
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathPercent QmlGraphicsPathPercent
- \since 4.7
- \brief The PathPercent manipulates the way a path is interpreted.
-
- The examples below show the normal distrubution of items along a path
- compared to a distribution which places 50% of the items along the
- PathLine section of the path.
- \table
- \row
- \o \image declarative-nopercent.png
- \o
- \qml
- Path {
- startX: 20; startY: 0
- PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 }
- PathLine { x: 150; y: 80 }
- PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 }
- }
- \endqml
- \row
- \o \image declarative-percent.png
- \o
- \qml
- Path {
- startX: 20; startY: 0
- PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 }
- PathPercent { value: 0.25 }
- PathLine { x: 150; y: 80 }
- PathPercent { value: 0.75 }
- PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 }
- PathPercent { value: 1 }
- }
- \endqml
- \endtable
-
- \sa Path
-*/
-
-/*!
- \internal
- \class QmlGraphicsPathPercent
- \ingroup group_utility
- \brief The QmlGraphicsPathPercent class manipulates the way a path is interpreted.
-
- QmlGraphicsPathPercent allows you to bunch up items (or spread out items) along various
- segments of a QmlGraphicsPathView's path.
-
- \sa QmlGraphicsPath
-
-*/
-
-qreal QmlGraphicsPathPercent::value() const
-{
- return _value;
-}
-
-void QmlGraphicsPathPercent::setValue(qreal value)
-{
- _value = value;
-}
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicspath_p.h b/src/declarative/graphicsitems/qmlgraphicspath_p.h
deleted file mode 100644
index 7ba5bbc..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspath_p.h
+++ /dev/null
@@ -1,262 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSPATH_H
-#define QMLGRAPHICSPATH_H
-
-#include "qmlgraphicsitem.h"
-
-#include <qml.h>
-
-#include <QtCore/QObject>
-#include <QtGui/QPainterPath>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class Q_DECLARATIVE_EXPORT QmlGraphicsPathElement : public QObject
-{
- Q_OBJECT
-public:
- QmlGraphicsPathElement(QObject *parent=0) : QObject(parent) {}
-Q_SIGNALS:
- void changed();
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsPathAttribute : public QmlGraphicsPathElement
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY changed)
-public:
- QmlGraphicsPathAttribute(QObject *parent=0) : QmlGraphicsPathElement(parent), _value(0) {}
-
-
- QString name() const;
- void setName(const QString &name);
-
- qreal value() const;
- void setValue(qreal value);
-
-private:
- QString _name;
- qreal _value;
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsCurve : public QmlGraphicsPathElement
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal x READ x WRITE setX NOTIFY changed)
- Q_PROPERTY(qreal y READ y WRITE setY NOTIFY changed)
-public:
- QmlGraphicsCurve(QObject *parent=0) : QmlGraphicsPathElement(parent), _x(0), _y(0) {}
-
- qreal x() const;
- void setX(qreal x);
-
- qreal y() const;
- void setY(qreal y);
-
- virtual void addToPath(QPainterPath &) {}
-
-private:
- qreal _x;
- qreal _y;
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsPathLine : public QmlGraphicsCurve
-{
- Q_OBJECT
-public:
- QmlGraphicsPathLine(QObject *parent=0) : QmlGraphicsCurve(parent) {}
-
- void addToPath(QPainterPath &path);
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsPathQuad : public QmlGraphicsCurve
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal controlX READ controlX WRITE setControlX NOTIFY changed)
- Q_PROPERTY(qreal controlY READ controlY WRITE setControlY NOTIFY changed)
-public:
- QmlGraphicsPathQuad(QObject *parent=0) : QmlGraphicsCurve(parent), _controlX(0), _controlY(0) {}
-
- qreal controlX() const;
- void setControlX(qreal x);
-
- qreal controlY() const;
- void setControlY(qreal y);
-
- void addToPath(QPainterPath &path);
-
-private:
- qreal _controlX;
- qreal _controlY;
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsPathCubic : public QmlGraphicsCurve
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal control1X READ control1X WRITE setControl1X NOTIFY changed)
- Q_PROPERTY(qreal control1Y READ control1Y WRITE setControl1Y NOTIFY changed)
- Q_PROPERTY(qreal control2X READ control2X WRITE setControl2X NOTIFY changed)
- Q_PROPERTY(qreal control2Y READ control2Y WRITE setControl2Y NOTIFY changed)
-public:
- QmlGraphicsPathCubic(QObject *parent=0) : QmlGraphicsCurve(parent), _control1X(0), _control1Y(0), _control2X(0), _control2Y(0) {}
-
- qreal control1X() const;
- void setControl1X(qreal x);
-
- qreal control1Y() const;
- void setControl1Y(qreal y);
-
- qreal control2X() const;
- void setControl2X(qreal x);
-
- qreal control2Y() const;
- void setControl2Y(qreal y);
-
- void addToPath(QPainterPath &path);
-
-private:
- int _control1X;
- int _control1Y;
- int _control2X;
- int _control2Y;
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsPathPercent : public QmlGraphicsPathElement
-{
- Q_OBJECT
- Q_PROPERTY(qreal value READ value WRITE setValue)
-public:
- QmlGraphicsPathPercent(QObject *parent=0) : QmlGraphicsPathElement(parent) {}
-
- qreal value() const;
- void setValue(qreal value);
-
-private:
- qreal _value;
-};
-
-class QmlGraphicsPathPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsPath : public QObject, public QmlParserStatus
-{
- Q_OBJECT
-
- Q_INTERFACES(QmlParserStatus)
- Q_PROPERTY(QmlListProperty<QmlGraphicsPathElement> pathElements READ pathElements)
- Q_PROPERTY(qreal startX READ startX WRITE setStartX)
- Q_PROPERTY(qreal startY READ startY WRITE setStartY)
- Q_PROPERTY(bool closed READ isClosed NOTIFY changed)
- Q_CLASSINFO("DefaultProperty", "pathElements")
- Q_INTERFACES(QmlParserStatus)
-public:
- QmlGraphicsPath(QObject *parent=0);
- ~QmlGraphicsPath();
-
- QmlListProperty<QmlGraphicsPathElement> pathElements();
-
- qreal startX() const;
- void setStartX(qreal x);
-
- qreal startY() const;
- void setStartY(qreal y);
-
- bool isClosed() const;
-
- QPainterPath path() const;
- QStringList attributes() const;
- qreal attributeAt(const QString &, qreal) const;
- QPointF pointAt(qreal) const;
-
-Q_SIGNALS:
- void changed();
-
-protected:
- virtual void componentComplete();
-
-private Q_SLOTS:
- void processPath();
-
-private:
- struct AttributePoint {
- AttributePoint() : percent(0), scale(1), origpercent(0) {}
- AttributePoint(const AttributePoint &other)
- : percent(other.percent), scale(other.scale), origpercent(other.origpercent), values(other.values) {}
- AttributePoint &operator=(const AttributePoint &other) {
- percent = other.percent; scale = other.scale; origpercent = other.origpercent; values = other.values; return *this;
- }
- qreal percent; //massaged percent along the painter path
- qreal scale;
- qreal origpercent; //'real' percent along the painter path
- QHash<QString, qreal> values;
- };
-
- void interpolate(int idx, const QString &name, qreal value);
- void endpoint(const QString &name);
- void createPointCache() const;
-
-private:
- Q_DISABLE_COPY(QmlGraphicsPath)
- Q_DECLARE_PRIVATE(QmlGraphicsPath)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsPathElement)
-QML_DECLARE_TYPE(QmlGraphicsPathAttribute)
-QML_DECLARE_TYPE(QmlGraphicsCurve)
-QML_DECLARE_TYPE(QmlGraphicsPathLine)
-QML_DECLARE_TYPE(QmlGraphicsPathQuad)
-QML_DECLARE_TYPE(QmlGraphicsPathCubic)
-QML_DECLARE_TYPE(QmlGraphicsPathPercent)
-QML_DECLARE_TYPE(QmlGraphicsPath)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSPATH_H
diff --git a/src/declarative/graphicsitems/qmlgraphicspath_p_p.h b/src/declarative/graphicsitems/qmlgraphicspath_p_p.h
deleted file mode 100644
index acff7c8..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspath_p_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSPATH_P_H
-#define QMLGRAPHICSPATH_P_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 "qmlgraphicspath_p.h"
-
-#include <qml.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-class QmlGraphicsPathPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsPath)
-
-public:
- QmlGraphicsPathPrivate() : startX(0), startY(0), closed(false) { }
-
- QPainterPath _path;
- QList<QmlGraphicsPathElement*> _pathElements;
- mutable QVector<QPointF> _pointCache;
- QList<QmlGraphicsPath::AttributePoint> _attributePoints;
- QStringList _attributes;
- int startX;
- int startY;
- bool closed;
-};
-
-QT_END_NAMESPACE
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
deleted file mode 100644
index 9a2c24d..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp
+++ /dev/null
@@ -1,979 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicspathview_p.h"
-#include "qmlgraphicspathview_p_p.h"
-
-#include <qmlstate_p.h>
-#include <qmlopenmetaobject_p.h>
-
-#include <QDebug>
-#include <QEvent>
-#include <qlistmodelinterface_p.h>
-#include <QGraphicsSceneEvent>
-
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-inline qreal qmlMod(qreal x, qreal y)
-{
-#ifdef QT_USE_MATH_H_FLOATS
- if(sizeof(qreal) == sizeof(float))
- return fmodf(float(x), float(y));
- else
-#endif
- return fmod(x, y);
-}
-
-
-class QmlGraphicsPathViewAttached : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool onPath READ isOnPath NOTIFY onPathChanged)
-public:
- QmlGraphicsPathViewAttached(QObject *parent)
- : QObject(parent), mo(new QmlOpenMetaObject(this)), onPath(false)
- {
- }
-
- ~QmlGraphicsPathViewAttached()
- {
- QmlGraphicsPathView::attachedProperties.remove(parent());
- }
-
- QVariant value(const QByteArray &name) const
- {
- return mo->value(name);
- }
- void setValue(const QByteArray &name, const QVariant &val)
- {
- mo->setValue(name, val);
- }
-
- bool isOnPath() const { return onPath; }
- void setOnPath(bool on) {
- if (on != onPath) {
- onPath = on;
- emit onPathChanged();
- }
- }
-
-Q_SIGNALS:
- void onPathChanged();
-
-private:
- QmlOpenMetaObject *mo;
- bool onPath;
-};
-
-
-QmlGraphicsItem *QmlGraphicsPathViewPrivate::getItem(int modelIndex)
-{
- Q_Q(QmlGraphicsPathView);
- requestedIndex = modelIndex;
- QmlGraphicsItem *item = model->item(modelIndex);
- if (item) {
- if (QObject *obj = QmlGraphicsPathView::qmlAttachedProperties(item))
- static_cast<QmlGraphicsPathViewAttached *>(obj)->setOnPath(true);
- item->setParentItem(q);
- }
- requestedIndex = -1;
- return item;
-}
-
-void QmlGraphicsPathViewPrivate::releaseItem(QmlGraphicsItem *item)
-{
- if (!item || !model)
- return;
- if (QObject *obj = QmlGraphicsPathView::qmlAttachedProperties(item))
- static_cast<QmlGraphicsPathViewAttached *>(obj)->setOnPath(false);
- if (model->release(item) == 0) {
- if (QObject *obj = QmlGraphicsPathView::qmlAttachedProperties(item))
- static_cast<QmlGraphicsPathViewAttached *>(obj)->setOnPath(false);
- }
-}
-
-/*!
- \qmlclass PathView QmlGraphicsPathView
- \since 4.7
- \brief The PathView element lays out model-provided items on a path.
- \inherits Item
-
- The model is typically provided by a QAbstractListModel "C++ model object", but can also be created directly in QML.
-
- The items are laid out along a path defined by a \l Path and may be flicked to scroll.
-
- \snippet doc/src/snippets/declarative/pathview/pathview.qml 0
-
- \image pathview.gif
-
- \sa Path
-*/
-
-QmlGraphicsPathView::QmlGraphicsPathView(QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsPathViewPrivate), parent)
-{
- Q_D(QmlGraphicsPathView);
- d->init();
-}
-
-QmlGraphicsPathView::~QmlGraphicsPathView()
-{
- Q_D(QmlGraphicsPathView);
- if (d->ownModel)
- delete d->model;
-}
-
-/*!
- \qmlattachedproperty bool PathView::onPath
- This attached property holds whether the item is currently on the path.
-
- If a pathItemCount has been set, it is possible that some items may
- be instantiated, but not considered to be currently on the path.
- Usually, these items would be set invisible, for example:
-
- \code
- Component {
- Rectangle {
- visible: PathView.onPath
- ...
- }
- }
- \endcode
-
- It is attached to each instance of the delegate.
-*/
-
-/*!
- \qmlproperty model PathView::model
- This property holds the model providing data for the view.
-
- The model provides a set of data that is used to create the items for the view.
- For large or dynamic datasets the model is usually provided by a C++ model object.
- Models can also be created directly in XML, using the ListModel element.
-
- \sa {qmlmodels}{Data Models}
-*/
-QVariant QmlGraphicsPathView::model() const
-{
- Q_D(const QmlGraphicsPathView);
- return d->modelVariant;
-}
-
-void QmlGraphicsPathView::setModel(const QVariant &model)
-{
- Q_D(QmlGraphicsPathView);
- if (d->model) {
- disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
- disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
- disconnect(d->model, SIGNAL(createdItem(int, QmlGraphicsItem*)), this, SLOT(createdItem(int,QmlGraphicsItem*)));
- for (int i=0; i<d->items.count(); i++){
- QmlGraphicsItem *p = d->items[i];
- d->model->release(p);
- }
- d->items.clear();
- }
-
- d->modelVariant = model;
- QObject *object = qvariant_cast<QObject*>(model);
- QmlGraphicsVisualModel *vim = 0;
- if (object && (vim = qobject_cast<QmlGraphicsVisualModel *>(object))) {
- if (d->ownModel) {
- delete d->model;
- d->ownModel = false;
- }
- d->model = vim;
- } else {
- if (!d->ownModel) {
- d->model = new QmlGraphicsVisualDataModel(qmlContext(this));
- d->ownModel = true;
- }
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model))
- dataModel->setModel(model);
- }
- if (d->model) {
- connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
- connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
- connect(d->model, SIGNAL(createdItem(int, QmlGraphicsItem*)), this, SLOT(createdItem(int,QmlGraphicsItem*)));
- }
- d->firstIndex = 0;
- d->pathOffset = 0;
- d->regenerate();
- d->fixOffset();
-}
-
-/*!
- \qmlproperty int PathView::count
- This property holds the number of items in the model.
-*/
-int QmlGraphicsPathView::count() const
-{
- Q_D(const QmlGraphicsPathView);
- return d->model ? d->model->count() : 0;
-}
-
-/*!
- \qmlproperty Path PathView::path
- \default
- This property holds the path used to lay out the items.
- For more information see the \l Path documentation.
-*/
-QmlGraphicsPath *QmlGraphicsPathView::path() const
-{
- Q_D(const QmlGraphicsPathView);
- return d->path;
-}
-
-void QmlGraphicsPathView::setPath(QmlGraphicsPath *path)
-{
- Q_D(QmlGraphicsPathView);
- d->path = path;
- connect(d->path, SIGNAL(changed()), this, SLOT(refill()));
- d->regenerate();
-}
-
-/*!
- \qmlproperty int PathView::currentIndex
- This property holds the index of the current item.
-*/
-int QmlGraphicsPathView::currentIndex() const
-{
- Q_D(const QmlGraphicsPathView);
- return d->currentIndex;
-}
-
-void QmlGraphicsPathView::setCurrentIndex(int idx)
-{
- Q_D(QmlGraphicsPathView);
- if (d->model && d->model->count())
- idx = qAbs(idx % d->model->count());
- if (d->model && idx != d->currentIndex) {
- d->currentIndex = idx;
- if (d->model->count()) {
- d->snapToCurrent();
- int itemIndex = (idx - d->firstIndex + d->model->count()) % d->model->count();
- if (itemIndex < d->items.count())
- d->items.at(itemIndex)->setFocus(true);
- }
- emit currentIndexChanged();
- }
-}
-
-/*!
- \qmlproperty real PathView::offset
-
- The offset specifies how far along the path the items are from their initial positions.
-*/
-qreal QmlGraphicsPathView::offset() const
-{
- Q_D(const QmlGraphicsPathView);
- return d->_offset;
-}
-
-void QmlGraphicsPathView::setOffset(qreal offset)
-{
- Q_D(QmlGraphicsPathView);
- d->setOffset(offset);
- d->updateCurrent();
-}
-
-void QmlGraphicsPathViewPrivate::setOffset(qreal o)
-{
- Q_Q(QmlGraphicsPathView);
- if (_offset != o) {
- _offset = qmlMod(o, qreal(100.0));
- if (_offset < 0)
- _offset = 100.0 + _offset;
- q->refill();
- }
-}
-
-/*!
- \qmlproperty real PathView::snapPosition
-
- This property determines the position (0-100) the nearest item will snap to.
-*/
-qreal QmlGraphicsPathView::snapPosition() const
-{
- Q_D(const QmlGraphicsPathView);
- return d->snapPos;
-}
-
-void QmlGraphicsPathView::setSnapPosition(qreal pos)
-{
- Q_D(QmlGraphicsPathView);
- d->snapPos = pos/100;
- d->fixOffset();
-}
-
-/*!
- \qmlproperty real PathView::dragMargin
- This property holds the maximum distance from the path that initiate mouse dragging.
-
- By default the path can only be dragged by clicking on an item. If
- dragMargin is greater than zero, a drag can be initiated by clicking
- within dragMargin pixels of the path.
-*/
-qreal QmlGraphicsPathView::dragMargin() const
-{
- Q_D(const QmlGraphicsPathView);
- return d->dragMargin;
-}
-
-void QmlGraphicsPathView::setDragMargin(qreal dragMargin)
-{
- Q_D(QmlGraphicsPathView);
- d->dragMargin = dragMargin;
-}
-
-/*!
- \qmlproperty component PathView::delegate
-
- The delegate provides a template defining each item instantiated by the view.
- The index is exposed as an accessible \c index property. Properties of the
- model are also available depending upon the type of \l {qmlmodels}{Data Model}.
-
- Note that the PathView will layout the items based on the size of the root
- item in the delegate.
-
- Here is an example delegate:
- \snippet doc/src/snippets/declarative/pathview/pathview.qml 1
-*/
-QmlComponent *QmlGraphicsPathView::delegate() const
-{
- Q_D(const QmlGraphicsPathView);
- if (d->model) {
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model))
- return dataModel->delegate();
- }
-
- return 0;
-}
-
-void QmlGraphicsPathView::setDelegate(QmlComponent *c)
-{
- Q_D(QmlGraphicsPathView);
- if (!d->ownModel) {
- d->model = new QmlGraphicsVisualDataModel(qmlContext(this));
- d->ownModel = true;
- }
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) {
- dataModel->setDelegate(c);
- d->regenerate();
- }
-}
-
-/*!
- \qmlproperty int PathView::pathItemCount
- This property holds the number of items visible on the path at any one time
-*/
-int QmlGraphicsPathView::pathItemCount() const
-{
- Q_D(const QmlGraphicsPathView);
- return d->pathItems;
-}
-
-void QmlGraphicsPathView::setPathItemCount(int i)
-{
- Q_D(QmlGraphicsPathView);
- if (i == d->pathItems)
- return;
- d->pathItems = i;
- d->regenerate();
-}
-
-QPointF QmlGraphicsPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
-{
- //XXX maybe do recursively at increasing resolution.
- qreal mindist = 1e10; // big number
- QPointF nearPoint = path->pointAt(0);
- qreal nearPc = 0;
- for (qreal i=1; i < 1000; i++) {
- QPointF pt = path->pointAt(i/1000.0);
- QPointF diff = pt - point;
- qreal dist = diff.x()*diff.x() + diff.y()*diff.y();
- if (dist < mindist) {
- nearPoint = pt;
- nearPc = i;
- mindist = dist;
- }
- }
-
- if (nearPercent)
- *nearPercent = nearPc / 10.0;
-
- return nearPoint;
-}
-
-
-void QmlGraphicsPathView::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsPathView);
- if (!d->items.count())
- return;
- QPointF scenePoint = mapToScene(event->pos());
- int idx = 0;
- for (; idx < d->items.count(); ++idx) {
- QRectF rect = d->items.at(idx)->boundingRect();
- rect = d->items.at(idx)->mapToScene(rect).boundingRect();
- if (rect.contains(scenePoint))
- break;
- }
- if (idx == d->items.count() && d->dragMargin == 0.) // didn't click on an item
- return;
-
- d->startPoint = d->pointNear(event->pos(), &d->startPc);
- if (idx == d->items.count()) {
- qreal distance = qAbs(event->pos().x() - d->startPoint.x()) + qAbs(event->pos().y() - d->startPoint.y());
- if (distance > d->dragMargin)
- return;
- }
-
- d->stealMouse = false;
- d->lastElapsed = 0;
- d->lastDist = 0;
- QmlGraphicsItemPrivate::start(d->lastPosTime);
- d->tl.clear();
-}
-
-void QmlGraphicsPathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsPathView);
- if (d->lastPosTime.isNull())
- return;
-
- if (!d->stealMouse) {
- QPointF delta = event->pos() - d->startPoint;
- if (qAbs(delta.x()) > QApplication::startDragDistance() && qAbs(delta.y()) > QApplication::startDragDistance())
- d->stealMouse = true;
- }
-
- if (d->stealMouse) {
- d->moveReason = QmlGraphicsPathViewPrivate::Mouse;
- qreal newPc;
- d->pointNear(event->pos(), &newPc);
- qreal diff = newPc - d->startPc;
- if (diff) {
- setOffset(d->_offset + diff);
-
- if (diff > 50)
- diff -= 100;
- else if (diff < -50)
- diff += 100;
-
- d->lastElapsed = QmlGraphicsItemPrivate::restart(d->lastPosTime);
- d->lastDist = diff;
- d->startPc = newPc;
- }
- }
-}
-
-void QmlGraphicsPathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
-{
- Q_D(QmlGraphicsPathView);
- if (d->lastPosTime.isNull())
- return;
-
- qreal elapsed = qreal(d->lastElapsed + QmlGraphicsItemPrivate::elapsed(d->lastPosTime)) / 1000.;
- qreal velocity = elapsed > 0. ? d->lastDist / elapsed : 0;
- if (d->model && d->model->count() && qAbs(velocity) > 5) {
- if (velocity > 100)
- velocity = 100;
- else if (velocity < -100)
- velocity = -100;
- qreal inc = qmlMod(d->_offset - d->snapPos, qreal(100.0 / d->model->count()));
- qreal dist = qAbs(velocity/2 - qmlMod(velocity/2, qreal(100.0 / d->model->count()) - inc));
- d->moveOffset.setValue(d->_offset);
- d->tl.accel(d->moveOffset, velocity, 10, dist);
- d->tl.callback(QmlTimeLineCallback(&d->moveOffset, d->fixOffsetCallback, d));
- } else {
- d->fixOffset();
- }
-
- d->lastPosTime = QTime();
- d->stealMouse = false;
- ungrabMouse();
-}
-
-bool QmlGraphicsPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsPathView);
- QGraphicsSceneMouseEvent mouseEvent(event->type());
- QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect();
- QGraphicsScene *s = scene();
- QmlGraphicsItem *grabber = s ? qobject_cast<QmlGraphicsItem*>(s->mouseGrabberItem()) : 0;
- if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
- mouseEvent.setAccepted(false);
- for (int i = 0x1; i <= 0x10; i <<= 1) {
- if (event->buttons() & i) {
- Qt::MouseButton button = Qt::MouseButton(i);
- mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button)));
- }
- }
- mouseEvent.setScenePos(event->scenePos());
- mouseEvent.setLastScenePos(event->lastScenePos());
- mouseEvent.setPos(mapFromScene(event->scenePos()));
- mouseEvent.setLastPos(mapFromScene(event->lastScenePos()));
-
- switch(mouseEvent.type()) {
- case QEvent::GraphicsSceneMouseMove:
- mouseMoveEvent(&mouseEvent);
- break;
- case QEvent::GraphicsSceneMousePress:
- mousePressEvent(&mouseEvent);
- break;
- case QEvent::GraphicsSceneMouseRelease:
- mouseReleaseEvent(&mouseEvent);
- break;
- default:
- break;
- }
- grabber = qobject_cast<QmlGraphicsItem*>(s->mouseGrabberItem());
- if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this)
- grabMouse();
-
- return d->stealMouse;
- } else if (!d->lastPosTime.isNull()) {
- d->lastPosTime = QTime();
- }
- return false;
-}
-
-bool QmlGraphicsPathView::sceneEventFilter(QGraphicsItem *i, QEvent *e)
-{
- if (!isVisible())
- return QmlGraphicsItem::sceneEventFilter(i, e);
-
- switch (e->type()) {
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseMove:
- case QEvent::GraphicsSceneMouseRelease:
- {
- bool ret = sendMouseEvent(static_cast<QGraphicsSceneMouseEvent *>(e));
- if (e->type() == QEvent::GraphicsSceneMouseRelease)
- return ret;
- break;
- }
- default:
- break;
- }
-
- return QmlGraphicsItem::sceneEventFilter(i, e);
-}
-
-void QmlGraphicsPathView::componentComplete()
-{
- Q_D(QmlGraphicsPathView);
- QmlGraphicsItem::componentComplete();
- d->regenerate();
-
- // move to correct offset
- if (d->items.count()) {
- int itemIndex = (d->currentIndex - d->firstIndex + d->model->count()) % d->model->count();
-
- itemIndex += d->pathOffset;
- itemIndex %= d->items.count();
- qreal targetOffset = qmlMod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0));
-
- if (targetOffset < 0)
- targetOffset = 100.0 + targetOffset;
- if (targetOffset != d->_offset) {
- d->moveOffset.setValue(targetOffset);
- }
- }
-}
-
-void QmlGraphicsPathViewPrivate::regenerate()
-{
- Q_Q(QmlGraphicsPathView);
- if (!q->isComponentComplete())
- return;
-
- for (int i=0; i<items.count(); i++){
- QmlGraphicsItem *p = items[i];
- releaseItem(p);
- }
- items.clear();
-
- if (!isValid())
- return;
-
- if (firstIndex >= model->count())
- firstIndex = model->count()-1;
- if (pathOffset >= model->count())
- pathOffset = model->count()-1;
-
- int numItems = pathItems >= 0 ? pathItems : model->count();
- for (int i=0; i < numItems && i < model->count(); ++i){
- int index = (i + firstIndex) % model->count();
- QmlGraphicsItem *item = getItem(index);
- if (!item) {
- qWarning() << "PathView: Cannot create item, index" << (i + firstIndex) % model->count();
- return;
- }
- items.append(item);
- item->setZValue(i);
- if (currentIndex == index)
- item->setFocus(true);
- }
- q->refill();
-}
-
-void QmlGraphicsPathViewPrivate::updateItem(QmlGraphicsItem *item, qreal percent)
-{
- if (QObject *obj = QmlGraphicsPathView::qmlAttachedProperties(item)) {
- foreach(const QString &attr, path->attributes())
- static_cast<QmlGraphicsPathViewAttached *>(obj)->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
- }
- QPointF pf = path->pointAt(percent);
- item->setX(pf.x() - item->width()*item->scale()/2);
- item->setY(pf.y() - item->height()*item->scale()/2);
-}
-
-void QmlGraphicsPathView::refill()
-{
- Q_D(QmlGraphicsPathView);
- if (!d->isValid() || !isComponentComplete())
- return;
-
- QList<qreal> positions;
- for (int i=0; i<d->items.count(); i++){
- qreal percent = i * (100. / d->items.count());
- percent = percent + d->_offset;
- percent = qmlMod(percent, qreal(100.0));
- positions << qAbs(percent/100.0);
- }
-
- if (d->pathItems==-1) {
- for (int i=0; i<positions.count(); i++)
- d->updateItem(d->items.at(i), positions[i]);
- return;
- }
-
- QList<qreal> rotatedPositions;
- for (int i=0; i<d->items.count(); i++)
- rotatedPositions << positions[(i + d->pathOffset + d->items.count()) % d->items.count()];
-
- int wrapIndex= -1;
- for (int i=0; i<d->items.count()-1; i++) {
- if (rotatedPositions[i] > rotatedPositions[i+1]){
- wrapIndex = i;
- break;
- }
- }
- if (wrapIndex != -1 ){
- //A wraparound has occured
- if (wrapIndex < d->items.count()/2){
- while(wrapIndex-- >= 0){
- QmlGraphicsItem* p = d->items.takeFirst();
- d->updateItem(p, 0.0);
- d->releaseItem(p);
- d->firstIndex++;
- d->firstIndex %= d->model->count();
- int index = (d->firstIndex + d->items.count())%d->model->count();
- QmlGraphicsItem *item = d->getItem(index);
- item->setZValue(wrapIndex);
- if (d->currentIndex == index)
- item->setFocus(true);
- d->items << item;
- d->pathOffset++;
- d->pathOffset=d->pathOffset % d->items.count();
- }
- } else {
- while(wrapIndex++ < d->items.count()-1){
- QmlGraphicsItem* p = d->items.takeLast();
- d->updateItem(p, 1.0);
- d->releaseItem(p);
- d->firstIndex--;
- if (d->firstIndex < 0)
- d->firstIndex = d->model->count() - 1;
- QmlGraphicsItem *item = d->getItem(d->firstIndex);
- item->setZValue(d->firstIndex);
- if (d->currentIndex == d->firstIndex)
- item->setFocus(true);
- d->items.prepend(item);
- d->pathOffset--;
- if (d->pathOffset < 0)
- d->pathOffset = d->items.count() - 1;
- }
- }
- for (int i=0; i<d->items.count(); i++)
- rotatedPositions[i] = positions[(i + d->pathOffset + d->items.count())
- % d->items.count()];
- }
- for (int i=0; i<d->items.count(); i++)
- d->updateItem(d->items.at(i), rotatedPositions[i]);
-}
-
-void QmlGraphicsPathView::itemsInserted(int modelIndex, int count)
-{
- //XXX support animated insertion
- Q_D(QmlGraphicsPathView);
- if (!d->isValid() || !isComponentComplete())
- return;
- if (d->pathItems == -1) {
- for (int i = 0; i < count; ++i) {
- QmlGraphicsItem *item = d->getItem(modelIndex + i);
- item->setZValue(modelIndex + i);
- d->items.insert(modelIndex + i, item);
- }
- refill();
- } else {
- //XXX This is pretty heavy handed until we reference count items.
- d->regenerate();
- }
-
- // make sure the current item is still at the snap position
- int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count();
- itemIndex += d->pathOffset;
- itemIndex %= d->items.count();
- qreal targetOffset = qmlMod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0));
-
- if (targetOffset < 0)
- targetOffset = 100.0 + targetOffset;
- if (targetOffset != d->_offset)
- d->moveOffset.setValue(targetOffset);
-}
-
-void QmlGraphicsPathView::itemsRemoved(int modelIndex, int count)
-{
- //XXX support animated removal
- Q_D(QmlGraphicsPathView);
- if (!d->isValid() || !isComponentComplete())
- return;
- if (d->pathItems == -1) {
- for (int i = 0; i < count; ++i) {
- QmlGraphicsItem* p = d->items.takeAt(modelIndex);
- d->model->release(p);
- }
- d->snapToCurrent();
- refill();
- } else {
- d->regenerate();
- }
-
- if (d->model->count() == 0) {
- d->currentIndex = -1;
- d->moveOffset.setValue(0);
- return;
- }
-
- // make sure the current item is still at the snap position
- if (d->currentIndex >= d->model->count())
- d->currentIndex = d->model->count() - 1;
- int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count();
- itemIndex += d->pathOffset;
- itemIndex %= d->items.count();
- qreal targetOffset = qmlMod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0));
-
- if (targetOffset < 0)
- targetOffset = 100.0 + targetOffset;
- if (targetOffset != d->_offset)
- d->moveOffset.setValue(targetOffset);
-}
-
-void QmlGraphicsPathView::createdItem(int index, QmlGraphicsItem *item)
-{
- Q_D(QmlGraphicsPathView);
- if (d->requestedIndex != index) {
- item->setParentItem(this);
- d->updateItem(item, index < d->firstIndex ? 0.0 : 1.0);
- }
-}
-
-void QmlGraphicsPathView::destroyingItem(QmlGraphicsItem *item)
-{
- Q_UNUSED(item);
-}
-
-void QmlGraphicsPathView::ticked()
-{
- Q_D(QmlGraphicsPathView);
- d->updateCurrent();
-}
-
-// find the item closest to the snap position
-int QmlGraphicsPathViewPrivate::calcCurrentIndex()
-{
- int current = -1;
- if (model && items.count()) {
- _offset = qmlMod(_offset, qreal(100.0));
- if (_offset < 0)
- _offset += 100.0;
-
- if (pathItems == -1) {
- qreal delta = qmlMod(_offset - snapPos, qreal(100.0));
- if (delta < 0)
- delta = 100.0 + delta;
- int ii = model->count() - qRound(delta * model->count() / 100);
- if (ii < 0)
- ii = 0;
- current = ii;
- } else {
- qreal bestDiff=1e9;
- int bestI=-1;
- for (int i=0; i<items.count(); i++){
- qreal percent = i * (100. / items.count());
- percent = percent + _offset;
- percent = qmlMod(percent, qreal(100.0));
- qreal diff = qAbs(snapPos - (percent/100.0));
- if (diff < bestDiff){
- bestDiff = diff;
- bestI = i;
- }
- }
- int modelIndex = (bestI - pathOffset + items.count())%items.count();
- modelIndex += firstIndex;
- current = modelIndex;
- }
- current = qAbs(current % model->count());
- }
-
- return current;
-}
-
-void QmlGraphicsPathViewPrivate::updateCurrent()
-{
- Q_Q(QmlGraphicsPathView);
- if (moveReason != Mouse)
- return;
- int idx = calcCurrentIndex();
- if (model && idx != currentIndex) {
- currentIndex = idx;
- int itemIndex = (idx - firstIndex + model->count()) % model->count();
- if (itemIndex < items.count())
- items.at(itemIndex)->setFocus(true);
- emit q->currentIndexChanged();
- }
-}
-
-void QmlGraphicsPathViewPrivate::fixOffsetCallback(void *d)
-{
- ((QmlGraphicsPathViewPrivate *)d)->fixOffset();
-}
-
-void QmlGraphicsPathViewPrivate::fixOffset()
-{
- Q_Q(QmlGraphicsPathView);
- if (model && items.count()) {
- int curr = calcCurrentIndex();
- if (curr != currentIndex)
- q->setCurrentIndex(curr);
- else
- snapToCurrent();
- }
-}
-
-void QmlGraphicsPathViewPrivate::snapToCurrent()
-{
- if (!model || model->count() <= 0)
- return;
-
- int itemIndex = (currentIndex - firstIndex + model->count()) % model->count();
-
- //Rounds is the number of times round to make the current item visible
- int rounds = itemIndex / items.count();
- int otherWayRounds = (model->count() - (itemIndex)) / items.count();
- if (otherWayRounds < rounds)
- rounds = -otherWayRounds;
-
- itemIndex += pathOffset;
- if(model->count() % items.count() && itemIndex - model->count() + items.count() > 0){
- //When model.count() is not a multiple of pathItemCount we need to manually
- //fix the index so that going backwards one step works correctly.
- itemIndex = itemIndex - model->count() + items.count();
- }
- itemIndex %= items.count();
- qreal targetOffset = qmlMod(100 + (snapPos*100) - 100.0 * itemIndex / items.count(), qreal(100.0));
-
- if (targetOffset < 0)
- targetOffset = 100.0 + targetOffset;
- if (targetOffset == _offset && rounds == 0)
- return;
-
- moveReason = Other;
- tl.clear();
- moveOffset.setValue(_offset);
-
- if (rounds!=0){
- //Compensate if the targetOffset would bring the target in from off the screen
- qreal distance = targetOffset - _offset;
- if (distance <= -50)
- rounds--;
- if (distance > 50)
- rounds++;
- tl.move(moveOffset, targetOffset + 100.0*(-rounds), QEasingCurve(QEasingCurve::InOutQuad),
- int(100*items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds))));
- tl.callback(QmlTimeLineCallback(&moveOffset, fixOffsetCallback, this));
- return;
- }
-
- if (targetOffset - _offset > 50.0) {
- qreal distance = 100 - targetOffset + _offset;
- tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * _offset / distance));
- tl.set(moveOffset, 100.0);
- tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * (100-targetOffset) / distance));
- } else if (targetOffset - _offset <= -50.0) {
- qreal distance = 100 - _offset + targetOffset;
- tl.move(moveOffset, 100.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * (100-_offset) / distance));
- tl.set(moveOffset, 0.0);
- tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * targetOffset / distance));
- } else {
- tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), 200);
- }
-}
-
-QHash<QObject*, QObject*> QmlGraphicsPathView::attachedProperties;
-QObject *QmlGraphicsPathView::qmlAttachedProperties(QObject *obj)
-{
- QObject *rv = attachedProperties.value(obj);
- if (!rv) {
- rv = new QmlGraphicsPathViewAttached(obj);
- attachedProperties.insert(obj, rv);
- }
- return rv;
-}
-
-QT_END_NAMESPACE
-
-#include <qmlgraphicspathview.moc>
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview_p.h b/src/declarative/graphicsitems/qmlgraphicspathview_p.h
deleted file mode 100644
index 8273ccc..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspathview_p.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSPATHVIEW_H
-#define QMLGRAPHICSPATHVIEW_H
-
-#include "qmlgraphicsitem.h"
-#include "qmlgraphicspath_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsPathViewPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsPathView : public QmlGraphicsItem
-{
- Q_OBJECT
-
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QmlGraphicsPath *path READ path WRITE setPath)
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
- Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
- Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition)
- Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin)
- Q_PROPERTY(int count READ count)
- Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
- Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount)
-
-public:
- QmlGraphicsPathView(QmlGraphicsItem *parent=0);
- virtual ~QmlGraphicsPathView();
-
- QVariant model() const;
- void setModel(const QVariant &);
-
- QmlGraphicsPath *path() const;
- void setPath(QmlGraphicsPath *);
-
- int currentIndex() const;
- void setCurrentIndex(int idx);
-
- qreal offset() const;
- void setOffset(qreal offset);
-
- qreal snapPosition() const;
- void setSnapPosition(qreal pos);
-
- qreal dragMargin() const;
- void setDragMargin(qreal margin);
-
- int count() const;
-
- QmlComponent *delegate() const;
- void setDelegate(QmlComponent *);
-
- int pathItemCount() const;
- void setPathItemCount(int);
-
- static QObject *qmlAttachedProperties(QObject *);
-
-Q_SIGNALS:
- void currentIndexChanged();
- void offsetChanged();
-
-protected:
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
- bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
- bool sceneEventFilter(QGraphicsItem *, QEvent *);
- void componentComplete();
-
-private Q_SLOTS:
- void refill();
- void ticked();
- void itemsInserted(int index, int count);
- void itemsRemoved(int index, int count);
- void createdItem(int index, QmlGraphicsItem *item);
- void destroyingItem(QmlGraphicsItem *item);
-
-private:
- friend class QmlGraphicsPathViewAttached;
- static QHash<QObject*, QObject*> attachedProperties;
- Q_DISABLE_COPY(QmlGraphicsPathView)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsPathView)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsPathView)
-QML_DECLARE_TYPEINFO(QmlGraphicsPathView, QML_HAS_ATTACHED_PROPERTIES)
-QT_END_HEADER
-
-#endif // QMLGRAPHICSPATHVIEW_H
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
deleted file mode 100644
index c635833..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSPATHVIEW_P_H
-#define QMLGRAPHICSPATHVIEW_P_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 "qmlgraphicspathview_p.h"
-
-#include "qmlgraphicsitem_p.h"
-#include "qmlgraphicsvisualitemmodel_p.h"
-
-#include <qml.h>
-#include <qmlanimation_p_p.h>
-
-#include <qdatetime.h>
-
-QT_BEGIN_NAMESPACE
-
-typedef struct PathViewItem{
- int index;
- QmlGraphicsItem* item;
-}PathViewItem;
-
-class QmlGraphicsPathViewPrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsPathView)
-
-public:
- QmlGraphicsPathViewPrivate()
- : path(0), currentIndex(0), startPc(0), lastDist(0)
- , lastElapsed(0), stealMouse(false), ownModel(false), activeItem(0)
- , snapPos(0), dragMargin(0), moveOffset(this, &QmlGraphicsPathViewPrivate::setOffset)
- , firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1)
- , moveReason(Other)
- {
- }
-
- void init()
- {
- Q_Q(QmlGraphicsPathView);
- _offset = 0;
- q->setAcceptedMouseButtons(Qt::LeftButton);
- q->setFlag(QGraphicsItem::ItemIsFocusScope);
- q->setFiltersChildEvents(true);
- q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked()));
- }
-
- QmlGraphicsItem *getItem(int modelIndex);
- void releaseItem(QmlGraphicsItem *item);
-
- bool isValid() const {
- return model && model->count() > 0 && model->isValid() && path;
- }
-
- int calcCurrentIndex();
- void updateCurrent();
- static void fixOffsetCallback(void*);
- void fixOffset();
- void setOffset(qreal offset);
- void regenerate();
- void updateItem(QmlGraphicsItem *, qreal);
- void snapToCurrent();
- QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const;
-
- QmlGraphicsPath *path;
- int currentIndex;
- qreal startPc;
- QPointF startPoint;
- qreal lastDist;
- int lastElapsed;
- qreal _offset;
- bool stealMouse : 1;
- bool ownModel : 1;
- QTime lastPosTime;
- QPointF lastPos;
- QmlGraphicsItem *activeItem;
- qreal snapPos;
- qreal dragMargin;
- QmlTimeLine tl;
- QmlTimeLineValueProxy<QmlGraphicsPathViewPrivate> moveOffset;
- int firstIndex;
- int pathItems;
- int pathOffset;
- int requestedIndex;
- QList<QmlGraphicsItem *> items;
- QGuard<QmlGraphicsVisualModel> model;
- QVariant modelVariant;
- enum MovementReason { Other, Key, Mouse };
- MovementReason moveReason;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
deleted file mode 100644
index fb71495..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
+++ /dev/null
@@ -1,891 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicspositioners_p.h"
-#include "qmlgraphicspositioners_p_p.h"
-
-#include <qml.h>
-#include <qmlstate_p.h>
-#include <qmlstategroup_p.h>
-#include <qmlstateoperations_p.h>
-#include <qfxperf_p_p.h>
-#include <QtCore/qmath.h>
-
-#include <QDebug>
-#include <QCoreApplication>
-
-QT_BEGIN_NAMESPACE
-
-static const QmlGraphicsItemPrivate::ChangeTypes watchedChanges
- = QmlGraphicsItemPrivate::Geometry
- | QmlGraphicsItemPrivate::SiblingOrder
- | QmlGraphicsItemPrivate::Visibility
- | QmlGraphicsItemPrivate::Opacity
- | QmlGraphicsItemPrivate::Destroyed;
-
-void QmlGraphicsBasePositionerPrivate::watchChanges(QmlGraphicsItem *other)
-{
- QmlGraphicsItemPrivate *otherPrivate = static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other));
- otherPrivate->addItemChangeListener(this, watchedChanges);
-}
-
-void QmlGraphicsBasePositionerPrivate::unwatchChanges(QmlGraphicsItem* other)
-{
- QmlGraphicsItemPrivate *otherPrivate = static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other));
- otherPrivate->removeItemChangeListener(this, watchedChanges);
-}
-
-/*!
- \internal
- \class QmlGraphicsBasePositioner
- \ingroup group_layouts
- \brief The QmlGraphicsBasePositioner class provides a base for QmlGraphics layouts.
-
- To create a QmlGraphics Positioner, simply subclass QmlGraphicsBasePositioner and implement
- doLayout(), which is automatically called when the layout might need
- updating. In doLayout() use the setX and setY functions from QmlBasePositioner, and the
- base class will apply the positions along with the appropriate transitions. The items to
- position are provided in order as the protected member positionedItems.
-
- You also need to set a PositionerType, to declare whether you are positioning the x, y or both
- for the child items. Depending on the chosen type, only x or y changes will be applied.
-
- Note that the subclass is responsible for adding the
- spacing in between items.
-*/
-QmlGraphicsBasePositioner::QmlGraphicsBasePositioner(PositionerType at, QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsBasePositionerPrivate), parent)
-{
- Q_D(QmlGraphicsBasePositioner);
- d->init(at);
-}
-
-QmlGraphicsBasePositioner::QmlGraphicsBasePositioner(QmlGraphicsBasePositionerPrivate &dd, PositionerType at, QmlGraphicsItem *parent)
- : QmlGraphicsItem(dd, parent)
-{
- Q_D(QmlGraphicsBasePositioner);
- d->init(at);
-}
-
-QmlGraphicsBasePositioner::~QmlGraphicsBasePositioner()
-{
- Q_D(QmlGraphicsBasePositioner);
- for (int i = 0; i < positionedItems.count(); ++i)
- d->unwatchChanges(positionedItems.at(i).item);
- positionedItems.clear();
-}
-
-int QmlGraphicsBasePositioner::spacing() const
-{
- Q_D(const QmlGraphicsBasePositioner);
- return d->spacing;
-}
-
-void QmlGraphicsBasePositioner::setSpacing(int s)
-{
- Q_D(QmlGraphicsBasePositioner);
- if (s==d->spacing)
- return;
- d->spacing = s;
- prePositioning();
- emit spacingChanged();
-}
-
-QmlTransition *QmlGraphicsBasePositioner::move() const
-{
- Q_D(const QmlGraphicsBasePositioner);
- return d->moveTransition;
-}
-
-void QmlGraphicsBasePositioner::setMove(QmlTransition *mt)
-{
- Q_D(QmlGraphicsBasePositioner);
- if (mt == d->moveTransition)
- return;
- d->moveTransition = mt;
- emit moveChanged();
-}
-
-QmlTransition *QmlGraphicsBasePositioner::add() const
-{
- Q_D(const QmlGraphicsBasePositioner);
- return d->addTransition;
-}
-
-void QmlGraphicsBasePositioner::setAdd(QmlTransition *add)
-{
- Q_D(QmlGraphicsBasePositioner);
- if (add == d->addTransition)
- return;
-
- d->addTransition = add;
- emit addChanged();
-}
-
-void QmlGraphicsBasePositioner::componentComplete()
-{
- Q_D(QmlGraphicsBasePositioner);
- QmlGraphicsItem::componentComplete();
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::BasepositionerComponentComplete> cc;
-#endif
- positionedItems.reserve(d->QGraphicsItemPrivate::children.count());
- prePositioning();
-}
-
-QVariant QmlGraphicsBasePositioner::itemChange(GraphicsItemChange change,
- const QVariant &value)
-{
- Q_D(QmlGraphicsBasePositioner);
- if (change == ItemChildAddedChange){
- QGraphicsItem* item = value.value<QGraphicsItem*>();
- QmlGraphicsItem* child = 0;
- if(item)
- child = qobject_cast<QmlGraphicsItem*>(item->toGraphicsObject());
- if (child)
- prePositioning();
- } else if (change == ItemChildRemovedChange) {
- QGraphicsItem* item = value.value<QGraphicsItem*>();
- QmlGraphicsItem* child = 0;
- if(item)
- child = qobject_cast<QmlGraphicsItem*>(item->toGraphicsObject());
- if (child) {
- QmlGraphicsBasePositioner::PositionedItem posItem(child);
- int idx = positionedItems.find(posItem);
- if (idx >= 0) {
- d->unwatchChanges(child);
- positionedItems.remove(idx);
- }
- prePositioning();
- }
- }
-
- return QmlGraphicsItem::itemChange(change, value);
-}
-
-void QmlGraphicsBasePositioner::prePositioning()
-{
- Q_D(QmlGraphicsBasePositioner);
- if (!isComponentComplete())
- return;
-
- d->queuedPositioning = false;
- //Need to order children by creation order modified by stacking order
- QList<QGraphicsItem *> children = d->QGraphicsItemPrivate::children;
- qSort(children.begin(), children.end(), d->insertionOrder);
-
- for (int ii = 0; ii < children.count(); ++ii) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(ii));
- if (!child)
- continue;
- PositionedItem *item = 0;
- PositionedItem posItem(child);
- int wIdx = positionedItems.find(posItem);
- if (wIdx < 0) {
- d->watchChanges(child);
- positionedItems.append(posItem);
- item = &positionedItems[positionedItems.count()-1];
- } else {
- item = &positionedItems[wIdx];
- }
- if (child->opacity() <= 0.0 || !child->isVisible()) {
- item->isVisible = false;
- continue;
- }
- if (!item->isVisible) {
- item->isVisible = true;
- item->isNew = true;
- } else {
- item->isNew = false;
- }
- }
- doPositioning();
- if(d->addTransition || d->moveTransition)
- finishApplyTransitions();
- //Set implicit size to the size of its children
- qreal h = 0.0f;
- qreal w = 0.0f;
- for (int i = 0; i < positionedItems.count(); ++i) {
- const PositionedItem &posItem = positionedItems.at(i);
- if (posItem.isVisible) {
- h = qMax(h, posItem.item->y() + posItem.item->height());
- w = qMax(w, posItem.item->x() + posItem.item->width());
- }
- }
- setImplicitHeight(h);
- setImplicitWidth(w);
-}
-
-void QmlGraphicsBasePositioner::positionX(int x, const PositionedItem &target)
-{
- Q_D(QmlGraphicsBasePositioner);
- if(d->type == Horizontal || d->type == Both){
- if(!d->addTransition && !d->moveTransition){
- target.item->setX(x);
- }else{
- if(target.isNew)
- d->addActions << QmlAction(target.item, QLatin1String("x"), QVariant(x));
- else
- d->moveActions << QmlAction(target.item, QLatin1String("x"), QVariant(x));
- }
- }
-}
-
-void QmlGraphicsBasePositioner::positionY(int y, const PositionedItem &target)
-{
- Q_D(QmlGraphicsBasePositioner);
- if(d->type == Vertical || d->type == Both){
- if(!d->addTransition && !d->moveTransition){
- target.item->setY(y);
- }else{
- if(target.isNew)
- d->addActions << QmlAction(target.item, QLatin1String("y"), QVariant(y));
- else
- d->moveActions << QmlAction(target.item, QLatin1String("y"), QVariant(y));
- }
- }
-}
-
-void QmlGraphicsBasePositioner::finishApplyTransitions()
-{
- Q_D(QmlGraphicsBasePositioner);
- // Note that if a transition is not set the transition manager will
- // apply the changes directly, in the case add/move aren't set
- d->addTransitionManager.transition(d->addActions, d->addTransition);
- d->moveTransitionManager.transition(d->moveActions, d->moveTransition);
- d->addActions.clear();
- d->moveActions.clear();
-}
-
-/*!
- \qmlclass Column QmlGraphicsColumn
- \since 4.7
- \brief The Column item lines up its children vertically.
- \inherits Item
-
- The Column item positions its child items so that they are vertically
- aligned and not overlapping. Spacing between items can be added.
-
- The below example positions differently shaped rectangles using a Column.
- \table
- \row
- \o \image verticalpositioner_example.png
- \o
- \qml
-Column {
- spacing: 2
- Rectangle { color: "red"; width: 50; height: 50 }
- Rectangle { color: "green"; width: 20; height: 50 }
- Rectangle { color: "blue"; width: 50; height: 20 }
-}
- \endqml
- \endtable
-
- Column also provides for transitions to be set when items are added, moved,
- or removed in the positioner. Adding and removing apply both to items which are deleted
- or have their position in the document changed so as to no longer be children of the positioner,
- as well as to items which have their opacity set to or from zero so as to appear or disappear.
-
- \table
- \row
- \o \image verticalpositioner_transition.gif
- \o
- \qml
-Column {
- spacing: 2
- remove: ...
- add: ...
- move: ...
- ...
-}
- \endqml
- \endtable
-
- Note that the positioner assumes that the x and y positions of its children
- will not change. If you manually change the x or y properties in script, bind
- the x or y properties, or use anchors on a child of a positioner, then the
- positioner may exhibit strange behaviour.
-
-*/
-/*!
- \qmlproperty Transition Column::add
-
- This property holds the transition to be applied when adding an
- item to the positioner. The transition will only be applied to the
- added item(s). Positioner transitions will only affect the
- position (x,y) of items.
-
- Added can mean that either the object has been created or
- reparented, and thus is now a child or the positioner, or that the
- object has had its opacity increased from zero, and thus is now
- visible.
-
-
-*/
-/*!
- \qmlproperty Transition Column::move
-
- This property holds the transition to apply when moving an item
- within the positioner. Positioner transitions will only affect
- the position (x,y) of items.
-
- This can happen when other items are added or removed from the
- positioner, or when items resize themselves.
-
- \table
- \row
- \o \image positioner-move.gif
- \o
- \qml
-Column {
- move: Transition {
- NumberAnimation {
- properties: "y"
- easing: "easeOutBounce"
- }
- }
-}
- \endqml
- \endtable
-*/
-/*!
- \qmlproperty int Column::spacing
-
- spacing is the amount in pixels left empty between each adjacent
- item, and defaults to 0.
-
- The below example places a Grid containing a red, a blue and a
- green rectangle on a gray background. The area the grid positioner
- occupies is colored white. The top positioner has the default of no spacing,
- and the bottom positioner has its spacing set to 2.
-
- \image spacing_a.png
- \image spacing_b.png
-
-*/
-/*!
- \internal
- \class QmlGraphicsColumn
- \brief The QmlGraphicsColumn class lines up items vertically.
- \ingroup group_positioners
-*/
-QmlGraphicsColumn::QmlGraphicsColumn(QmlGraphicsItem *parent)
-: QmlGraphicsBasePositioner(Vertical, parent)
-{
-}
-
-static inline bool isInvisible(QmlGraphicsItem *child)
-{
- return child->opacity() == 0.0 || !child->isVisible() || !child->width() || !child->height();
-}
-
-void QmlGraphicsColumn::doPositioning()
-{
- int voffset = 0;
-
- for (int ii = 0; ii < positionedItems.count(); ++ii) {
- const PositionedItem &child = positionedItems.at(ii);
- if (!child.item || isInvisible(child.item))
- continue;
-
- if(child.item->y() != voffset)
- positionY(voffset, child);
-
- voffset += child.item->height();
- voffset += spacing();
- }
-}
-
-/*!
- \qmlclass Row QmlGraphicsRow
- \since 4.7
- \brief The Row item lines up its children horizontally.
- \inherits Item
-
- The Row item positions its child items so that they are
- horizontally aligned and not overlapping. Spacing can be added between the
- items, and a margin around all items can also be added. It also provides for
- transitions to be set when items are added, moved, or removed in the
- positioner. Adding and removing apply both to items which are deleted or have
- their position in the document changed so as to no longer be children of the
- positioner, as well as to items which have their opacity set to or from zero
- so as to appear or disappear.
-
- The below example lays out differently shaped rectangles using a Row.
- \qml
-Row {
- spacing: 2
- Rectangle { color: "red"; width: 50; height: 50 }
- Rectangle { color: "green"; width: 20; height: 50 }
- Rectangle { color: "blue"; width: 50; height: 20 }
-}
- \endqml
- \image horizontalpositioner_example.png
-
- Note that the positioner assumes that the x and y positions of its children
- will not change. If you manually change the x or y properties in script, bind
- the x or y properties, or use anchors on a child of a positioner, then the
- positioner may exhibit strange behaviour.
-
-*/
-/*!
- \qmlproperty Transition Row::add
- This property holds the transition to apply when adding an item to the positioner.
- The transition will only be applied to the added item(s).
- Positioner transitions will only affect the position (x,y) of items.
-
- Added can mean that either the object has been created or
- reparented, and thus is now a child or the positioner, or that the
- object has had its opacity increased from zero, and thus is now
- visible.
-
-
-*/
-/*!
- \qmlproperty Transition Row::move
-
- This property holds the transition to apply when moving an item
- within the positioner. Positioner transitions will only affect
- the position (x,y) of items.
-
- This can happen when other items are added or removed from the
- positioner, or when items resize themselves.
-
- \qml
-Row {
- id: positioner
- move: Transition {
- NumberAnimation {
- properties: "x"
- ease: "easeOutBounce"
- }
- }
-}
- \endqml
-
-*/
-/*!
- \qmlproperty int Row::spacing
-
- spacing is the amount in pixels left empty between each adjacent
- item, and defaults to 0.
-
- The below example places a Grid containing a red, a blue and a
- green rectangle on a gray background. The area the grid positioner
- occupies is colored white. The top positioner has the default of no spacing,
- and the bottom positioner has its spacing set to 2.
-
- \image spacing_a.png
- \image spacing_b.png
-
-*/
-/*!
- \internal
- \class QmlGraphicsRow
- \brief The QmlGraphicsRow class lines up items horizontally.
- \ingroup group_positioners
-*/
-QmlGraphicsRow::QmlGraphicsRow(QmlGraphicsItem *parent)
-: QmlGraphicsBasePositioner(Horizontal, parent)
-{
-}
-
-void QmlGraphicsRow::doPositioning()
-{
- int hoffset = 0;
-
- for (int ii = 0; ii < positionedItems.count(); ++ii) {
- const PositionedItem &child = positionedItems.at(ii);
- if (!child.item || isInvisible(child.item))
- continue;
-
- if(child.item->x() != hoffset)
- positionX(hoffset, child);
-
- hoffset += child.item->width();
- hoffset += spacing();
- }
-}
-
-
-/*!
- \qmlclass Grid QmlGraphicsGrid
- \since 4.7
- \brief The Grid item positions its children in a grid.
- \inherits Item
-
- The Grid item positions its child items so that they are
- aligned in a grid and are not overlapping. Spacing can be added
- between the items. It also provides for transitions to be set when items are
- added, moved, or removed in the positioner. Adding and removing apply
- both to items which are deleted or have their position in the
- document changed so as to no longer be children of the positioner, as
- well as to items which have their opacity set to or from zero so
- as to appear or disappear.
-
- The Grid defaults to using four columns, and as many rows as
- are necessary to fit all the child items. The number of rows
- and/or the number of columns can be constrained by setting the rows
- or columns properties. The grid positioner calculates a grid with
- rectangular cells of sufficient size to hold all items, and then
- places the items in the cells, going across then down, and
- positioning each item at the (0,0) corner of the cell. The below
- example demonstrates this.
-
- \table
- \row
- \o \image gridLayout_example.png
- \o
- \qml
-Grid {
- columns: 3
- spacing: 2
- Rectangle { color: "red"; width: 50; height: 50 }
- Rectangle { color: "green"; width: 20; height: 50 }
- Rectangle { color: "blue"; width: 50; height: 20 }
- Rectangle { color: "cyan"; width: 50; height: 50 }
- Rectangle { color: "magenta"; width: 10; height: 10 }
-}
- \endqml
- \endtable
-
- Note that the positioner assumes that the x and y positions of its children
- will not change. If you manually change the x or y properties in script, bind
- the x or y properties, or use anchors on a child of a positioner, then the
- positioner may exhibit strange behaviour.
-*/
-/*!
- \qmlproperty Transition Grid::add
- This property holds the transition to apply when adding an item to the positioner.
- The transition is only applied to the added item(s).
- Positioner transitions will only affect the position (x,y) of items.
-
- Added can mean that either the object has been created or
- reparented, and thus is now a child or the positioner, or that the
- object has had its opacity increased from zero, and thus is now
- visible.
-
-
-*/
-/*!
- \qmlproperty Transition Grid::move
- This property holds the transition to apply when moving an item within the positioner.
- Positioner transitions will only affect the position (x,y) of items.
-
- This can happen when other items are added or removed from the positioner, or
- when items resize themselves.
-
- \qml
-Grid {
- move: Transition {
- NumberAnimation {
- properties: "x,y"
- ease: "easeOutBounce"
- }
- }
-}
- \endqml
-
-*/
-/*!
- \qmlproperty int Grid::spacing
-
- spacing is the amount in pixels left empty between each adjacent
- item, and defaults to 0.
-
- The below example places a Grid containing a red, a blue and a
- green rectangle on a gray background. The area the grid positioner
- occupies is colored white. The top positioner has the default of no spacing,
- and the bottom positioner has its spacing set to 2.
-
- \image spacing_a.png
- \image spacing_b.png
-
-*/
-/*!
- \internal
- \class QmlGraphicsGrid
- \brief The QmlGraphicsGrid class lays out items in a grid.
- \ingroup group_layouts
-
-*/
-QmlGraphicsGrid::QmlGraphicsGrid(QmlGraphicsItem *parent) :
- QmlGraphicsBasePositioner(Both, parent)
-{
- _columns=-1;
- _rows=-1;
-}
-
-/*!
- \qmlproperty int Grid::columns
- This property holds the number of columns in the grid.
-
- When the columns property is set the Grid will always have
- that many columns. Note that if you do not have enough items to
- fill this many columns some columns will be of zero width.
-*/
-
-/*!
- \qmlproperty int Grid::rows
- This property holds the number of rows in the grid.
-
- When the rows property is set the Grid will always have that
- many rows. Note that if you do not have enough items to fill this
- many rows some rows will be of zero width.
-*/
-
-void QmlGraphicsGrid::setColumns(const int columns)
-{
- if (columns == _columns)
- return;
- _columns = columns;
- prePositioning();
- emit columnsChanged();
-}
-
-void QmlGraphicsGrid::setRows(const int rows)
-{
- if (rows == _rows)
- return;
- _rows = rows;
- prePositioning();
- emit rowsChanged();
-}
-
-void QmlGraphicsGrid::doPositioning()
-{
- int c=_columns,r=_rows;//Actual number of rows/columns
- int numVisible = positionedItems.count();
- if (_columns==-1 && _rows==-1){
- c = 4;
- r = (numVisible+3)/4;
- }else if (_rows==-1){
- r = (numVisible+(_columns-1))/_columns;
- }else if (_columns==-1){
- c = (numVisible+(_rows-1))/_rows;
- }
-
- QList<int> maxColWidth;
- QList<int> maxRowHeight;
- int childIndex =0;
- for (int i=0; i<r; i++){
- for (int j=0; j<c; j++){
- if (j==0)
- maxRowHeight << 0;
- if (i==0)
- maxColWidth << 0;
-
- if (childIndex == positionedItems.count())
- continue;
- const PositionedItem &child = positionedItems.at(childIndex++);
- if (!child.item || isInvisible(child.item))
- continue;
- if (child.item->width() > maxColWidth[j])
- maxColWidth[j] = child.item->width();
- if (child.item->height() > maxRowHeight[i])
- maxRowHeight[i] = child.item->height();
- }
- }
-
- int xoffset=0;
- int yoffset=0;
- int curRow =0;
- int curCol =0;
- for (int i = 0; i < positionedItems.count(); ++i) {
- const PositionedItem &child = positionedItems.at(i);
- if (!child.item || isInvisible(child.item))
- continue;
- if((child.item->x()!=xoffset)||(child.item->y()!=yoffset)){
- positionX(xoffset, child);
- positionY(yoffset, child);
- }
- xoffset+=maxColWidth[curCol]+spacing();
- curCol++;
- curCol%=c;
- if (!curCol){
- yoffset+=maxRowHeight[curRow]+spacing();
- xoffset=0;
- curRow++;
- if (curRow>=r)
- break;
- }
- }
-}
-
-
-/*!
- \qmlclass Flow QmlGraphicsFlow
- \since 4.7
- \brief The Flow item lines up its children side by side, wrapping as necessary.
- \inherits Item
-
-
-*/
-/*!
- \qmlproperty Transition Flow::add
- This property holds the transition to apply when adding an item to the positioner.
- The transition will only be applied to the added item(s).
- Positioner transitions will only affect the position (x,y) of items.
-
- Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible.
-
-
-*/
-/*!
- \qmlproperty Transition Flow::move
- This property holds the transition to apply when moving an item within the positioner.
- Positioner transitions will only affect the position (x,y) of items.
-
- This can happen when other items are added or removed from the positioner, or when items resize themselves.
-
- \qml
-Flow {
- id: positioner
- move: Transition {
- NumberAnimation {
- properties: "x,y"
- ease: "easeOutBounce"
- }
- }
-}
- \endqml
-
-*/
-/*!
- \qmlproperty int Flow::spacing
-
- spacing is the amount in pixels left empty between each adjacent
- item, and defaults to 0.
-
-*/
-
-class QmlGraphicsFlowPrivate : public QmlGraphicsBasePositionerPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsFlow)
-
-public:
- QmlGraphicsFlowPrivate()
- : QmlGraphicsBasePositionerPrivate(), flow(QmlGraphicsFlow::LeftToRight)
- {}
-
- QmlGraphicsFlow::Flow flow;
-};
-
-QmlGraphicsFlow::QmlGraphicsFlow(QmlGraphicsItem *parent)
-: QmlGraphicsBasePositioner(*(new QmlGraphicsFlowPrivate), Both, parent)
-{
-}
-
-/*!
- \qmlproperty enumeration Flow::flow
- This property holds the flow of the layout.
-
- Possible values are \c LeftToRight (default) and \c TopToBottom.
-
- If \a flow is \c LeftToRight, the items are positioned next to
- to each other from left to right until the width of the Flow
- is exceeded, then wrapped to the next line.
- If \a flow is \c TopToBottom, the items are positioned next to each
- other from top to bottom until the height of the Flow is exceeded,
- then wrapped to the next column.
-*/
-QmlGraphicsFlow::Flow QmlGraphicsFlow::flow() const
-{
- Q_D(const QmlGraphicsFlow);
- return d->flow;
-}
-
-void QmlGraphicsFlow::setFlow(Flow flow)
-{
- Q_D(QmlGraphicsFlow);
- if (d->flow != flow) {
- d->flow = flow;
- prePositioning();
- emit flowChanged();
- }
-}
-
-void QmlGraphicsFlow::doPositioning()
-{
- Q_D(QmlGraphicsFlow);
-
- int hoffset = 0;
- int voffset = 0;
- int linemax = 0;
-
- for (int i = 0; i < positionedItems.count(); ++i) {
- const PositionedItem &child = positionedItems.at(i);
- if (!child.item || isInvisible(child.item))
- continue;
-
- if (d->flow == LeftToRight) {
- if (hoffset && hoffset + child.item->width() > width()) {
- hoffset = 0;
- voffset += linemax + spacing();
- linemax = 0;
- }
- } else {
- if (voffset && voffset + child.item->height() > height()) {
- voffset = 0;
- hoffset += linemax + spacing();
- linemax = 0;
- }
- }
-
- if(child.item->x() != hoffset || child.item->y() != voffset){
- positionX(hoffset, child);
- positionY(voffset, child);
- }
-
- if (d->flow == LeftToRight) {
- hoffset += child.item->width();
- hoffset += spacing();
- linemax = qMax(linemax, qCeil(child.item->height()));
- } else {
- voffset += child.item->height();
- voffset += spacing();
- linemax = qMax(linemax, qCeil(child.item->width()));
- }
- }
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
deleted file mode 100644
index 2f905e5..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSLAYOUTS_H
-#define QMLGRAPHICSLAYOUTS_H
-
-#include "qmlgraphicsitem.h"
-
-#include "../util/qmlstate_p.h"
-#include <private/qpodvector_p.h>
-
-#include <QtCore/QObject>
-#include <QtCore/QString>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QmlGraphicsBasePositionerPrivate;
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsBasePositioner : public QmlGraphicsItem
-{
- Q_OBJECT
-
- Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
- Q_PROPERTY(QmlTransition *move READ move WRITE setMove NOTIFY moveChanged)
- Q_PROPERTY(QmlTransition *add READ add WRITE setAdd NOTIFY addChanged)
-public:
- enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
- QmlGraphicsBasePositioner(PositionerType, QmlGraphicsItem *parent);
- ~QmlGraphicsBasePositioner();
-
- int spacing() const;
- void setSpacing(int);
-
- QmlTransition *move() const;
- void setMove(QmlTransition *);
-
- QmlTransition *add() const;
- void setAdd(QmlTransition *);
-
-protected:
- QmlGraphicsBasePositioner(QmlGraphicsBasePositionerPrivate &dd, PositionerType at, QmlGraphicsItem *parent);
- virtual void componentComplete();
- virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
- void finishApplyTransitions();
-
-Q_SIGNALS:
- void spacingChanged();
- void moveChanged();
- void addChanged();
-
-protected Q_SLOTS:
- virtual void doPositioning()=0;
- void prePositioning();
-
-protected:
- struct PositionedItem {
- PositionedItem(QmlGraphicsItem *i) : item(i), isNew(false), isVisible(true) {}
- bool operator==(const PositionedItem &other) const { return other.item == item; }
- QmlGraphicsItem *item;
- bool isNew;
- bool isVisible;
- };
-
- QPODVector<PositionedItem,8> positionedItems;
- void positionX(int,const PositionedItem &target);
- void positionY(int,const PositionedItem &target);
-
-private:
- Q_DISABLE_COPY(QmlGraphicsBasePositioner)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsBasePositioner)
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsColumn : public QmlGraphicsBasePositioner
-{
- Q_OBJECT
-public:
- QmlGraphicsColumn(QmlGraphicsItem *parent=0);
-protected Q_SLOTS:
- virtual void doPositioning();
-private:
- Q_DISABLE_COPY(QmlGraphicsColumn)
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsRow: public QmlGraphicsBasePositioner
-{
- Q_OBJECT
-public:
- QmlGraphicsRow(QmlGraphicsItem *parent=0);
-protected Q_SLOTS:
- virtual void doPositioning();
-private:
- Q_DISABLE_COPY(QmlGraphicsRow)
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsGrid : public QmlGraphicsBasePositioner
-{
- Q_OBJECT
- Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowChanged)
- Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
-public:
- QmlGraphicsGrid(QmlGraphicsItem *parent=0);
-
- int rows() const {return _rows;}
- void setRows(const int rows);
-
- int columns() const {return _columns;}
- void setColumns(const int columns);
-
-Q_SIGNALS:
- void rowsChanged();
- void columnsChanged();
-
-protected Q_SLOTS:
- virtual void doPositioning();
-
-private:
- int _rows;
- int _columns;
- Q_DISABLE_COPY(QmlGraphicsGrid)
-};
-
-class QmlGraphicsFlowPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsFlow: public QmlGraphicsBasePositioner
-{
- Q_OBJECT
- Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
-public:
- QmlGraphicsFlow(QmlGraphicsItem *parent=0);
-
- Q_ENUMS(Flow)
- enum Flow { LeftToRight, TopToBottom };
- Flow flow() const;
- void setFlow(Flow);
-
-Q_SIGNALS:
- void flowChanged();
-
-protected Q_SLOTS:
- virtual void doPositioning();
-
-protected:
- QmlGraphicsFlow(QmlGraphicsFlowPrivate &dd, QmlGraphicsItem *parent);
-private:
- Q_DISABLE_COPY(QmlGraphicsFlow)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsFlow)
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsColumn)
-QML_DECLARE_TYPE(QmlGraphicsRow)
-QML_DECLARE_TYPE(QmlGraphicsGrid)
-QML_DECLARE_TYPE(QmlGraphicsFlow)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h
deleted file mode 100644
index e9b6aa8..0000000
--- a/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSLAYOUTS_P_H
-#define QMLGRAPHICSLAYOUTS_P_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 "qmlgraphicspositioners_p.h"
-
-#include "qmlgraphicsitem_p.h"
-
-#include <qmlstate_p.h>
-#include <qmltransitionmanager_p_p.h>
-#include <qmlstateoperations_p.h>
-
-#include <QtCore/QObject>
-#include <QtCore/QString>
-#include <QtCore/QTimer>
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-class QmlGraphicsBasePositionerPrivate : public QmlGraphicsItemPrivate, public QmlGraphicsItemChangeListener
-{
- Q_DECLARE_PUBLIC(QmlGraphicsBasePositioner)
-
-public:
- QmlGraphicsBasePositionerPrivate()
- : spacing(0), type(QmlGraphicsBasePositioner::None), moveTransition(0), addTransition(0),
- queuedPositioning(false)
- {
- }
-
- void init(QmlGraphicsBasePositioner::PositionerType at)
- {
- type = at;
- }
-
- int spacing;
- QmlGraphicsBasePositioner::PositionerType type;
- QmlTransition *moveTransition;
- QmlTransition *addTransition;
- QmlStateOperation::ActionList addActions;
- QmlStateOperation::ActionList moveActions;
- QmlTransitionManager addTransitionManager;
- QmlTransitionManager moveTransitionManager;
-
- void watchChanges(QmlGraphicsItem *other);
- void unwatchChanges(QmlGraphicsItem* other);
- bool queuedPositioning;
-
- virtual void itemSiblingOrderChanged(QmlGraphicsItem* other)
- {
- Q_Q(QmlGraphicsBasePositioner);
- Q_UNUSED(other);
- if(!queuedPositioning){
- //Delay is due to many children often being reordered at once
- //And we only want to reposition them all once
- QTimer::singleShot(0,q,SLOT(prePositioning()));
- queuedPositioning = true;
- }
- }
-
- void itemGeometryChanged(QmlGraphicsItem *, const QRectF &newGeometry, const QRectF &oldGeometry)
- {
- Q_Q(QmlGraphicsBasePositioner);
- if (newGeometry.size() != oldGeometry.size())
- q->prePositioning();
- }
- virtual void itemVisibilityChanged(QmlGraphicsItem *)
- {
- Q_Q(QmlGraphicsBasePositioner);
- q->prePositioning();
- }
- virtual void itemOpacityChanged(QmlGraphicsItem *)
- {
- Q_Q(QmlGraphicsBasePositioner);
- q->prePositioning();
- }
-
- void itemDestroyed(QmlGraphicsItem *item)
- {
- Q_Q(QmlGraphicsBasePositioner);
- q->positionedItems.removeOne(QmlGraphicsBasePositioner::PositionedItem(item));
- }
-};
-
-QT_END_NAMESPACE
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp b/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp
deleted file mode 100644
index adc4cf3..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp
+++ /dev/null
@@ -1,466 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsrectangle_p.h"
-#include "qmlgraphicsrectangle_p_p.h"
-
-#include <QPainter>
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- \class QmlGraphicsPen
- \brief The QmlGraphicsPen class provides a pen used for drawing rectangle borders on a QmlView.
-
- By default, the pen is invalid and nothing is drawn. You must either set a color (then the default
- width is 1) or a width (then the default color is black).
-
- A width of 1 indicates is a single-pixel line on the border of the item being painted.
-
- Example:
- \qml
- Rectangle { border.width: 2; border.color: "red" ... }
- \endqml
-*/
-
-void QmlGraphicsPen::setColor(const QColor &c)
-{
- _color = c;
- _valid = _color.alpha() ? true : false;
- emit penChanged();
-}
-
-void QmlGraphicsPen::setWidth(int w)
-{
- if (_width == w && _valid)
- return;
-
- _width = w;
- _valid = (_width < 1) ? false : true;
- emit penChanged();
-}
-
-
-/*!
- \qmlclass GradientStop QmlGraphicsGradientStop
- \since 4.7
- \brief The GradientStop item defines the color at a position in a Gradient
-
- \sa Gradient
-*/
-
-/*!
- \qmlproperty real GradientStop::position
- \qmlproperty color GradientStop::color
-
- Sets a \e color at a \e position in a gradient.
-*/
-
-void QmlGraphicsGradientStop::updateGradient()
-{
- if (QmlGraphicsGradient *grad = qobject_cast<QmlGraphicsGradient*>(parent()))
- grad->doUpdate();
-}
-
-/*!
- \qmlclass Gradient QmlGraphicsGradient
- \since 4.7
- \brief The Gradient item defines a gradient fill.
-
- A gradient is defined by two or more colors, which will be blended seemlessly. The
- colors are specified at their position in the range 0.0 - 1.0 via
- the GradientStop item. For example, the following code paints a
- rectangle with a gradient starting with red, blending to yellow at 1/3 of the
- size of the rectangle, and ending with Green:
-
- \table
- \row
- \o \image gradient.png
- \o \quotefile doc/src/snippets/declarative/gradient.qml
- \endtable
-
- \sa GradientStop
-*/
-
-/*!
- \qmlproperty list<GradientStop> Gradient::stops
- This property holds the gradient stops describing the gradient.
-*/
-
-const QGradient *QmlGraphicsGradient::gradient() const
-{
- if (!m_gradient && !m_stops.isEmpty()) {
- m_gradient = new QLinearGradient(0,0,0,1.0);
- for (int i = 0; i < m_stops.count(); ++i) {
- const QmlGraphicsGradientStop *stop = m_stops.at(i);
- m_gradient->setCoordinateMode(QGradient::ObjectBoundingMode);
- m_gradient->setColorAt(stop->position(), stop->color());
- }
- }
-
- return m_gradient;
-}
-
-void QmlGraphicsGradient::doUpdate()
-{
- delete m_gradient;
- m_gradient = 0;
- emit updated();
-}
-
-
-/*!
- \qmlclass Rectangle QmlGraphicsRectangle
- \since 4.7
- \brief The Rectangle item allows you to add rectangles to a scene.
- \inherits Item
-
- A Rectangle is painted having a solid fill (color) and an optional border.
- You can also create rounded rectangles using the radius property.
-
- \qml
- Rectangle {
- width: 100
- height: 100
- color: "red"
- border.color: "black"
- border.width: 5
- radius: 10
- }
- \endqml
-
- \image declarative-rect.png
-*/
-
-/*!
- \internal
- \class QmlGraphicsRectangle
- \brief The QmlGraphicsRectangle class provides a rectangle item that you can add to a QmlView.
-*/
-QmlGraphicsRectangle::QmlGraphicsRectangle(QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsRectanglePrivate), parent)
-{
- Q_D(QmlGraphicsRectangle);
- d->init();
- setFlag(QGraphicsItem::ItemHasNoContents, false);
-}
-
-void QmlGraphicsRectangle::doUpdate()
-{
- Q_D(QmlGraphicsRectangle);
- d->rectImage = QPixmap();
- const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
- d->setPaintMargin((pw+1)/2);
- update();
-}
-
-/*!
- \qmlproperty int Rectangle::border.width
- \qmlproperty color Rectangle::border.color
-
- The width and color used to draw the border of the rectangle.
-
- A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color.
-
- To keep the border smooth (rather than blurry), odd widths cause the rectangle to be painted at
- a half-pixel offset;
-*/
-QmlGraphicsPen *QmlGraphicsRectangle::border()
-{
- Q_D(QmlGraphicsRectangle);
- return d->getPen();
-}
-
-/*!
- \qmlproperty Gradient Rectangle::gradient
-
- The gradient to use to fill the rectangle.
-
- This property allows for the construction of simple vertical gradients.
- Other gradients may by formed by adding rotation to the rectangle.
-
- \table
- \row
- \o \image declarative-rect_gradient.png
- \o
- \qml
- Rectangle { y: 0; width: 80; height: 80; color: "lightsteelblue" }
- Rectangle { y: 100; width: 80; height: 80
- gradient: Gradient {
- GradientStop { position: 0.0; color: "lightsteelblue" }
- GradientStop { position: 1.0; color: "blue" }
- }
- }
- Rectangle { rotation: 90; x: 80; y: 200; width: 80; height: 80
- gradient: Gradient {
- GradientStop { position: 0.0; color: "lightsteelblue" }
- GradientStop { position: 1.0; color: "blue" }
- }
- }
- // The x offset is needed because the rotation is from the top left corner
- \endqml
- \endtable
-
- If both a gradient and a color are specified, the gradient will be used.
-
- \sa Gradient, color
-*/
-QmlGraphicsGradient *QmlGraphicsRectangle::gradient() const
-{
- Q_D(const QmlGraphicsRectangle);
- return d->gradient;
-}
-
-void QmlGraphicsRectangle::setGradient(QmlGraphicsGradient *gradient)
-{
- Q_D(QmlGraphicsRectangle);
- if (d->gradient == gradient)
- return;
- if (d->gradient)
- disconnect(d->gradient, SIGNAL(updated()), this, SLOT(doUpdate()));
- d->gradient = gradient;
- if (d->gradient)
- connect(d->gradient, SIGNAL(updated()), this, SLOT(doUpdate()));
- update();
-}
-
-
-/*!
- \qmlproperty real Rectangle::radius
- This property holds the corner radius used to draw a rounded rectangle.
-
- If radius is non-zero, the rectangle will be painted as a rounded rectangle, otherwise it will be
- painted as a normal rectangle. The same radius is used by all 4 corners; there is currently
- no way to specify different radii for different corners.
-*/
-qreal QmlGraphicsRectangle::radius() const
-{
- Q_D(const QmlGraphicsRectangle);
- return d->radius;
-}
-
-void QmlGraphicsRectangle::setRadius(qreal radius)
-{
- Q_D(QmlGraphicsRectangle);
- if (d->radius == radius)
- return;
-
- d->radius = radius;
- d->rectImage = QPixmap();
- update();
- emit radiusChanged();
-}
-
-/*!
- \qmlproperty color Rectangle::color
- This property holds the color used to fill the rectangle.
-
- \qml
- // green rectangle using hexidecimal notation
- Rectangle { color: "#00FF00" }
-
- // steelblue rectangle using SVG color name
- Rectangle { color: "steelblue" }
- \endqml
-
- The default color is white.
-
- If both a gradient and a color are specified, the gradient will be used.
-*/
-QColor QmlGraphicsRectangle::color() const
-{
- Q_D(const QmlGraphicsRectangle);
- return d->color;
-}
-
-void QmlGraphicsRectangle::setColor(const QColor &c)
-{
- Q_D(QmlGraphicsRectangle);
- if (d->color == c)
- return;
-
- d->color = c;
- d->rectImage = QPixmap();
- update();
- emit colorChanged();
-}
-
-void QmlGraphicsRectangle::generateRoundedRect()
-{
- Q_D(QmlGraphicsRectangle);
- if (d->rectImage.isNull()) {
- const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
- const int radius = qCeil(d->radius); //ensure odd numbered width/height so we get 1-pixel center
- d->rectImage = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2);
- d->rectImage.fill(Qt::transparent);
- QPainter p(&(d->rectImage));
- p.setRenderHint(QPainter::Antialiasing);
- if (d->pen && d->pen->isValid()) {
- QPen pn(QColor(d->pen->color()), d->pen->width());
- p.setPen(pn);
- } else {
- p.setPen(Qt::NoPen);
- }
- p.setBrush(d->color);
- if (pw%2)
- p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)), d->radius, d->radius);
- else
- p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw), d->radius, d->radius);
- }
-}
-
-void QmlGraphicsRectangle::generateBorderedRect()
-{
- Q_D(QmlGraphicsRectangle);
- if (d->rectImage.isNull()) {
- const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
- d->rectImage = QPixmap(pw*2 + 3, pw*2 + 3);
- d->rectImage.fill(Qt::transparent);
- QPainter p(&(d->rectImage));
- p.setRenderHint(QPainter::Antialiasing);
- if (d->pen && d->pen->isValid()) {
- QPen pn(QColor(d->pen->color()), d->pen->width());
- pn.setJoinStyle(Qt::MiterJoin);
- p.setPen(pn);
- } else {
- p.setPen(Qt::NoPen);
- }
- p.setBrush(d->color);
- if (pw%2)
- p.drawRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)));
- else
- p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw));
- }
-}
-
-void QmlGraphicsRectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
-{
- Q_D(QmlGraphicsRectangle);
- if (d->radius > 0 || (d->pen && d->pen->isValid())
- || (d->gradient && d->gradient->gradient()) ) {
- drawRect(*p);
- }
- else {
- bool oldAA = p->testRenderHint(QPainter::Antialiasing);
- if (d->smooth)
- p->setRenderHints(QPainter::Antialiasing, true);
- p->fillRect(QRectF(0, 0, width(), height()), d->color);
- if (d->smooth)
- p->setRenderHint(QPainter::Antialiasing, oldAA);
- }
-}
-
-void QmlGraphicsRectangle::drawRect(QPainter &p)
-{
- Q_D(QmlGraphicsRectangle);
- if (d->gradient && d->gradient->gradient()) {
- // XXX This path is still slower than the image path
- // Image path won't work for gradients though
- bool oldAA = p.testRenderHint(QPainter::Antialiasing);
- if (d->smooth)
- p.setRenderHint(QPainter::Antialiasing);
- if (d->pen && d->pen->isValid()) {
- QPen pn(QColor(d->pen->color()), d->pen->width());
- p.setPen(pn);
- } else {
- p.setPen(Qt::NoPen);
- }
- p.setBrush(*d->gradient->gradient());
- if (d->radius > 0.)
- p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius);
- else
- p.drawRect(0, 0, width(), height());
- if (d->smooth)
- p.setRenderHint(QPainter::Antialiasing, oldAA);
- } else {
- bool oldAA = p.testRenderHint(QPainter::Antialiasing);
- bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform);
- if (d->smooth)
- p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
-
- const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0;
-
- if (d->radius > 0)
- generateRoundedRect();
- else
- generateBorderedRect();
-
- int xOffset = (d->rectImage.width()-1)/2;
- int yOffset = (d->rectImage.height()-1)/2;
- Q_ASSERT(d->rectImage.width() == 2*xOffset + 1);
- Q_ASSERT(d->rectImage.height() == 2*yOffset + 1);
-
- QMargins margins(xOffset, yOffset, xOffset, yOffset);
- QTileRules rules(Qt::StretchTile, Qt::StretchTile);
- //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects
- qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width()+pw, height()+pw), margins, d->rectImage, d->rectImage.rect(), margins, rules);
-
- if (d->smooth) {
- p.setRenderHint(QPainter::Antialiasing, oldAA);
- p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
- }
- }
-}
-
-/*!
- \qmlproperty bool Rectangle::smooth
-
- Set this property if you want the item to be smoothly scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the item is displayed at its natural size, this property has no visual or
- performance effect.
-
- \note Generally scaling artifacts are only visible if the item is stationary on
- the screen. A common pattern when animating an item is to disable smooth
- filtering at the beginning of the animation and reenable it at the conclusion.
-
- \image rect-smooth.png
-*/
-
-QRectF QmlGraphicsRectangle::boundingRect() const
-{
- Q_D(const QmlGraphicsRectangle);
- return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h b/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h
deleted file mode 100644
index 66552f6..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSRECT_H
-#define QMLGRAPHICSRECT_H
-
-#include "qmlgraphicsitem.h"
-
-#include <QtGui/qbrush.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class Q_DECLARATIVE_EXPORT QmlGraphicsPen : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(int width READ width WRITE setWidth NOTIFY penChanged)
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged)
-public:
- QmlGraphicsPen(QObject *parent=0)
- : QObject(parent), _width(1), _color("#000000"), _valid(false)
- {}
-
- int width() const { return _width; }
- void setWidth(int w);
-
- QColor color() const { return _color; }
- void setColor(const QColor &c);
-
- bool isValid() { return _valid; };
-
-Q_SIGNALS:
- void penChanged();
-
-private:
- int _width;
- QColor _color;
- bool _valid;
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsGradientStop : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal position READ position WRITE setPosition)
- Q_PROPERTY(QColor color READ color WRITE setColor)
-
-public:
- QmlGraphicsGradientStop(QObject *parent=0) : QObject(parent) {}
-
- qreal position() const { return m_position; }
- void setPosition(qreal position) { m_position = position; updateGradient(); }
-
- QColor color() const { return m_color; }
- void setColor(const QColor &color) { m_color = color; updateGradient(); }
-
-private:
- void updateGradient();
-
-private:
- qreal m_position;
- QColor m_color;
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsGradient : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QmlListProperty<QmlGraphicsGradientStop> stops READ stops)
- Q_CLASSINFO("DefaultProperty", "stops")
-
-public:
- QmlGraphicsGradient(QObject *parent=0) : QObject(parent), m_gradient(0) {}
- ~QmlGraphicsGradient() { delete m_gradient; }
-
- QmlListProperty<QmlGraphicsGradientStop> stops() { return QmlListProperty<QmlGraphicsGradientStop>(this, m_stops); }
-
- const QGradient *gradient() const;
-
-Q_SIGNALS:
- void updated();
-
-private:
- void doUpdate();
-
-private:
- QList<QmlGraphicsGradientStop *> m_stops;
- mutable QGradient *m_gradient;
- friend class QmlGraphicsGradientStop;
-};
-
-class QmlGraphicsRectanglePrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsRectangle : public QmlGraphicsItem
-{
- Q_OBJECT
-
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
- Q_PROPERTY(QmlGraphicsGradient *gradient READ gradient WRITE setGradient)
- Q_PROPERTY(QmlGraphicsPen * border READ border CONSTANT)
- Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
-public:
- QmlGraphicsRectangle(QmlGraphicsItem *parent=0);
-
- QColor color() const;
- void setColor(const QColor &);
-
- QmlGraphicsPen *border();
-
- QmlGraphicsGradient *gradient() const;
- void setGradient(QmlGraphicsGradient *gradient);
-
- qreal radius() const;
- void setRadius(qreal radius);
-
- QRectF boundingRect() const;
-
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
-
-Q_SIGNALS:
- void colorChanged();
- void radiusChanged();
-
-private Q_SLOTS:
- void doUpdate();
-
-private:
- void generateRoundedRect();
- void generateBorderedRect();
- void drawRect(QPainter &painter);
-
-private:
- Q_DISABLE_COPY(QmlGraphicsRectangle)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsRectangle)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsPen)
-QML_DECLARE_TYPE(QmlGraphicsGradientStop)
-QML_DECLARE_TYPE(QmlGraphicsGradient)
-QML_DECLARE_TYPE(QmlGraphicsRectangle)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSRECT_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsrectangle_p_p.h b/src/declarative/graphicsitems/qmlgraphicsrectangle_p_p.h
deleted file mode 100644
index f91e7e2..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsrectangle_p_p.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSRECT_P_H
-#define QMLGRAPHICSRECT_P_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 "qmlgraphicsitem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsGradient;
-class QmlGraphicsRectangle;
-class QmlGraphicsRectanglePrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsRectangle)
-
-public:
- QmlGraphicsRectanglePrivate() :
- color(Qt::white), gradient(0), pen(0), radius(0), paintmargin(0)
- {
- }
-
- ~QmlGraphicsRectanglePrivate()
- {
- delete pen;
- }
-
- void init()
- {
- }
-
- QColor getColor();
- QColor color;
- QmlGraphicsGradient *gradient;
- QmlGraphicsPen *getPen() {
- if (!pen) {
- Q_Q(QmlGraphicsRectangle);
- pen = new QmlGraphicsPen;
- QObject::connect(pen, SIGNAL(penChanged()), q, SLOT(doUpdate()));
- }
- return pen;
- }
- QmlGraphicsPen *pen;
- qreal radius;
- qreal paintmargin;
- QPixmap rectImage;
-
- void setPaintMargin(qreal margin)
- {
- Q_Q(QmlGraphicsRectangle);
- if (margin == paintmargin)
- return;
- q->prepareGeometryChange();
- paintmargin = margin;
- }
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLGRAPHICSRECT_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp
deleted file mode 100644
index 23c3aae..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp
+++ /dev/null
@@ -1,328 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsrepeater_p.h"
-#include "qmlgraphicsrepeater_p_p.h"
-
-#include "qmlgraphicsvisualitemmodel_p.h"
-
-#include <qmllistaccessor_p.h>
-
-#include <qlistmodelinterface_p.h>
-
-QT_BEGIN_NAMESPACE
-QmlGraphicsRepeaterPrivate::QmlGraphicsRepeaterPrivate()
-: model(0), ownModel(false)
-{
-}
-
-QmlGraphicsRepeaterPrivate::~QmlGraphicsRepeaterPrivate()
-{
- if (ownModel)
- delete model;
-}
-
-/*!
- \qmlclass Repeater QmlGraphicsRepeater
- \since 4.7
- \inherits Item
-
- \brief The Repeater item allows you to repeat a component based on a model.
-
- The Repeater item is used when you want to create a large number of
- similar items. For each entry in the model, an item is instantiated
- in a context seeded with data from the model. If the repeater will
- be instantiating a large number of instances, it may be more efficient to
- use one of Qt Declarative's \l {xmlViews}{view items}.
-
- The model may be either an object list, a string list, a number or a Qt model.
- In each case, the data element and the index is exposed to each instantiated
- component.
-
- The index is always exposed as an accessible \c index property.
- In the case of an object or string list, the data element (of type string
- or object) is available as the \c modelData property. In the case of a Qt model,
- all roles are available as named properties just like in the view classes. The
- following example shows how to use the index property inside the instantiated
- items.
-
- \snippet doc/src/snippets/declarative/repeater-index.qml 0
-
- \image repeater-index.png
-
- Items instantiated by the Repeater are inserted, in order, as
- children of the Repeater's parent. The insertion starts immediately after
- the repeater's position in its parent stacking list. This is to allow
- you to use a Repeater inside a layout. The following QML example shows how
- the instantiated items would visually appear stacked between the red and
- blue rectangles.
-
- \snippet doc/src/snippets/declarative/repeater.qml 0
-
- \image repeater.png
-
- The repeater instance continues to own all items it instantiates, even
- if they are otherwise manipulated. It is illegal to manually remove an item
- created by the Repeater.
- */
-
-/*!
- \internal
- \class QmlGraphicsRepeater
- \qmlclass Repeater
-
- XXX Repeater is very conservative in how it instatiates/deletes items. Also
- new model entries will not be created and old ones will not be removed.
- */
-
-/*!
- Create a new QmlGraphicsRepeater instance.
- */
-QmlGraphicsRepeater::QmlGraphicsRepeater(QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsRepeaterPrivate), parent)
-{
-}
-
-/*!
- Destroy the repeater instance. All items it instantiated are also
- destroyed.
- */
-QmlGraphicsRepeater::~QmlGraphicsRepeater()
-{
-}
-
-/*!
- \qmlproperty any Repeater::model
-
- The model providing data for the repeater.
-
- The model may be either an object list, a string list, a number or a Qt model.
- In each case, the data element and the index is exposed to each instantiated
- component. The index is always exposed as an accessible \c index property.
- In the case of an object or string list, the data element (of type string
- or object) is available as the \c modelData property. In the case of a Qt model,
- all roles are available as named properties just like in the view classes.
-
- As a special case the model can also be merely a number. In this case it will
- create that many instances of the component. They will also be assigned an index
- based on the order they are created.
-
- Models can also be created directly in QML, using a \l{ListModel} or \l{XmlListModel}.
-
- \sa {qmlmodels}{Data Models}
-*/
-QVariant QmlGraphicsRepeater::model() const
-{
- Q_D(const QmlGraphicsRepeater);
- return d->dataSource;
-}
-
-void QmlGraphicsRepeater::setModel(const QVariant &model)
-{
- Q_D(QmlGraphicsRepeater);
- if (d->dataSource == model)
- return;
-
- clear();
- if (d->model) {
- disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
- disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
- disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
- /*
- disconnect(d->model, SIGNAL(createdItem(int, QmlGraphicsItem*)), this, SLOT(createdItem(int,QmlGraphicsItem*)));
- disconnect(d->model, SIGNAL(destroyingItem(QmlGraphicsItem*)), this, SLOT(destroyingItem(QmlGraphicsItem*)));
- */
- }
- d->dataSource = model;
- emit modelChanged();
- QObject *object = qvariant_cast<QObject*>(model);
- QmlGraphicsVisualModel *vim = 0;
- if (object && (vim = qobject_cast<QmlGraphicsVisualModel *>(object))) {
- if (d->ownModel) {
- delete d->model;
- d->ownModel = false;
- }
- d->model = vim;
- } else {
- if (!d->ownModel) {
- d->model = new QmlGraphicsVisualDataModel(qmlContext(this));
- d->ownModel = true;
- }
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model))
- dataModel->setModel(model);
- }
- if (d->model) {
- connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
- connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
- connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
- /*
- connect(d->model, SIGNAL(createdItem(int, QmlGraphicsItem*)), this, SLOT(createdItem(int,QmlGraphicsItem*)));
- connect(d->model, SIGNAL(destroyingItem(QmlGraphicsItem*)), this, SLOT(destroyingItem(QmlGraphicsItem*)));
- */
- regenerate();
- emit countChanged();
- }
-}
-
-/*!
- \qmlproperty Component Repeater::delegate
- \default
-
- The delegate provides a template defining each item instantiated by the repeater.
- The index is exposed as an accessible \c index property. Properties of the
- model are also available depending upon the type of \l {qmlmodels}{Data Model}.
- */
-QmlComponent *QmlGraphicsRepeater::delegate() const
-{
- Q_D(const QmlGraphicsRepeater);
- if (d->model) {
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model))
- return dataModel->delegate();
- }
-
- return 0;
-}
-
-void QmlGraphicsRepeater::setDelegate(QmlComponent *delegate)
-{
- Q_D(QmlGraphicsRepeater);
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model))
- if (delegate == dataModel->delegate())
- return;
-
- if (!d->ownModel) {
- d->model = new QmlGraphicsVisualDataModel(qmlContext(this));
- d->ownModel = true;
- }
- if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) {
- dataModel->setDelegate(delegate);
- regenerate();
- emit delegateChanged();
- }
-}
-
-/*!
- \qmlproperty int Repeater::count
-
- This property holds the number of items in the repeater.
-*/
-int QmlGraphicsRepeater::count() const
-{
- Q_D(const QmlGraphicsRepeater);
- if (d->model)
- return d->model->count();
- return 0;
-}
-
-
-/*!
- \internal
- */
-void QmlGraphicsRepeater::componentComplete()
-{
- QmlGraphicsItem::componentComplete();
- regenerate();
-}
-
-/*!
- \internal
- */
-QVariant QmlGraphicsRepeater::itemChange(GraphicsItemChange change,
- const QVariant &value)
-{
- QVariant rv = QmlGraphicsItem::itemChange(change, value);
- if (change == ItemParentHasChanged) {
- regenerate();
- }
-
- return rv;
-}
-
-void QmlGraphicsRepeater::clear()
-{
- Q_D(QmlGraphicsRepeater);
- if (d->model) {
- foreach (QmlGraphicsItem *item, d->deletables) {
- item->setParentItem(this);
- d->model->release(item);
- }
- }
- d->deletables.clear();
-}
-
-/*!
- \internal
- */
-void QmlGraphicsRepeater::regenerate()
-{
- Q_D(QmlGraphicsRepeater);
-
- clear();
-
- if (!d->model || !d->model->count() || !d->model->isValid() || !parentItem() || !isComponentComplete())
- return;
-
- for (int ii = 0; ii < count(); ++ii) {
- QmlGraphicsItem *item = d->model->item(ii);
- if (item) {
- item->setParent(parentItem());
- item->stackBefore(this);
- d->deletables << item;
- }
- }
-}
-
-void QmlGraphicsRepeater::itemsInserted(int, int)
-{
- regenerate();
-}
-
-void QmlGraphicsRepeater::itemsRemoved(int, int)
-{
- regenerate();
-}
-
-void QmlGraphicsRepeater::itemsMoved(int,int,int)
-{
- regenerate();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h b/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h
deleted file mode 100644
index 2324916..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSREPEATER_H
-#define QMLGRAPHICSREPEATER_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsRepeaterPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsRepeater : public QmlGraphicsItem
-{
- Q_OBJECT
-
- Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
- Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
- Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_CLASSINFO("DefaultProperty", "delegate")
-
-public:
- QmlGraphicsRepeater(QmlGraphicsItem *parent=0);
- virtual ~QmlGraphicsRepeater();
-
- QVariant model() const;
- void setModel(const QVariant &);
-
- QmlComponent *delegate() const;
- void setDelegate(QmlComponent *);
-
- int count() const;
-
-Q_SIGNALS:
- void modelChanged();
- void delegateChanged();
- void countChanged();
-private:
- void clear();
- void regenerate();
-
-protected:
- virtual void componentComplete();
- QVariant itemChange(GraphicsItemChange change, const QVariant &value);
-
-private Q_SLOTS:
- void itemsInserted(int,int);
- void itemsRemoved(int,int);
- void itemsMoved(int,int,int);
-
-private:
- Q_DISABLE_COPY(QmlGraphicsRepeater)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsRepeater)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsRepeater)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSREPEATER_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater_p_p.h b/src/declarative/graphicsitems/qmlgraphicsrepeater_p_p.h
deleted file mode 100644
index 5680288..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsrepeater_p_p.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSREPEATER_P_H
-#define QMLGRAPHICSREPEATER_P_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 "qmlgraphicsrepeater_p.h"
-
-#include "qmlgraphicsitem_p.h"
-
-#include <QPointer>
-
-QT_BEGIN_NAMESPACE
-
-class QmlContext;
-class QmlGraphicsVisualModel;
-class QmlGraphicsRepeaterPrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsRepeater)
-
-public:
- QmlGraphicsRepeaterPrivate();
- ~QmlGraphicsRepeaterPrivate();
-
- QmlGraphicsVisualModel *model;
- QVariant dataSource;
- bool ownModel;
-
- QList<QPointer<QmlGraphicsItem> > deletables;
-};
-
-QT_END_NAMESPACE
-#endif // QMLGRAPHICSREPEATER_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp b/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp
deleted file mode 100644
index 1956939..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsscalegrid_p_p.h"
-
-#include <qml.h>
-
-#include <QBuffer>
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-/*!
- \internal
- \class QmlGraphicsScaleGrid
- \brief The QmlGraphicsScaleGrid class allows you to specify a 3x3 grid to use in scaling an image.
-*/
-
-QmlGraphicsScaleGrid::QmlGraphicsScaleGrid(QObject *parent) : QObject(parent), _left(0), _top(0), _right(0), _bottom(0)
-{
-}
-
-QmlGraphicsScaleGrid::~QmlGraphicsScaleGrid()
-{
-}
-
-bool QmlGraphicsScaleGrid::isNull() const
-{
- return !_left && !_top && !_right && !_bottom;
-}
-
-void QmlGraphicsScaleGrid::setLeft(int pos)
-{
- if (_left != pos) {
- _left = pos;
- emit borderChanged();
- }
-}
-
-void QmlGraphicsScaleGrid::setTop(int pos)
-{
- if (_top != pos) {
- _top = pos;
- emit borderChanged();
- }
-}
-
-void QmlGraphicsScaleGrid::setRight(int pos)
-{
- if (_right != pos) {
- _right = pos;
- emit borderChanged();
- }
-}
-
-void QmlGraphicsScaleGrid::setBottom(int pos)
-{
- if (_bottom != pos) {
- _bottom = pos;
- emit borderChanged();
- }
-}
-
-QmlGraphicsGridScaledImage::QmlGraphicsGridScaledImage()
-: _l(-1), _r(-1), _t(-1), _b(-1),
- _h(QmlGraphicsBorderImage::Stretch), _v(QmlGraphicsBorderImage::Stretch)
-{
-}
-
-QmlGraphicsGridScaledImage::QmlGraphicsGridScaledImage(const QmlGraphicsGridScaledImage &o)
-: _l(o._l), _r(o._r), _t(o._t), _b(o._b), _h(o._h), _v(o._v), _pix(o._pix)
-{
-}
-
-QmlGraphicsGridScaledImage &QmlGraphicsGridScaledImage::operator=(const QmlGraphicsGridScaledImage &o)
-{
- _l = o._l;
- _r = o._r;
- _t = o._t;
- _b = o._b;
- _h = o._h;
- _v = o._v;
- _pix = o._pix;
- return *this;
-}
-
-QmlGraphicsGridScaledImage::QmlGraphicsGridScaledImage(QIODevice *data)
-: _l(-1), _r(-1), _t(-1), _b(-1), _h(QmlGraphicsBorderImage::Stretch), _v(QmlGraphicsBorderImage::Stretch)
-{
- int l = -1;
- int r = -1;
- int t = -1;
- int b = -1;
- QString imgFile;
-
- while(!data->atEnd()) {
- QString line = QString::fromUtf8(data->readLine().trimmed());
- if (line.isEmpty() || line.startsWith(QLatin1Char('#')))
- continue;
-
- QStringList list = line.split(QLatin1Char(':'));
- if (list.count() != 2)
- return;
-
- list[0] = list[0].trimmed();
- list[1] = list[1].trimmed();
-
- if (list[0] == QLatin1String("border.left"))
- l = list[1].toInt();
- else if (list[0] == QLatin1String("border.right"))
- r = list[1].toInt();
- else if (list[0] == QLatin1String("border.top"))
- t = list[1].toInt();
- else if (list[0] == QLatin1String("border.bottom"))
- b = list[1].toInt();
- else if (list[0] == QLatin1String("source"))
- imgFile = list[1];
- else if (list[0] == QLatin1String("horizontalTileRule"))
- _h = stringToRule(list[1]);
- else if (list[0] == QLatin1String("verticalTileRule"))
- _v = stringToRule(list[1]);
- }
-
- if (l < 0 || r < 0 || t < 0 || b < 0 || imgFile.isEmpty())
- return;
-
- _l = l; _r = r; _t = t; _b = b;
-
- _pix = imgFile;
-}
-
-QmlGraphicsBorderImage::TileMode QmlGraphicsGridScaledImage::stringToRule(const QString &s)
-{
- if (s == QLatin1String("Stretch"))
- return QmlGraphicsBorderImage::Stretch;
- if (s == QLatin1String("Repeat"))
- return QmlGraphicsBorderImage::Repeat;
- if (s == QLatin1String("Round"))
- return QmlGraphicsBorderImage::Round;
-
- qWarning() << "Unknown tile rule specified. Using Stretch";
- return QmlGraphicsBorderImage::Stretch;
-}
-
-bool QmlGraphicsGridScaledImage::isValid() const
-{
- return _l >= 0;
-}
-
-int QmlGraphicsGridScaledImage::gridLeft() const
-{
- return _l;
-}
-
-int QmlGraphicsGridScaledImage::gridRight() const
-{
- return _r;
-}
-
-int QmlGraphicsGridScaledImage::gridTop() const
-{
- return _t;
-}
-
-int QmlGraphicsGridScaledImage::gridBottom() const
-{
- return _b;
-}
-
-QString QmlGraphicsGridScaledImage::pixmapUrl() const
-{
- return _pix;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h b/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h
deleted file mode 100644
index 650be62..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSSCALEGRID_H
-#define QMLGRAPHICSSCALEGRID_H
-
-#include "qmlgraphicsborderimage_p.h"
-
-#include "../util/qmlpixmapcache_p.h"
-#include <qml.h>
-
-#include <QtCore/QString>
-#include <QtCore/QObject>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsScaleGrid : public QObject
-{
- Q_OBJECT
- Q_ENUMS(TileRule)
-
- Q_PROPERTY(int left READ left WRITE setLeft NOTIFY borderChanged)
- Q_PROPERTY(int top READ top WRITE setTop NOTIFY borderChanged)
- Q_PROPERTY(int right READ right WRITE setRight NOTIFY borderChanged)
- Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY borderChanged)
-
-public:
- QmlGraphicsScaleGrid(QObject *parent=0);
- ~QmlGraphicsScaleGrid();
-
- bool isNull() const;
-
- int left() const { return _left; }
- void setLeft(int);
-
- int top() const { return _top; }
- void setTop(int);
-
- int right() const { return _right; }
- void setRight(int);
-
- int bottom() const { return _bottom; }
- void setBottom(int);
-
-Q_SIGNALS:
- void borderChanged();
-
-private:
- int _left;
- int _top;
- int _right;
- int _bottom;
-};
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsGridScaledImage
-{
-public:
- QmlGraphicsGridScaledImage();
- QmlGraphicsGridScaledImage(const QmlGraphicsGridScaledImage &);
- QmlGraphicsGridScaledImage(QIODevice*);
- QmlGraphicsGridScaledImage &operator=(const QmlGraphicsGridScaledImage &);
- bool isValid() const;
- int gridLeft() const;
- int gridRight() const;
- int gridTop() const;
- int gridBottom() const;
- QmlGraphicsBorderImage::TileMode horizontalTileRule() const { return _h; }
- QmlGraphicsBorderImage::TileMode verticalTileRule() const { return _v; }
-
- QString pixmapUrl() const;
-
-private:
- static QmlGraphicsBorderImage::TileMode stringToRule(const QString &);
-
-private:
- int _l;
- int _r;
- int _t;
- int _b;
- QmlGraphicsBorderImage::TileMode _h;
- QmlGraphicsBorderImage::TileMode _v;
- QString _pix;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsScaleGrid)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSSCALEGRID_H
diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp
deleted file mode 100644
index 57b44d2..0000000
--- a/src/declarative/graphicsitems/qmlgraphicstext.cpp
+++ /dev/null
@@ -1,936 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicstext_p.h"
-#include "qmlgraphicstext_p_p.h"
-#include <qmlstyledtext_p.h>
-
-#include <qfxperf_p_p.h>
-
-#include <QTextLayout>
-#include <QTextLine>
-#include <QTextDocument>
-#include <QTextCursor>
-#include <QGraphicsSceneMouseEvent>
-#include <QPainter>
-#include <QAbstractTextDocumentLayout>
-#include <qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass Text QmlGraphicsText
- \since 4.7
- \brief The Text item allows you to add formatted text to a scene.
- \inherits Item
-
- It can display both plain and rich text. For example:
-
- \qml
- Text { text: "Hello World!"; font.family: "Helvetica"; font.pointSize: 24; color: "red" }
- Text { text: "<b>Hello</b> <i>World!</i>" }
- \endqml
-
- \image declarative-text.png
-
- If height and width are not explicitly set, Text will attempt to determine how
- much room is needed and set it accordingly. Unless \c wrap is set, it will always
- prefer width to height (all text will be placed on a single line).
-
- The \c elide property can alternatively be used to fit a single line of
- plain text to a set width.
-
- Text provides read-only text. For editable text, see \l TextEdit.
-*/
-
-/*!
- \internal
- \class QmlGraphicsText
- \qmlclass Text
- \ingroup group_coreitems
-
- \brief The QmlGraphicsText class provides a formatted text item that you can add to a QmlView.
-
- Text was designed for read-only text; it does not allow for any text editing.
- It can display both plain and rich text. For example:
-
- \qml
- Text { text: "Hello World!"; font.family: "Helvetica"; font.pointSize: 24; color: "red" }
- Text { text: "<b>Hello</b> <i>World!</i>" }
- \endqml
-
- \image text.png
-
- If height and width are not explicitly set, Text will attempt to determine how
- much room is needed and set it accordingly. Unless \c wrap is set, it will always
- prefer width to height (all text will be placed on a single line).
-
- The \c elide property can alternatively be used to fit a line of plain text to a set width.
-
- A QmlGraphicsText object can be instantiated in Qml using the tag \c Text.
-*/
-QmlGraphicsText::QmlGraphicsText(QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsTextPrivate), parent)
-{
- setAcceptedMouseButtons(Qt::LeftButton);
- setFlag(QGraphicsItem::ItemHasNoContents, false);
-}
-
-QmlGraphicsText::~QmlGraphicsText()
-{
-}
-
-
-QmlGraphicsTextPrivate::~QmlGraphicsTextPrivate()
-{
-}
-
-/*!
- \qmlproperty string Text::font.family
- \qmlproperty bool Text::font.bold
- \qmlproperty bool Text::font.italic
- \qmlproperty bool Text::font.underline
- \qmlproperty real Text::font.pointSize
- \qmlproperty int Text::font.pixelSize
-
- Set the Text's font attributes.
-*/
-QFont QmlGraphicsText::font() const
-{
- Q_D(const QmlGraphicsText);
- return d->font;
-}
-
-void QmlGraphicsText::setFont(const QFont &font)
-{
- Q_D(QmlGraphicsText);
- if (d->font == font)
- return;
-
- d->font = font;
-
- d->updateLayout();
- d->markImgDirty();
- emit fontChanged(d->font);
-}
-
-void QmlGraphicsText::setText(const QString &n)
-{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::QmlGraphicsText_setText> st;
-#endif
- Q_D(QmlGraphicsText);
- if (d->text == n)
- return;
-
- d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(n));
- if (d->richText) {
- if (!d->doc) {
- d->doc = new QTextDocument(this);
- d->doc->setDocumentMargin(0);
- }
- d->doc->setHtml(n);
- }
-
- d->text = n;
- d->updateLayout();
- d->markImgDirty();
- emit textChanged(d->text);
-}
-
-/*!
- \qmlproperty string Text::text
-
- The text to display. Text supports both plain and rich text strings.
-
- The item will try to automatically determine whether the text should
- be treated as rich text. This determination is made using Qt::mightBeRichText().
-*/
-QString QmlGraphicsText::text() const
-{
- Q_D(const QmlGraphicsText);
- return d->text;
-}
-
-void QmlGraphicsText::setColor(const QColor &color)
-{
- Q_D(QmlGraphicsText);
- if (d->color == color)
- return;
-
- d->color = color;
- d->markImgDirty();
- emit colorChanged(d->color);
-}
-
-/*!
- \qmlproperty color Text::color
-
- The text color.
-
- \qml
- //green text using hexadecimal notation
- Text { color: "#00FF00"; ... }
-
- //steelblue text using SVG color name
- Text { color: "steelblue"; ... }
- \endqml
-*/
-
-QColor QmlGraphicsText::color() const
-{
- Q_D(const QmlGraphicsText);
- return d->color;
-}
-
-/*!
- \qmlproperty enumeration Text::style
-
- Set an additional text style.
-
- Supported text styles are \c Normal, \c Outline, \c Raised and \c Sunken.
-
- \qml
- Row {
- Text { font.pointSize: 24; text: "Normal" }
- Text { font.pointSize: 24; text: "Raised"; style: Text.Raised; styleColor: "#AAAAAA" }
- Text { font.pointSize: 24; text: "Outline"; style: Text.Outline; styleColor: "red" }
- Text { font.pointSize: 24; text: "Sunken"; style: Text.Sunken; styleColor: "#AAAAAA" }
- }
- \endqml
-
- \image declarative-textstyle.png
-*/
-QmlGraphicsText::TextStyle QmlGraphicsText::style() const
-{
- Q_D(const QmlGraphicsText);
- return d->style;
-}
-
-void QmlGraphicsText::setStyle(QmlGraphicsText::TextStyle style)
-{
- Q_D(QmlGraphicsText);
- if (d->style == style)
- return;
-
- d->style = style;
- d->markImgDirty();
- emit styleChanged(d->style);
-}
-
-void QmlGraphicsText::setStyleColor(const QColor &color)
-{
- Q_D(QmlGraphicsText);
- if (d->styleColor == color)
- return;
-
- d->styleColor = color;
- d->markImgDirty();
- emit styleColorChanged(d->styleColor);
-}
-
-/*!
- \qmlproperty color Text::styleColor
-
- Defines the secondary color used by text styles.
-
- \c styleColor is used as the outline color for outlined text, and as the
- shadow color for raised or sunken text. If no style has been set, it is not
- used at all.
- */
-QColor QmlGraphicsText::styleColor() const
-{
- Q_D(const QmlGraphicsText);
- return d->styleColor;
-}
-
-/*!
- \qmlproperty enumeration Text::horizontalAlignment
- \qmlproperty enumeration Text::verticalAlignment
-
- Sets the horizontal and vertical alignment of the text within the Text items
- width and height. By default, the text is top-left aligned.
-
- The valid values for \c horizontalAlignment are \c AlignLeft, \c AlignRight and
- \c AlignHCenter. The valid values for \c verticalAlignment are \c AlignTop, \c AlignBottom
- and \c AlignVCenter.
-*/
-QmlGraphicsText::HAlignment QmlGraphicsText::hAlign() const
-{
- Q_D(const QmlGraphicsText);
- return d->hAlign;
-}
-
-void QmlGraphicsText::setHAlign(HAlignment align)
-{
- Q_D(QmlGraphicsText);
- if (d->hAlign == align)
- return;
-
- d->hAlign = align;
- emit horizontalAlignmentChanged(align);
-}
-
-QmlGraphicsText::VAlignment QmlGraphicsText::vAlign() const
-{
- Q_D(const QmlGraphicsText);
- return d->vAlign;
-}
-
-void QmlGraphicsText::setVAlign(VAlignment align)
-{
- Q_D(QmlGraphicsText);
- if (d->vAlign == align)
- return;
-
- d->vAlign = align;
- emit verticalAlignmentChanged(align);
-}
-
-/*!
- \qmlproperty bool Text::wrap
-
- Set this property to wrap the text to the Text item's width. The text will only
- wrap if an explicit width has been set.
-
- Wrapping is done on word boundaries (i.e. it is a "word-wrap"). If the text cannot be
- word-wrapped to the specified width it will be partially drawn outside of the item's bounds.
- If this is undesirable then enable clipping on the item (Item::clip).
-
- Wrapping is off by default.
-*/
-//### Future may provide choice of wrap modes, such as QTextOption::WrapAtWordBoundaryOrAnywhere
-bool QmlGraphicsText::wrap() const
-{
- Q_D(const QmlGraphicsText);
- return d->wrap;
-}
-
-void QmlGraphicsText::setWrap(bool w)
-{
- Q_D(QmlGraphicsText);
- if (w == d->wrap)
- return;
-
- d->wrap = w;
-
- d->updateLayout();
- d->markImgDirty();
- emit wrapChanged(d->wrap);
-}
-
-/*!
- \qmlproperty enumeration Text::textFormat
-
- The way the text property should be displayed.
-
- Supported text formats are \c AutoText, \c PlainText, \c RichText and \c StyledText
-
- The default is AutoText. If the text format is AutoText the text element
- will automatically determine whether the text should be treated as
- rich text. This determination is made using Qt::mightBeRichText().
-
- StyledText is an optimized format supporting some basic text
- styling markup, in the style of html 3.2:
-
- \code
- <font size="4" color="#ff0000">font size and color</font>
- <b>bold</b>
- <i>italic</i>
- <br>
- &gt; &lt; &amp;
- \endcode
-
- \c StyledText parser is strict, requiring tags to be correctly nested.
-
- \table
- \row
- \o
- \qml
-Column {
- TextEdit {
- font.pointSize: 24
- text: "<b>Hello</b> <i>World!</i>"
- }
- TextEdit {
- font.pointSize: 24
- textFormat: "RichText"
- text: "<b>Hello</b> <i>World!</i>"
- }
- TextEdit {
- font.pointSize: 24
- textFormat: "PlainText"
- text: "<b>Hello</b> <i>World!</i>"
- }
-}
- \endqml
- \o \image declarative-textformat.png
- \endtable
-*/
-
-QmlGraphicsText::TextFormat QmlGraphicsText::textFormat() const
-{
- Q_D(const QmlGraphicsText);
- return d->format;
-}
-
-void QmlGraphicsText::setTextFormat(TextFormat format)
-{
- Q_D(QmlGraphicsText);
- if (format == d->format)
- return;
- d->format = format;
- bool wasRich = d->richText;
- d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text));
-
- if (wasRich && !d->richText) {
- //### delete control? (and vice-versa below)
- d->updateLayout();
- d->markImgDirty();
- } else if (!wasRich && d->richText) {
- if (!d->doc) {
- d->doc = new QTextDocument(this);
- d->doc->setDocumentMargin(0);
- }
- d->doc->setHtml(d->text);
- d->updateLayout();
- d->markImgDirty();
- }
-
- emit textFormatChanged(d->format);
-}
-
-/*!
- \qmlproperty enumeration Text::elide
-
- Set this property to elide parts of the text fit to the Text item's width.
- The text will only elide if an explicit width has been set.
-
- This property cannot be used with wrap enabled or with rich text.
-
- Eliding can be \c ElideNone (the default), \c ElideLeft, \c ElideMiddle, or \c ElideRight.
-
- If the text is a multi-length string, and the mode is not \c ElideNone,
- the first string that fits will be used, otherwise the last will be elided.
-
- Multi-length strings are ordered from longest to shortest, separated by the
- Unicode "String Terminator" character \c U009C (write this in QML with \c{"\u009C"} or \c{"\x9C"}).
-*/
-QmlGraphicsText::TextElideMode QmlGraphicsText::elideMode() const
-{
- Q_D(const QmlGraphicsText);
- return d->elideMode;
-}
-
-void QmlGraphicsText::setElideMode(QmlGraphicsText::TextElideMode mode)
-{
- Q_D(QmlGraphicsText);
- if (mode == d->elideMode)
- return;
-
- d->elideMode = mode;
-
- d->updateLayout();
- d->markImgDirty();
- emit elideModeChanged(d->elideMode);
-}
-
-void QmlGraphicsText::geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry)
-{
- Q_D(QmlGraphicsText);
- if (newGeometry.width() != oldGeometry.width()) {
- if (d->wrap || d->elideMode != QmlGraphicsText::ElideNone) {
- //re-elide if needed
- if (d->singleline && d->elideMode != QmlGraphicsText::ElideNone &&
- isComponentComplete() && widthValid()) {
-
- QFontMetrics fm(d->font);
- QString tmp = fm.elidedText(d->text,(Qt::TextElideMode)d->elideMode,width()); // XXX still worth layout...?
- d->layout.setText(tmp);
- }
-
- d->imgDirty = true;
- d->updateSize();
- }
- }
- QmlGraphicsItem::geometryChanged(newGeometry, oldGeometry);
-}
-
-void QmlGraphicsTextPrivate::updateLayout()
-{
- Q_Q(QmlGraphicsText);
- if (q->isComponentComplete()) {
- //setup instance of QTextLayout for all cases other than richtext
- if (!richText) {
- layout.clearLayout();
- layout.setFont(font);
- if (format != QmlGraphicsText::StyledText) {
- QString tmp = text;
- tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
- singleline = !tmp.contains(QChar::LineSeparator);
- if (singleline && elideMode != QmlGraphicsText::ElideNone && q->widthValid()) {
- QFontMetrics fm(font);
- tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); // XXX still worth layout...?
- }
- layout.setText(tmp);
- } else {
- singleline = false;
- QmlStyledText::parse(text, layout);
- }
- }
- updateSize();
- } else {
- dirty = true;
- }
-}
-
-void QmlGraphicsTextPrivate::updateSize()
-{
- Q_Q(QmlGraphicsText);
- if (q->isComponentComplete()) {
- QFontMetrics fm(font);
- if (text.isEmpty()) {
- q->setImplicitHeight(fm.height());
- return;
- }
-
- int dy = q->height();
- QSize size(0, 0);
-
- //setup instance of QTextLayout for all cases other than richtext
- if (!richText) {
- size = setupTextLayout(&layout);
- cachedLayoutSize = size;
- dy -= size.height();
- } else {
- singleline = false; // richtext can't elide or be optimized for single-line case
- doc->setDefaultFont(font);
- QTextOption option((Qt::Alignment)int(hAlign | vAlign));
- if (wrap)
- option.setWrapMode(QTextOption::WordWrap);
- else
- option.setWrapMode(QTextOption::NoWrap);
- doc->setDefaultTextOption(option);
- if (wrap && !q->heightValid() && q->widthValid())
- doc->setTextWidth(q->width());
- else
- doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
- dy -= (int)doc->size().height();
- cachedLayoutSize = doc->size().toSize();
- }
- int yoff = 0;
-
- if (q->heightValid()) {
- if (vAlign == QmlGraphicsText::AlignBottom)
- yoff = dy;
- else if (vAlign == QmlGraphicsText::AlignVCenter)
- yoff = dy/2;
- }
- q->setBaselineOffset(fm.ascent() + yoff);
-
- //### need to comfirm cost of always setting these for richText
- q->setImplicitWidth(richText ? (int)doc->idealWidth() : size.width());
- q->setImplicitHeight(richText ? (int)doc->size().height() : size.height());
- } else {
- dirty = true;
- }
-}
-
-// ### text layout handling should be profiled and optimized as needed
-// what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine);
-
-void QmlGraphicsTextPrivate::drawOutline()
-{
- QPixmap img = QPixmap(imgStyleCache.width()+2,imgStyleCache.height()+2);
- img.fill(Qt::transparent);
-
- QPainter ppm(&img);
-
- QPoint pos(imgCache.rect().topLeft());
- pos += QPoint(-1, 0);
- ppm.drawPixmap(pos, imgStyleCache);
- pos += QPoint(2, 0);
- ppm.drawPixmap(pos, imgStyleCache);
- pos += QPoint(-1, -1);
- ppm.drawPixmap(pos, imgStyleCache);
- pos += QPoint(0, 2);
- ppm.drawPixmap(pos, imgStyleCache);
-
- pos += QPoint(0, -1);
- ppm.drawPixmap(pos, imgCache);
- ppm.end();
-
- imgCache = img;
-}
-
-void QmlGraphicsTextPrivate::drawOutline(int yOffset)
-{
- QPixmap img = QPixmap(imgStyleCache.width()+2,imgStyleCache.height()+2);
- img.fill(Qt::transparent);
-
- QPainter ppm(&img);
-
- QPoint pos(imgCache.rect().topLeft());
- pos += QPoint(0, yOffset);
- ppm.drawPixmap(pos, imgStyleCache);
-
- pos += QPoint(0, -yOffset);
- ppm.drawPixmap(pos, imgCache);
- ppm.end();
-
- imgCache = img;
-}
-
-QSize QmlGraphicsTextPrivate::setupTextLayout(QTextLayout *layout)
-{
- Q_Q(QmlGraphicsText);
- layout->setCacheEnabled(true);
-
- int height = 0;
- qreal widthUsed = 0;
- qreal lineWidth = 0;
-
- //set manual width
- if ((wrap || elideMode != QmlGraphicsText::ElideNone) && q->widthValid())
- lineWidth = q->width();
-
- layout->beginLayout();
-
- while (1) {
- QTextLine line = layout->createLine();
- if (!line.isValid())
- break;
-
- if ((wrap || elideMode != QmlGraphicsText::ElideNone) && q->widthValid())
- line.setLineWidth(lineWidth);
- }
- layout->endLayout();
-
- int x = 0;
- for (int i = 0; i < layout->lineCount(); ++i) {
- QTextLine line = layout->lineAt(i);
- widthUsed = qMax(widthUsed, line.naturalTextWidth());
- line.setPosition(QPointF(0, height));
- height += int(line.height());
-
- if (!cache) {
- if (hAlign == QmlGraphicsText::AlignLeft) {
- x = 0;
- } else if (hAlign == QmlGraphicsText::AlignRight) {
- x = q->width() - (int)line.naturalTextWidth();
- } else if (hAlign == QmlGraphicsText::AlignHCenter) {
- x = (q->width() - (int)line.naturalTextWidth()) / 2;
- }
- line.setPosition(QPoint(x, (int)line.y()));
- }
- }
-
- return QSize(qCeil(widthUsed), height);
-}
-
-QPixmap QmlGraphicsTextPrivate::wrappedTextImage(bool drawStyle)
-{
- //do layout
- QSize size = cachedLayoutSize;
-
- int x = 0;
- for (int i = 0; i < layout.lineCount(); ++i) {
- QTextLine line = layout.lineAt(i);
- if (hAlign == QmlGraphicsText::AlignLeft) {
- x = 0;
- } else if (hAlign == QmlGraphicsText::AlignRight) {
- x = size.width() - (int)line.naturalTextWidth();
- } else if (hAlign == QmlGraphicsText::AlignHCenter) {
- x = (size.width() - (int)line.naturalTextWidth()) / 2;
- }
- line.setPosition(QPoint(x, (int)line.y()));
- }
-
- //paint text
- QPixmap img(size);
- if (!size.isEmpty()) {
- img.fill(Qt::transparent);
- QPainter p(&img);
- drawWrappedText(&p, QPointF(0,0), drawStyle);
- }
- return img;
-}
-
-void QmlGraphicsTextPrivate::drawWrappedText(QPainter *p, const QPointF &pos, bool drawStyle)
-{
- if (drawStyle)
- p->setPen(styleColor);
- else
- p->setPen(color);
- p->setFont(font);
- layout.draw(p, pos);
-}
-
-QPixmap QmlGraphicsTextPrivate::richTextImage(bool drawStyle)
-{
- QSize size = doc->size().toSize();
-
- //paint text
- QPixmap img(size);
- img.fill(Qt::transparent);
- QPainter p(&img);
-
- QAbstractTextDocumentLayout::PaintContext context;
-
- if (drawStyle) {
- context.palette.setColor(QPalette::Text, styleColor);
- // ### Do we really want this?
- QTextOption colorOption;
- colorOption.setFlags(QTextOption::SuppressColors);
- doc->setDefaultTextOption(colorOption);
- } else {
- context.palette.setColor(QPalette::Text, color);
- }
- doc->documentLayout()->draw(&p, context);
- if (drawStyle)
- doc->setDefaultTextOption(QTextOption());
- return img;
-}
-
-void QmlGraphicsTextPrivate::checkImgCache()
-{
- if (!imgDirty)
- return;
-
- bool empty = text.isEmpty();
- if (empty) {
- imgCache = QPixmap();
- imgStyleCache = QPixmap();
- } else if (richText) {
- imgCache = richTextImage(false);
- if (style != QmlGraphicsText::Normal)
- imgStyleCache = richTextImage(true); //### should use styleColor
- } else {
- imgCache = wrappedTextImage(false);
- if (style != QmlGraphicsText::Normal)
- imgStyleCache = wrappedTextImage(true); //### should use styleColor
- }
- if (!empty)
- switch (style) {
- case QmlGraphicsText::Outline:
- drawOutline();
- break;
- case QmlGraphicsText::Sunken:
- drawOutline(-1);
- break;
- case QmlGraphicsText::Raised:
- drawOutline(1);
- break;
- default:
- break;
- }
-
- imgDirty = false;
-}
-
-void QmlGraphicsText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
-{
- Q_D(QmlGraphicsText);
-
- if (d->cache || d->style != Normal) {
- d->checkImgCache();
- if (d->imgCache.isNull())
- return;
-
- bool oldAA = p->testRenderHint(QPainter::Antialiasing);
- bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
- if (d->smooth)
- p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
-
- int w = width();
- int h = height();
-
- int x = 0;
- int y = 0;
-
- switch (d->hAlign) {
- case AlignLeft:
- x = 0;
- break;
- case AlignRight:
- x = w - d->imgCache.width();
- break;
- case AlignHCenter:
- x = (w - d->imgCache.width()) / 2;
- break;
- }
-
- switch (d->vAlign) {
- case AlignTop:
- y = 0;
- break;
- case AlignBottom:
- y = h - d->imgCache.height();
- break;
- case AlignVCenter:
- y = (h - d->imgCache.height()) / 2;
- break;
- }
-
- bool needClip = !clip() && (d->imgCache.width() > width() ||
- d->imgCache.height() > height());
-
- if (needClip) {
- p->save();
- p->setClipRect(boundingRect(), Qt::IntersectClip);
- }
- p->drawPixmap(x, y, d->imgCache);
- if (needClip)
- p->restore();
-
- if (d->smooth) {
- p->setRenderHint(QPainter::Antialiasing, oldAA);
- p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
- }
- } else {
- int h = height();
- int y = 0;
-
- switch (d->vAlign) {
- case AlignTop:
- y = 0;
- break;
- case AlignBottom:
- y = h - d->cachedLayoutSize.height();
- break;
- case AlignVCenter:
- y = (h - d->cachedLayoutSize.height()) / 2;
- break;
- }
- bool needClip = !clip() && (d->cachedLayoutSize.width() > width() ||
- d->cachedLayoutSize.height() > height());
-
- if (needClip) {
- p->save();
- p->setClipRect(boundingRect(), Qt::IntersectClip);
- }
- if (d->richText) {
- QAbstractTextDocumentLayout::PaintContext context;
- context.palette.setColor(QPalette::Text, d->color);
- p->translate(0, y);
- d->doc->documentLayout()->draw(p, context);
- p->translate(0, -y);
- } else {
- d->drawWrappedText(p, QPointF(0,y), false);
- }
- if (needClip)
- p->restore();
- }
-}
-
-/*!
- \qmlproperty bool Text::smooth
-
- Set this property if you want the text to be smoothly scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the item is displayed at its natural size, this property has no visual or
- performance effect.
-
- \note Generally scaling artifacts are only visible if the item is stationary on
- the screen. A common pattern when animating an item is to disable smooth
- filtering at the beginning of the animation and reenable it at the conclusion.
-*/
-
-void QmlGraphicsText::componentComplete()
-{
- Q_D(QmlGraphicsText);
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::TextComponentComplete> cc;
-#endif
- QmlGraphicsItem::componentComplete();
- if (d->dirty) {
- d->updateLayout();
- d->dirty = false;
- }
-}
-
-/*!
- \overload
- Handles the given mouse \a event.
- */
-void QmlGraphicsText::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsText);
-
- if (!d->richText || !d->doc || d->doc->documentLayout()->anchorAt(event->pos()).isEmpty()) {
- event->setAccepted(false);
- d->activeLink = QString();
- } else {
- d->activeLink = d->doc->documentLayout()->anchorAt(event->pos());
- }
-
- // ### may malfunction if two of the same links are clicked & dragged onto each other)
-
- if (!event->isAccepted())
- QmlGraphicsItem::mousePressEvent(event);
-
-}
-
-/*!
- \qmlsignal Text::linkActivated(link)
-
- This handler is called when the user clicks on a link embedded in the text.
-*/
-
-/*!
- \overload
- Handles the given mouse \a event.
- */
-void QmlGraphicsText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsText);
-
- // ### confirm the link, and send a signal out
- if (d->richText && d->doc && d->activeLink == d->doc->documentLayout()->anchorAt(event->pos()))
- emit linkActivated(d->activeLink);
- else
- event->setAccepted(false);
-
- if (!event->isAccepted())
- QmlGraphicsItem::mouseReleaseEvent(event);
-}
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicstext_p.h b/src/declarative/graphicsitems/qmlgraphicstext_p.h
deleted file mode 100644
index ad35524..0000000
--- a/src/declarative/graphicsitems/qmlgraphicstext_p.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSTEXT_H
-#define QMLGRAPHICSTEXT_H
-
-#include "qmlgraphicsitem.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QmlGraphicsTextPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsText : public QmlGraphicsItem
-{
- Q_OBJECT
- Q_ENUMS(HAlignment)
- Q_ENUMS(VAlignment)
- Q_ENUMS(TextStyle)
- Q_ENUMS(TextFormat)
- Q_ENUMS(TextElideMode)
-
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
- Q_PROPERTY(TextStyle style READ style WRITE setStyle NOTIFY styleChanged)
- Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor NOTIFY styleColorChanged)
- Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
- Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
- Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged) //### there are several wrap modes in Qt
- Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
- Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode?
-
-public:
- QmlGraphicsText(QmlGraphicsItem *parent=0);
- ~QmlGraphicsText();
-
- enum HAlignment { AlignLeft = Qt::AlignLeft,
- AlignRight = Qt::AlignRight,
- AlignHCenter = Qt::AlignHCenter };
- enum VAlignment { AlignTop = Qt::AlignTop,
- AlignBottom = Qt::AlignBottom,
- AlignVCenter = Qt::AlignVCenter };
- enum TextStyle { Normal,
- Outline,
- Raised,
- Sunken };
- enum TextFormat { PlainText = Qt::PlainText,
- RichText = Qt::RichText,
- AutoText = Qt::AutoText,
- StyledText = 4 };
- enum TextElideMode { ElideLeft = Qt::ElideLeft,
- ElideRight = Qt::ElideRight,
- ElideMiddle = Qt::ElideMiddle,
- ElideNone = Qt::ElideNone };
-
- QString text() const;
- void setText(const QString &);
-
- QFont font() const;
- void setFont(const QFont &font);
-
- QColor color() const;
- void setColor(const QColor &c);
-
- TextStyle style() const;
- void setStyle(TextStyle style);
-
- QColor styleColor() const;
- void setStyleColor(const QColor &c);
-
- HAlignment hAlign() const;
- void setHAlign(HAlignment align);
-
- VAlignment vAlign() const;
- void setVAlign(VAlignment align);
-
- bool wrap() const;
- void setWrap(bool w);
-
- TextFormat textFormat() const;
- void setTextFormat(TextFormat format);
-
- TextElideMode elideMode() const;
- void setElideMode(TextElideMode);
-
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
-
- virtual void componentComplete();
-
-Q_SIGNALS:
- void textChanged(const QString &text);
- void linkActivated(const QString &link);
- void fontChanged(const QFont &font);
- void colorChanged(const QColor &color);
- void styleChanged(TextStyle style);
- void styleColorChanged(const QColor &color);
- void horizontalAlignmentChanged(HAlignment alignment);
- void verticalAlignmentChanged(VAlignment alignment);
- void wrapChanged(bool wrap);
- void textFormatChanged(TextFormat textFormat);
- void elideModeChanged(TextElideMode mode);
-
-protected:
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- virtual void geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry);
-
-private:
- Q_DISABLE_COPY(QmlGraphicsText)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsText)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsText)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
deleted file mode 100644
index f67d57c..0000000
--- a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSTEXT_P_H
-#define QMLGRAPHICSTEXT_P_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 "qmlgraphicsitem.h"
-#include "qmlgraphicsitem_p.h"
-
-#include <qml.h>
-
-#include <QtGui/qtextlayout.h>
-
-QT_BEGIN_NAMESPACE
-
-class QTextLayout;
-class QTextDocument;
-
-class QmlGraphicsTextPrivate : public QmlGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsText)
-public:
- QmlGraphicsTextPrivate()
- : color((QRgb)0), style(QmlGraphicsText::Normal), imgDirty(true),
- hAlign(QmlGraphicsText::AlignLeft), vAlign(QmlGraphicsText::AlignTop), elideMode(QmlGraphicsText::ElideNone),
- dirty(true), wrap(false), richText(false), singleline(false), cache(true), doc(0),
- format(QmlGraphicsText::AutoText)
- {
-#if defined(QML_NO_TEXT_CACHE)
- cache = false;
-#endif
- }
-
- ~QmlGraphicsTextPrivate();
-
- void updateSize();
- void updateLayout();
- void markImgDirty() {
- Q_Q(QmlGraphicsText);
- imgDirty = true;
- if (q->isComponentComplete())
- q->update();
- }
- void checkImgCache();
-
- void drawOutline();
- void drawOutline(int yOffset);
-
- QPixmap wrappedTextImage(bool drawStyle);
- void drawWrappedText(QPainter *p, const QPointF &pos, bool drawStyle);
- QPixmap richTextImage(bool drawStyle);
- QSize setupTextLayout(QTextLayout *layout);
-
- QString text;
- QFont font;
- QColor color;
- QmlGraphicsText::TextStyle style;
- QColor styleColor;
- QString activeLink;
- bool imgDirty;
- QPixmap imgCache;
- QPixmap imgStyleCache;
- QmlGraphicsText::HAlignment hAlign;
- QmlGraphicsText::VAlignment vAlign;
- QmlGraphicsText::TextElideMode elideMode;
- bool dirty:1;
- bool wrap:1;
- bool richText:1;
- bool singleline:1;
- bool cache:1;
- QTextDocument *doc;
- QTextLayout layout;
- QSize cachedLayoutSize;
- QmlGraphicsText::TextFormat format;
-};
-
-QT_END_NAMESPACE
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
deleted file mode 100644
index 364751d..0000000
--- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
+++ /dev/null
@@ -1,1035 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicstextedit_p.h"
-#include "qmlgraphicstextedit_p_p.h"
-
-#include "qmlgraphicsevents_p_p.h"
-
-#include <qfxperf_p_p.h>
-
-#include <QTextLayout>
-#include <QTextLine>
-#include <QTextDocument>
-#include <QGraphicsSceneMouseEvent>
-#include <QDebug>
-#include <QPainter>
-
-#include <private/qtextcontrol_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass TextEdit QmlGraphicsTextEdit
- \since 4.7
- \brief The TextEdit item allows you to add editable formatted text to a scene.
-
- It can display both plain and rich text. For example:
-
- \qml
-TextEdit {
- id: edit
- text: "<b>Hello</b> <i>World!</i>"
- focus: true
- font.family: "Helvetica"
- font.pointSize: 20
- color: "blue"
- width: 240
-}
- \endqml
-
- \image declarative-textedit.gif
-
- \sa Text
-*/
-
-/*!
- \internal
- \class QmlGraphicsTextEdit
- \qmlclass TextEdit
- \ingroup group_coreitems
-
- \brief The QmlGraphicsTextEdit class provides an editable formatted text item that you can add to a QmlView.
-
- It can display both plain and rich text.
-
- \image declarative-textedit.png
-
- A QmlGraphicsTextEdit object can be instantiated in Qml using the tag \c &lt;TextEdit&gt;.
-*/
-
-/*!
- Constructs a new QmlGraphicsTextEdit.
-*/
-QmlGraphicsTextEdit::QmlGraphicsTextEdit(QmlGraphicsItem *parent)
-: QmlGraphicsPaintedItem(*(new QmlGraphicsTextEditPrivate), parent)
-{
- Q_D(QmlGraphicsTextEdit);
- d->init();
-}
-
-QString QmlGraphicsTextEdit::text() const
-{
- Q_D(const QmlGraphicsTextEdit);
-
- if (d->richText)
- return d->document->toHtml();
- else
- return d->document->toPlainText();
-}
-
-/*!
- \qmlproperty string TextEdit::font.family
- \qmlproperty bool TextEdit::font.bold
- \qmlproperty bool TextEdit::font.italic
- \qmlproperty bool TextEdit::font.underline
- \qmlproperty real TextEdit::font.pointSize
- \qmlproperty int TextEdit::font.pixelSize
-
- Set the TextEdit's font attributes.
-*/
-
-/*!
- \qmlproperty string TextEdit::text
-
- The text to display. If the text format is AutoText the text edit will
- automatically determine whether the text should be treated as
- rich text. This determination is made using Qt::mightBeRichText().
-*/
-void QmlGraphicsTextEdit::setText(const QString &text)
-{
- Q_D(QmlGraphicsTextEdit);
- if (QmlGraphicsTextEdit::text() == text)
- return;
- d->text = text;
- d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text));
- if (d->richText) {
- d->control->setHtml(text);
- } else {
- d->control->setPlainText(text);
- }
- q_textChanged();
-}
-
-/*!
- \qmlproperty enumeration TextEdit::textFormat
-
- The way the text property should be displayed.
-
- Supported text formats are \c AutoText, \c PlainText and \c RichText.
-
- The default is AutoText. If the text format is AutoText the text edit
- will automatically determine whether the text should be treated as
- rich text. This determination is made using Qt::mightBeRichText().
-
- \table
- \row
- \o
- \qml
-Column {
- TextEdit {
- font.pointSize: 24
- text: "<b>Hello</b> <i>World!</i>"
- }
- TextEdit {
- font.pointSize: 24
- textFormat: "RichText"
- text: "<b>Hello</b> <i>World!</i>"
- }
- TextEdit {
- font.pointSize: 24
- textFormat: "PlainText"
- text: "<b>Hello</b> <i>World!</i>"
- }
-}
- \endqml
- \o \image declarative-textformat.png
- \endtable
-*/
-QmlGraphicsTextEdit::TextFormat QmlGraphicsTextEdit::textFormat() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->format;
-}
-
-void QmlGraphicsTextEdit::setTextFormat(TextFormat format)
-{
- Q_D(QmlGraphicsTextEdit);
- if (format == d->format)
- return;
- bool wasRich = d->richText;
- d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text));
-
- if (wasRich && !d->richText) {
- d->control->setPlainText(d->text);
- updateSize();
- } else if (!wasRich && d->richText) {
- d->control->setHtml(d->text);
- updateSize();
- }
- d->format = format;
- emit textFormatChanged(d->format);
-}
-
-QFont QmlGraphicsTextEdit::font() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->font;
-}
-
-void QmlGraphicsTextEdit::setFont(const QFont &font)
-{
- Q_D(QmlGraphicsTextEdit);
- d->font = font;
-
- clearCache();
- d->document->setDefaultFont(d->font);
- if(d->cursor){
- d->cursor->setHeight(QFontMetrics(d->font).height());
- moveCursorDelegate();
- }
- updateSize();
- update();
-}
-
-/*!
- \qmlproperty color TextEdit::color
-
- The text color.
-
- \qml
-// green text using hexadecimal notation
-TextEdit { color: "#00FF00"; ... }
-
-// steelblue text using SVG color name
-TextEdit { color: "steelblue"; ... }
- \endqml
-*/
-QColor QmlGraphicsTextEdit::color() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->color;
-}
-
-void QmlGraphicsTextEdit::setColor(const QColor &color)
-{
- Q_D(QmlGraphicsTextEdit);
- if (d->color == color)
- return;
-
- clearCache();
- d->color = color;
- QPalette pal = d->control->palette();
- pal.setColor(QPalette::Text, color);
- d->control->setPalette(pal);
- update();
- emit colorChanged(d->color);
-}
-
-/*!
- \qmlproperty color TextEdit::selectionColor
-
- The text highlight color, used behind selections.
-*/
-QColor QmlGraphicsTextEdit::selectionColor() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->selectionColor;
-}
-
-void QmlGraphicsTextEdit::setSelectionColor(const QColor &color)
-{
- Q_D(QmlGraphicsTextEdit);
- if (d->selectionColor == color)
- return;
-
- clearCache();
- d->selectionColor = color;
- QPalette pal = d->control->palette();
- pal.setColor(QPalette::Highlight, color);
- d->control->setPalette(pal);
- update();
- emit selectionColorChanged(d->selectionColor);
-}
-
-/*!
- \qmlproperty color TextEdit::selectedTextColor
-
- The selected text color, used in selections.
-*/
-QColor QmlGraphicsTextEdit::selectedTextColor() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->selectedTextColor;
-}
-
-void QmlGraphicsTextEdit::setSelectedTextColor(const QColor &color)
-{
- Q_D(QmlGraphicsTextEdit);
- if (d->selectedTextColor == color)
- return;
-
- clearCache();
- d->selectedTextColor = color;
- QPalette pal = d->control->palette();
- pal.setColor(QPalette::HighlightedText, color);
- d->control->setPalette(pal);
- update();
- emit selectedTextColorChanged(d->selectedTextColor);
-}
-
-/*!
- \qmlproperty enumeration TextEdit::horizontalAlignment
- \qmlproperty enumeration TextEdit::verticalAlignment
-
- Sets the horizontal and vertical alignment of the text within the TextEdit items
- width and height. By default, the text is top-left aligned.
-
- The valid values for \c horizontalAlignment are \c AlignLeft, \c AlignRight and
- \c AlignHCenter. The valid values for \c verticalAlignment are \c AlignTop, \c AlignBottom
- and \c AlignVCenter.
-*/
-QmlGraphicsTextEdit::HAlignment QmlGraphicsTextEdit::hAlign() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->hAlign;
-}
-
-void QmlGraphicsTextEdit::setHAlign(QmlGraphicsTextEdit::HAlignment alignment)
-{
- Q_D(QmlGraphicsTextEdit);
- if (alignment == d->hAlign)
- return;
- d->hAlign = alignment;
- d->updateDefaultTextOption();
- updateSize();
- emit horizontalAlignmentChanged(d->hAlign);
-}
-
-QmlGraphicsTextEdit::VAlignment QmlGraphicsTextEdit::vAlign() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->vAlign;
-}
-
-void QmlGraphicsTextEdit::setVAlign(QmlGraphicsTextEdit::VAlignment alignment)
-{
- Q_D(QmlGraphicsTextEdit);
- if (alignment == d->vAlign)
- return;
- d->vAlign = alignment;
- d->updateDefaultTextOption();
- updateSize();
- emit verticalAlignmentChanged(d->vAlign);
-}
-
-bool QmlGraphicsTextEdit::wrap() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->wrap;
-}
-
-/*!
- \qmlproperty bool TextEdit::wrap
-
- Set this property to wrap the text to the TextEdit item's width.
- The text will only wrap if an explicit width has been set.
-
- Wrapping is done on word boundaries (i.e. it is a "word-wrap"). Wrapping is off by default.
-*/
-void QmlGraphicsTextEdit::setWrap(bool w)
-{
- Q_D(QmlGraphicsTextEdit);
- if (w == d->wrap)
- return;
- d->wrap = w;
- d->updateDefaultTextOption();
- updateSize();
- emit wrapChanged(d->wrap);
-}
-
-/*!
- \qmlproperty bool TextEdit::cursorVisible
- If true the text edit shows a cursor.
-
- This property is set and unset when the text edit gets focus, but it can also
- be set directly (useful, for example, if a KeyProxy might forward keys to it).
-*/
-bool QmlGraphicsTextEdit::isCursorVisible() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->cursorVisible;
-}
-
-void QmlGraphicsTextEdit::setCursorVisible(bool on)
-{
- Q_D(QmlGraphicsTextEdit);
- if (d->cursorVisible == on)
- return;
- d->cursorVisible = on;
- QFocusEvent focusEvent(on ? QEvent::FocusIn : QEvent::FocusOut);
- if (!on && !d->persistentSelection)
- d->control->setCursorIsFocusIndicator(true);
- d->control->processEvent(&focusEvent, QPointF(0, 0));
- emit cursorVisibleChanged(d->cursorVisible);
-}
-
-/*!
- \qmlproperty int TextEdit::cursorPosition
- The position of the cursor in the TextEdit.
-*/
-int QmlGraphicsTextEdit::cursorPosition() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->textCursor().position();
-}
-
-void QmlGraphicsTextEdit::setCursorPosition(int pos)
-{
- Q_D(QmlGraphicsTextEdit);
- QTextCursor cursor = d->control->textCursor();
- if (cursor.position() == pos)
- return;
- cursor.setPosition(pos);
- d->control->setTextCursor(cursor);
-}
-
-/*!
- \qmlproperty Component TextEdit::cursorDelegate
- The delegate for the cursor in the TextEdit.
-
- If you set a cursorDelegate for a TextEdit, this delegate will be used for
- drawing the cursor instead of the standard cursor. An instance of the
- delegate will be created and managed by the text edit when a cursor is
- needed, and the x and y properties of delegate instance will be set so as
- to be one pixel before the top left of the current character.
-
- Note that the root item of the delegate component must be a QmlGraphicsItem or
- QmlGraphicsItem derived item.
-*/
-QmlComponent* QmlGraphicsTextEdit::cursorDelegate() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->cursorComponent;
-}
-
-void QmlGraphicsTextEdit::setCursorDelegate(QmlComponent* c)
-{
- Q_D(QmlGraphicsTextEdit);
- if(d->cursorComponent){
- if(d->cursor){
- disconnect(d->control, SIGNAL(cursorPositionChanged()),
- this, SLOT(moveCursorDelegate()));
- d->control->setCursorWidth(-1);
- dirtyCache(cursorRect());
- delete d->cursor;
- d->cursor = 0;
- }
- }
- d->cursorComponent = c;
- if(c && c->isReady()){
- loadCursorDelegate();
- }else{
- if(c)
- connect(c, SIGNAL(statusChanged()),
- this, SLOT(loadCursorDelegate()));
- }
-
- emit cursorDelegateChanged();
-}
-
-void QmlGraphicsTextEdit::loadCursorDelegate()
-{
- Q_D(QmlGraphicsTextEdit);
- if(d->cursorComponent->isLoading())
- return;
- d->cursor = qobject_cast<QmlGraphicsItem*>(d->cursorComponent->create(qmlContext(this)));
- if(d->cursor){
- connect(d->control, SIGNAL(cursorPositionChanged()),
- this, SLOT(moveCursorDelegate()));
- d->control->setCursorWidth(0);
- dirtyCache(cursorRect());
- d->cursor->setParentItem(this);
- d->cursor->setHeight(QFontMetrics(d->font).height());
- moveCursorDelegate();
- }else{
- qWarning() << QLatin1String("Error loading cursor delegate for TextEdit:") + objectName();
- }
-}
-
-/*!
- \qmlproperty int TextEdit::selectionStart
-
- The cursor position before the first character in the current selection.
- Setting this and selectionEnd allows you to specify a selection in the
- text edit.
-
- Note that if selectionStart == selectionEnd then there is no current
- selection. If you attempt to set selectionStart to a value outside of
- the current text, selectionStart will not be changed.
-
- \sa selectionEnd, cursorPosition, selectedText
-*/
-int QmlGraphicsTextEdit::selectionStart() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->textCursor().selectionStart();
-}
-
-void QmlGraphicsTextEdit::setSelectionStart(int s)
-{
- Q_D(QmlGraphicsTextEdit);
- if(d->lastSelectionStart == s || s < 0 || s > text().length())
- return;
- d->lastSelectionStart = s;
- d->updateSelection();// Will emit the relevant signals
-}
-
-/*!
- \qmlproperty int TextEdit::selectionEnd
-
- The cursor position after the last character in the current selection.
- Setting this and selectionStart allows you to specify a selection in the
- text edit.
-
- Note that if selectionStart == selectionEnd then there is no current
- selection. If you attempt to set selectionEnd to a value outside of
- the current text, selectionEnd will not be changed.
-
- \sa selectionStart, cursorPosition, selectedText
-*/
-int QmlGraphicsTextEdit::selectionEnd() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->textCursor().selectionEnd();
-}
-
-void QmlGraphicsTextEdit::setSelectionEnd(int s)
-{
- Q_D(QmlGraphicsTextEdit);
- if(d->lastSelectionEnd == s || s < 0 || s > text().length())
- return;
- d->lastSelectionEnd = s;
- d->updateSelection();// Will emit the relevant signals
-}
-
-/*!
- \qmlproperty string TextEdit::selectedText
-
- This read-only property provides the text currently selected in the
- text edit.
-
- It is equivalent to the following snippet, but is faster and easier
- to use.
- \code
- //myTextEdit is the id of the TextEdit
- myTextEdit.text.toString().substring(myTextEdit.selectionStart,
- myTextEdit.selectionEnd);
- \endcode
-*/
-QString QmlGraphicsTextEdit::selectedText() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->textCursor().selectedText();
-}
-
-/*!
- \qmlproperty bool TextEdit::focusOnPress
-
- Whether the TextEdit should gain focus on a mouse press. By default this is
- set to true.
-*/
-bool QmlGraphicsTextEdit::focusOnPress() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->focusOnPress;
-}
-
-void QmlGraphicsTextEdit::setFocusOnPress(bool on)
-{
- Q_D(QmlGraphicsTextEdit);
- if (d->focusOnPress == on)
- return;
- d->focusOnPress = on;
- emit focusOnPressChanged(d->focusOnPress);
-}
-
-/*!
- \qmlproperty bool TextEdit::persistentSelection
-
- Whether the TextEdit should keep the selection visible when it loses focus to another
- item in the scene. By default this is set to true;
-*/
-bool QmlGraphicsTextEdit::persistentSelection() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->persistentSelection;
-}
-
-void QmlGraphicsTextEdit::setPersistentSelection(bool on)
-{
- Q_D(QmlGraphicsTextEdit);
- if (d->persistentSelection == on)
- return;
- d->persistentSelection = on;
- emit persistentSelectionChanged(d->persistentSelection);
-}
-
-qreal QmlGraphicsTextEdit::textMargin() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->textMargin;
-}
-
-void QmlGraphicsTextEdit::setTextMargin(qreal margin)
-{
- Q_D(QmlGraphicsTextEdit);
- if (d->textMargin == margin)
- return;
- d->textMargin = margin;
- d->document->setDocumentMargin(d->textMargin);
- emit textMarginChanged(d->textMargin);
-}
-
-void QmlGraphicsTextEdit::geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry)
-{
- if (newGeometry.width() != oldGeometry.width())
- updateSize();
- QmlGraphicsPaintedItem::geometryChanged(newGeometry, oldGeometry);
-}
-
-/*!
- Ensures any delayed caching or data loading the class
- needs to performed is complete.
-*/
-void QmlGraphicsTextEdit::componentComplete()
-{
- Q_D(QmlGraphicsTextEdit);
- QmlGraphicsPaintedItem::componentComplete();
- if (d->dirty) {
- updateSize();
- d->dirty = false;
- }
-}
-
-/*!
- \qmlproperty bool TextEdit::readOnly
-
- Whether the user an interact with the TextEdit item. If this
- property is set to true the text cannot be edited by user interaction.
-
- By default this property is false.
-*/
-void QmlGraphicsTextEdit::setReadOnly(bool r)
-{
- Q_D(QmlGraphicsTextEdit);
- if (r == isReadOnly())
- return;
-
-
- Qt::TextInteractionFlags flags = Qt::NoTextInteraction;
- if (r) {
- flags = Qt::TextSelectableByMouse;
- } else {
- flags = Qt::TextEditorInteraction;
- }
- d->control->setTextInteractionFlags(flags);
- if (!r)
- d->control->moveCursor(QTextCursor::End);
-
- emit readOnlyChanged(r);
-}
-
-bool QmlGraphicsTextEdit::isReadOnly() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return !(d->control->textInteractionFlags() & Qt::TextEditable);
-}
-
-/*!
- Sets how the text edit should interact with user input to the given
- \a flags.
-*/
-void QmlGraphicsTextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags)
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->setTextInteractionFlags(flags);
-}
-
-/*!
- Returns the flags specifying how the text edit should interact
- with user input.
-*/
-Qt::TextInteractionFlags QmlGraphicsTextEdit::textInteractionFlags() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->textInteractionFlags();
-}
-
-/*!
- Returns the rectangle where the text cursor is rendered
- within the text edit.
-*/
-QRect QmlGraphicsTextEdit::cursorRect() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->cursorRect().toRect();
-}
-
-
-/*!
-\overload
-Handles the given \a event.
-*/
-bool QmlGraphicsTextEdit::event(QEvent *event)
-{
- Q_D(QmlGraphicsTextEdit);
- if (event->type() == QEvent::ShortcutOverride) {
- d->control->processEvent(event, QPointF(0, 0));
- return event->isAccepted();
- }
- return QmlGraphicsPaintedItem::event(event);
-}
-
-/*!
-\overload
-Handles the given key \a event.
-*/
-void QmlGraphicsTextEdit::keyPressEvent(QKeyEvent *event)
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->processEvent(event, QPointF(0, 0));
-
- if (!event->isAccepted())
- QmlGraphicsPaintedItem::keyPressEvent(event);
-}
-
-/*!
-\overload
-Handles the given key \a event.
-*/
-void QmlGraphicsTextEdit::keyReleaseEvent(QKeyEvent *event)
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->processEvent(event, QPointF(0, 0));
- if (!event->isAccepted())
- QmlGraphicsPaintedItem::keyReleaseEvent(event);
-}
-
-/*!
- \overload
- Handles changing of the focus property. Focus is applied to the control
- even if the edit does not have active focus. This is because things
- like KeyProxy can give the behavior of focus even when hasFocus() isn't
- true.
-*/
-void QmlGraphicsTextEdit::focusChanged(bool hasFocus)
-{
- setCursorVisible(hasFocus);
- QmlGraphicsItem::focusChanged(hasFocus);
-}
-
-/*!
- Causes all text to be selected.
-*/
-void QmlGraphicsTextEdit::selectAll()
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->selectAll();
-}
-
-/*!
-\overload
-Handles the given mouse \a event.
-*/
-void QmlGraphicsTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsTextEdit);
- if (d->focusOnPress){
- QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope?
- while(p) {
- if(p->flags() & QGraphicsItem::ItemIsFocusScope){
- p->setFocus();
- break;
- }
- p = p->parentItem();
- }
- setFocus(true);
- }
- d->control->processEvent(event, QPointF(0, 0));
- if (!event->isAccepted())
- QmlGraphicsPaintedItem::mousePressEvent(event);
-}
-
-/*!
-\overload
-Handles the given mouse \a event.
-*/
-void QmlGraphicsTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsTextEdit);
- QWidget *widget = event->widget();
- if (widget && (d->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos()))
- qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress);
-
- d->control->processEvent(event, QPointF(0, 0));
- if (!event->isAccepted())
- QmlGraphicsPaintedItem::mousePressEvent(event);
-}
-
-/*!
-\overload
-Handles the given mouse \a event.
-*/
-void QmlGraphicsTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->processEvent(event, QPointF(0, 0));
- if (!event->isAccepted())
- QmlGraphicsPaintedItem::mouseDoubleClickEvent(event);
-}
-
-/*!
-\overload
-Handles the given mouse \a event.
-*/
-void QmlGraphicsTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->processEvent(event, QPointF(0, 0));
- if (!event->isAccepted())
- QmlGraphicsPaintedItem::mousePressEvent(event);
-}
-
-/*!
-\overload
-Handles the given input method \a event.
-*/
-void QmlGraphicsTextEdit::inputMethodEvent(QInputMethodEvent *event)
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->processEvent(event, QPointF(0, 0));
-}
-
-/*!
-\overload
-Returns the value of the given \a property.
-*/
-QVariant QmlGraphicsTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->inputMethodQuery(property);
-}
-
-/*!
-Draws the contents of the text edit using the given \a painter within
-the given \a bounds.
-*/
-void QmlGraphicsTextEdit::drawContents(QPainter *painter, const QRect &bounds)
-{
- Q_D(QmlGraphicsTextEdit);
-
- painter->setRenderHint(QPainter::TextAntialiasing, true);
-
- d->control->drawContents(painter, bounds);
-}
-
-void QmlGraphicsTextEdit::updateImgCache(const QRectF &r)
-{
- dirtyCache(r.toRect());
- emit update();
-}
-
-/*!
- \qmlproperty bool TextEdit::smooth
-
- Set this property if you want the text to be smoothly scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the item is displayed at its natural size, this property has no visual or
- performance effect.
-
- \note Generally scaling artifacts are only visible if the item is stationary on
- the screen. A common pattern when animating an item is to disable smooth
- filtering at the beginning of the animation and reenable it at the conclusion.
-*/
-
-void QmlGraphicsTextEditPrivate::init()
-{
- Q_Q(QmlGraphicsTextEdit);
-
- q->setSmooth(smooth);
- q->setAcceptedMouseButtons(Qt::LeftButton);
- q->setFlag(QGraphicsItem::ItemHasNoContents, false);
- q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
-
- control = new QTextControl(q);
- control->setIgnoreUnusedNavigationEvents(true);
-
- QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF)));
-
- QObject::connect(control, SIGNAL(textChanged()), q, SLOT(q_textChanged()));
- QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
- QObject::connect(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers()));
- QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers()));
- QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
-
- document = control->document();
- document->setDefaultFont(font);
- document->setDocumentMargin(textMargin);
- document->setUndoRedoEnabled(false); // flush undo buffer.
- document->setUndoRedoEnabled(true);
- updateDefaultTextOption();
-}
-
-void QmlGraphicsTextEdit::q_textChanged()
-{
- updateSize();
- emit textChanged(text());
-}
-
-void QmlGraphicsTextEdit::moveCursorDelegate()
-{
- Q_D(QmlGraphicsTextEdit);
- if(!d->cursor)
- return;
- QRectF cursorRect = d->control->cursorRect();
- d->cursor->setX(cursorRect.x());
- d->cursor->setY(cursorRect.y());
-}
-
-void QmlGraphicsTextEditPrivate::updateSelection()
-{
- Q_Q(QmlGraphicsTextEdit);
- QTextCursor cursor = control->textCursor();
- bool startChange = (lastSelectionStart != cursor.selectionStart());
- bool endChange = (lastSelectionEnd != cursor.selectionEnd());
- //### Is it worth calculating a more minimal set of movements?
- cursor.beginEditBlock();
- cursor.setPosition(lastSelectionStart, QTextCursor::MoveAnchor);
- cursor.setPosition(lastSelectionEnd, QTextCursor::KeepAnchor);
- cursor.endEditBlock();
- control->setTextCursor(cursor);
- if(startChange)
- q->selectionStartChanged();
- if(endChange)
- q->selectionEndChanged();
- startChange = (lastSelectionStart != control->textCursor().selectionStart());
- endChange = (lastSelectionEnd != control->textCursor().selectionEnd());
- if(startChange || endChange)
- qWarning() << "QmlGraphicsTextEditPrivate::updateSelection() has failed you.";
-}
-
-void QmlGraphicsTextEdit::updateSelectionMarkers()
-{
- Q_D(QmlGraphicsTextEdit);
- if(d->lastSelectionStart != d->control->textCursor().selectionStart()){
- d->lastSelectionStart = d->control->textCursor().selectionStart();
- emit selectionStartChanged();
- }
- if(d->lastSelectionEnd != d->control->textCursor().selectionEnd()){
- d->lastSelectionEnd = d->control->textCursor().selectionEnd();
- emit selectionEndChanged();
- }
-}
-
-//### we should perhaps be a bit smarter here -- depending on what has changed, we shouldn't
-// need to do all the calculations each time
-void QmlGraphicsTextEdit::updateSize()
-{
- Q_D(QmlGraphicsTextEdit);
- if (isComponentComplete()) {
- QFontMetrics fm = QFontMetrics(d->font);
- int dy = height();
- // ### assumes that if the width is set, the text will fill to edges
- // ### (unless wrap is false, then clipping will occur)
- if (widthValid())
- d->document->setTextWidth(width());
- dy -= (int)d->document->size().height();
-
- int yoff = 0;
- if (heightValid()) {
- if (d->vAlign == AlignBottom)
- yoff = dy;
- else if (d->vAlign == AlignVCenter)
- yoff = dy/2;
- }
- setBaselineOffset(fm.ascent() + yoff + d->textMargin);
-
- //### need to comfirm cost of always setting these
- int newWidth = (int)d->document->idealWidth();
- d->document->setTextWidth(newWidth); // ### QTextDoc> Alignment will not work unless textWidth is set. Does Text need this line as well?
- int cursorWidth = 1;
- if(d->cursor)
- cursorWidth = d->cursor->width();
- newWidth += cursorWidth;
- if(!d->document->isEmpty())
- newWidth += 3;// ### Need a better way of accounting for space between char and cursor
- // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed.
- setImplicitWidth(newWidth);
- setImplicitHeight(d->text.isEmpty() ? fm.height() : (int)d->document->size().height());
-
- setContentsSize(QSize(width(), height()));
- } else {
- d->dirty = true;
- }
- emit update();
-}
-
-void QmlGraphicsTextEditPrivate::updateDefaultTextOption()
-{
- QTextOption opt = document->defaultTextOption();
- int oldAlignment = opt.alignment();
- opt.setAlignment((Qt::Alignment)(int)(hAlign | vAlign));
-
- QTextOption::WrapMode oldWrapMode = opt.wrapMode();
-
- if (wrap)
- opt.setWrapMode(QTextOption::WordWrap);
- else
- opt.setWrapMode(QTextOption::NoWrap);
-
- if (oldWrapMode == opt.wrapMode() && oldAlignment == opt.alignment())
- return;
- document->setDefaultTextOption(opt);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit_p.h b/src/declarative/graphicsitems/qmlgraphicstextedit_p.h
deleted file mode 100644
index 337cd9d..0000000
--- a/src/declarative/graphicsitems/qmlgraphicstextedit_p.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSTEXTEDIT_H
-#define QMLGRAPHICSTEXTEDIT_H
-
-#include "qmlgraphicstext_p.h"
-#include "qmlgraphicspainteditem_p.h"
-
-#include <QtGui/qtextdocument.h>
-#include <QtGui/qtextoption.h>
-#include <QtGui/qtextcursor.h>
-#include <QtGui/qtextformat.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-
-class QmlGraphicsTextEditPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsTextEdit : public QmlGraphicsPaintedItem
-{
- Q_OBJECT
- Q_ENUMS(VAlignment)
- Q_ENUMS(HAlignment)
- Q_ENUMS(TextFormat)
-
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
- Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
- Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
- Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
- Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
- Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged) //### other wrap modes
- Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
- Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
- Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
- Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
- Q_PROPERTY(QmlComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
- Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
- Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
- Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged)
- Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged)
- Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
- Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
- Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
-
-public:
- QmlGraphicsTextEdit(QmlGraphicsItem *parent=0);
-
- enum HAlignment {
- AlignLeft = Qt::AlignLeft,
- AlignRight = Qt::AlignRight,
- AlignHCenter = Qt::AlignHCenter
- };
-
- enum VAlignment {
- AlignTop = Qt::AlignTop,
- AlignBottom = Qt::AlignBottom,
- AlignVCenter = Qt::AlignVCenter
- };
-
- enum TextFormat {
- PlainText = Qt::PlainText,
- RichText = Qt::RichText,
- AutoText = Qt::AutoText
- };
-
- QString text() const;
- void setText(const QString &);
-
- TextFormat textFormat() const;
- void setTextFormat(TextFormat format);
-
- QFont font() const;
- void setFont(const QFont &font);
-
- QColor color() const;
- void setColor(const QColor &c);
-
- QColor selectionColor() const;
- void setSelectionColor(const QColor &c);
-
- QColor selectedTextColor() const;
- void setSelectedTextColor(const QColor &c);
-
- HAlignment hAlign() const;
- void setHAlign(HAlignment align);
-
- VAlignment vAlign() const;
- void setVAlign(VAlignment align);
-
- bool wrap() const;
- void setWrap(bool w);
-
- bool isCursorVisible() const;
- void setCursorVisible(bool on);
-
- int cursorPosition() const;
- void setCursorPosition(int pos);
-
- QmlComponent* cursorDelegate() const;
- void setCursorDelegate(QmlComponent*);
-
- int selectionStart() const;
- void setSelectionStart(int);
-
- int selectionEnd() const;
- void setSelectionEnd(int);
-
- QString selectedText() const;
-
- bool focusOnPress() const;
- void setFocusOnPress(bool on);
-
- bool persistentSelection() const;
- void setPersistentSelection(bool on);
-
- qreal textMargin() const;
- void setTextMargin(qreal margin);
-
- virtual void componentComplete();
-
- /* FROM EDIT */
- void setReadOnly(bool);
- bool isReadOnly() const;
-
- void setTextInteractionFlags(Qt::TextInteractionFlags flags);
- Qt::TextInteractionFlags textInteractionFlags() const;
-
- QRect cursorRect() const;
-
- QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
-
-Q_SIGNALS:
- void textChanged(const QString &);
- void cursorPositionChanged();
- void selectionStartChanged();
- void selectionEndChanged();
- void selectionChanged();
- void colorChanged(const QColor &color);
- void selectionColorChanged(const QColor &color);
- void selectedTextColorChanged(const QColor &color);
- void fontChanged(const QFont &font);
- void horizontalAlignmentChanged(HAlignment alignment);
- void verticalAlignmentChanged(VAlignment alignment);
- void wrapChanged(bool isWrapped);
- void textFormatChanged(TextFormat textFormat);
- void readOnlyChanged(bool isReadOnly);
- void cursorVisibleChanged(bool isCursorVisible);
- void cursorDelegateChanged();
- void focusOnPressChanged(bool focusIsPressed);
- void persistentSelectionChanged(bool isPersistentSelection);
- void textMarginChanged(qreal textMargin);
-
-public Q_SLOTS:
- void selectAll();
-
-private Q_SLOTS:
- void updateImgCache(const QRectF &rect);
- void q_textChanged();
- void updateSelectionMarkers();
- void moveCursorDelegate();
- void loadCursorDelegate();
-
-private:
- void updateSize();
-
-protected:
- virtual void geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry);
-
- bool event(QEvent *);
- void keyPressEvent(QKeyEvent *);
- void keyReleaseEvent(QKeyEvent *);
-
- void focusChanged(bool);
-
- // mouse filter?
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
-
- void inputMethodEvent(QInputMethodEvent *e);
-
- void drawContents(QPainter *, const QRect &);
-private:
- Q_DISABLE_COPY(QmlGraphicsTextEdit)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsTextEdit)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsTextEdit)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit_p_p.h b/src/declarative/graphicsitems/qmlgraphicstextedit_p_p.h
deleted file mode 100644
index 7d4ca88..0000000
--- a/src/declarative/graphicsitems/qmlgraphicstextedit_p_p.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSTEXTEDIT_P_H
-#define QMLGRAPHICSTEXTEDIT_P_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 "qmlgraphicsitem.h"
-#include "qmlgraphicspainteditem_p_p.h"
-
-#include <qml.h>
-
-QT_BEGIN_NAMESPACE
-class QTextLayout;
-class QTextDocument;
-class QTextControl;
-class QmlGraphicsTextEditPrivate : public QmlGraphicsPaintedItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsTextEdit)
-
-public:
- QmlGraphicsTextEditPrivate()
- : color("black"), imgDirty(true), hAlign(QmlGraphicsTextEdit::AlignLeft), vAlign(QmlGraphicsTextEdit::AlignTop),
- dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(true),
- persistentSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
- cursorComponent(0), cursor(0), format(QmlGraphicsTextEdit::AutoText), document(0)
- {
- }
-
- void init();
-
- void updateDefaultTextOption();
- void relayoutDocument();
- void updateSelection();
-
- QString text;
- QFont font;
- QColor color;
- QColor selectionColor;
- QColor selectedTextColor;
- QString style;
- QColor styleColor;
- bool imgDirty;
- QPixmap imgCache;
- QPixmap imgStyleCache;
- QmlGraphicsTextEdit::HAlignment hAlign;
- QmlGraphicsTextEdit::VAlignment vAlign;
- bool dirty;
- bool wrap;
- bool richText;
- bool cursorVisible;
- bool focusOnPress;
- bool persistentSelection;
- qreal textMargin;
- int lastSelectionStart;
- int lastSelectionEnd;
- QmlComponent* cursorComponent;
- QmlGraphicsItem* cursor;
- QmlGraphicsTextEdit::TextFormat format;
- QTextDocument *document;
- QTextControl *control;
-};
-
-QT_END_NAMESPACE
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
deleted file mode 100644
index d3c1f1f..0000000
--- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
+++ /dev/null
@@ -1,913 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicstextinput_p.h"
-#include "qmlgraphicstextinput_p_p.h"
-
-#include <qmlinfo.h>
-
-#include <QValidator>
-#include <QApplication>
-#include <QFontMetrics>
-#include <QPainter>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass TextInput QmlGraphicsTextInput
- \since 4.7
- The TextInput item allows you to add an editable line of text to a scene.
-
- TextInput can only display a single line of text, and can only display
- plain text. However it can provide addition input constraints on the text.
-
- Input constraints include setting a QValidator, an input mask, or a
- maximum input length.
-*/
-QmlGraphicsTextInput::QmlGraphicsTextInput(QmlGraphicsItem* parent)
- : QmlGraphicsPaintedItem(*(new QmlGraphicsTextInputPrivate), parent)
-{
- Q_D(QmlGraphicsTextInput);
- d->init();
-}
-
-QmlGraphicsTextInput::~QmlGraphicsTextInput()
-{
-}
-
-/*!
- \qmlproperty string TextInput::text
-
- The text in the TextInput.
-*/
-
-QString QmlGraphicsTextInput::text() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->control->text();
-}
-
-void QmlGraphicsTextInput::setText(const QString &s)
-{
- Q_D(QmlGraphicsTextInput);
- if(s == text())
- return;
- d->control->setText(s);
- //emit textChanged();
-}
-
-/*!
- \qmlproperty string TextInput::font.family
- \qmlproperty bool TextInput::font.bold
- \qmlproperty bool TextInput::font.italic
- \qmlproperty bool TextInput::font.underline
- \qmlproperty real TextInput::font.pointSize
- \qmlproperty int TextInput::font.pixelSize
-
- Set the TextInput's font attributes.
-*/
-QFont QmlGraphicsTextInput::font() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->font;
-}
-
-void QmlGraphicsTextInput::setFont(const QFont &font)
-{
- Q_D(QmlGraphicsTextInput);
- if (d->font == font)
- return;
-
- d->font = font;
-
- d->control->setFont(d->font);
- if(d->cursorItem){
- d->cursorItem->setHeight(QFontMetrics(d->font).height());
- moveCursor();
- }
- updateSize();
- emit fontChanged(d->font);
-}
-
-/*!
- \qmlproperty color TextInput::color
-
- The text color.
-*/
-QColor QmlGraphicsTextInput::color() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->color;
-}
-
-void QmlGraphicsTextInput::setColor(const QColor &c)
-{
- Q_D(QmlGraphicsTextInput);
- d->color = c;
-}
-
-
-/*!
- \qmlproperty color TextInput::selectionColor
-
- The text highlight color, used behind selections.
-*/
-QColor QmlGraphicsTextInput::selectionColor() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->selectionColor;
-}
-
-void QmlGraphicsTextInput::setSelectionColor(const QColor &color)
-{
- Q_D(QmlGraphicsTextInput);
- if (d->selectionColor == color)
- return;
-
- d->selectionColor = color;
- QPalette p = d->control->palette();
- p.setColor(QPalette::Highlight, d->selectionColor);
- d->control->setPalette(p);
- emit selectionColorChanged(color);
-}
-
-/*!
- \qmlproperty color TextInput::selectedTextColor
-
- The highlighted text color, used in selections.
-*/
-QColor QmlGraphicsTextInput::selectedTextColor() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->selectedTextColor;
-}
-
-void QmlGraphicsTextInput::setSelectedTextColor(const QColor &color)
-{
- Q_D(QmlGraphicsTextInput);
- if (d->selectedTextColor == color)
- return;
-
- d->selectedTextColor = color;
- QPalette p = d->control->palette();
- p.setColor(QPalette::HighlightedText, d->selectedTextColor);
- d->control->setPalette(p);
- emit selectedTextColorChanged(color);
-}
-
-/*!
- \qmlproperty enumeration TextInput::horizontalAlignment
-
- Sets the horizontal alignment of the text within the TextInput item's
- width and height. By default, the text is left aligned.
-
- TextInput does not have vertical alignment, as the natural height is
- exactly the height of the single line of text. If you set the height
- manually to something larger, TextInput will always be top aligned
- vertically. You can use anchors to align it however you want within
- another item.
-
- The valid values for \c horizontalAlignment are \c AlignLeft, \c AlignRight and
- \c AlignHCenter.
-*/
-QmlGraphicsTextInput::HAlignment QmlGraphicsTextInput::hAlign() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->hAlign;
-}
-
-void QmlGraphicsTextInput::setHAlign(HAlignment align)
-{
- Q_D(QmlGraphicsTextInput);
- if(align == d->hAlign)
- return;
- d->hAlign = align;
- emit horizontalAlignmentChanged(d->hAlign);
-}
-
-bool QmlGraphicsTextInput::isReadOnly() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->control->isReadOnly();
-}
-
-void QmlGraphicsTextInput::setReadOnly(bool ro)
-{
- Q_D(QmlGraphicsTextInput);
- if (d->control->isReadOnly() == ro)
- return;
-
- d->control->setReadOnly(ro);
-
- emit readOnlyChanged(ro);
-}
-
-int QmlGraphicsTextInput::maxLength() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->control->maxLength();
-}
-
-void QmlGraphicsTextInput::setMaxLength(int ml)
-{
- Q_D(QmlGraphicsTextInput);
- if (d->control->maxLength() == ml)
- return;
-
- d->control->setMaxLength(ml);
-
- emit maximumLengthChanged(ml);
-}
-
-/*!
- \qmlproperty bool TextInput::cursorVisible
- Set to true when the TextInput shows a cursor.
-
- This property is set and unset when the TextInput gets focus, so that other
- properties can be bound to whether the cursor is currently showing. As it
- gets set and unset automatically, when you set the value yourself you must
- keep in mind that your value may be overwritten.
-
- It can be set directly in script, for example if a KeyProxy might
- forward keys to it and you desire it to look active when this happens
- (but without actually giving it the focus).
-
- It should not be set directly on the element, like in the below QML,
- as the specified value will be overridden an lost on focus changes.
-
- \code
- TextInput {
- text: "Text"
- cursorVisible: false
- }
- \endcode
-
- In the above snippet the cursor will still become visible when the
- TextInput gains focus.
-*/
-bool QmlGraphicsTextInput::isCursorVisible() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->cursorVisible;
-}
-
-void QmlGraphicsTextInput::setCursorVisible(bool on)
-{
- Q_D(QmlGraphicsTextInput);
- if (d->cursorVisible == on)
- return;
- d->cursorVisible = on;
- d->control->setCursorBlinkPeriod(on?QApplication::cursorFlashTime():0);
- //d->control should emit the cursor update regions
- emit cursorVisibleChanged(d->cursorVisible);
-}
-
-/*!
- \qmlproperty int TextInput::cursorPosition
- The position of the cursor in the TextInput.
-*/
-int QmlGraphicsTextInput::cursorPosition() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->control->cursor();
-}
-void QmlGraphicsTextInput::setCursorPosition(int cp)
-{
- Q_D(QmlGraphicsTextInput);
- d->control->moveCursor(cp);
-}
-
-/*!
- \internal
-
- Returns a Rect which encompasses the cursor, but which may be larger than is
- required. Ignores custom cursor delegates.
-*/
-QRect QmlGraphicsTextInput::cursorRect() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->control->cursorRect();
-}
-
-/*!
- \qmlproperty int TextInput::selectionStart
-
- The cursor position before the first character in the current selection.
- Setting this and selectionEnd allows you to specify a selection in the
- text edit.
-
- Note that if selectionStart == selectionEnd then there is no current
- selection. If you attempt to set selectionStart to a value outside of
- the current text, selectionStart will not be changed.
-
- \sa selectionEnd, cursorPosition, selectedText
-*/
-int QmlGraphicsTextInput::selectionStart() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->lastSelectionStart;
-}
-
-void QmlGraphicsTextInput::setSelectionStart(int s)
-{
- Q_D(QmlGraphicsTextInput);
- if(d->lastSelectionStart == s || s < 0 || s > text().length())
- return;
- d->lastSelectionStart = s;
- d->control->setSelection(s, d->lastSelectionEnd - s);
-}
-
-/*!
- \qmlproperty int TextInput::selectionEnd
-
- The cursor position after the last character in the current selection.
- Setting this and selectionStart allows you to specify a selection in the
- text edit.
-
- Note that if selectionStart == selectionEnd then there is no current
- selection. If you attempt to set selectionEnd to a value outside of
- the current text, selectionEnd will not be changed.
-
- \sa selectionStart, cursorPosition, selectedText
-*/
-int QmlGraphicsTextInput::selectionEnd() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->lastSelectionEnd;
-}
-
-void QmlGraphicsTextInput::setSelectionEnd(int s)
-{
- Q_D(QmlGraphicsTextInput);
- if(d->lastSelectionEnd == s || s < 0 || s > text().length())
- return;
- d->lastSelectionEnd = s;
- d->control->setSelection(d->lastSelectionStart, s - d->lastSelectionStart);
-}
-
-/*!
- \qmlproperty string TextInput::selectedText
-
- This read-only property provides the text currently selected in the
- text input.
-
- It is equivalent to the following snippet, but is faster and easier
- to use.
-
- \qml
- myTextInput.text.toString().substring(myTextInput.selectionStart,
- myTextInput.selectionEnd);
- \endqml
-*/
-QString QmlGraphicsTextInput::selectedText() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->control->selectedText();
-}
-
-/*!
- \qmlproperty bool TextInput::focusOnPress
-
- Whether the TextInput should gain focus on a mouse press. By default this is
- set to true.
-*/
-bool QmlGraphicsTextInput::focusOnPress() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->focusOnPress;
-}
-
-void QmlGraphicsTextInput::setFocusOnPress(bool b)
-{
- Q_D(QmlGraphicsTextInput);
- if (d->focusOnPress == b)
- return;
-
- d->focusOnPress = b;
-
- emit focusOnPressChanged(d->focusOnPress);
-}
-
-/*!
- \qmlproperty QValidator* TextInput::validator
-
- Allows you to set a QValidator on the TextInput. When a validator is set
- the TextInput will only accept input which leaves the text property in
- an acceptable or intermediate state. The accepted signal will only be sent
- if the text is in an acceptable state when enter is pressed.
-
- Currently supported validators are QIntValidator, QDoubleValidator and
- QRegExpValidator. For details, refer to their C++ documentation and remember
- that all Q_PROPERTIES are accessible from Qml. A brief usage guide follows:
-
- QIntValidator and QDoubleValidator both are controllable through two properties,
- top and bottom. The difference is that for QIntValidator the top and bottom properties
- should be integers, and for QDoubleValidator they should be doubles. QRegExpValidator
- has a single string property, regExp, which should be set to the regular expression to
- be used for validation. An example of using validators is shown below, which allows
- input of integers between 11 and 31 into the text input:
-
- \code
- import Qt 4.6
- TextInput{
- validator: QIntValidator{bottom: 11; top: 31;}
- focus: true
- }
- \endcode
-
- \sa acceptableInput, inputMask
-*/
-QValidator* QmlGraphicsTextInput::validator() const
-{
- Q_D(const QmlGraphicsTextInput);
- //###const cast isn't good, but needed for property system?
- return const_cast<QValidator*>(d->control->validator());
-}
-
-void QmlGraphicsTextInput::setValidator(QValidator* v)
-{
- Q_D(QmlGraphicsTextInput);
- if (d->control->validator() == v)
- return;
-
- d->control->setValidator(v);
- if(!d->control->hasAcceptableInput()){
- d->oldValidity = false;
- emit acceptableInputChanged();
- }
-
- emit validatorChanged();
-}
-
-/*!
- \qmlproperty string TextInput::inputMask
-
- Allows you to set an input mask on the TextInput, restricting the allowable
- text inputs. See QLineEdit::inputMask for further details, as the exact
- same mask strings are used by TextInput.
-
- \sa acceptableInput, validator
-*/
-QString QmlGraphicsTextInput::inputMask() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->control->inputMask();
-}
-
-void QmlGraphicsTextInput::setInputMask(const QString &im)
-{
- Q_D(QmlGraphicsTextInput);
- if (d->control->inputMask() == im)
- return;
-
- d->control->setInputMask(im);
- emit inputMaskChanged(d->control->inputMask());
-}
-
-/*!
- \qmlproperty bool TextInput::acceptableInput
-
- This property is always true unless a validator or input mask has been set.
- If a validator or input mask has been set, this property will only be true
- if the current text is acceptable to the validator or input mask as a final
- string (not as an intermediate string).
-*/
-bool QmlGraphicsTextInput::hasAcceptableInput() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->control->hasAcceptableInput();
-}
-
-/*!
- \qmlproperty TextInput.EchoMode TextInput::echoMode
-
- Specifies how the text should be displayed in the TextInput.
- The default is Normal, which displays the text as it is. Other values
- are Password, which displays asterixes instead of characters, NoEcho,
- which displays nothing, and PasswordEchoOnEdit, which displays all but the
- current character as asterixes.
-
-*/
-QmlGraphicsTextInput::EchoMode QmlGraphicsTextInput::echoMode() const
-{
- Q_D(const QmlGraphicsTextInput);
- return (QmlGraphicsTextInput::EchoMode)d->control->echoMode();
-}
-
-void QmlGraphicsTextInput::setEchoMode(QmlGraphicsTextInput::EchoMode echo)
-{
- Q_D(QmlGraphicsTextInput);
- if (echoMode() == echo)
- return;
-
- d->control->setEchoMode((uint)echo);
- emit echoModeChanged(echoMode());
-}
-
-/*!
- \qmlproperty Component TextInput::cursorDelegate
- The delegate for the cursor in the TextInput.
-
- If you set a cursorDelegate for a TextInput, this delegate will be used for
- drawing the cursor instead of the standard cursor. An instance of the
- delegate will be created and managed by the TextInput when a cursor is
- needed, and the x property of delegate instance will be set so as
- to be one pixel before the top left of the current character.
-
- Note that the root item of the delegate component must be a QmlGraphicsItem or
- QmlGraphicsItem derived item.
-*/
-QmlComponent* QmlGraphicsTextInput::cursorDelegate() const
-{
- Q_D(const QmlGraphicsTextInput);
- return d->cursorComponent;
-}
-
-void QmlGraphicsTextInput::setCursorDelegate(QmlComponent* c)
-{
- Q_D(QmlGraphicsTextInput);
- if (d->cursorComponent == c)
- return;
-
- d->cursorComponent = c;
- if(!c){
- //note that the components are owned by something else
- disconnect(d->control, SIGNAL(cursorPositionChanged(int, int)),
- this, SLOT(moveCursor()));
- delete d->cursorItem;
- }else{
- d->startCreatingCursor();
- }
-
- emit cursorDelegateChanged();
-}
-
-void QmlGraphicsTextInputPrivate::startCreatingCursor()
-{
- Q_Q(QmlGraphicsTextInput);
- q->connect(control, SIGNAL(cursorPositionChanged(int, int)),
- q, SLOT(moveCursor()));
- if(cursorComponent->isReady()){
- q->createCursor();
- }else if(cursorComponent->isLoading()){
- q->connect(cursorComponent, SIGNAL(statusChanged(int)),
- q, SLOT(createCursor()));
- }else{//isError
- qmlInfo(q) << QmlGraphicsTextInput::tr("Could not load cursor delegate");
- qWarning() << cursorComponent->errors();
- }
-}
-
-void QmlGraphicsTextInput::createCursor()
-{
- Q_D(QmlGraphicsTextInput);
- if(d->cursorComponent->isError()){
- qmlInfo(this) << tr("Could not load cursor delegate");
- qWarning() << d->cursorComponent->errors();
- return;
- }
-
- if(!d->cursorComponent->isReady())
- return;
-
- if(d->cursorItem)
- delete d->cursorItem;
- d->cursorItem = qobject_cast<QmlGraphicsItem*>(d->cursorComponent->create());
- if(!d->cursorItem){
- qmlInfo(this) << tr("Could not instantiate cursor delegate");
- //The failed instantiation should print its own error messages
- return;
- }
-
- d->cursorItem->setParentItem(this);
- d->cursorItem->setX(d->control->cursorToX());
- d->cursorItem->setHeight(d->control->height());
-}
-
-void QmlGraphicsTextInput::moveCursor()
-{
- Q_D(QmlGraphicsTextInput);
- if(!d->cursorItem)
- return;
- d->cursorItem->setX(d->control->cursorToX() - d->hscroll);
-}
-
-int QmlGraphicsTextInput::xToPos(int x)
-{
- Q_D(const QmlGraphicsTextInput);
- return d->control->xToPos(x - d->hscroll);
-}
-
-void QmlGraphicsTextInput::focusChanged(bool hasFocus)
-{
- Q_D(QmlGraphicsTextInput);
- d->focused = hasFocus;
- setCursorVisible(hasFocus);
- QmlGraphicsItem::focusChanged(hasFocus);
-}
-
-void QmlGraphicsTextInput::keyPressEvent(QKeyEvent* ev)
-{
- Q_D(QmlGraphicsTextInput);
- if(((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
- || (d->control->cursor() == d->control->text().length()
- && ev->key() == Qt::Key_Right))
- && (d->lastSelectionStart == d->lastSelectionEnd)){
- //ignore when moving off the end
- //unless there is a selection, because then moving will do something (deselect)
- ev->ignore();
- }else{
- d->control->processKeyEvent(ev);
- }
- if (!ev->isAccepted())
- QmlGraphicsPaintedItem::keyPressEvent(ev);
-}
-
-void QmlGraphicsTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsTextInput);
- if(d->focusOnPress){
- QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope?
- while(p) {
- if(p->flags() & QGraphicsItem::ItemIsFocusScope){
- p->setFocus();
- break;
- }
- p = p->parentItem();
- }
- setFocus(true);
- }
- d->control->processEvent(event);
-}
-
-/*!
-\overload
-Handles the given mouse \a event.
-*/
-void QmlGraphicsTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsTextInput);
- QWidget *widget = event->widget();
- if (widget && !d->control->isReadOnly() && boundingRect().contains(event->pos()))
- qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress);
- d->control->processEvent(event);
-}
-
-bool QmlGraphicsTextInput::event(QEvent* ev)
-{
- Q_D(QmlGraphicsTextInput);
- //Anything we don't deal with ourselves, pass to the control
- bool handled = false;
- switch(ev->type()){
- case QEvent::KeyPress:
- case QEvent::KeyRelease://###Should the control be doing anything with release?
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- break;
- default:
- handled = d->control->processEvent(ev);
- }
- if(!handled)
- return QmlGraphicsPaintedItem::event(ev);
- return true;
-}
-
-void QmlGraphicsTextInput::geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry)
-{
- if (newGeometry.width() != oldGeometry.width())
- updateSize();
- QmlGraphicsPaintedItem::geometryChanged(newGeometry, oldGeometry);
-}
-
-void QmlGraphicsTextInput::drawContents(QPainter *p, const QRect &r)
-{
- Q_D(QmlGraphicsTextInput);
- p->setRenderHint(QPainter::TextAntialiasing, true);
- p->save();
- p->setPen(QPen(d->color));
- int flags = QLineControl::DrawText;
- if(!isReadOnly() && d->cursorVisible && !d->cursorItem)
- flags |= QLineControl::DrawCursor;
- if (d->control->hasSelectedText()){
- flags |= QLineControl::DrawSelections;
- }
-
- QPoint offset = QPoint(0,0);
- if(d->hAlign != AlignLeft){
- QFontMetrics fm = QFontMetrics(d->font);
- //###Is this using bearing appropriately?
- int minLB = qMax(0, -fm.minLeftBearing());
- int minRB = qMax(0, -fm.minRightBearing());
- int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB;
- int hOffset = 0;
- if(d->hAlign == AlignRight){
- hOffset = width() - widthUsed;
- }else if(d->hAlign == AlignHCenter){
- hOffset = (width() - widthUsed) / 2;
- }
- hOffset -= minLB;
- offset = QPoint(hOffset, 0);
- }
- QRect clipRect = r;
- d->control->draw(p, offset, clipRect, flags);
-
- p->restore();
-}
-
-/*!
-\overload
-Returns the value of the given \a property.
-*/
-QVariant QmlGraphicsTextInput::inputMethodQuery(Qt::InputMethodQuery property) const
-{
- Q_D(const QmlGraphicsTextInput);
- switch(property) {
- case Qt::ImFont:
- return font();
- case Qt::ImCursorPosition:
- return QVariant(d->control->cursor());
- case Qt::ImSurroundingText:
- return QVariant(text());
- case Qt::ImCurrentSelection:
- return QVariant(selectedText());
- case Qt::ImMaximumTextLength:
- return QVariant(maxLength());
- case Qt::ImAnchorPosition:
- if (d->control->selectionStart() == d->control->selectionEnd())
- return QVariant(d->control->cursor());
- else if (d->control->selectionStart() == d->control->cursor())
- return QVariant(d->control->selectionEnd());
- else
- return QVariant(d->control->selectionStart());
- default:
- return QVariant();
- }
-}
-
-void QmlGraphicsTextInput::selectAll()
-{
- Q_D(QmlGraphicsTextInput);
- d->control->setSelection(0, d->control->text().length());
-}
-
-
-/*!
- \qmlproperty bool TextInput::smooth
-
- Set this property if you want the text to be smoothly scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the item is displayed at its natural size, this property has no visual or
- performance effect.
-
- \note Generally scaling artifacts are only visible if the item is stationary on
- the screen. A common pattern when animating an item is to disable smooth
- filtering at the beginning of the animation and reenable it at the conclusion.
-*/
-
-void QmlGraphicsTextInputPrivate::init()
-{
- Q_Q(QmlGraphicsTextInput);
- control->setCursorWidth(1);
- control->setPasswordCharacter(QLatin1Char('*'));
- control->setLayoutDirection(Qt::LeftToRight);
- q->setSmooth(smooth);
- q->setAcceptedMouseButtons(Qt::LeftButton);
- q->setFlag(QGraphicsItem::ItemHasNoContents, false);
- q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
- q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
- q, SLOT(cursorPosChanged()));
- q->connect(control, SIGNAL(selectionChanged()),
- q, SLOT(selectionChanged()));
- q->connect(control, SIGNAL(textChanged(const QString &)),
- q, SLOT(q_textChanged()));
- q->connect(control, SIGNAL(accepted()),
- q, SIGNAL(accepted()));
- q->connect(control, SIGNAL(updateNeeded(QRect)),
- q, SLOT(updateRect(QRect)));
- q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
- q, SLOT(updateRect()));//TODO: Only update rect between pos's
- q->connect(control, SIGNAL(selectionChanged()),
- q, SLOT(updateRect()));//TODO: Only update rect in selection
- //Note that above TODOs probably aren't that big a savings
- q->updateSize();
- oldValidity = control->hasAcceptableInput();
- lastSelectionStart = 0;
- lastSelectionEnd = 0;
-}
-
-void QmlGraphicsTextInput::cursorPosChanged()
-{
- Q_D(QmlGraphicsTextInput);
- emit cursorPositionChanged();
-
- if(!d->control->hasSelectedText()){
- if(d->lastSelectionStart != d->control->cursor()){
- d->lastSelectionStart = d->control->cursor();
- emit selectionStartChanged();
- }
- if(d->lastSelectionEnd != d->control->cursor()){
- d->lastSelectionEnd = d->control->cursor();
- emit selectionEndChanged();
- }
- }
-}
-
-void QmlGraphicsTextInput::selectionChanged()
-{
- Q_D(QmlGraphicsTextInput);
- emit selectedTextChanged();
-
- if(d->lastSelectionStart != d->control->selectionStart()){
- d->lastSelectionStart = d->control->selectionStart();
- if(d->lastSelectionStart == -1)
- d->lastSelectionStart = d->control->cursor();
- emit selectionStartChanged();
- }
- if(d->lastSelectionEnd != d->control->selectionEnd()){
- d->lastSelectionEnd = d->control->selectionEnd();
- if(d->lastSelectionEnd == -1)
- d->lastSelectionEnd = d->control->cursor();
- emit selectionEndChanged();
- }
-}
-
-void QmlGraphicsTextInput::q_textChanged()
-{
- Q_D(QmlGraphicsTextInput);
- updateSize();
- emit textChanged();
- if(hasAcceptableInput() != d->oldValidity){
- d->oldValidity = hasAcceptableInput();
- emit acceptableInputChanged();
- }
-}
-
-void QmlGraphicsTextInput::updateRect(const QRect &r)
-{
- if(r == QRect())
- clearCache();
- else
- dirtyCache(r);
- update();
-}
-
-void QmlGraphicsTextInput::updateSize(bool needsRedraw)
-{
- Q_D(QmlGraphicsTextInput);
- int w = width();
- int h = height();
- setImplicitHeight(d->control->height());
- int cursorWidth = d->control->cursorWidth();
- if(d->cursorItem)
- cursorWidth = d->cursorItem->width();
- //### Is QFontMetrics too slow?
- QFontMetricsF fm(d->font);
- setImplicitWidth(fm.width(d->control->displayText())+cursorWidth);
- setContentsSize(QSize(width(), height()));//Repaints if changed
- if(w==width() && h==height() && needsRedraw){
- clearCache();
- update();
- }
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
deleted file mode 100644
index 2b37b78..0000000
--- a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSTEXTINPUT_H
-#define QMLGRAPHICSTEXTINPUT_H
-
-#include "qmlgraphicstext_p.h"
-#include "qmlgraphicspainteditem_p.h"
-
-#include <QGraphicsSceneMouseEvent>
-#include <QIntValidator>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsTextInputPrivate;
-class QValidator;
-class Q_DECLARATIVE_EXPORT QmlGraphicsTextInput : public QmlGraphicsPaintedItem
-{
- Q_OBJECT
- Q_ENUMS(HAlignment)
- Q_ENUMS(EchoMode)
-
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
- Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
- Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
- Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
-
- Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
- Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
- Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
- Q_PROPERTY(QRect cursorRect READ cursorRect NOTIFY cursorPositionChanged)
- Q_PROPERTY(QmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
- Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
- Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
- Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged)
-
- Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged)
- Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged)
- Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged)
- Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
-
- Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
- Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged)
- Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged)
-
-public:
- QmlGraphicsTextInput(QmlGraphicsItem* parent=0);
- ~QmlGraphicsTextInput();
-
- enum EchoMode {//To match QLineEdit::EchoMode
- Normal,
- NoEcho,
- Password,
- PasswordEchoOnEdit
- };
-
- enum HAlignment {
- AlignLeft = Qt::AlignLeft,
- AlignRight = Qt::AlignRight,
- AlignHCenter = Qt::AlignHCenter
- };
-
- //### Should we have this function, x based properties,
- //### or copy TextEdit with x instead of QTextCursor?
- Q_INVOKABLE int xToPos(int x);
-
- QString text() const;
- void setText(const QString &);
-
- QFont font() const;
- void setFont(const QFont &font);
-
- QColor color() const;
- void setColor(const QColor &c);
-
- QColor selectionColor() const;
- void setSelectionColor(const QColor &c);
-
- QColor selectedTextColor() const;
- void setSelectedTextColor(const QColor &c);
-
- HAlignment hAlign() const;
- void setHAlign(HAlignment align);
-
- bool isReadOnly() const;
- void setReadOnly(bool);
-
- bool isCursorVisible() const;
- void setCursorVisible(bool on);
-
- int cursorPosition() const;
- void setCursorPosition(int cp);
-
- QRect cursorRect() const;
-
- int selectionStart() const;
- void setSelectionStart(int);
-
- int selectionEnd() const;
- void setSelectionEnd(int);
-
- QString selectedText() const;
-
- int maxLength() const;
- void setMaxLength(int ml);
-
- QValidator * validator() const;
- void setValidator(QValidator* v);
-
- QString inputMask() const;
- void setInputMask(const QString &im);
-
- EchoMode echoMode() const;
- void setEchoMode(EchoMode echo);
-
- QmlComponent* cursorDelegate() const;
- void setCursorDelegate(QmlComponent*);
-
- bool focusOnPress() const;
- void setFocusOnPress(bool);
-
- bool hasAcceptableInput() const;
-
- void drawContents(QPainter *p,const QRect &r);
- QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
-
-Q_SIGNALS:
- void textChanged();
- void cursorPositionChanged();
- void selectionStartChanged();
- void selectionEndChanged();
- void selectedTextChanged();
- void accepted();
- void acceptableInputChanged();
- void colorChanged(const QColor &color);
- void selectionColorChanged(const QColor &color);
- void selectedTextColorChanged(const QColor &color);
- void fontChanged(const QFont &font);
- void horizontalAlignmentChanged(HAlignment alignment);
- void readOnlyChanged(bool isReadOnly);
- void cursorVisibleChanged(bool isCursorVisible);
- void cursorDelegateChanged();
- void maximumLengthChanged(int maximumLength);
- void validatorChanged();
- void inputMaskChanged(const QString &inputMask);
- void echoModeChanged(EchoMode echoMode);
- void focusOnPressChanged(bool focusOnPress);
-
-protected:
- virtual void geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry);
-
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void keyPressEvent(QKeyEvent* ev);
- bool event(QEvent *e);
-
- void focusChanged(bool hasFocus);
-
-public Q_SLOTS:
- void selectAll();
-
-private Q_SLOTS:
- void updateSize(bool needsRedraw = true);
- void q_textChanged();
- void selectionChanged();
- void createCursor();
- void moveCursor();
- void cursorPosChanged();
- void updateRect(const QRect &r = QRect());
-
-private:
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsTextInput)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsTextInput)
-QML_DECLARE_TYPE(QValidator)
-QML_DECLARE_TYPE(QIntValidator)
-#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
-QML_DECLARE_TYPE(QDoubleValidator)
-QML_DECLARE_TYPE(QRegExpValidator)
-#endif
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSTEXTINPUT_H
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput_p_p.h b/src/declarative/graphicsitems/qmlgraphicstextinput_p_p.h
deleted file mode 100644
index 694ec93..0000000
--- a/src/declarative/graphicsitems/qmlgraphicstextinput_p_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSTEXTINPUT_P_H
-#define QMLGRAPHICSTEXTINPUT_P_H
-
-#include "qmlgraphicstextinput_p.h"
-
-#include "qmlgraphicspainteditem_p_p.h"
-
-#include <qml.h>
-
-#include <QPointer>
-
-#include <private/qlinecontrol_p.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.
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsTextInputPrivate : public QmlGraphicsPaintedItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsTextInput)
-public:
- QmlGraphicsTextInputPrivate() : control(new QLineControl(QString())),
- color((QRgb)0), style(QmlGraphicsText::Normal),
- styleColor((QRgb)0), hAlign(QmlGraphicsTextInput::AlignLeft),
- hscroll(0), oldScroll(0), focused(false), focusOnPress(true),
- cursorVisible(false)
- {
- }
-
- ~QmlGraphicsTextInputPrivate()
- {
- delete control;
- }
-
- void init();
- void startCreatingCursor();
-
- QLineControl* control;
-
- QFont font;
- QColor color;
- QColor selectionColor;
- QColor selectedTextColor;
- QmlGraphicsText::TextStyle style;
- QColor styleColor;
- QmlGraphicsTextInput::HAlignment hAlign;
- QPointer<QmlComponent> cursorComponent;
- QPointer<QmlGraphicsItem> cursorItem;
-
- int lastSelectionStart;
- int lastSelectionEnd;
- int oldHeight;
- int oldWidth;
- bool oldValidity;
- int hscroll;
- int oldScroll;
- bool focused;
- bool focusOnPress;
- bool cursorVisible;
-};
-
-QT_END_NAMESPACE
-
-#endif
-
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
deleted file mode 100644
index 97e4a97..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
+++ /dev/null
@@ -1,1256 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicsvisualitemmodel_p.h"
-
-#include "qmlgraphicsitem.h"
-
-#include <qmlcontext.h>
-#include <qmlengine.h>
-#include <qmlexpression.h>
-#include <qmlpackage_p.h>
-#include <qmlopenmetaobject_p.h>
-#include <qmllistaccessor_p.h>
-#include <qmlinfo.h>
-#include <qmldeclarativedata_p.h>
-#include <qmlpropertycache_p.h>
-#include <qmlguard_p.h>
-
-#include <qlistmodelinterface_p.h>
-#include <qhash.h>
-#include <qlist.h>
-#include <qmetaobjectbuilder_p.h>
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QHash<QObject*, QmlGraphicsVisualItemModelAttached*> QmlGraphicsVisualItemModelAttached::attachedProperties;
-
-
-class QmlGraphicsVisualItemModelPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsVisualItemModel)
-public:
- QmlGraphicsVisualItemModelPrivate() : QObjectPrivate() {}
-
- static void children_append(QmlListProperty<QmlGraphicsItem> *prop, QmlGraphicsItem *item) {
- item->QObject::setParent(prop->object);
- static_cast<QmlGraphicsVisualItemModelPrivate *>(prop->data)->children.append(item);
- static_cast<QmlGraphicsVisualItemModelPrivate *>(prop->data)->itemAppended();
- static_cast<QmlGraphicsVisualItemModelPrivate *>(prop->data)->emitChildrenChanged();
- }
-
- void itemAppended() {
- Q_Q(QmlGraphicsVisualItemModel);
- QmlGraphicsVisualItemModelAttached *attached = QmlGraphicsVisualItemModelAttached::properties(children.last());
- attached->setIndex(children.count()-1);
- emit q->itemsInserted(children.count()-1, 1);
- emit q->countChanged();
- }
-
- void emitChildrenChanged() {
- Q_Q(QmlGraphicsVisualItemModel);
- emit q->childrenChanged();
- }
-
- QList<QmlGraphicsItem *> children;
-};
-
-
-/*!
- \qmlclass VisualItemModel QmlGraphicsVisualItemModel
- \since 4.7
- \brief The VisualItemModel allows items to be provided to a view.
-
- The children of the VisualItemModel are provided in a model which
- can be used in a view. Note that no delegate should be
- provided to a view since the VisualItemModel contains the
- visual delegate (items).
-
- An item can determine its index within the
- model via the VisualItemModel.index attached property.
-
- The example below places three colored rectangles in a ListView.
- \code
- Item {
- VisualItemModel {
- id: itemModel
- Rectangle { height: 30; width: 80; color: "red" }
- Rectangle { height: 30; width: 80; color: "green" }
- Rectangle { height: 30; width: 80; color: "blue" }
- }
-
- ListView {
- anchors.fill: parent
- model: itemModel
- }
- }
- \endcode
-*/
-QmlGraphicsVisualItemModel::QmlGraphicsVisualItemModel()
- : QmlGraphicsVisualModel(*(new QmlGraphicsVisualItemModelPrivate))
-{
-}
-
-QmlListProperty<QmlGraphicsItem> QmlGraphicsVisualItemModel::children()
-{
- Q_D(QmlGraphicsVisualItemModel);
- return QmlListProperty<QmlGraphicsItem>(this, d, QmlGraphicsVisualItemModelPrivate::children_append);
-}
-
-/*!
- \qmlproperty int VisualItemModel::count
-
- The number of items in the model. This property is readonly.
-*/
-int QmlGraphicsVisualItemModel::count() const
-{
- Q_D(const QmlGraphicsVisualItemModel);
- return d->children.count();
-}
-
-bool QmlGraphicsVisualItemModel::isValid() const
-{
- return true;
-}
-
-QmlGraphicsItem *QmlGraphicsVisualItemModel::item(int index, bool)
-{
- Q_D(QmlGraphicsVisualItemModel);
- return d->children.at(index);
-}
-
-QmlGraphicsVisualModel::ReleaseFlags QmlGraphicsVisualItemModel::release(QmlGraphicsItem *)
-{
- // Nothing to do
- return 0;
-}
-
-void QmlGraphicsVisualItemModel::completeItem()
-{
- // Nothing to do
-}
-
-QString QmlGraphicsVisualItemModel::stringValue(int index, const QString &name)
-{
- Q_D(QmlGraphicsVisualItemModel);
- if (index < 0 || index >= d->children.count())
- return QString();
- return QmlEngine::contextForObject(d->children.at(index))->contextProperty(name).toString();
-}
-
-QVariant QmlGraphicsVisualItemModel::evaluate(int index, const QString &expression, QObject *objectContext)
-{
- Q_D(QmlGraphicsVisualItemModel);
- if (index < 0 || index >= d->children.count())
- return QVariant();
- QmlContext *ccontext = qmlContext(this);
- QmlContext *ctxt = new QmlContext(ccontext);
- ctxt->addDefaultObject(d->children.at(index));
- QmlExpression e(ctxt, expression, objectContext);
- QVariant value = e.value();
- delete ctxt;
- return value;
-}
-
-int QmlGraphicsVisualItemModel::indexOf(QmlGraphicsItem *item, QObject *) const
-{
- Q_D(const QmlGraphicsVisualItemModel);
- return d->children.indexOf(item);
-}
-
-QmlGraphicsVisualItemModelAttached *QmlGraphicsVisualItemModel::qmlAttachedProperties(QObject *obj)
-{
- return QmlGraphicsVisualItemModelAttached::properties(obj);
-}
-
-//============================================================================
-
-class VDMDelegateDataType : public QmlOpenMetaObjectType
-{
-public:
- VDMDelegateDataType(const QMetaObject *base, QmlEngine *engine) : QmlOpenMetaObjectType(base, engine) {}
-
- void propertyCreated(int, QMetaPropertyBuilder &prop) {
- prop.setWritable(false);
- }
-};
-
-class QmlGraphicsVisualDataModelParts;
-class QmlGraphicsVisualDataModelData;
-class QmlGraphicsVisualDataModelPrivate : public QObjectPrivate
-{
-public:
- QmlGraphicsVisualDataModelPrivate(QmlContext *);
-
- static QmlGraphicsVisualDataModelPrivate *get(QmlGraphicsVisualDataModel *m) {
- return static_cast<QmlGraphicsVisualDataModelPrivate *>(QObjectPrivate::get(m));
- }
-
- QmlGuard<QListModelInterface> m_listModelInterface;
- QmlGuard<QAbstractItemModel> m_abstractItemModel;
- QmlGuard<QmlGraphicsVisualDataModel> m_visualItemModel;
- QString m_part;
-
- QmlComponent *m_delegate;
- QmlContext *m_context;
- QList<int> m_roles;
- QHash<QByteArray,int> m_roleNames;
- void ensureRoles() {
- if (m_roleNames.isEmpty()) {
- if (m_listModelInterface) {
- m_roles = m_listModelInterface->roles();
- for (int ii = 0; ii < m_roles.count(); ++ii)
- m_roleNames.insert(m_listModelInterface->toString(m_roles.at(ii)).toUtf8(), m_roles.at(ii));
- if (m_roles.count() == 1)
- m_roleNames.insert("modelData", m_roles.at(0));
- } else if (m_abstractItemModel) {
- for (QHash<int,QByteArray>::const_iterator it = m_abstractItemModel->roleNames().begin();
- it != m_abstractItemModel->roleNames().end(); ++it) {
- m_roles.append(it.key());
- m_roleNames.insert(*it, it.key());
- }
- if (m_roles.count() == 1)
- m_roleNames.insert("modelData", m_roles.at(0));
- } else if (m_listAccessor) {
- m_roleNames.insert("modelData", 0);
- if (m_listAccessor->type() == QmlListAccessor::Instance) {
- if (QObject *object = m_listAccessor->at(0).value<QObject*>()) {
- int count = object->metaObject()->propertyCount();
- for (int ii = 1; ii < count; ++ii) {
- const QMetaProperty &prop = object->metaObject()->property(ii);
- m_roleNames.insert(prop.name(), 0);
- }
- }
- }
- }
- }
- }
-
- void createMetaData() {
- if (!m_metaDataCreated) {
- ensureRoles();
- QHash<QByteArray, int>::const_iterator it = m_roleNames.begin();
- while (it != m_roleNames.end()) {
- m_delegateDataType->createProperty(it.key());
- ++it;
- }
- m_metaDataCreated = true;
- }
- }
-
- struct ObjectRef {
- ObjectRef(QObject *object=0) : obj(object), ref(1) {}
- QObject *obj;
- int ref;
- };
- class Cache : public QHash<int, ObjectRef> {
- public:
- QObject *getItem(int index) {
- QObject *item = 0;
- QHash<int,ObjectRef>::iterator it = find(index);
- if (it != end()) {
- (*it).ref++;
- item = (*it).obj;
- }
- return item;
- }
- QObject *item(int index) {
- QObject *item = 0;
- QHash<int, ObjectRef>::const_iterator it = find(index);
- if (it != end())
- item = (*it).obj;
- return item;
- }
- void insertItem(int index, QObject *obj) {
- insert(index, ObjectRef(obj));
- }
- bool releaseItem(QObject *obj) {
- QHash<int, ObjectRef>::iterator it = begin();
- for (; it != end(); ++it) {
- ObjectRef &objRef = *it;
- if (objRef.obj == obj) {
- if (--objRef.ref == 0) {
- erase(it);
- return true;
- }
- break;
- }
- }
- return false;
- }
- };
-
- int modelCount() const {
- if (m_visualItemModel)
- return m_visualItemModel->count();
- if (m_listModelInterface)
- return m_listModelInterface->count();
- if (m_abstractItemModel)
- return m_abstractItemModel->rowCount(m_root);
- if (m_listAccessor)
- return m_listAccessor->count();
- return 0;
- }
-
- Cache m_cache;
- QHash<QObject *, QmlPackage*> m_packaged;
-
- QmlGraphicsVisualDataModelParts *m_parts;
- friend class QmlGraphicsVisualItemParts;
-
- VDMDelegateDataType *m_delegateDataType;
- friend class QmlGraphicsVisualDataModelData;
- bool m_metaDataCreated;
- bool m_metaDataCacheable;
-
- QmlGraphicsVisualDataModelData *data(QObject *item);
-
- QVariant m_modelVariant;
- QmlListAccessor *m_listAccessor;
-
- QModelIndex m_root;
-};
-
-class QmlGraphicsVisualDataModelDataMetaObject : public QmlOpenMetaObject
-{
-public:
- QmlGraphicsVisualDataModelDataMetaObject(QObject *parent, QmlOpenMetaObjectType *type)
- : QmlOpenMetaObject(parent, type) {}
-
- virtual QVariant initialValue(int);
- virtual int createProperty(const char *, const char *);
-
-private:
- friend class QmlGraphicsVisualDataModelData;
- QHash<int,int> roleToProp;
-};
-
-class QmlGraphicsVisualDataModelData : public QObject
-{
-Q_OBJECT
-public:
- QmlGraphicsVisualDataModelData(int index, QmlGraphicsVisualDataModel *model);
- ~QmlGraphicsVisualDataModelData();
-
- Q_PROPERTY(int index READ index NOTIFY indexChanged)
- int index() const;
- void setIndex(int index);
-
- int propForRole(int) const;
- void setValue(int, const QVariant &);
-
-Q_SIGNALS:
- void indexChanged();
-
-private:
- friend class QmlGraphicsVisualDataModelDataMetaObject;
- int m_index;
- QmlGuard<QmlGraphicsVisualDataModel> m_model;
- QmlGraphicsVisualDataModelDataMetaObject *m_meta;
-};
-
-int QmlGraphicsVisualDataModelData::propForRole(int id) const
-{
- QHash<int,int>::const_iterator it = m_meta->roleToProp.find(id);
- if (it != m_meta->roleToProp.end())
- return m_meta->roleToProp[id];
- return -1;
-}
-
-void QmlGraphicsVisualDataModelData::setValue(int id, const QVariant &val)
-{
- m_meta->setValue(id, val);
-}
-
-int QmlGraphicsVisualDataModelDataMetaObject::createProperty(const char *name, const char *type)
-{
- QmlGraphicsVisualDataModelData *data =
- static_cast<QmlGraphicsVisualDataModelData *>(object());
-
- if (!data->m_model)
- return -1;
-
- QmlGraphicsVisualDataModelPrivate *model = QmlGraphicsVisualDataModelPrivate::get(data->m_model);
-
- if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) {
- if (model->m_listAccessor->type() == QmlListAccessor::ListProperty) {
- model->ensureRoles();
- QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>();
- if (object && (object->property(name).isValid() || qstrcmp(name,"modelData")==0))
- return QmlOpenMetaObject::createProperty(name, type);
- }
- }
- return -1;
-}
-
-QVariant QmlGraphicsVisualDataModelDataMetaObject::initialValue(int propId)
-{
- QmlGraphicsVisualDataModelData *data =
- static_cast<QmlGraphicsVisualDataModelData *>(object());
-
- Q_ASSERT(data->m_model);
- QmlGraphicsVisualDataModelPrivate *model = QmlGraphicsVisualDataModelPrivate::get(data->m_model);
-
- QByteArray propName = name(propId);
- if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) {
- if (propName == "modelData") {
- if (model->m_listAccessor->type() == QmlListAccessor::Instance) {
- QObject *object = model->m_listAccessor->at(0).value<QObject*>();
- return object->metaObject()->property(1).read(object); // the first property after objectName
- }
- return model->m_listAccessor->at(data->m_index);
- } else {
- // return any property of a single object instance.
- QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>();
- return object->property(propName);
- }
- } else if (model->m_listModelInterface) {
- model->ensureRoles();
- QHash<QByteArray,int>::const_iterator it = model->m_roleNames.find(propName);
- if (it != model->m_roleNames.end()) {
- roleToProp.insert(*it, propId);
- QVariant value = model->m_listModelInterface->data(data->m_index, *it);
- return value;
- } else if (model->m_roles.count() == 1 && propName == "modelData") {
- //for compatability with other lists, assign modelData if there is only a single role
- roleToProp.insert(model->m_roles.first(), propId);
- QVariant value = model->m_listModelInterface->data(data->m_index, model->m_roles.first());
- return value;
- }
- } else if (model->m_abstractItemModel) {
- model->ensureRoles();
- QHash<QByteArray,int>::const_iterator it = model->m_roleNames.find(propName);
- if (it != model->m_roleNames.end()) {
- roleToProp.insert(*it, propId);
- QModelIndex index = model->m_abstractItemModel->index(data->m_index, 0, model->m_root);
- return model->m_abstractItemModel->data(index, *it);
- }
- }
- Q_ASSERT(!"Can never be reached");
- return QVariant();
-}
-
-QmlGraphicsVisualDataModelData::QmlGraphicsVisualDataModelData(int index,
- QmlGraphicsVisualDataModel *model)
-: m_index(index), m_model(model),
-m_meta(new QmlGraphicsVisualDataModelDataMetaObject(this, QmlGraphicsVisualDataModelPrivate::get(model)->m_delegateDataType))
-{
- QmlGraphicsVisualDataModelPrivate *modelPriv = QmlGraphicsVisualDataModelPrivate::get(model);
- if (modelPriv->m_metaDataCacheable) {
- if (!modelPriv->m_metaDataCreated)
- modelPriv->createMetaData();
- m_meta->setCached(true);
- }
-}
-
-QmlGraphicsVisualDataModelData::~QmlGraphicsVisualDataModelData()
-{
-}
-
-int QmlGraphicsVisualDataModelData::index() const
-{
- return m_index;
-}
-
-// This is internal only - it should not be set from qml
-void QmlGraphicsVisualDataModelData::setIndex(int index)
-{
- m_index = index;
- emit indexChanged();
-}
-
-//---------------------------------------------------------------------------
-
-class QmlGraphicsVisualDataModelPartsMetaObject : public QmlOpenMetaObject
-{
-public:
- QmlGraphicsVisualDataModelPartsMetaObject(QObject *parent)
- : QmlOpenMetaObject(parent) {}
-
- virtual void propertyCreated(int, QMetaPropertyBuilder &);
- virtual QVariant initialValue(int);
-};
-
-class QmlGraphicsVisualDataModelParts : public QObject
-{
-Q_OBJECT
-public:
- QmlGraphicsVisualDataModelParts(QmlGraphicsVisualDataModel *parent);
-
-private:
- friend class QmlGraphicsVisualDataModelPartsMetaObject;
- QmlGraphicsVisualDataModel *model;
-};
-
-void QmlGraphicsVisualDataModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop)
-{
- prop.setWritable(false);
-}
-
-QVariant QmlGraphicsVisualDataModelPartsMetaObject::initialValue(int id)
-{
- QmlGraphicsVisualDataModel *m = new QmlGraphicsVisualDataModel;
- m->setParent(object());
- m->setPart(QString::fromUtf8(name(id)));
- m->setModel(QVariant::fromValue(static_cast<QmlGraphicsVisualDataModelParts *>(object())->model));
-
- QVariant var = QVariant::fromValue((QObject *)m);
- return var;
-}
-
-QmlGraphicsVisualDataModelParts::QmlGraphicsVisualDataModelParts(QmlGraphicsVisualDataModel *parent)
-: QObject(parent), model(parent)
-{
- new QmlGraphicsVisualDataModelPartsMetaObject(this);
-}
-
-QmlGraphicsVisualDataModelPrivate::QmlGraphicsVisualDataModelPrivate(QmlContext *ctxt)
-: m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0)
-, m_context(ctxt), m_parts(0), m_delegateDataType(0), m_metaDataCreated(false)
-, m_metaDataCacheable(false), m_listAccessor(0)
-{
-}
-
-QmlGraphicsVisualDataModelData *QmlGraphicsVisualDataModelPrivate::data(QObject *item)
-{
- QmlGraphicsVisualDataModelData *dataItem =
- item->findChild<QmlGraphicsVisualDataModelData *>();
- Q_ASSERT(dataItem);
- return dataItem;
-}
-
-//---------------------------------------------------------------------------
-
-/*!
- \qmlclass VisualDataModel QmlGraphicsVisualDataModel
- \brief The VisualDataModel encapsulates a model and delegate
-
- A VisualDataModel encapsulates a model and the delegate that will
- be instantiated for items in the model.
-
- It is usually not necessary to create a VisualDataModel directly,
- since the QML views will create one internally.
-
- The example below illustrates using a VisualDataModel with a ListView.
-
- \code
- VisualDataModel {
- id: visualModel
- model: myModel
- delegate: Component {
- Rectangle {
- height: 25
- width: 100
- Text { text: "Name:" + name}
- }
- }
- }
- ListView {
- width: 100
- height: 100
- anchors.fill: parent
- model: visualModel
- }
- \endcode
-*/
-
-QmlGraphicsVisualDataModel::QmlGraphicsVisualDataModel()
-: QmlGraphicsVisualModel(*(new QmlGraphicsVisualDataModelPrivate(0)))
-{
-}
-
-QmlGraphicsVisualDataModel::QmlGraphicsVisualDataModel(QmlContext *ctxt)
-: QmlGraphicsVisualModel(*(new QmlGraphicsVisualDataModelPrivate(ctxt)))
-{
-}
-
-QmlGraphicsVisualDataModel::~QmlGraphicsVisualDataModel()
-{
- Q_D(QmlGraphicsVisualDataModel);
- if (d->m_listAccessor)
- delete d->m_listAccessor;
- if (d->m_delegateDataType)
- d->m_delegateDataType->release();
-}
-
-/*!
- \qmlproperty model VisualDataModel::model
- This property holds the model providing data for the VisualDataModel.
-
- The model provides a set of data that is used to create the items
- for a view. For large or dynamic datasets the model is usually
- provided by a C++ model object. The C++ model object must be a \l
- {QAbstractItemModel} subclass or a simple list.
-
- Models can also be created directly in QML, using a \l{ListModel} or
- \l{XmlListModel}.
-
- \sa {qmlmodels}{Data Models}
-*/
-QVariant QmlGraphicsVisualDataModel::model() const
-{
- Q_D(const QmlGraphicsVisualDataModel);
- return d->m_modelVariant;
-}
-
-void QmlGraphicsVisualDataModel::setModel(const QVariant &model)
-{
- Q_D(QmlGraphicsVisualDataModel);
- delete d->m_listAccessor;
- d->m_listAccessor = 0;
- d->m_modelVariant = model;
- if (d->m_listModelInterface) {
- // Assume caller has released all items.
- QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsChanged(int,int,QList<int>)),
- this, SLOT(_q_itemsChanged(int,int,QList<int>)));
- QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsInserted(int,int)),
- this, SLOT(_q_itemsInserted(int,int)));
- QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsRemoved(int,int)),
- this, SLOT(_q_itemsRemoved(int,int)));
- QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)),
- this, SLOT(_q_itemsMoved(int,int,int)));
- d->m_listModelInterface = 0;
- } else if (d->m_abstractItemModel) {
- QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsInserted(const QModelIndex &,int,int)),
- this, SLOT(_q_rowsInserted(const QModelIndex &,int,int)));
- QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsRemoved(const QModelIndex &,int,int)),
- this, SLOT(_q_rowsRemoved(const QModelIndex &,int,int)));
- QObject::disconnect(d->m_abstractItemModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)),
- this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&)));
- QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)),
- this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)));
- } else if (d->m_visualItemModel) {
- QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)),
- this, SIGNAL(itemsInserted(int,int)));
- QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)),
- this, SIGNAL(itemsRemoved(int,int)));
- QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsMoved(int,int,int)),
- this, SIGNAL(itemsMoved(int,int,int)));
- QObject::disconnect(d->m_visualItemModel, SIGNAL(createdPackage(int,QmlPackage*)),
- this, SLOT(_q_createdPackage(int,QmlPackage*)));
- QObject::disconnect(d->m_visualItemModel, SIGNAL(destroyingPackage(QmlPackage*)),
- this, SLOT(_q_destroyingPackage(QmlPackage*)));
- d->m_visualItemModel = 0;
- }
-
- d->m_roles.clear();
- d->m_roleNames.clear();
- if (d->m_delegateDataType)
- d->m_delegateDataType->release();
- d->m_metaDataCreated = 0;
- d->m_metaDataCacheable = false;
- d->m_delegateDataType = new VDMDelegateDataType(&QmlGraphicsVisualDataModelData::staticMetaObject, d->m_context?d->m_context->engine():qmlEngine(this));
-
- QObject *object = qvariant_cast<QObject *>(model);
- if (object && (d->m_listModelInterface = qobject_cast<QListModelInterface *>(object))) {
- QObject::connect(d->m_listModelInterface, SIGNAL(itemsChanged(int,int,QList<int>)),
- this, SLOT(_q_itemsChanged(int,int,QList<int>)));
- QObject::connect(d->m_listModelInterface, SIGNAL(itemsInserted(int,int)),
- this, SLOT(_q_itemsInserted(int,int)));
- QObject::connect(d->m_listModelInterface, SIGNAL(itemsRemoved(int,int)),
- this, SLOT(_q_itemsRemoved(int,int)));
- QObject::connect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)),
- this, SLOT(_q_itemsMoved(int,int,int)));
- d->m_metaDataCacheable = true;
- if (d->m_delegate && d->m_listModelInterface->count())
- emit itemsInserted(0, d->m_listModelInterface->count());
- return;
- } else if (object && (d->m_abstractItemModel = qobject_cast<QAbstractItemModel *>(object))) {
- QObject::connect(d->m_abstractItemModel, SIGNAL(rowsInserted(const QModelIndex &,int,int)),
- this, SLOT(_q_rowsInserted(const QModelIndex &,int,int)));
- QObject::connect(d->m_abstractItemModel, SIGNAL(rowsRemoved(const QModelIndex &,int,int)),
- this, SLOT(_q_rowsRemoved(const QModelIndex &,int,int)));
- QObject::connect(d->m_abstractItemModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)),
- this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&)));
- QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)),
- this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)));
- d->m_metaDataCacheable = true;
- return;
- }
- if ((d->m_visualItemModel = qvariant_cast<QmlGraphicsVisualDataModel *>(model))) {
- QObject::connect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)),
- this, SIGNAL(itemsInserted(int,int)));
- QObject::connect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)),
- this, SIGNAL(itemsRemoved(int,int)));
- QObject::connect(d->m_visualItemModel, SIGNAL(itemsMoved(int,int,int)),
- this, SIGNAL(itemsMoved(int,int,int)));
- QObject::connect(d->m_visualItemModel, SIGNAL(createdPackage(int,QmlPackage*)),
- this, SLOT(_q_createdPackage(int,QmlPackage*)));
- QObject::connect(d->m_visualItemModel, SIGNAL(destroyingPackage(QmlPackage*)),
- this, SLOT(_q_destroyingPackage(QmlPackage*)));
- return;
- }
- d->m_listAccessor = new QmlListAccessor;
- d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this));
- if (d->m_listAccessor->type() != QmlListAccessor::ListProperty)
- d->m_metaDataCacheable = true;
- if (d->m_delegate && d->modelCount()) {
- emit itemsInserted(0, d->modelCount());
- emit countChanged();
- }
-}
-
-/*!
- \qmlproperty component VisualDataModel::delegate
-
- The delegate provides a template defining each item instantiated by a view.
- The index is exposed as an accessible \c index property. Properties of the
- model are also available depending upon the type of \l {qmlmodels}{Data Model}.
-
- Here is an example delegate:
- \snippet doc/src/snippets/declarative/listview/listview.qml 0
-*/
-QmlComponent *QmlGraphicsVisualDataModel::delegate() const
-{
- Q_D(const QmlGraphicsVisualDataModel);
- if (d->m_visualItemModel)
- return d->m_visualItemModel->delegate();
- return d->m_delegate;
-}
-
-void QmlGraphicsVisualDataModel::setDelegate(QmlComponent *delegate)
-{
- Q_D(QmlGraphicsVisualDataModel);
- bool wasValid = d->m_delegate != 0;
- d->m_delegate = delegate;
- if (!wasValid && d->modelCount() && d->m_delegate) {
- emit itemsInserted(0, d->modelCount());
- emit countChanged();
- }
- if (wasValid && !d->m_delegate && d->modelCount()) {
- emit itemsRemoved(0, d->modelCount());
- emit countChanged();
- }
-}
-
-/*!
- \qmlproperty QModelIndex VisualDataModel::rootIndex
-
- QAbstractItemModel provides a heirachical tree of data, whereas
- QML only operates on list data. rootIndex allows the children of
- any node in a QAbstractItemModel to be provided by this model.
-
- This property only affects models of type QAbstractItemModel.
-
- \code
- // main.cpp
- Q_DECLARE_METATYPE(QModelIndex)
-
- class MyModel : public QDirModel
- {
- Q_OBJECT
- public:
- MyModel(QmlContext *ctxt) : QDirModel(), context(ctxt) {
- QHash<int,QByteArray> roles = roleNames();
- roles.insert(FilePathRole, "path");
- setRoleNames(roles);
- context->setContextProperty("myModel", this);
- context->setContextProperty("myRoot", QVariant::fromValue(index(0,0,QModelIndex())));
- }
-
- Q_INVOKABLE void setRoot(const QString &path) {
- QModelIndex root = index(path);
- context->setContextProperty("myRoot", QVariant::fromValue(root));
- }
-
- QmlContext *context;
- };
-
- int main(int argc, char ** argv)
- {
- QApplication app(argc, argv);
-
- QmlView view;
-
- MyModel model(view.rootContext());
-
- view.setSource(QUrl("qrc:view.qml"));
- view.show();
-
- return app.exec();
- }
-
- #include "main.moc"
- \endcode
-
- \code
- // view.qml
- import Qt 4.6
-
- ListView {
- width: 200
- height: 200
- model: VisualDataModel {
- model: myModel
- rootIndex: myRoot
- delegate: Component {
- Rectangle {
- height: 25; width: 100
- Text { text: path }
- MouseRegion {
- anchors.fill: parent;
- onClicked: myModel.setRoot(path)
- }
- }
- }
- }
- }
- \endcode
-
-*/
-QModelIndex QmlGraphicsVisualDataModel::rootIndex() const
-{
- Q_D(const QmlGraphicsVisualDataModel);
- return d->m_root;
-}
-
-void QmlGraphicsVisualDataModel::setRootIndex(const QModelIndex &root)
-{
- Q_D(QmlGraphicsVisualDataModel);
- if (d->m_root != root) {
- int oldCount = d->modelCount();
- d->m_root = root;
- int newCount = d->modelCount();
- if (d->m_delegate && oldCount)
- emit itemsRemoved(0, oldCount);
- if (d->m_delegate && newCount)
- emit itemsInserted(0, newCount);
- if (newCount != oldCount)
- emit countChanged();
- emit rootIndexChanged();
- }
-}
-
-QString QmlGraphicsVisualDataModel::part() const
-{
- Q_D(const QmlGraphicsVisualDataModel);
- return d->m_part;
-}
-
-void QmlGraphicsVisualDataModel::setPart(const QString &part)
-{
- Q_D(QmlGraphicsVisualDataModel);
- d->m_part = part;
-}
-
-int QmlGraphicsVisualDataModel::count() const
-{
- Q_D(const QmlGraphicsVisualDataModel);
- return d->modelCount();
-}
-
-QmlGraphicsItem *QmlGraphicsVisualDataModel::item(int index, bool complete)
-{
- Q_D(QmlGraphicsVisualDataModel);
- if (d->m_visualItemModel)
- return d->m_visualItemModel->item(index, d->m_part.toUtf8(), complete);
- return item(index, QByteArray(), complete);
-}
-
-/*
- Returns ReleaseStatus flags.
-*/
-QmlGraphicsVisualDataModel::ReleaseFlags QmlGraphicsVisualDataModel::release(QmlGraphicsItem *item)
-{
- Q_D(QmlGraphicsVisualDataModel);
- if (d->m_visualItemModel)
- return d->m_visualItemModel->release(item);
-
- ReleaseFlags stat = 0;
- QObject *obj = item;
- bool inPackage = false;
-
- QHash<QObject*,QmlPackage*>::iterator it = d->m_packaged.find(item);
- if (it != d->m_packaged.end()) {
- QmlPackage *package = *it;
- d->m_packaged.erase(it);
- if (d->m_packaged.contains(item))
- stat |= Referenced;
- inPackage = true;
- obj = package; // fall through and delete
- }
-
- if (d->m_cache.releaseItem(obj)) {
- if (inPackage) {
- emit destroyingPackage(qobject_cast<QmlPackage*>(obj));
- } else {
- item->setVisible(false);
- static_cast<QGraphicsItem*>(item)->setParentItem(0);
- }
- stat |= Destroyed;
- obj->deleteLater();
- } else if (!inPackage) {
- stat |= Referenced;
- }
-
- return stat;
-}
-
-QObject *QmlGraphicsVisualDataModel::parts()
-{
- Q_D(QmlGraphicsVisualDataModel);
- if (!d->m_parts)
- d->m_parts = new QmlGraphicsVisualDataModelParts(this);
- return d->m_parts;
-}
-
-QmlGraphicsItem *QmlGraphicsVisualDataModel::item(int index, const QByteArray &viewId, bool complete)
-{
- Q_D(QmlGraphicsVisualDataModel);
- if (d->m_visualItemModel)
- return d->m_visualItemModel->item(index, viewId, complete);
-
- if (d->modelCount() <= 0 || !d->m_delegate)
- return 0;
- QObject *nobj = d->m_cache.getItem(index);
- if (!nobj) {
- QmlContext *ccontext = d->m_context;
- if (!ccontext) ccontext = qmlContext(this);
- QmlContext *ctxt = new QmlContext(ccontext);
- QmlGraphicsVisualDataModelData *data = new QmlGraphicsVisualDataModelData(index, this);
- ctxt->setContextProperty(QLatin1String("model"), data);
- ctxt->addDefaultObject(data);
- nobj = d->m_delegate->beginCreate(ctxt);
- if (complete)
- d->m_delegate->completeCreate();
- if (nobj) {
- ctxt->setParent(nobj);
- data->setParent(nobj);
- d->m_cache.insertItem(index, nobj);
- if (QmlPackage *package = qobject_cast<QmlPackage *>(nobj))
- emit createdPackage(index, package);
- } else {
- delete data;
- delete ctxt;
- qWarning() << d->m_delegate->errors();
- }
- }
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(nobj);
- if (!item) {
- QmlPackage *package = qobject_cast<QmlPackage *>(nobj);
- if (package) {
- QObject *o = package->part(QString::fromUtf8(viewId));
- item = qobject_cast<QmlGraphicsItem *>(o);
- if (item)
- d->m_packaged.insertMulti(item, package);
- }
- }
- if (!item) {
- d->m_cache.releaseItem(nobj);
- qmlInfo(d->m_delegate) << QmlGraphicsVisualDataModel::tr("Delegate component must be Item type.");
- }
-
- return item;
-}
-
-void QmlGraphicsVisualDataModel::completeItem()
-{
- Q_D(QmlGraphicsVisualDataModel);
- if (d->m_visualItemModel) {
- d->m_visualItemModel->completeItem();
- return;
- }
-
- d->m_delegate->completeCreate();
-}
-
-QString QmlGraphicsVisualDataModel::stringValue(int index, const QString &name)
-{
- Q_D(QmlGraphicsVisualDataModel);
- if (d->m_visualItemModel)
- return d->m_visualItemModel->stringValue(index, name);
-
- if ((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate)
- return QString();
-
- QString val;
- QObject *data = 0;
- bool tempData = false;
-
- if (QObject *nobj = d->m_cache.item(index))
- data = d->data(nobj);
- if (!data) {
- data = new QmlGraphicsVisualDataModelData(index, this);
- tempData = true;
- }
-
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(data);
- if (ddata && ddata->propertyCache) {
- QmlPropertyCache::Data *prop = ddata->propertyCache->property(name);
- if (prop) {
- if (prop->propType == QVariant::String) {
- void *args[] = { &val, 0 };
- QMetaObject::metacall(data, QMetaObject::ReadProperty, prop->coreIndex, args);
- } else if (prop->propType == qMetaTypeId<QVariant>()) {
- QVariant v;
- void *args[] = { &v, 0 };
- QMetaObject::metacall(data, QMetaObject::ReadProperty, prop->coreIndex, args);
- val = v.toString();
- }
- } else {
- val = data->property(name.toUtf8()).toString();
- }
- } else {
- val = data->property(name.toUtf8()).toString();
- }
-
- if (tempData)
- delete data;
-
- return val;
-}
-
-QVariant QmlGraphicsVisualDataModel::evaluate(int index, const QString &expression, QObject *objectContext)
-{
- Q_D(QmlGraphicsVisualDataModel);
- if (d->m_visualItemModel)
- return d->m_visualItemModel->evaluate(index, expression, objectContext);
-
- if ((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate)
- return QVariant();
-
- QVariant value;
- QObject *nobj = d->m_cache.item(index);
- if (nobj) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(nobj);
- if (item) {
- QmlExpression e(qmlContext(item), expression, objectContext);
- value = e.value();
- }
- } else {
- QmlContext *ccontext = d->m_context;
- if (!ccontext) ccontext = qmlContext(this);
- QmlContext *ctxt = new QmlContext(ccontext);
- QmlGraphicsVisualDataModelData *data = new QmlGraphicsVisualDataModelData(index, this);
- ctxt->addDefaultObject(data);
- QmlExpression e(ctxt, expression, objectContext);
- value = e.value();
- delete data;
- delete ctxt;
- }
-
- return value;
-}
-
-int QmlGraphicsVisualDataModel::indexOf(QmlGraphicsItem *item, QObject *) const
-{
- QVariant val = QmlEngine::contextForObject(item)->contextProperty(QLatin1String("index"));
- return val.toInt();
- return -1;
-}
-
-void QmlGraphicsVisualDataModel::_q_itemsChanged(int index, int count,
- const QList<int> &roles)
-{
- Q_D(QmlGraphicsVisualDataModel);
- // XXX - highly inefficient
- for (int ii = index; ii < index + count; ++ii) {
-
- if (QObject *item = d->m_cache.item(ii)) {
- QmlGraphicsVisualDataModelData *data = d->data(item);
-
- for (int roleIdx = 0; roleIdx < roles.count(); ++roleIdx) {
- int role = roles.at(roleIdx);
- int propId = data->propForRole(role);
- if (propId != -1) {
- if (d->m_listModelInterface) {
- data->setValue(propId, d->m_listModelInterface->data(ii, QList<int>() << role).value(role));
- } else if (d->m_abstractItemModel) {
- QModelIndex index = d->m_abstractItemModel->index(ii, 0, d->m_root);
- data->setValue(propId, d->m_abstractItemModel->data(index, role));
- }
- }
- }
- }
- }
-}
-
-void QmlGraphicsVisualDataModel::_q_itemsInserted(int index, int count)
-{
- Q_D(QmlGraphicsVisualDataModel);
- // XXX - highly inefficient
- QHash<int,QmlGraphicsVisualDataModelPrivate::ObjectRef> items;
- for (QHash<int,QmlGraphicsVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin();
- iter != d->m_cache.end(); ) {
-
- if (iter.key() >= index) {
- QmlGraphicsVisualDataModelPrivate::ObjectRef objRef = *iter;
- int index = iter.key() + count;
- iter = d->m_cache.erase(iter);
-
- items.insert(index, objRef);
-
- QmlGraphicsVisualDataModelData *data = d->data(objRef.obj);
- data->setIndex(index);
- } else {
- ++iter;
- }
- }
- d->m_cache.unite(items);
-
- emit itemsInserted(index, count);
- emit countChanged();
-}
-
-void QmlGraphicsVisualDataModel::_q_itemsRemoved(int index, int count)
-{
- Q_D(QmlGraphicsVisualDataModel);
- // XXX - highly inefficient
- QHash<int, QmlGraphicsVisualDataModelPrivate::ObjectRef> items;
- for (QHash<int, QmlGraphicsVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin();
- iter != d->m_cache.end(); ) {
- if (iter.key() >= index && iter.key() < index + count) {
- QmlGraphicsVisualDataModelPrivate::ObjectRef objRef = *iter;
- iter = d->m_cache.erase(iter);
- items.insertMulti(-1, objRef); //XXX perhaps better to maintain separately
- QmlGraphicsVisualDataModelData *data = d->data(objRef.obj);
- data->setIndex(-1);
- } else if (iter.key() >= index + count) {
- QmlGraphicsVisualDataModelPrivate::ObjectRef objRef = *iter;
- int index = iter.key() - count;
- iter = d->m_cache.erase(iter);
- items.insert(index, objRef);
- QmlGraphicsVisualDataModelData *data = d->data(objRef.obj);
- data->setIndex(index);
- } else {
- ++iter;
- }
- }
-
- d->m_cache.unite(items);
- emit itemsRemoved(index, count);
- emit countChanged();
-}
-
-void QmlGraphicsVisualDataModel::_q_itemsMoved(int from, int to, int count)
-{
- Q_D(QmlGraphicsVisualDataModel);
- // XXX - highly inefficient
- QHash<int,QmlGraphicsVisualDataModelPrivate::ObjectRef> items;
- for (QHash<int,QmlGraphicsVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin();
- iter != d->m_cache.end(); ) {
-
- if (iter.key() >= from && iter.key() < from + count) {
- QmlGraphicsVisualDataModelPrivate::ObjectRef objRef = *iter;
- int index = iter.key() - from + to;
- iter = d->m_cache.erase(iter);
-
- items.insert(index, objRef);
-
- QmlGraphicsVisualDataModelData *data = d->data(objRef.obj);
- data->setIndex(index);
- } else {
- ++iter;
- }
- }
- for (QHash<int,QmlGraphicsVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin();
- iter != d->m_cache.end(); ) {
-
- int diff = from > to ? count : -count;
- if (iter.key() >= qMin(from,to) && iter.key() < qMax(from+count,to+count)) {
- QmlGraphicsVisualDataModelPrivate::ObjectRef objRef = *iter;
- int index = iter.key() + diff;
- iter = d->m_cache.erase(iter);
-
- items.insert(index, objRef);
-
- QmlGraphicsVisualDataModelData *data = d->data(objRef.obj);
- data->setIndex(index);
- } else {
- ++iter;
- }
- }
- d->m_cache.unite(items);
-
- emit itemsMoved(from, to, count);
-}
-
-void QmlGraphicsVisualDataModel::_q_rowsInserted(const QModelIndex &parent, int begin, int end)
-{
- if (!parent.isValid())
- _q_itemsInserted(begin, end - begin + 1);
-}
-
-void QmlGraphicsVisualDataModel::_q_rowsRemoved(const QModelIndex &parent, int begin, int end)
-{
- if (!parent.isValid())
- _q_itemsRemoved(begin, end - begin + 1);
-}
-
-void QmlGraphicsVisualDataModel::_q_rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
-{
- const int count = sourceEnd - sourceStart + 1;
- if (!destinationParent.isValid() && !sourceParent.isValid()) {
- _q_itemsMoved(sourceStart, destinationRow, count);
- } else if (!sourceParent.isValid()) {
- _q_itemsRemoved(sourceStart, count);
- } else if (!destinationParent.isValid()) {
- _q_itemsInserted(destinationRow, count);
- }
-}
-
-void QmlGraphicsVisualDataModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end)
-{
- Q_D(QmlGraphicsVisualDataModel);
- if (!begin.parent().isValid())
- _q_itemsChanged(begin.row(), end.row() - begin.row() + 1, d->m_roles);
-}
-
-void QmlGraphicsVisualDataModel::_q_createdPackage(int index, QmlPackage *package)
-{
- Q_D(QmlGraphicsVisualDataModel);
- emit createdItem(index, qobject_cast<QmlGraphicsItem*>(package->part(d->m_part)));
-}
-
-void QmlGraphicsVisualDataModel::_q_destroyingPackage(QmlPackage *package)
-{
- Q_D(QmlGraphicsVisualDataModel);
- emit destroyingItem(qobject_cast<QmlGraphicsItem*>(package->part(d->m_part)));
-}
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QListModelInterface)
-
-#include <qmlgraphicsvisualitemmodel.moc>
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
deleted file mode 100644
index 7dc41a8..0000000
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
+++ /dev/null
@@ -1,253 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSVISUALDATAMODEL_H
-#define QMLGRAPHICSVISUALDATAMODEL_H
-
-#include <qml.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qabstractitemmodel.h>
-
-QT_BEGIN_HEADER
-
-Q_DECLARE_METATYPE(QModelIndex)
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-/*****************************************************************************
- *****************************************************************************
- XXX Experimental
- *****************************************************************************
-*****************************************************************************/
-
-class QmlGraphicsItem;
-class QmlComponent;
-class QmlPackage;
-class QmlGraphicsVisualDataModelPrivate;
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsVisualModel : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(int count READ count NOTIFY countChanged)
-
-public:
- QmlGraphicsVisualModel() {}
- virtual ~QmlGraphicsVisualModel() {}
-
- enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 };
- Q_DECLARE_FLAGS(ReleaseFlags, ReleaseFlag)
-
- virtual int count() const = 0;
- virtual bool isValid() const = 0;
- virtual QmlGraphicsItem *item(int index, bool complete=true) = 0;
- virtual ReleaseFlags release(QmlGraphicsItem *item) = 0;
- virtual void completeItem() = 0;
- virtual QVariant evaluate(int index, const QString &expression, QObject *objectContext) = 0;
- virtual QString stringValue(int, const QString &) { return QString(); }
-
- virtual int indexOf(QmlGraphicsItem *item, QObject *objectContext) const = 0;
-
-Q_SIGNALS:
- void countChanged();
- void itemsInserted(int index, int count);
- void itemsRemoved(int index, int count);
- void itemsMoved(int from, int to, int count);
- void createdItem(int index, QmlGraphicsItem *item);
- void destroyingItem(QmlGraphicsItem *item);
-
-protected:
- QmlGraphicsVisualModel(QObjectPrivate &dd, QObject *parent = 0)
- : QObject(dd, parent) {}
-
-private:
- Q_DISABLE_COPY(QmlGraphicsVisualModel)
-};
-
-class QmlGraphicsVisualItemModelAttached;
-class QmlGraphicsVisualItemModelPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsVisualItemModel : public QmlGraphicsVisualModel
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlGraphicsVisualItemModel)
-
- Q_PROPERTY(QmlListProperty<QmlGraphicsItem> children READ children NOTIFY childrenChanged DESIGNABLE false)
- Q_CLASSINFO("DefaultProperty", "children")
-
-public:
- QmlGraphicsVisualItemModel();
- virtual ~QmlGraphicsVisualItemModel() {}
-
- virtual int count() const;
- virtual bool isValid() const;
- virtual QmlGraphicsItem *item(int index, bool complete=true);
- virtual ReleaseFlags release(QmlGraphicsItem *item);
- virtual void completeItem();
- virtual QString stringValue(int index, const QString &role);
- virtual QVariant evaluate(int index, const QString &expression, QObject *objectContext);
-
- virtual int indexOf(QmlGraphicsItem *item, QObject *objectContext) const;
-
- QmlListProperty<QmlGraphicsItem> children();
-
- static QmlGraphicsVisualItemModelAttached *qmlAttachedProperties(QObject *obj);
-
-Q_SIGNALS:
- void childrenChanged();
-
-private:
- Q_DISABLE_COPY(QmlGraphicsVisualItemModel)
-};
-
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsVisualDataModel : public QmlGraphicsVisualModel
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlGraphicsVisualDataModel)
-
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
- Q_PROPERTY(QString part READ part WRITE setPart)
- Q_PROPERTY(QObject *parts READ parts CONSTANT)
- Q_PROPERTY(QModelIndex rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged)
- Q_CLASSINFO("DefaultProperty", "delegate")
-public:
- QmlGraphicsVisualDataModel();
- QmlGraphicsVisualDataModel(QmlContext *);
- virtual ~QmlGraphicsVisualDataModel();
-
- QVariant model() const;
- void setModel(const QVariant &);
-
- QmlComponent *delegate() const;
- void setDelegate(QmlComponent *);
-
- QModelIndex rootIndex() const;
- void setRootIndex(const QModelIndex &root);
-
- QString part() const;
- void setPart(const QString &);
-
- int count() const;
- bool isValid() const { return delegate() != 0; }
- QmlGraphicsItem *item(int index, bool complete=true);
- QmlGraphicsItem *item(int index, const QByteArray &, bool complete=true);
- ReleaseFlags release(QmlGraphicsItem *item);
- void completeItem();
- virtual QString stringValue(int index, const QString &role);
- QVariant evaluate(int index, const QString &expression, QObject *objectContext);
-
- int indexOf(QmlGraphicsItem *item, QObject *objectContext) const;
-
- QObject *parts();
-
-Q_SIGNALS:
- void createdPackage(int index, QmlPackage *package);
- void destroyingPackage(QmlPackage *package);
- void rootIndexChanged();
-
-private Q_SLOTS:
- void _q_itemsChanged(int, int, const QList<int> &);
- void _q_itemsInserted(int index, int count);
- void _q_itemsRemoved(int index, int count);
- void _q_itemsMoved(int from, int to, int count);
- void _q_rowsInserted(const QModelIndex &,int,int);
- void _q_rowsRemoved(const QModelIndex &,int,int);
- void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
- void _q_dataChanged(const QModelIndex&,const QModelIndex&);
- void _q_createdPackage(int index, QmlPackage *package);
- void _q_destroyingPackage(QmlPackage *package);
-
-private:
- Q_DISABLE_COPY(QmlGraphicsVisualDataModel)
-};
-
-class QmlGraphicsVisualItemModelAttached : public QObject
-{
- Q_OBJECT
-
-public:
- QmlGraphicsVisualItemModelAttached(QObject *parent)
- : QObject(parent), m_index(0) {}
- ~QmlGraphicsVisualItemModelAttached() {
- attachedProperties.remove(parent());
- }
-
- Q_PROPERTY(int index READ index NOTIFY indexChanged)
- int index() const { return m_index; }
- void setIndex(int idx) {
- if (m_index != idx) {
- m_index = idx;
- emit indexChanged();
- }
- }
-
- static QmlGraphicsVisualItemModelAttached *properties(QObject *obj) {
- QmlGraphicsVisualItemModelAttached *rv = attachedProperties.value(obj);
- if (!rv) {
- rv = new QmlGraphicsVisualItemModelAttached(obj);
- attachedProperties.insert(obj, rv);
- }
- return rv;
- }
-
-Q_SIGNALS:
- void indexChanged();
-
-public:
- int m_index;
-
- static QHash<QObject*, QmlGraphicsVisualItemModelAttached*> attachedProperties;
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsVisualModel)
-QML_DECLARE_TYPE(QmlGraphicsVisualItemModel)
-QML_DECLARE_TYPEINFO(QmlGraphicsVisualItemModel, QML_HAS_ATTACHED_PROPERTIES)
-QML_DECLARE_TYPE(QmlGraphicsVisualDataModel)
-
-QT_END_HEADER
-
-#endif // QMLGRAPHICSVISUALDATAMODEL_H
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
deleted file mode 100644
index 92ec4c4..0000000
--- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ /dev/null
@@ -1,1335 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlgraphicswebview_p.h"
-#include "qmlgraphicswebview_p_p.h"
-
-#include "qmlgraphicspainteditem_p_p.h"
-
-#include <qml.h>
-#include <qmlengine.h>
-#include <qmlstate_p.h>
-
-#include <QDebug>
-#include <QPen>
-#include <QFile>
-#include <QEvent>
-#include <QMouseEvent>
-#include <QKeyEvent>
-#include <QBasicTimer>
-#include <QApplication>
-#include <QGraphicsSceneMouseEvent>
-#include <QtWebKit/QWebPage>
-#include <QtWebKit/QWebFrame>
-#include <QtWebKit/QWebElement>
-#include <QtWebKit/QWebSettings>
-#include <qlistmodelinterface_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system
-
-class QmlGraphicsWebViewPrivate : public QmlGraphicsPaintedItemPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsWebView)
-
-public:
- QmlGraphicsWebViewPrivate()
- : QmlGraphicsPaintedItemPrivate(), page(0), preferredwidth(0), preferredheight(0),
- progress(1.0), status(QmlGraphicsWebView::Null), pending(PendingNone),
- newWindowComponent(0), newWindowParent(0),
- pressTime(400),
- rendering(true)
- {
- }
-
- QUrl url; // page url might be different if it has not loaded yet
- QWebPage *page;
-
- int preferredwidth, preferredheight;
- qreal progress;
- QmlGraphicsWebView::Status status;
- QString statusText;
- enum { PendingNone, PendingUrl, PendingHtml, PendingContent } pending;
- QUrl pending_url;
- QString pending_string;
- QByteArray pending_data;
- mutable QmlGraphicsWebSettings settings;
- QmlComponent *newWindowComponent;
- QmlGraphicsItem *newWindowParent;
-
- QBasicTimer pressTimer;
- QPoint pressPoint;
- int pressTime; // milliseconds before it's a "hold"
-
-
- static void windowObjects_append(QmlListProperty<QObject> *prop, QObject *o) {
- static_cast<QmlGraphicsWebViewPrivate *>(prop->data)->windowObjects.append(o);
- static_cast<QmlGraphicsWebViewPrivate *>(prop->data)->updateWindowObjects();
- }
-
- void updateWindowObjects();
- QObjectList windowObjects;
-
- bool rendering;
-};
-
-/*!
- \qmlclass WebView QmlGraphicsWebView
- \since 4.7
- \brief The WebView item allows you to add web content to a canvas.
- \inherits Item
-
- A WebView renders web content based on a URL.
-
- If the width and height of the item is not set, they will
- dynamically adjust to a size appropriate for the content.
- This width may be large for typical online web pages.
-
- If the preferredWidth is set, the width will be this amount or larger,
- usually laying out the web content to fit the preferredWidth.
-
- \qml
- WebView {
- url: "http://www.nokia.com"
- width: 490
- height: 400
- scale: 0.5
- smooth: false
- smoothCache: true
- }
- \endqml
-
- \image webview.png
-
- The item includes no scrolling, scaling,
- toolbars, etc., those must be implemented around WebView. See the WebBrowser example
- for a demonstration of this.
-*/
-
-/*!
- \internal
- \class QmlGraphicsWebView
- \brief The QmlGraphicsWebView class allows you to add web content to a QmlView.
-
- A WebView renders web content base on a URL.
-
- \image webview.png
-
- The item includes no scrolling, scaling,
- toolbars, etc., those must be implemented around WebView. See the WebBrowser example
- for a demonstration of this.
-
- A QmlGraphicsWebView object can be instantiated in Qml using the tag \l WebView.
-*/
-
-QmlGraphicsWebView::QmlGraphicsWebView(QmlGraphicsItem *parent)
- : QmlGraphicsPaintedItem(*(new QmlGraphicsWebViewPrivate), parent)
-{
- init();
-}
-
-QmlGraphicsWebView::~QmlGraphicsWebView()
-{
- Q_D(QmlGraphicsWebView);
- delete d->page;
-}
-
-void QmlGraphicsWebView::init()
-{
- Q_D(QmlGraphicsWebView);
-
- setAcceptHoverEvents(true);
- setAcceptedMouseButtons(Qt::LeftButton);
- setFlag(QGraphicsItem::ItemHasNoContents, false);
-
- d->page = 0;
-}
-
-void QmlGraphicsWebView::componentComplete()
-{
- QmlGraphicsPaintedItem::componentComplete();
- Q_D(QmlGraphicsWebView);
- switch (d->pending) {
- case QmlGraphicsWebViewPrivate::PendingUrl:
- setUrl(d->pending_url);
- break;
- case QmlGraphicsWebViewPrivate::PendingHtml:
- setHtml(d->pending_string, d->pending_url);
- break;
- case QmlGraphicsWebViewPrivate::PendingContent:
- setContent(d->pending_data, d->pending_string, d->pending_url);
- break;
- default:
- break;
- }
- d->pending = QmlGraphicsWebViewPrivate::PendingNone;
- d->updateWindowObjects();
-}
-
-QmlGraphicsWebView::Status QmlGraphicsWebView::status() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->status;
-}
-
-
-/*!
- \qmlproperty real WebView::progress
- This property holds the progress of loading the current URL, from 0 to 1.
-
- If you just want to know when progress gets to 1, use
- WebView::onLoadFinished() or WebView::onLoadFailed() instead.
-*/
-qreal QmlGraphicsWebView::progress() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->progress;
-}
-
-void QmlGraphicsWebView::doLoadStarted()
-{
- Q_D(QmlGraphicsWebView);
-
- if (!d->url.isEmpty()) {
- d->status = Loading;
- emit statusChanged(d->status);
- }
- emit loadStarted();
-}
-
-void QmlGraphicsWebView::doLoadProgress(int p)
-{
- Q_D(QmlGraphicsWebView);
- if (d->progress == p/100.0)
- return;
- d->progress = p/100.0;
- emit progressChanged();
-}
-
-void QmlGraphicsWebView::pageUrlChanged()
-{
- Q_D(QmlGraphicsWebView);
-
- page()->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth : width(),
- d->preferredheight>0 ? d->preferredheight : height()));
- expandToWebPage();
-
- if ((d->url.isEmpty() && page()->mainFrame()->url() != QUrl(QLatin1String("about:blank")))
- || (d->url != page()->mainFrame()->url() && !page()->mainFrame()->url().isEmpty()))
- {
- d->url = page()->mainFrame()->url();
- if (d->url == QUrl(QLatin1String("about:blank")))
- d->url = QUrl();
- emit urlChanged();
- }
-}
-
-void QmlGraphicsWebView::doLoadFinished(bool ok)
-{
- Q_D(QmlGraphicsWebView);
-
- if (title().isEmpty())
- pageUrlChanged(); // XXX bug 232556 - pages with no title never get urlChanged()
-
- if (ok) {
- d->status = d->url.isEmpty() ? Null : Ready;
- emit loadFinished();
- } else {
- d->status = Error;
- emit loadFailed();
- }
- emit statusChanged(d->status);
-}
-
-/*!
- \qmlproperty url WebView::url
- This property holds the URL to the page displayed in this item. It can be set,
- but also can change spontaneously (eg. because of network redirection).
-
- If the url is empty, the page is blank.
-
- The url is always absolute (QML will resolve relative URL strings in the context
- of the containing QML document).
-*/
-QUrl QmlGraphicsWebView::url() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->url;
-}
-
-void QmlGraphicsWebView::setUrl(const QUrl &url)
-{
- Q_D(QmlGraphicsWebView);
- if (url == d->url)
- return;
-
- if (isComponentComplete()) {
- d->url = url;
- page()->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth : width(),
- d->preferredheight>0 ? d->preferredheight : height()));
- QUrl seturl = url;
- if (seturl.isEmpty())
- seturl = QUrl(QLatin1String("about:blank"));
-
- Q_ASSERT(!seturl.isRelative());
-
- page()->mainFrame()->load(seturl);
-
- emit urlChanged();
- } else {
- d->pending = d->PendingUrl;
- d->pending_url = url;
- }
-}
-
-/*!
- \qmlproperty int WebView::preferredWidth
- This property holds the ideal width for displaying the current URL.
-*/
-int QmlGraphicsWebView::preferredWidth() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->preferredwidth;
-}
-
-void QmlGraphicsWebView::setPreferredWidth(int iw)
-{
- Q_D(QmlGraphicsWebView);
- if (d->preferredwidth == iw) return;
- d->preferredwidth = iw;
- //expandToWebPage();
- emit preferredWidthChanged();
-}
-
-/*!
- \qmlproperty int WebView::preferredHeight
- This property holds the ideal height for displaying the current URL.
- This only affects the area zoomed by heuristicZoom().
-*/
-int QmlGraphicsWebView::preferredHeight() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->preferredheight;
-}
-void QmlGraphicsWebView::setPreferredHeight(int ih)
-{
- Q_D(QmlGraphicsWebView);
- if (d->preferredheight == ih) return;
- d->preferredheight = ih;
- emit preferredHeightChanged();
-}
-
-/*!
- \qmlmethod bool WebView::evaluateJavaScript(string)
-
- Evaluates the \a scriptSource JavaScript inside the context of the
- main web frame, and returns the result of the last executed statement.
-
- Note that this JavaScript does \e not have any access to QML objects
- except as made available as windowObjects.
-*/
-QVariant QmlGraphicsWebView::evaluateJavaScript(const QString &scriptSource)
-{
- return this->page()->mainFrame()->evaluateJavaScript(scriptSource);
-}
-
-void QmlGraphicsWebView::focusChanged(bool hasFocus)
-{
- QFocusEvent e(hasFocus ? QEvent::FocusIn : QEvent::FocusOut);
- page()->event(&e);
- QmlGraphicsItem::focusChanged(hasFocus);
-}
-
-void QmlGraphicsWebView::initialLayout()
-{
- // nothing useful to do at this point
-}
-
-void QmlGraphicsWebView::noteContentsSizeChanged(const QSize&)
-{
- expandToWebPage();
-}
-
-void QmlGraphicsWebView::expandToWebPage()
-{
- Q_D(QmlGraphicsWebView);
- QSize cs = page()->mainFrame()->contentsSize();
- if (cs.width() < d->preferredwidth)
- cs.setWidth(d->preferredwidth);
- if (cs.height() < d->preferredheight)
- cs.setHeight(d->preferredheight);
- if (widthValid())
- cs.setWidth(width());
- if (heightValid())
- cs.setHeight(height());
- if (cs != page()->viewportSize()) {
- page()->setViewportSize(cs);
- }
- if (cs != contentsSize())
- setContentsSize(cs);
-}
-
-void QmlGraphicsWebView::geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry)
-{
- if (newGeometry.size() != oldGeometry.size())
- expandToWebPage();
- QmlGraphicsPaintedItem::geometryChanged(newGeometry, oldGeometry);
-}
-
-void QmlGraphicsWebView::paintPage(const QRect& r)
-{
- dirtyCache(r);
- update();
-}
-
-/*!
- \qmlproperty list<object> WebView::javaScriptWindowObjects
-
- This property is a list of object that are available from within
- the webview's JavaScript context.
-
- The \a object will be inserted as a child of the frame's window
- object, under the name given by the attached property \c WebView.windowObjectName.
-
- \qml
- WebView {
- javaScriptWindowObjects: Object {
- WebView.windowObjectName: "coordinates"
- }
- }
- \endqml
-
- Properties of the object will be exposed as JavaScript properties and slots as
- JavaScript methods.
-
- If Javascript is not enabled for this page, then this property does nothing.
-*/
-QmlListProperty<QObject> QmlGraphicsWebView::javaScriptWindowObjects()
-{
- Q_D(QmlGraphicsWebView);
- return QmlListProperty<QObject>(this, d, &QmlGraphicsWebViewPrivate::windowObjects_append);
-}
-
-QmlGraphicsWebViewAttached *QmlGraphicsWebView::qmlAttachedProperties(QObject *o)
-{
- return new QmlGraphicsWebViewAttached(o);
-}
-
-void QmlGraphicsWebViewPrivate::updateWindowObjects()
-{
- Q_Q(QmlGraphicsWebView);
- if (!q->isComponentComplete() || !page)
- return;
-
- for (int ii = 0; ii < windowObjects.count(); ++ii) {
- QObject *object = windowObjects.at(ii);
- QmlGraphicsWebViewAttached *attached = static_cast<QmlGraphicsWebViewAttached *>(qmlAttachedPropertiesObject<QmlGraphicsWebView>(object));
- if (attached && !attached->windowObjectName().isEmpty()) {
- page->mainFrame()->addToJavaScriptWindowObject(attached->windowObjectName(), object);
- }
- }
-}
-
-bool QmlGraphicsWebView::renderingEnabled() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->rendering;
-}
-
-void QmlGraphicsWebView::setRenderingEnabled(bool enabled)
-{
- Q_D(QmlGraphicsWebView);
- if (d->rendering == enabled)
- return;
- d->rendering = enabled;
- emit renderingEnabledChanged();
-
- setCacheFrozen(!enabled);
- if (enabled)
- clearCache();
-}
-
-
-void QmlGraphicsWebView::drawContents(QPainter *p, const QRect &r)
-{
- Q_D(QmlGraphicsWebView);
- if (d->rendering)
- page()->mainFrame()->render(p,r);
-}
-
-QMouseEvent *QmlGraphicsWebView::sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e)
-{
- QEvent::Type t;
- switch(e->type()) {
- default:
- case QEvent::GraphicsSceneMousePress:
- t = QEvent::MouseButtonPress;
- break;
- case QEvent::GraphicsSceneMouseRelease:
- t = QEvent::MouseButtonRelease;
- break;
- case QEvent::GraphicsSceneMouseMove:
- t = QEvent::MouseMove;
- break;
- case QGraphicsSceneEvent::GraphicsSceneMouseDoubleClick:
- t = QEvent::MouseButtonDblClick;
- break;
- }
-
- QMouseEvent *me = new QMouseEvent(t, (e->pos()/contentsScale()).toPoint(), e->button(), e->buttons(), 0);
- return me;
-}
-
-QMouseEvent *QmlGraphicsWebView::sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *e)
-{
- QEvent::Type t = QEvent::MouseMove;
-
- QMouseEvent *me = new QMouseEvent(t, (e->pos()/contentsScale()).toPoint(), Qt::NoButton, Qt::NoButton, 0);
-
- return me;
-}
-
-
-/*!
- \qmlsignal WebView::onDoubleClick(clickx,clicky)
-
- The WebView does not pass double-click events to the web engine, but rather
- emits this signals.
-*/
-
-void QmlGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
-{
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
- emit doubleClick(me->x(),me->y());
- delete me;
-}
-
-/*!
- \qmlmethod bool WebView::heuristicZoom(clickX,clickY,maxzoom)
-
- Finds a zoom that:
- \list
- \i shows a whole item
- \i includes (\a clickX, \a clickY)
- \i fits into the preferredWidth and preferredHeight
- \i zooms by no more than \a maxzoom
- \i is more than 10% above the current zoom
- \endlist
-
- If such a zoom exists, emits zoomTo(zoom,centerX,centerY) and returns true; otherwise,
- no signal is emitted and returns false.
-*/
-bool QmlGraphicsWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom)
-{
- Q_D(QmlGraphicsWebView);
- if (contentsScale() >= maxzoom/zoomFactor())
- return false;
- qreal ozf = contentsScale();
- QRect showarea = elementAreaAt(clickX, clickY, d->preferredwidth/maxzoom, d->preferredheight/maxzoom);
- qreal z = qMin(qreal(d->preferredwidth)/showarea.width(),qreal(d->preferredheight)/showarea.height());
- if (z > maxzoom/zoomFactor())
- z = maxzoom/zoomFactor();
- if (z/ozf > 1.2) {
- QRectF r(showarea.left()*z, showarea.top()*z, showarea.width()*z, showarea.height()*z);
- emit zoomTo(z,r.x()+r.width()/2, r.y()+r.height()/2);
- return true;
- } else {
- return false;
- }
-}
-
-/*!
- \qmlproperty int WebView::pressGrabTime
-
- The number of milliseconds the user must press before the WebView
- starts passing move events through to the web engine (rather than
- letting other QML elements such as a Flickable take them).
-
- Defaults to 400ms. Set to 0 to always grab and pass move events to
- the web engine.
-*/
-int QmlGraphicsWebView::pressGrabTime() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->pressTime;
-}
-
-void QmlGraphicsWebView::setPressGrabTime(int ms)
-{
- Q_D(QmlGraphicsWebView);
- if (d->pressTime == ms)
- return;
- d->pressTime = ms;
- emit pressGrabTimeChanged();
-}
-
-void QmlGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsWebView);
-
- setFocus (true);
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
-
- d->pressPoint = me->pos();
- if (d->pressTime) {
- d->pressTimer.start(d->pressTime,this);
- setKeepMouseGrab(false);
- } else {
- grabMouse();
- setKeepMouseGrab(true);
- }
-
- page()->event(me);
- event->setAccepted(
-/*
- It is not correct to send the press event upwards, if it is not accepted by WebKit
- e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit
- Might be a bug in WebKit, though
- */
-#if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835
- true
-#else
- me->isAccepted()
-#endif
- );
- delete me;
- if (!event->isAccepted()) {
- QmlGraphicsPaintedItem::mousePressEvent(event);
- }
-}
-
-void QmlGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsWebView);
-
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
- page()->event(me);
- d->pressTimer.stop();
- event->setAccepted(
-/*
- It is not correct to send the press event upwards, if it is not accepted by WebKit
- e.g. push button does not work, if done so as QGraphicsScene will not send all the events to WebKit
- */
-#if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835
- true
-#else
- me->isAccepted()
-#endif
- );
- delete me;
- if (!event->isAccepted()) {
- QmlGraphicsPaintedItem::mouseReleaseEvent(event);
- }
- setKeepMouseGrab(false);
- ungrabMouse();
-}
-
-void QmlGraphicsWebView::timerEvent(QTimerEvent *event)
-{
- Q_D(QmlGraphicsWebView);
- if (event->timerId() == d->pressTimer.timerId()) {
- d->pressTimer.stop();
- grabMouse();
- setKeepMouseGrab(true);
- }
-}
-
-void QmlGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QmlGraphicsWebView);
-
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
- if (d->pressTimer.isActive()) {
- if ((me->pos() - d->pressPoint).manhattanLength() > QApplication::startDragDistance()) {
- d->pressTimer.stop();
- }
- }
- if (keepMouseGrab()) {
- page()->event(me);
- event->setAccepted(
-/*
- It is not correct to send the press event upwards, if it is not accepted by WebKit
- e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit
- Might be a bug in WebKit, though
- */
-#if 1 // QT_VERSION <= 0x040500 // XXX see bug 230835
- true
-#else
- me->isAccepted()
-#endif
- );
- }
- delete me;
- if (!event->isAccepted())
- QmlGraphicsPaintedItem::mouseMoveEvent(event);
-
-}
-void QmlGraphicsWebView::hoverMoveEvent (QGraphicsSceneHoverEvent * event)
-{
- QMouseEvent *me = sceneHoverMoveEventToMouseEvent(event);
- page()->event(me);
- event->setAccepted(
-#if QT_VERSION <= 0x040500 // XXX see bug 230835
- true
-#else
- me->isAccepted()
-#endif
- );
- delete me;
- if (!event->isAccepted())
- QmlGraphicsPaintedItem::hoverMoveEvent(event);
-}
-
-void QmlGraphicsWebView::keyPressEvent(QKeyEvent* event)
-{
- page()->event(event);
- if (!event->isAccepted())
- QmlGraphicsPaintedItem::keyPressEvent(event);
-}
-
-void QmlGraphicsWebView::keyReleaseEvent(QKeyEvent* event)
-{
- page()->event(event);
- if (!event->isAccepted())
- QmlGraphicsPaintedItem::keyReleaseEvent(event);
-}
-
-bool QmlGraphicsWebView::sceneEvent(QEvent *event)
-{
- if (event->type() == QEvent::KeyPress) {
- QKeyEvent *k = static_cast<QKeyEvent *>(event);
- if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
- if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
- page()->event(event);
- if (event->isAccepted())
- return true;
- }
- }
- }
- return QmlGraphicsPaintedItem::sceneEvent(event);
-}
-
-
-/*!
- \qmlproperty action WebView::back
- This property holds the action for causing the previous URL in the history to be displayed.
-*/
-QAction *QmlGraphicsWebView::backAction() const
-{
- return page()->action(QWebPage::Back);
-}
-
-/*!
- \qmlproperty action WebView::forward
- This property holds the action for causing the next URL in the history to be displayed.
-*/
-QAction *QmlGraphicsWebView::forwardAction() const
-{
- return page()->action(QWebPage::Forward);
-}
-
-/*!
- \qmlproperty action WebView::reload
- This property holds the action for reloading with the current URL
-*/
-QAction *QmlGraphicsWebView::reloadAction() const
-{
- return page()->action(QWebPage::Reload);
-}
-
-/*!
- \qmlproperty action WebView::stop
- This property holds the action for stopping loading with the current URL
-*/
-QAction *QmlGraphicsWebView::stopAction() const
-{
- return page()->action(QWebPage::Stop);
-}
-
-/*!
- \qmlproperty real WebView::title
- This property holds the title of the web page currently viewed
-
- By default, this property contains an empty string.
-*/
-QString QmlGraphicsWebView::title() const
-{
- return page()->mainFrame()->title();
-}
-
-
-
-/*!
- \qmlproperty pixmap WebView::icon
- This property holds the icon associated with the web page currently viewed
-*/
-QPixmap QmlGraphicsWebView::icon() const
-{
- return page()->mainFrame()->icon().pixmap(QSize(256,256));
-}
-
-
-/*!
- \qmlproperty real WebView::zoomFactor
- This property holds the multiplier used to scale the contents of a Web page.
-*/
-void QmlGraphicsWebView::setZoomFactor(qreal factor)
-{
- Q_D(QmlGraphicsWebView);
- if (factor == page()->mainFrame()->zoomFactor())
- return;
-
- page()->mainFrame()->setZoomFactor(factor);
- page()->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth*factor : width()*factor,
- d->preferredheight>0 ? d->preferredheight*factor : height()*factor));
- expandToWebPage();
-
- emit zoomFactorChanged();
-}
-
-qreal QmlGraphicsWebView::zoomFactor() const
-{
- return page()->mainFrame()->zoomFactor();
-}
-
-/*!
- \qmlproperty string WebView::statusText
-
- This property is the current status suggested by the current web page. In a web browser,
- such status is often shown in some kind of status bar.
-*/
-void QmlGraphicsWebView::setStatusText(const QString& s)
-{
- Q_D(QmlGraphicsWebView);
- d->statusText = s;
- emit statusTextChanged();
-}
-
-void QmlGraphicsWebView::windowObjectCleared()
-{
- Q_D(QmlGraphicsWebView);
- d->updateWindowObjects();
-}
-
-QString QmlGraphicsWebView::statusText() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->statusText;
-}
-
-QWebPage *QmlGraphicsWebView::page() const
-{
- Q_D(const QmlGraphicsWebView);
-
- if (!d->page) {
- QmlGraphicsWebView *self = const_cast<QmlGraphicsWebView*>(this);
- QWebPage *wp = new QmlGraphicsWebPage(self);
-
- // QML items don't default to having a background,
- // even though most we pages will set one anyway.
- QPalette pal = QApplication::palette();
- pal.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0));
- wp->setPalette(pal);
-
- wp->setNetworkAccessManager(qmlEngine(this)->networkAccessManager());
-
- self->setPage(wp);
-
- return wp;
- }
-
- return d->page;
-}
-
-
-// The QObject interface to settings().
-/*!
- \qmlproperty string WebView::settings.standardFontFamily
- \qmlproperty string WebView::settings.fixedFontFamily
- \qmlproperty string WebView::settings.serifFontFamily
- \qmlproperty string WebView::settings.sansSerifFontFamily
- \qmlproperty string WebView::settings.cursiveFontFamily
- \qmlproperty string WebView::settings.fantasyFontFamily
-
- \qmlproperty int WebView::settings.minimumFontSize
- \qmlproperty int WebView::settings.minimumLogicalFontSize
- \qmlproperty int WebView::settings.defaultFontSize
- \qmlproperty int WebView::settings.defaultFixedFontSize
-
- \qmlproperty bool WebView::settings.autoLoadImages
- \qmlproperty bool WebView::settings.javascriptEnabled
- \qmlproperty bool WebView::settings.javaEnabled
- \qmlproperty bool WebView::settings.pluginsEnabled
- \qmlproperty bool WebView::settings.privateBrowsingEnabled
- \qmlproperty bool WebView::settings.javascriptCanOpenWindows
- \qmlproperty bool WebView::settings.javascriptCanAccessClipboard
- \qmlproperty bool WebView::settings.developerExtrasEnabled
- \qmlproperty bool WebView::settings.linksIncludedInFocusChain
- \qmlproperty bool WebView::settings.zoomTextOnly
- \qmlproperty bool WebView::settings.printElementBackgrounds
- \qmlproperty bool WebView::settings.offlineStorageDatabaseEnabled
- \qmlproperty bool WebView::settings.offlineWebApplicationCacheEnabled
- \qmlproperty bool WebView::settings.localStorageDatabaseEnabled
- \qmlproperty bool WebView::settings.localContentCanAccessRemoteUrls
-
- These properties give access to the settings controlling the web view.
-
- See QWebSettings for details of these properties.
-
- \qml
- WebView {
- settings.pluginsEnabled: true
- settings.standardFontFamily: "Arial"
- ...
- }
- \endqml
-*/
-QmlGraphicsWebSettings *QmlGraphicsWebView::settingsObject() const
-{
- Q_D(const QmlGraphicsWebView);
- d->settings.s = page()->settings();
- return &d->settings;
-}
-
-void QmlGraphicsWebView::setPage(QWebPage *page)
-{
- Q_D(QmlGraphicsWebView);
- if (d->page == page)
- return;
- if (d->page) {
- if (d->page->parent() == this) {
- delete d->page;
- } else {
- d->page->disconnect(this);
- }
- }
- d->page = page;
- d->page->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth : width(),
- d->preferredheight>0 ? d->preferredheight : height()));
- d->page->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff);
- d->page->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff);
- connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect)));
- connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SLOT(pageUrlChanged()));
- connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
- connect(d->page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged()));
- connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(noteContentsSizeChanged(QSize)));
- connect(d->page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout()));
-
- connect(d->page,SIGNAL(loadStarted()),this,SLOT(doLoadStarted()));
- connect(d->page,SIGNAL(loadProgress(int)),this,SLOT(doLoadProgress(int)));
- connect(d->page,SIGNAL(loadFinished(bool)),this,SLOT(doLoadFinished(bool)));
- connect(d->page,SIGNAL(statusBarMessage(QString)),this,SLOT(setStatusText(QString)));
-
- connect(d->page->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(windowObjectCleared()));
-}
-
-/*!
- \qmlsignal WebView::onLoadStarted()
-
- This handler is called when the web engine begins loading
- a page. Later, WebView::onLoadFinished() or WebView::onLoadFailed()
- will be emitted.
-*/
-
-/*!
- \qmlsignal WebView::onLoadFinished()
-
- This handler is called when the web engine \e successfully
- finishes loading a page, including any component content
- (WebView::onLoadFailed() will be emitted otherwise).
-
- \sa progress
-*/
-
-/*!
- \qmlsignal WebView::onLoadFailed()
-
- This handler is called when the web engine fails loading
- a page or any component content
- (WebView::onLoadFinished() will be emitted on success).
-*/
-
-void QmlGraphicsWebView::load(const QNetworkRequest &request,
- QNetworkAccessManager::Operation operation,
- const QByteArray &body)
-{
- page()->mainFrame()->load(request, operation, body);
-}
-
-QString QmlGraphicsWebView::html() const
-{
- return page()->mainFrame()->toHtml();
-}
-
-/*!
- \qmlproperty string WebView::html
- This property holds HTML text set directly
-
- The html property can be set as a string.
-
- \qml
- WebView {
- html: "<p>This is <b>HTML</b>."
- }
- \endqml
-*/
-void QmlGraphicsWebView::setHtml(const QString &html, const QUrl &baseUrl)
-{
- Q_D(QmlGraphicsWebView);
- page()->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth : width(),
- d->preferredheight>0 ? d->preferredheight : height()));
- if (isComponentComplete())
- page()->mainFrame()->setHtml(html, baseUrl);
- else {
- d->pending = d->PendingHtml;
- d->pending_url = baseUrl;
- d->pending_string = html;
- }
- emit htmlChanged();
-}
-
-void QmlGraphicsWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
-{
- Q_D(QmlGraphicsWebView);
- page()->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth : width(),
- d->preferredheight>0 ? d->preferredheight : height()));
-
- if (isComponentComplete())
- page()->mainFrame()->setContent(data,mimeType,qmlContext(this)->resolvedUrl(baseUrl));
- else {
- d->pending = d->PendingContent;
- d->pending_url = baseUrl;
- d->pending_string = mimeType;
- d->pending_data = data;
- }
-}
-
-QWebHistory *QmlGraphicsWebView::history() const
-{
- return page()->history();
-}
-
-QWebSettings *QmlGraphicsWebView::settings() const
-{
- return page()->settings();
-}
-
-QmlGraphicsWebView *QmlGraphicsWebView::createWindow(QWebPage::WebWindowType type)
-{
- Q_D(QmlGraphicsWebView);
- switch (type) {
- case QWebPage::WebBrowserWindow: {
- if (!d->newWindowComponent && d->newWindowParent)
- qWarning("WebView::newWindowComponent not set - WebView::newWindowParent ignored");
- else if (d->newWindowComponent && !d->newWindowParent)
- qWarning("WebView::newWindowParent not set - WebView::newWindowComponent ignored");
- else if (d->newWindowComponent && d->newWindowParent) {
- QmlGraphicsWebView *webview = 0;
- QmlContext *windowContext = new QmlContext(qmlContext(this));
-
- QObject *nobj = d->newWindowComponent->create(windowContext);
- if (nobj) {
- windowContext->setParent(nobj);
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(nobj);
- if (!item) {
- delete nobj;
- } else {
- webview = item->findChild<QmlGraphicsWebView*>();
- if (!webview) {
- delete item;
- } else {
- nobj->setParent(d->newWindowParent);
- static_cast<QGraphicsObject*>(item)->setParentItem(d->newWindowParent);
- }
- }
- } else {
- delete windowContext;
- }
-
- return webview;
- }
- }
- break;
- case QWebPage::WebModalDialog: {
- // Not supported
- }
- }
- return 0;
-}
-
-/*!
- \qmlproperty component WebView::newWindowComponent
-
- This property holds the component to use for new windows.
- The component must have a WebView somewhere in its structure.
-
- When the web engine requests a new window, it will be an instance of
- this component.
-
- The parent of the new window is set by newWindowParent. It must be set.
-*/
-QmlComponent *QmlGraphicsWebView::newWindowComponent() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->newWindowComponent;
-}
-
-void QmlGraphicsWebView::setNewWindowComponent(QmlComponent *newWindow)
-{
- Q_D(QmlGraphicsWebView);
- if (newWindow == d->newWindowComponent)
- return;
- d->newWindowComponent = newWindow;
- emit newWindowComponentChanged();
-}
-
-
-/*!
- \qmlproperty item WebView::newWindowParent
-
- The parent item for new windows.
-
- \sa newWindowComponent
-*/
-QmlGraphicsItem *QmlGraphicsWebView::newWindowParent() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->newWindowParent;
-}
-
-void QmlGraphicsWebView::setNewWindowParent(QmlGraphicsItem *parent)
-{
- Q_D(QmlGraphicsWebView);
- if (parent == d->newWindowParent)
- return;
- if (d->newWindowParent && parent) {
- QList<QGraphicsItem *> children = d->newWindowParent->childItems();
- for (int i = 0; i < children.count(); ++i) {
- children.at(i)->setParentItem(parent);
- }
- }
- d->newWindowParent = parent;
- emit newWindowParentChanged();
-}
-
-/*!
- Returns the area of the largest element at position (\a x,\a y) that is no larger
- than \a maxwidth by \a maxheight pixels.
-
- May return an area larger in the case when no smaller element is at the position.
-*/
-QRect QmlGraphicsWebView::elementAreaAt(int x, int y, int maxwidth, int maxheight) const
-{
- QWebHitTestResult hit = page()->mainFrame()->hitTestContent(QPoint(x,y));
- QRect rv = hit.boundingRect();
- QWebElement element = hit.enclosingBlockElement();
- if (maxwidth<=0) maxwidth = INT_MAX;
- if (maxheight<=0) maxheight = INT_MAX;
- while (!element.parent().isNull() && element.geometry().width() <= maxwidth && element.geometry().height() <= maxheight) {
- rv = element.geometry();
- element = element.parent();
- }
- return rv;
-}
-
-/*!
- \internal
- \class QmlGraphicsWebPage
- \brief The QmlGraphicsWebPage class is a QWebPage that can create QML plugins.
-
- \sa QmlGraphicsWebView
-*/
-QmlGraphicsWebPage::QmlGraphicsWebPage(QmlGraphicsWebView *parent) :
- QWebPage(parent)
-{
-}
-
-QmlGraphicsWebPage::~QmlGraphicsWebPage()
-{
-}
-
-void QmlGraphicsWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID)
-{
- qWarning() << sourceID << ':' << lineNumber << ':' << message;
-}
-
-QString QmlGraphicsWebPage::chooseFile(QWebFrame *originatingFrame, const QString& oldFile)
-{
- // Not supported (it's modal)
- Q_UNUSED(originatingFrame)
- Q_UNUSED(oldFile)
- return oldFile;
-}
-
-void QmlGraphicsWebPage::javaScriptAlert(QWebFrame *originatingFrame, const QString& msg)
-{
- Q_UNUSED(originatingFrame)
- emit viewItem()->alert(msg);
-}
-
-bool QmlGraphicsWebPage::javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg)
-{
- // Not supported (it's modal)
- Q_UNUSED(originatingFrame)
- Q_UNUSED(msg)
- return false;
-}
-
-bool QmlGraphicsWebPage::javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result)
-{
- // Not supported (it's modal)
- Q_UNUSED(originatingFrame)
- Q_UNUSED(msg)
- Q_UNUSED(defaultValue)
- Q_UNUSED(result)
- return false;
-}
-
-
-/*
- Qt WebKit does not understand non-QWidget plugins, so dummy widgets
- are created, parented to a single dummy tool window.
-
- The requirements for QML object plugins are input to the Qt WebKit
- non-QWidget plugin support, which will obsolete this kludge.
-*/
-class QWidget_Dummy_Plugin : public QWidget
-{
- Q_OBJECT
-public:
- static QWidget *dummy_shared_parent()
- {
- static QWidget *dsp = 0;
- if (!dsp) {
- dsp = new QWidget(0,Qt::Tool);
- dsp->setGeometry(-10000,-10000,0,0);
- dsp->show();
- }
- return dsp;
- }
- QWidget_Dummy_Plugin(const QUrl& url, QmlGraphicsWebView *view, const QStringList &paramNames, const QStringList &paramValues) :
- QWidget(dummy_shared_parent()),
- propertyNames(paramNames),
- propertyValues(paramValues),
- webview(view)
- {
- QmlEngine *engine = qmlEngine(webview);
- component = new QmlComponent(engine, url, this);
- item = 0;
- if (component->isLoading())
- connect(component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(qmlLoaded()));
- else
- qmlLoaded();
- }
-
-public Q_SLOTS:
- void qmlLoaded()
- {
- if (component->isError()) {
- // ### Could instead give these errors to the WebView to handle.
- qWarning() << component->errors();
- return;
- }
- item = qobject_cast<QmlGraphicsItem*>(component->create(qmlContext(webview)));
- item->setParent(webview);
- QString jsObjName;
- for (int i=0; i<propertyNames.count(); ++i) {
- if (propertyNames[i] != QLatin1String("type") && propertyNames[i] != QLatin1String("data")) {
- item->setProperty(propertyNames[i].toUtf8(),propertyValues[i]);
- if (propertyNames[i] == QLatin1String("objectname"))
- jsObjName = propertyValues[i];
- }
- }
- if (!jsObjName.isNull()) {
- QWebFrame *f = webview->page()->mainFrame();
- f->addToJavaScriptWindowObject(jsObjName, item);
- }
- resizeEvent(0);
- delete component;
- component = 0;
- }
- void resizeEvent(QResizeEvent*)
- {
- if (item) {
- item->setX(x());
- item->setY(y());
- item->setWidth(width());
- item->setHeight(height());
- }
- }
-
-private:
- QmlComponent *component;
- QmlGraphicsItem *item;
- QStringList propertyNames, propertyValues;
- QmlGraphicsWebView *webview;
-};
-
-QmlGraphicsWebView *QmlGraphicsWebPage::viewItem()
-{
- return static_cast<QmlGraphicsWebView*>(parent());
-}
-
-QObject *QmlGraphicsWebPage::createPlugin(const QString &, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
-{
- QUrl comp = qmlContext(viewItem())->resolvedUrl(url);
- return new QWidget_Dummy_Plugin(comp,viewItem(),paramNames,paramValues);
-}
-
-QWebPage *QmlGraphicsWebPage::createWindow(WebWindowType type)
-{
- QmlGraphicsWebView *newView = viewItem()->createWindow(type);
- if (newView)
- return newView->page();
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#include <qmlgraphicswebview.moc>
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
deleted file mode 100644
index ca63be9..0000000
--- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h
+++ /dev/null
@@ -1,286 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSWEBVIEW_H
-#define QMLGRAPHICSWEBVIEW_H
-
-#include "qmlgraphicspainteditem_p.h"
-
-#include <QtGui/QAction>
-#include <QtCore/QUrl>
-#include <QtNetwork/qnetworkaccessmanager.h>
-#include <QtWebKit/QWebPage>
-
-QT_BEGIN_HEADER
-
-class QWebHistory;
-class QWebSettings;
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QmlGraphicsWebViewPrivate;
-class QNetworkRequest;
-class QmlGraphicsWebView;
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsWebPage : public QWebPage
-{
- Q_OBJECT
-public:
- explicit QmlGraphicsWebPage(QmlGraphicsWebView *parent);
- ~QmlGraphicsWebPage();
-protected:
- QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
- QWebPage *createWindow(WebWindowType type);
- void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID);
- QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile);
- void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg);
- bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg);
- bool javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result);
-
-private:
- QmlGraphicsWebView *viewItem();
-};
-
-
-class QmlGraphicsWebViewAttached;
-class QmlGraphicsWebSettings;
-
-//### TODO: browser plugins
-
-class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem
-{
- Q_OBJECT
-
- Q_ENUMS(Status SelectionMode)
-
- Q_PROPERTY(QString title READ title NOTIFY titleChanged)
- Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged)
- Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
- Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged)
-
- Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged)
-
- Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime NOTIFY pressGrabTimeChanged)
-
- Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged)
- Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged)
- Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
-
- Q_PROPERTY(QAction* reload READ reloadAction CONSTANT)
- Q_PROPERTY(QAction* back READ backAction CONSTANT)
- Q_PROPERTY(QAction* forward READ forwardAction CONSTANT)
- Q_PROPERTY(QAction* stop READ stopAction CONSTANT)
-
- Q_PROPERTY(QmlGraphicsWebSettings* settings READ settingsObject CONSTANT)
-
- Q_PROPERTY(QmlListProperty<QObject> javaScriptWindowObjects READ javaScriptWindowObjects CONSTANT)
-
- Q_PROPERTY(QmlComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent NOTIFY newWindowComponentChanged)
- Q_PROPERTY(QmlGraphicsItem* newWindowParent READ newWindowParent WRITE setNewWindowParent NOTIFY newWindowParentChanged)
-
- Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged)
-
-public:
- QmlGraphicsWebView(QmlGraphicsItem *parent=0);
- ~QmlGraphicsWebView();
-
- QUrl url() const;
- void setUrl(const QUrl &);
-
- QString title() const;
-
- QPixmap icon() const;
-
- qreal zoomFactor() const;
- void setZoomFactor(qreal);
- Q_INVOKABLE bool heuristicZoom(int clickX, int clickY, qreal maxzoom);
- QRect elementAreaAt(int x, int y, int minwidth, int minheight) const;
-
- int pressGrabTime() const;
- void setPressGrabTime(int);
-
- int preferredWidth() const;
- void setPreferredWidth(int);
- int preferredHeight() const;
- void setPreferredHeight(int);
-
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
- qreal progress() const;
- QString statusText() const;
-
- QAction *reloadAction() const;
- QAction *backAction() const;
- QAction *forwardAction() const;
- QAction *stopAction() const;
-
- QWebPage *page() const;
- void setPage(QWebPage *page);
-
- void load(const QNetworkRequest &request,
- QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
- const QByteArray &body = QByteArray());
-
- QString html() const;
-
- void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
- void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
-
- QWebHistory *history() const;
- QWebSettings *settings() const;
- QmlGraphicsWebSettings *settingsObject() const;
-
- bool renderingEnabled() const;
- void setRenderingEnabled(bool);
-
- QmlListProperty<QObject> javaScriptWindowObjects();
-
- static QmlGraphicsWebViewAttached *qmlAttachedProperties(QObject *);
-
- QmlComponent *newWindowComponent() const;
- void setNewWindowComponent(QmlComponent *newWindow);
- QmlGraphicsItem *newWindowParent() const;
- void setNewWindowParent(QmlGraphicsItem *newWindow);
-
-Q_SIGNALS:
- void preferredWidthChanged();
- void preferredHeightChanged();
- void urlChanged();
- void progressChanged();
- void statusChanged(Status);
- void titleChanged(const QString&);
- void iconChanged();
- void statusTextChanged();
- void htmlChanged();
- void pressGrabTimeChanged();
- void zoomFactorChanged();
- void newWindowComponentChanged();
- void newWindowParentChanged();
- void renderingEnabledChanged();
-
- void loadStarted();
- void loadFinished();
- void loadFailed();
-
- void doubleClick(int clickX, int clickY);
-
- void zoomTo(qreal zoom, int centerX, int centerY);
-
- void alert(const QString& message);
-
-public Q_SLOTS:
- QVariant evaluateJavaScript(const QString&);
-
-private Q_SLOTS:
- void expandToWebPage();
- void paintPage(const QRect&);
- void doLoadStarted();
- void doLoadProgress(int p);
- void doLoadFinished(bool ok);
- void setStatusText(const QString&);
- void windowObjectCleared();
- void pageUrlChanged();
- void noteContentsSizeChanged(const QSize&);
- void initialLayout();
-
-protected:
- void drawContents(QPainter *, const QRect &);
-
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
- void timerEvent(QTimerEvent *event);
- void hoverMoveEvent (QGraphicsSceneHoverEvent * event);
- void keyPressEvent(QKeyEvent* event);
- void keyReleaseEvent(QKeyEvent* event);
- virtual void geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry);
- virtual void focusChanged(bool);
- virtual bool sceneEvent(QEvent *event);
- QmlGraphicsWebView *createWindow(QWebPage::WebWindowType type);
-
-private:
- void init();
- virtual void componentComplete();
- Q_DISABLE_COPY(QmlGraphicsWebView)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsWebView)
- QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *);
- QMouseEvent *sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *);
- friend class QmlGraphicsWebPage;
-};
-
-class QmlGraphicsWebViewAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName)
-public:
- QmlGraphicsWebViewAttached(QObject *parent)
- : QObject(parent)
- {
- }
-
- QString windowObjectName() const
- {
- return m_windowObjectName;
- }
-
- void setWindowObjectName(const QString &n)
- {
- m_windowObjectName = n;
- }
-
-private:
- QString m_windowObjectName;
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsWebView)
-QML_DECLARE_TYPEINFO(QmlGraphicsWebView, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p_p.h
deleted file mode 100644
index e132cae..0000000
--- a/src/declarative/graphicsitems/qmlgraphicswebview_p_p.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSWEBVIEW_P_H
-#define QMLGRAPHICSWEBVIEW_P_H
-
-#include <qml.h>
-
-#include <QtWebKit/QWebPage>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsWebSettings : public QObject {
- Q_OBJECT
-
- Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily)
- Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily)
- Q_PROPERTY(QString serifFontFamily READ serifFontFamily WRITE setSerifFontFamily)
- Q_PROPERTY(QString sansSerifFontFamily READ sansSerifFontFamily WRITE setSansSerifFontFamily)
- Q_PROPERTY(QString cursiveFontFamily READ cursiveFontFamily WRITE setCursiveFontFamily)
- Q_PROPERTY(QString fantasyFontFamily READ fantasyFontFamily WRITE setFantasyFontFamily)
-
- Q_PROPERTY(int minimumFontSize READ minimumFontSize WRITE setMinimumFontSize)
- Q_PROPERTY(int minimumLogicalFontSize READ minimumLogicalFontSize WRITE setMinimumLogicalFontSize)
- Q_PROPERTY(int defaultFontSize READ defaultFontSize WRITE setDefaultFontSize)
- Q_PROPERTY(int defaultFixedFontSize READ defaultFixedFontSize WRITE setDefaultFixedFontSize)
-
- Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages)
- Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled)
- Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled)
- Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled)
- Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled)
- Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows)
- Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard)
- Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled)
- Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain)
- Q_PROPERTY(bool zoomTextOnly READ zoomTextOnly WRITE setZoomTextOnly)
- Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds)
- Q_PROPERTY(bool offlineStorageDatabaseEnabled READ offlineStorageDatabaseEnabled WRITE setOfflineStorageDatabaseEnabled)
- Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled)
- Q_PROPERTY(bool localStorageDatabaseEnabled READ localStorageDatabaseEnabled WRITE setLocalStorageDatabaseEnabled)
- Q_PROPERTY(bool localContentCanAccessRemoteUrls READ localContentCanAccessRemoteUrls WRITE setLocalContentCanAccessRemoteUrls)
-
-public:
- QmlGraphicsWebSettings() {}
-
- QString standardFontFamily() const { return s->fontFamily(QWebSettings::StandardFont); }
- void setStandardFontFamily(const QString& f) { s->setFontFamily(QWebSettings::StandardFont,f); }
- QString fixedFontFamily() const { return s->fontFamily(QWebSettings::FixedFont); }
- void setFixedFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FixedFont,f); }
- QString serifFontFamily() const { return s->fontFamily(QWebSettings::SerifFont); }
- void setSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SerifFont,f); }
- QString sansSerifFontFamily() const { return s->fontFamily(QWebSettings::SansSerifFont); }
- void setSansSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SansSerifFont,f); }
- QString cursiveFontFamily() const { return s->fontFamily(QWebSettings::CursiveFont); }
- void setCursiveFontFamily(const QString& f) { s->setFontFamily(QWebSettings::CursiveFont,f); }
- QString fantasyFontFamily() const { return s->fontFamily(QWebSettings::FantasyFont); }
- void setFantasyFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FantasyFont,f); }
-
- int minimumFontSize() const { return s->fontSize(QWebSettings::MinimumFontSize); }
- void setMinimumFontSize(int size) { s->setFontSize(QWebSettings::MinimumFontSize,size); }
- int minimumLogicalFontSize() const { return s->fontSize(QWebSettings::MinimumLogicalFontSize); }
- void setMinimumLogicalFontSize(int size) { s->setFontSize(QWebSettings::MinimumLogicalFontSize,size); }
- int defaultFontSize() const { return s->fontSize(QWebSettings::DefaultFontSize); }
- void setDefaultFontSize(int size) { s->setFontSize(QWebSettings::DefaultFontSize,size); }
- int defaultFixedFontSize() const { return s->fontSize(QWebSettings::DefaultFixedFontSize); }
- void setDefaultFixedFontSize(int size) { s->setFontSize(QWebSettings::DefaultFixedFontSize,size); }
-
- bool autoLoadImages() const { return s->testAttribute(QWebSettings::AutoLoadImages); }
- void setAutoLoadImages(bool on) { s->setAttribute(QWebSettings::AutoLoadImages, on); }
- bool javascriptEnabled() const { return s->testAttribute(QWebSettings::JavascriptEnabled); }
- void setJavascriptEnabled(bool on) { s->setAttribute(QWebSettings::JavascriptEnabled, on); }
- bool javaEnabled() const { return s->testAttribute(QWebSettings::JavaEnabled); }
- void setJavaEnabled(bool on) { s->setAttribute(QWebSettings::JavaEnabled, on); }
- bool pluginsEnabled() const { return s->testAttribute(QWebSettings::PluginsEnabled); }
- void setPluginsEnabled(bool on) { s->setAttribute(QWebSettings::PluginsEnabled, on); }
- bool privateBrowsingEnabled() const { return s->testAttribute(QWebSettings::PrivateBrowsingEnabled); }
- void setPrivateBrowsingEnabled(bool on) { s->setAttribute(QWebSettings::PrivateBrowsingEnabled, on); }
- bool javascriptCanOpenWindows() const { return s->testAttribute(QWebSettings::JavascriptCanOpenWindows); }
- void setJavascriptCanOpenWindows(bool on) { s->setAttribute(QWebSettings::JavascriptCanOpenWindows, on); }
- bool javascriptCanAccessClipboard() const { return s->testAttribute(QWebSettings::JavascriptCanAccessClipboard); }
- void setJavascriptCanAccessClipboard(bool on) { s->setAttribute(QWebSettings::JavascriptCanAccessClipboard, on); }
- bool developerExtrasEnabled() const { return s->testAttribute(QWebSettings::DeveloperExtrasEnabled); }
- void setDeveloperExtrasEnabled(bool on) { s->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); }
- bool linksIncludedInFocusChain() const { return s->testAttribute(QWebSettings::LinksIncludedInFocusChain); }
- void setLinksIncludedInFocusChain(bool on) { s->setAttribute(QWebSettings::LinksIncludedInFocusChain, on); }
- bool zoomTextOnly() const { return s->testAttribute(QWebSettings::ZoomTextOnly); }
- void setZoomTextOnly(bool on) { s->setAttribute(QWebSettings::ZoomTextOnly, on); }
- bool printElementBackgrounds() const { return s->testAttribute(QWebSettings::PrintElementBackgrounds); }
- void setPrintElementBackgrounds(bool on) { s->setAttribute(QWebSettings::PrintElementBackgrounds, on); }
- bool offlineStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::OfflineStorageDatabaseEnabled); }
- void setOfflineStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, on); }
- bool offlineWebApplicationCacheEnabled() const { return s->testAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); }
- void setOfflineWebApplicationCacheEnabled(bool on) { s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, on); }
- bool localStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::LocalStorageDatabaseEnabled); }
- void setLocalStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, on); }
- bool localContentCanAccessRemoteUrls() const { return s->testAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); }
- void setLocalContentCanAccessRemoteUrls(bool on) { s->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, on); }
-
- QWebSettings *s;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsWebSettings)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/qml/parser/parser.pri b/src/declarative/qml/parser/parser.pri
index 4530479..fd4361c 100644
--- a/src/declarative/qml/parser/parser.pri
+++ b/src/declarative/qml/parser/parser.pri
@@ -1,21 +1,21 @@
INCLUDEPATH += $$PWD
HEADERS += \
- $$PWD/qmljsast_p.h \
- $$PWD/qmljsastfwd_p.h \
- $$PWD/qmljsastvisitor_p.h \
- $$PWD/qmljsengine_p.h \
- $$PWD/qmljsgrammar_p.h \
- $$PWD/qmljslexer_p.h \
- $$PWD/qmljsmemorypool_p.h \
- $$PWD/qmljsnodepool_p.h \
- $$PWD/qmljsparser_p.h \
- $$PWD/qmljsglobal_p.h
+ $$PWD/qdeclarativejsast_p.h \
+ $$PWD/qdeclarativejsastfwd_p.h \
+ $$PWD/qdeclarativejsastvisitor_p.h \
+ $$PWD/qdeclarativejsengine_p.h \
+ $$PWD/qdeclarativejsgrammar_p.h \
+ $$PWD/qdeclarativejslexer_p.h \
+ $$PWD/qdeclarativejsmemorypool_p.h \
+ $$PWD/qdeclarativejsnodepool_p.h \
+ $$PWD/qdeclarativejsparser_p.h \
+ $$PWD/qdeclarativejsglobal_p.h
SOURCES += \
- $$PWD/qmljsast.cpp \
- $$PWD/qmljsastvisitor.cpp \
- $$PWD/qmljsengine_p.cpp \
- $$PWD/qmljsgrammar.cpp \
- $$PWD/qmljslexer.cpp \
- $$PWD/qmljsparser.cpp
+ $$PWD/qdeclarativejsast.cpp \
+ $$PWD/qdeclarativejsastvisitor.cpp \
+ $$PWD/qdeclarativejsengine_p.cpp \
+ $$PWD/qdeclarativejsgrammar.cpp \
+ $$PWD/qdeclarativejslexer.cpp \
+ $$PWD/qdeclarativejsparser.cpp
diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g
new file mode 100644
index 0000000..e1cb5a5
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejs.g
@@ -0,0 +1,3075 @@
+----------------------------------------------------------------------------
+--
+-- Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+-- All rights reserved.
+-- Contact: Nokia Corporation (qt-info@nokia.com)
+--
+-- This file is part of the QtDeclarative module of the Qt Toolkit.
+--
+-- $QT_BEGIN_LICENSE:LGPL-ONLY$
+-- GNU Lesser General Public License Usage
+-- This file may be used under the terms of the GNU Lesser
+-- General Public License version 2.1 as published by the Free Software
+-- Foundation and appearing in the file LICENSE.LGPL included in the
+-- packaging of this file. Please review the following information to
+-- ensure the GNU Lesser General Public License version 2.1 requirements
+-- will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+--
+-- If you have questions regarding the use of this file, please contact
+-- Nokia at qt-info@nokia.com.
+-- $QT_END_LICENSE$
+--
+----------------------------------------------------------------------------
+
+%parser QDeclarativeJSGrammar
+%decl qdeclarativejsparser_p.h
+%impl qdeclarativejsparser.cpp
+%expect 2
+%expect-rr 2
+
+%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&="
+%token T_BREAK "break" T_CASE "case" T_CATCH "catch"
+%token T_COLON ":" T_COMMA ";" T_CONTINUE "continue"
+%token T_DEFAULT "default" T_DELETE "delete" T_DIVIDE_ "/"
+%token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "."
+%token T_ELSE "else" T_EQ "=" T_EQ_EQ "=="
+%token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for"
+%token T_FUNCTION "function" T_GE ">=" T_GT ">"
+%token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>"
+%token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if"
+%token T_IN "in" T_INSTANCEOF "instanceof" T_LBRACE "{"
+%token T_LBRACKET "[" T_LE "<=" T_LPAREN "("
+%token T_LT "<" T_LT_LT "<<" T_LT_LT_EQ "<<="
+%token T_MINUS "-" T_MINUS_EQ "-=" T_MINUS_MINUS "--"
+%token T_NEW "new" T_NOT "!" T_NOT_EQ "!="
+%token T_NOT_EQ_EQ "!==" T_NUMERIC_LITERAL "numeric literal" T_OR "|"
+%token T_OR_EQ "|=" T_OR_OR "||" T_PLUS "+"
+%token T_PLUS_EQ "+=" T_PLUS_PLUS "++" T_QUESTION "?"
+%token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%"
+%token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")"
+%token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*"
+%token T_STAR_EQ "*=" T_STRING_LITERAL "string literal"
+%token T_PROPERTY "property" T_SIGNAL "signal" T_READONLY "readonly"
+%token T_SWITCH "switch" T_THIS "this" T_THROW "throw"
+%token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof"
+%token T_VAR "var" T_VOID "void" T_WHILE "while"
+%token T_WITH "with" T_XOR "^" T_XOR_EQ "^="
+%token T_NULL "null" T_TRUE "true" T_FALSE "false"
+%token T_CONST "const"
+%token T_DEBUGGER "debugger"
+%token T_RESERVED_WORD "reserved word"
+%token T_MULTILINE_STRING_LITERAL "multiline string literal"
+%token T_COMMENT "comment"
+
+--- context keywords.
+%token T_PUBLIC "public"
+%token T_IMPORT "import"
+%token T_AS "as"
+
+--- feed tokens
+%token T_FEED_UI_PROGRAM
+%token T_FEED_UI_OBJECT_MEMBER
+%token T_FEED_JS_STATEMENT
+%token T_FEED_JS_EXPRESSION
+%token T_FEED_JS_SOURCE_ELEMENT
+%token T_FEED_JS_PROGRAM
+
+%nonassoc SHIFT_THERE
+%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY
+%nonassoc REDUCE_HERE
+
+%start TopLevel
+
+/./****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtDebug>
+#include <QtGui/QApplication>
+
+#include <string.h>
+
+#include "qdeclarativejsengine_p.h"
+#include "qdeclarativejslexer_p.h"
+#include "qdeclarativejsast_p.h"
+#include "qdeclarativejsnodepool_p.h"
+
+./
+
+/:/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+//
+// 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.
+//
+
+//
+// This file is automatically generated from qmljs.g.
+// Changes will be lost.
+//
+
+#ifndef QDECLARATIVEJSPARSER_P_H
+#define QDECLARATIVEJSPARSER_P_H
+
+#include "qdeclarativejsglobal_p.h"
+#include "qdeclarativejsgrammar_p.h"
+#include "qdeclarativejsast_p.h"
+#include "qdeclarativejsengine_p.h"
+
+#include <QtCore/QList>
+#include <QtCore/QString>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS {
+
+class Engine;
+class NameId;
+
+class QML_PARSER_EXPORT Parser: protected $table
+{
+public:
+ union Value {
+ int ival;
+ double dval;
+ NameId *sval;
+ AST::ArgumentList *ArgumentList;
+ AST::CaseBlock *CaseBlock;
+ AST::CaseClause *CaseClause;
+ AST::CaseClauses *CaseClauses;
+ AST::Catch *Catch;
+ AST::DefaultClause *DefaultClause;
+ AST::ElementList *ElementList;
+ AST::Elision *Elision;
+ AST::ExpressionNode *Expression;
+ AST::Finally *Finally;
+ AST::FormalParameterList *FormalParameterList;
+ AST::FunctionBody *FunctionBody;
+ AST::FunctionDeclaration *FunctionDeclaration;
+ AST::Node *Node;
+ AST::PropertyName *PropertyName;
+ AST::PropertyNameAndValueList *PropertyNameAndValueList;
+ AST::SourceElement *SourceElement;
+ AST::SourceElements *SourceElements;
+ AST::Statement *Statement;
+ AST::StatementList *StatementList;
+ AST::Block *Block;
+ AST::VariableDeclaration *VariableDeclaration;
+ AST::VariableDeclarationList *VariableDeclarationList;
+
+ AST::UiProgram *UiProgram;
+ AST::UiImportList *UiImportList;
+ AST::UiImport *UiImport;
+ AST::UiParameterList *UiParameterList;
+ AST::UiPublicMember *UiPublicMember;
+ AST::UiObjectDefinition *UiObjectDefinition;
+ AST::UiObjectInitializer *UiObjectInitializer;
+ AST::UiObjectBinding *UiObjectBinding;
+ AST::UiScriptBinding *UiScriptBinding;
+ AST::UiArrayBinding *UiArrayBinding;
+ AST::UiObjectMember *UiObjectMember;
+ AST::UiObjectMemberList *UiObjectMemberList;
+ AST::UiArrayMemberList *UiArrayMemberList;
+ AST::UiQualifiedId *UiQualifiedId;
+ AST::UiSignature *UiSignature;
+ AST::UiFormalList *UiFormalList;
+ AST::UiFormal *UiFormal;
+ };
+
+public:
+ Parser(Engine *engine);
+ ~Parser();
+
+ // parse a UI program
+ bool parse() { return parse(T_FEED_UI_PROGRAM); }
+ bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
+ bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
+ bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
+ bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
+ bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
+
+ AST::UiProgram *ast() const
+ { return AST::cast<AST::UiProgram *>(program); }
+
+ AST::Statement *statement() const
+ {
+ if (! program)
+ return 0;
+
+ return program->statementCast();
+ }
+
+ AST::ExpressionNode *expression() const
+ {
+ if (! program)
+ return 0;
+
+ return program->expressionCast();
+ }
+
+ AST::UiObjectMember *uiObjectMember() const
+ {
+ if (! program)
+ return 0;
+
+ return program->uiObjectMemberCast();
+ }
+
+ AST::Node *rootNode() const
+ { return program; }
+
+ QList<DiagnosticMessage> diagnosticMessages() const
+ { return diagnostic_messages; }
+
+ inline DiagnosticMessage diagnosticMessage() const
+ {
+ foreach (const DiagnosticMessage &d, diagnostic_messages) {
+ if (! d.kind == DiagnosticMessage::Warning)
+ return d;
+ }
+
+ return DiagnosticMessage();
+ }
+
+ inline QString errorMessage() const
+ { return diagnosticMessage().message; }
+
+ inline int errorLineNumber() const
+ { return diagnosticMessage().loc.startLine; }
+
+ inline int errorColumnNumber() const
+ { return diagnosticMessage().loc.startColumn; }
+
+protected:
+ bool parse(int startToken);
+
+ void reallocateStack();
+
+ inline Value &sym(int index)
+ { return sym_stack [tos + index - 1]; }
+
+ inline AST::SourceLocation &loc(int index)
+ { return location_stack [tos + index - 1]; }
+
+ AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
+
+protected:
+ Engine *driver;
+ int tos;
+ int stack_size;
+ Value *sym_stack;
+ int *state_stack;
+ AST::SourceLocation *location_stack;
+
+ AST::Node *program;
+
+ // error recovery
+ enum { TOKEN_BUFFER_SIZE = 3 };
+
+ struct SavedToken {
+ int token;
+ double dval;
+ AST::SourceLocation loc;
+ };
+
+ double yylval;
+ AST::SourceLocation yylloc;
+ AST::SourceLocation yyprevlloc;
+
+ SavedToken token_buffer[TOKEN_BUFFER_SIZE];
+ SavedToken *first_token;
+ SavedToken *last_token;
+
+ QList<DiagnosticMessage> diagnostic_messages;
+};
+
+} // end of namespace QDeclarativeJS
+
+
+:/
+
+
+/.
+
+#include "qdeclarativejsparser_p.h"
+#include <QVarLengthArray>
+
+//
+// This file is automatically generated from qmljs.g.
+// Changes will be lost.
+//
+
+using namespace QDeclarativeJS;
+
+QT_QML_BEGIN_NAMESPACE
+
+void Parser::reallocateStack()
+{
+ if (! stack_size)
+ stack_size = 128;
+ else
+ stack_size <<= 1;
+
+ sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
+ state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
+ location_stack = reinterpret_cast<AST::SourceLocation*> (qRealloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
+}
+
+inline static bool automatic(Engine *driver, int token)
+{
+ return token == $table::T_RBRACE
+ || token == 0
+ || driver->lexer()->prevTerminator();
+}
+
+
+Parser::Parser(Engine *engine):
+ driver(engine),
+ tos(0),
+ stack_size(0),
+ sym_stack(0),
+ state_stack(0),
+ location_stack(0),
+ first_token(0),
+ last_token(0)
+{
+}
+
+Parser::~Parser()
+{
+ if (stack_size) {
+ qFree(sym_stack);
+ qFree(state_stack);
+ qFree(location_stack);
+ }
+}
+
+static inline AST::SourceLocation location(Lexer *lexer)
+{
+ AST::SourceLocation loc;
+ loc.offset = lexer->tokenOffset();
+ loc.length = lexer->tokenLength();
+ loc.startLine = lexer->startLineNo();
+ loc.startColumn = lexer->startColumnNo();
+ return loc;
+}
+
+AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
+{
+ QVarLengthArray<NameId *, 4> nameIds;
+ QVarLengthArray<AST::SourceLocation, 4> locations;
+
+ AST::ExpressionNode *it = expr;
+ while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
+ nameIds.append(m->name);
+ locations.append(m->identifierToken);
+ it = m->base;
+ }
+
+ if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
+ AST::UiQualifiedId *q = makeAstNode<AST::UiQualifiedId>(driver->nodePool(), idExpr->name);
+ q->identifierToken = idExpr->identifierToken;
+
+ AST::UiQualifiedId *currentId = q;
+ for (int i = nameIds.size() - 1; i != -1; --i) {
+ currentId = makeAstNode<AST::UiQualifiedId>(driver->nodePool(), currentId, nameIds[i]);
+ currentId->identifierToken = locations[i];
+ }
+
+ return currentId->finish();
+ }
+
+ return 0;
+}
+
+bool Parser::parse(int startToken)
+{
+ Lexer *lexer = driver->lexer();
+ bool hadErrors = false;
+ int yytoken = -1;
+ int action = 0;
+
+ token_buffer[0].token = startToken;
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[1];
+
+ tos = -1;
+ program = 0;
+
+ do {
+ if (++tos == stack_size)
+ reallocateStack();
+
+ state_stack[tos] = action;
+
+ _Lcheck_token:
+ if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
+ yyprevlloc = yylloc;
+
+ if (first_token == last_token) {
+ yytoken = lexer->lex();
+ yylval = lexer->dval();
+ yylloc = location(lexer);
+ } else {
+ yytoken = first_token->token;
+ yylval = first_token->dval;
+ yylloc = first_token->loc;
+ ++first_token;
+ }
+ }
+
+ action = t_action(action, yytoken);
+ if (action > 0) {
+ if (action != ACCEPT_STATE) {
+ yytoken = -1;
+ sym(1).dval = yylval;
+ loc(1) = yylloc;
+ } else {
+ --tos;
+ return ! hadErrors;
+ }
+ } else if (action < 0) {
+ const int r = -action - 1;
+ tos -= rhs[r];
+
+ switch (r) {
+./
+
+--------------------------------------------------------------------------------------------------------
+-- Declarative UI
+--------------------------------------------------------------------------------------------------------
+
+TopLevel: T_FEED_UI_PROGRAM UiProgram ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_JS_STATEMENT Statement ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_JS_EXPRESSION Expression ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_JS_SOURCE_ELEMENT SourceElement ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_JS_PROGRAM Program ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+UiProgram: UiImportListOpt UiRootMember ;
+/.
+case $rule_number: {
+ sym(1).UiProgram = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList,
+ sym(2).UiObjectMemberList->finish());
+} break;
+./
+
+UiImportListOpt: Empty ;
+UiImportListOpt: UiImportList ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).UiImportList->finish();
+} break;
+./
+
+UiImportList: UiImport ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(), sym(1).UiImport);
+} break;
+./
+
+UiImportList: UiImportList UiImport ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(),
+ sym(1).UiImportList, sym(2).UiImport);
+} break;
+./
+
+ImportId: MemberExpression ;
+
+UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ;
+UiImport: UiImportHead T_SEMICOLON ;
+/.
+case $rule_number: {
+ sym(1).UiImport->semicolonToken = loc(2);
+} break;
+./
+
+UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ;
+UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ;
+/.
+case $rule_number: {
+ sym(1).UiImport->versionToken = loc(2);
+ sym(1).UiImport->semicolonToken = loc(3);
+} break;
+./
+
+UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ sym(1).UiImport->versionToken = loc(2);
+ sym(1).UiImport->asToken = loc(3);
+ sym(1).UiImport->importIdToken = loc(4);
+ sym(1).UiImport->importId = sym(4).sval;
+ sym(1).UiImport->semicolonToken = loc(5);
+} break;
+./
+
+UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ sym(1).UiImport->asToken = loc(2);
+ sym(1).UiImport->importIdToken = loc(3);
+ sym(1).UiImport->importId = sym(3).sval;
+ sym(1).UiImport->semicolonToken = loc(4);
+} break;
+./
+
+
+UiImportHead: T_IMPORT ImportId ;
+/.
+case $rule_number: {
+ AST::UiImport *node = 0;
+
+ if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
+ node = makeAstNode<AST::UiImport>(driver->nodePool(), importIdLiteral->value);
+ node->fileNameToken = loc(2);
+ } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
+ QString text;
+ for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) {
+ text += q->name->asString();
+ if (q->next) text += QLatin1String(".");
+ }
+ node = makeAstNode<AST::UiImport>(driver->nodePool(), qualifiedId);
+ node->fileNameToken = loc(2);
+ }
+
+ sym(1).Node = node;
+
+ if (! node) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
+ QLatin1String("Expected a qualified name id or a string literal")));
+
+ return false; // ### remove me
+ }
+} break;
+./
+
+Empty: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+UiRootMember: UiObjectDefinition ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
+} break;
+./
+
+UiObjectMemberList: UiObjectMember ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
+} break;
+./
+
+UiObjectMemberList: UiObjectMemberList UiObjectMember ;
+/.
+case $rule_number: {
+ AST::UiObjectMemberList *node = makeAstNode<AST:: UiObjectMemberList> (driver->nodePool(),
+ sym(1).UiObjectMemberList, sym(2).UiObjectMember);
+ sym(1).Node = node;
+} break;
+./
+
+UiArrayMemberList: UiObjectDefinition ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(), sym(1).UiObjectMember);
+} break;
+./
+
+UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ;
+/.
+case $rule_number: {
+ AST::UiArrayMemberList *node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(),
+ sym(1).UiArrayMemberList, sym(3).UiObjectMember);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectInitializer: T_LBRACE T_RBRACE ;
+/.
+case $rule_number: {
+ AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), (AST::UiObjectMemberList*)0);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE ;
+/.
+case $rule_number: {
+ AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), sym(2).UiObjectMemberList->finish());
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectDefinition: UiQualifiedId UiObjectInitializer ;
+/.
+case $rule_number: {
+ AST::UiObjectDefinition *node = makeAstNode<AST::UiObjectDefinition> (driver->nodePool(), sym(1).UiQualifiedId,
+ sym(2).UiObjectInitializer);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: UiObjectDefinition ;
+
+UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::UiArrayBinding *node = makeAstNode<AST::UiArrayBinding> (driver->nodePool(),
+ sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
+ node->colonToken = loc(2);
+ node->lbracketToken = loc(3);
+ node->rbracketToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ;
+/.
+case $rule_number: {
+ AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
+ sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: UiQualifiedId T_COLON Block ;
+/.case $rule_number:./
+
+UiObjectMember: UiQualifiedId T_COLON EmptyStatement ;
+/.case $rule_number:./
+
+UiObjectMember: UiQualifiedId T_COLON ExpressionStatement ;
+/.case $rule_number:./
+
+UiObjectMember: UiQualifiedId T_COLON IfStatement ; --- ### do we really want if statement in a binding?
+/.case $rule_number:./
+
+/.
+{
+ AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
+ sym(1).UiQualifiedId, sym(3).Statement);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UiPropertyType: T_VAR ;
+/.
+case $rule_number:
+./
+UiPropertyType: T_RESERVED_WORD ;
+/.
+case $rule_number: {
+ sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
+ break;
+}
+./
+
+UiPropertyType: T_IDENTIFIER ;
+
+UiParameterListOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+UiParameterListOpt: UiParameterList ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).UiParameterList->finish ();
+} break;
+./
+
+UiParameterList: UiPropertyType JsIdentifier ;
+/.
+case $rule_number: {
+ AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).sval, sym(2).sval);
+ node->identifierToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ;
+/.
+case $rule_number: {
+ AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).UiParameterList, sym(3).sval, sym(4).sval);
+ node->commaToken = loc(2);
+ node->identifierToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
+ node->type = AST::UiPublicMember::Signal;
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(2);
+ node->parameters = sym(4).UiParameterList;
+ node->semicolonToken = loc(6);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
+ node->type = AST::UiPublicMember::Signal;
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT T_IDENTIFIER T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(4).sval, sym(6).sval);
+ node->typeModifier = sym(2).sval;
+ node->propertyToken = loc(1);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(6);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval);
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->semicolonToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval);
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->semicolonToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval,
+ sym(5).Expression);
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->colonToken = loc(4);
+ node->semicolonToken = loc(6);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_READONLY T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_READONLY T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
+ sym(6).Expression);
+ node->isReadonlyMember = true;
+ node->readonlyToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->colonToken = loc(5);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
+ sym(6).Expression);
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->colonToken = loc(5);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: FunctionDeclaration ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
+} break;
+./
+
+UiObjectMember: VariableStatement ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
+} break;
+./
+
+JsIdentifier: T_IDENTIFIER;
+
+JsIdentifier: T_PROPERTY ;
+/.
+case $rule_number: {
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_PROPERTY]);
+ sym(1).sval = driver->intern(s.constData(), s.length());
+ break;
+}
+./
+
+JsIdentifier: T_SIGNAL ;
+/.
+case $rule_number: {
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_SIGNAL]);
+ sym(1).sval = driver->intern(s.constData(), s.length());
+ break;
+}
+./
+
+JsIdentifier: T_READONLY ;
+/.
+case $rule_number: {
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_READONLY]);
+ sym(1).sval = driver->intern(s.constData(), s.length());
+ break;
+}
+./
+
+--------------------------------------------------------------------------------------------------------
+-- Expressions
+--------------------------------------------------------------------------------------------------------
+
+PrimaryExpression: T_THIS ;
+/.
+case $rule_number: {
+ AST::ThisExpression *node = makeAstNode<AST::ThisExpression> (driver->nodePool());
+ node->thisToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: JsIdentifier ;
+/.
+case $rule_number: {
+ AST::IdentifierExpression *node = makeAstNode<AST::IdentifierExpression> (driver->nodePool(), sym(1).sval);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_NULL ;
+/.
+case $rule_number: {
+ AST::NullExpression *node = makeAstNode<AST::NullExpression> (driver->nodePool());
+ node->nullToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_TRUE ;
+/.
+case $rule_number: {
+ AST::TrueLiteral *node = makeAstNode<AST::TrueLiteral> (driver->nodePool());
+ node->trueToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_FALSE ;
+/.
+case $rule_number: {
+ AST::FalseLiteral *node = makeAstNode<AST::FalseLiteral> (driver->nodePool());
+ node->falseToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_NUMERIC_LITERAL ;
+/.
+case $rule_number: {
+ AST::NumericLiteral *node = makeAstNode<AST::NumericLiteral> (driver->nodePool(), sym(1).dval);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_MULTILINE_STRING_LITERAL ;
+/.case $rule_number:./
+
+PrimaryExpression: T_STRING_LITERAL ;
+/.
+case $rule_number: {
+ AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_DIVIDE_ ;
+/:
+#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number
+:/
+/.
+case $rule_number: {
+ bool rx = lexer->scanRegExp(Lexer::NoPrefix);
+ if (!rx) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
+ return false; // ### remove me
+ }
+ AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_DIVIDE_EQ ;
+/:
+#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number
+:/
+/.
+case $rule_number: {
+ bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
+ if (!rx) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
+ return false;
+ }
+ AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACKET T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), (AST::Elision *) 0);
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACKET Elision T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).Elision->finish());
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish ());
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACKET ElementList T_COMMA T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (),
+ (AST::Elision *) 0);
+ node->lbracketToken = loc(1);
+ node->commaToken = loc(3);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACKET ElementList T_COMMA Elision T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (),
+ sym(4).Elision->finish());
+ node->lbracketToken = loc(1);
+ node->commaToken = loc(3);
+ node->rbracketToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+-- PrimaryExpression: T_LBRACE T_RBRACE ;
+-- /.
+-- case $rule_number: {
+-- sym(1).Node = makeAstNode<AST::ObjectLiteral> (driver->nodePool());
+-- } break;
+-- ./
+
+PrimaryExpression: T_LBRACE PropertyNameAndValueListOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::ObjectLiteral *node = 0;
+ if (sym(2).Node)
+ node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
+ sym(2).PropertyNameAndValueList->finish ());
+ else
+ node = makeAstNode<AST::ObjectLiteral> (driver->nodePool());
+ node->lbraceToken = loc(1);
+ node->lbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACE PropertyNameAndValueList T_COMMA T_RBRACE ;
+/.
+case $rule_number: {
+ AST::ObjectLiteral *node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
+ sym(2).PropertyNameAndValueList->finish ());
+ node->lbraceToken = loc(1);
+ node->lbraceToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LPAREN Expression T_RPAREN ;
+/.
+case $rule_number: {
+ AST::NestedExpression *node = makeAstNode<AST::NestedExpression>(driver->nodePool(), sym(2).Expression);
+ node->lparenToken = loc(1);
+ node->rparenToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+UiQualifiedId: MemberExpression ;
+/.
+case $rule_number: {
+ if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
+ QLatin1String("Ignored annotation")));
+
+ sym(1).Expression = mem->base;
+ }
+
+ if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
+ sym(1).UiQualifiedId = qualifiedId;
+ } else {
+ sym(1).UiQualifiedId = 0;
+
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
+ QLatin1String("Expected a qualified name id")));
+
+ return false; // ### recover
+ }
+} break;
+./
+
+ElementList: AssignmentExpression ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), (AST::Elision *) 0, sym(1).Expression);
+} break;
+./
+
+ElementList: Elision AssignmentExpression ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).Elision->finish(), sym(2).Expression);
+} break;
+./
+
+ElementList: ElementList T_COMMA AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::ElementList *node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).ElementList,
+ (AST::Elision *) 0, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ElementList: ElementList T_COMMA Elision AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::ElementList *node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).ElementList, sym(3).Elision->finish(),
+ sym(4).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+Elision: T_COMMA ;
+/.
+case $rule_number: {
+ AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool());
+ node->commaToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+Elision: Elision T_COMMA ;
+/.
+case $rule_number: {
+ AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool(), sym(1).Elision);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyNameAndValueList: PropertyName T_COLON AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
+ sym(1).PropertyName, sym(3).Expression);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyNameAndValueList: PropertyNameAndValueList T_COMMA PropertyName T_COLON AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
+ sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
+ node->commaToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyName: T_IDENTIFIER %prec REDUCE_HERE ;
+/.
+case $rule_number: {
+ AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyName: T_SIGNAL ;
+/.case $rule_number:./
+
+PropertyName: T_PROPERTY ;
+/.
+case $rule_number: {
+ AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyName: T_STRING_LITERAL ;
+/.
+case $rule_number: {
+ AST::StringLiteralPropertyName *node = makeAstNode<AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyName: T_NUMERIC_LITERAL ;
+/.
+case $rule_number: {
+ AST::NumericLiteralPropertyName *node = makeAstNode<AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyName: ReservedIdentifier ;
+/.
+case $rule_number: {
+ AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+ReservedIdentifier: T_BREAK ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_CASE ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_CATCH ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_CONTINUE ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_DEFAULT ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_DELETE ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_DO ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_ELSE ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_FALSE ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_FINALLY ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_FOR ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_FUNCTION ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_IF ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_IN ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_INSTANCEOF ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_NEW ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_NULL ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_RETURN ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_SWITCH ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_THIS ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_THROW ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_TRUE ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_TRY ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_TYPEOF ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_VAR ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_VOID ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_WHILE ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_CONST ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_DEBUGGER ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_RESERVED_WORD ;
+/.
+case $rule_number:
+./
+ReservedIdentifier: T_WITH ;
+/.
+case $rule_number:
+{
+ sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
+} break;
+./
+
+PropertyIdentifier: JsIdentifier ;
+PropertyIdentifier: ReservedIdentifier ;
+
+MemberExpression: PrimaryExpression ;
+MemberExpression: FunctionExpression ;
+
+MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayMemberExpression *node = makeAstNode<AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
+ node->lbracketToken = loc(2);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+MemberExpression: MemberExpression T_DOT PropertyIdentifier ;
+/.
+case $rule_number: {
+ AST::FieldMemberExpression *node = makeAstNode<AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+MemberExpression: T_NEW MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ;
+/.
+case $rule_number: {
+ AST::NewMemberExpression *node = makeAstNode<AST::NewMemberExpression> (driver->nodePool(), sym(2).Expression, sym(4).ArgumentList);
+ node->newToken = loc(1);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+NewExpression: MemberExpression ;
+
+NewExpression: T_NEW NewExpression ;
+/.
+case $rule_number: {
+ AST::NewExpression *node = makeAstNode<AST::NewExpression> (driver->nodePool(), sym(2).Expression);
+ node->newToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+CallExpression: MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ;
+/.
+case $rule_number: {
+ AST::CallExpression *node = makeAstNode<AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(3).ArgumentList);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+CallExpression: CallExpression T_LPAREN ArgumentListOpt T_RPAREN ;
+/.
+case $rule_number: {
+ AST::CallExpression *node = makeAstNode<AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(3).ArgumentList);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayMemberExpression *node = makeAstNode<AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
+ node->lbracketToken = loc(2);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+CallExpression: CallExpression T_DOT PropertyIdentifier ;
+/.
+case $rule_number: {
+ AST::FieldMemberExpression *node = makeAstNode<AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+ArgumentListOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+ArgumentListOpt: ArgumentList ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).ArgumentList->finish();
+} break;
+./
+
+ArgumentList: AssignmentExpression ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).Expression);
+} break;
+./
+
+ArgumentList: ArgumentList T_COMMA AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::ArgumentList *node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).ArgumentList, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LeftHandSideExpression: NewExpression ;
+LeftHandSideExpression: CallExpression ;
+PostfixExpression: LeftHandSideExpression ;
+
+PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ;
+/.
+case $rule_number: {
+ AST::PostIncrementExpression *node = makeAstNode<AST::PostIncrementExpression> (driver->nodePool(), sym(1).Expression);
+ node->incrementToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ;
+/.
+case $rule_number: {
+ AST::PostDecrementExpression *node = makeAstNode<AST::PostDecrementExpression> (driver->nodePool(), sym(1).Expression);
+ node->decrementToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: PostfixExpression ;
+
+UnaryExpression: T_DELETE UnaryExpression ;
+/.
+case $rule_number: {
+ AST::DeleteExpression *node = makeAstNode<AST::DeleteExpression> (driver->nodePool(), sym(2).Expression);
+ node->deleteToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_VOID UnaryExpression ;
+/.
+case $rule_number: {
+ AST::VoidExpression *node = makeAstNode<AST::VoidExpression> (driver->nodePool(), sym(2).Expression);
+ node->voidToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_TYPEOF UnaryExpression ;
+/.
+case $rule_number: {
+ AST::TypeOfExpression *node = makeAstNode<AST::TypeOfExpression> (driver->nodePool(), sym(2).Expression);
+ node->typeofToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_PLUS_PLUS UnaryExpression ;
+/.
+case $rule_number: {
+ AST::PreIncrementExpression *node = makeAstNode<AST::PreIncrementExpression> (driver->nodePool(), sym(2).Expression);
+ node->incrementToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_MINUS_MINUS UnaryExpression ;
+/.
+case $rule_number: {
+ AST::PreDecrementExpression *node = makeAstNode<AST::PreDecrementExpression> (driver->nodePool(), sym(2).Expression);
+ node->decrementToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_PLUS UnaryExpression ;
+/.
+case $rule_number: {
+ AST::UnaryPlusExpression *node = makeAstNode<AST::UnaryPlusExpression> (driver->nodePool(), sym(2).Expression);
+ node->plusToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_MINUS UnaryExpression ;
+/.
+case $rule_number: {
+ AST::UnaryMinusExpression *node = makeAstNode<AST::UnaryMinusExpression> (driver->nodePool(), sym(2).Expression);
+ node->minusToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_TILDE UnaryExpression ;
+/.
+case $rule_number: {
+ AST::TildeExpression *node = makeAstNode<AST::TildeExpression> (driver->nodePool(), sym(2).Expression);
+ node->tildeToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_NOT UnaryExpression ;
+/.
+case $rule_number: {
+ AST::NotExpression *node = makeAstNode<AST::NotExpression> (driver->nodePool(), sym(2).Expression);
+ node->notToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+MultiplicativeExpression: UnaryExpression ;
+
+MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Mul, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Div, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Mod, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+AdditiveExpression: MultiplicativeExpression ;
+
+AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Add, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Sub, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ShiftExpression: AdditiveExpression ;
+
+ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::LShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::RShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::URShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: ShiftExpression ;
+
+RelationalExpression: RelationalExpression T_LT ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Lt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: RelationalExpression T_GT ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Gt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: RelationalExpression T_LE ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Le, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: RelationalExpression T_GE ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Ge, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::InstanceOf, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: RelationalExpression T_IN ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::In, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpressionNotIn: ShiftExpression ;
+
+RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Lt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Gt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Le, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Ge, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::InstanceOf, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpression: RelationalExpression ;
+
+EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Equal, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::NotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::StrictEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::StrictNotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpressionNotIn: RelationalExpressionNotIn ;
+
+EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Equal, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::NotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::StrictEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::StrictNotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseANDExpression: EqualityExpression ;
+
+BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitAnd, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseANDExpressionNotIn: EqualityExpressionNotIn ;
+
+BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitAnd, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseXORExpression: BitwiseANDExpression ;
+
+BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitXor, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ;
+
+BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitXor, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseORExpression: BitwiseXORExpression ;
+
+BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitOr, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ;
+
+BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitOr, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LogicalANDExpression: BitwiseORExpression ;
+
+LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::And, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ;
+
+LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::And, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LogicalORExpression: LogicalANDExpression ;
+
+LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Or, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LogicalORExpressionNotIn: LogicalANDExpressionNotIn ;
+
+LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Or, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ConditionalExpression: LogicalORExpression ;
+
+ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression,
+ sym(3).Expression, sym(5).Expression);
+ node->questionToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+ConditionalExpressionNotIn: LogicalORExpressionNotIn ;
+
+ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression,
+ sym(3).Expression, sym(5).Expression);
+ node->questionToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+AssignmentExpression: ConditionalExpression ;
+
+AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+AssignmentExpressionNotIn: ConditionalExpressionNotIn ;
+
+AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+AssignmentOperator: T_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::Assign;
+} break;
+./
+
+AssignmentOperator: T_STAR_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceMul;
+} break;
+./
+
+AssignmentOperator: T_DIVIDE_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceDiv;
+} break;
+./
+
+AssignmentOperator: T_REMAINDER_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceMod;
+} break;
+./
+
+AssignmentOperator: T_PLUS_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceAdd;
+} break;
+./
+
+AssignmentOperator: T_MINUS_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceSub;
+} break;
+./
+
+AssignmentOperator: T_LT_LT_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceLeftShift;
+} break;
+./
+
+AssignmentOperator: T_GT_GT_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceRightShift;
+} break;
+./
+
+AssignmentOperator: T_GT_GT_GT_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceURightShift;
+} break;
+./
+
+AssignmentOperator: T_AND_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceAnd;
+} break;
+./
+
+AssignmentOperator: T_XOR_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceXor;
+} break;
+./
+
+AssignmentOperator: T_OR_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceOr;
+} break;
+./
+
+Expression: AssignmentExpression ;
+
+Expression: Expression T_COMMA AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ExpressionOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+ExpressionOpt: Expression ;
+
+ExpressionNotIn: AssignmentExpressionNotIn ;
+
+ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ExpressionNotInOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+ExpressionNotInOpt: ExpressionNotIn ;
+
+Statement: Block ;
+Statement: VariableStatement ;
+Statement: EmptyStatement ;
+Statement: ExpressionStatement ;
+Statement: IfStatement ;
+Statement: IterationStatement ;
+Statement: ContinueStatement ;
+Statement: BreakStatement ;
+Statement: ReturnStatement ;
+Statement: WithStatement ;
+Statement: LabelledStatement ;
+Statement: SwitchStatement ;
+Statement: ThrowStatement ;
+Statement: TryStatement ;
+Statement: DebuggerStatement ;
+
+
+Block: T_LBRACE StatementListOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::Block *node = makeAstNode<AST::Block> (driver->nodePool(), sym(2).StatementList);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+StatementList: Statement ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).Statement);
+} break;
+./
+
+StatementList: StatementList Statement ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).StatementList, sym(2).Statement);
+} break;
+./
+
+StatementListOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+StatementListOpt: StatementList ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).StatementList->finish ();
+} break;
+./
+
+VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::VariableStatement *node = makeAstNode<AST::VariableStatement> (driver->nodePool(),
+ sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
+ node->declarationKindToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+VariableDeclarationKind: T_CONST ;
+/.
+case $rule_number: {
+ sym(1).ival = T_CONST;
+} break;
+./
+
+VariableDeclarationKind: T_VAR ;
+/.
+case $rule_number: {
+ sym(1).ival = T_VAR;
+} break;
+./
+
+VariableDeclarationList: VariableDeclaration ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
+} break;
+./
+
+VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ;
+/.
+case $rule_number: {
+ AST::VariableDeclarationList *node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(),
+ sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+VariableDeclarationListNotIn: VariableDeclarationNotIn ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
+} break;
+./
+
+VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
+} break;
+./
+
+VariableDeclaration: JsIdentifier InitialiserOpt ;
+/.
+case $rule_number: {
+ AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+VariableDeclarationNotIn: JsIdentifier InitialiserNotInOpt ;
+/.
+case $rule_number: {
+ AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+Initialiser: T_EQ AssignmentExpression ;
+/.
+case $rule_number: {
+ // ### TODO: AST for initializer
+ sym(1) = sym(2);
+} break;
+./
+
+InitialiserOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+InitialiserOpt: Initialiser ;
+
+InitialiserNotIn: T_EQ AssignmentExpressionNotIn ;
+/.
+case $rule_number: {
+ // ### TODO: AST for initializer
+ sym(1) = sym(2);
+} break;
+./
+
+InitialiserNotInOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+InitialiserNotInOpt: InitialiserNotIn ;
+
+EmptyStatement: T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::EmptyStatement *node = makeAstNode<AST::EmptyStatement> (driver->nodePool());
+ node->semicolonToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+ExpressionStatement: Expression T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ;
+/.
+case $rule_number: {
+ AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement);
+ node->ifToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ node->elseToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
+ node->ifToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+
+IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::DoWhileStatement *node = makeAstNode<AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression);
+ node->doToken = loc(1);
+ node->whileToken = loc(3);
+ node->lparenToken = loc(4);
+ node->rparenToken = loc(6);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+./
+
+IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::WhileStatement *node = makeAstNode<AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
+ node->whileToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::ForStatement *node = makeAstNode<AST::ForStatement> (driver->nodePool(), sym(3).Expression,
+ sym(5).Expression, sym(7).Expression, sym(9).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->firstSemicolonToken = loc(4);
+ node->secondSemicolonToken = loc(6);
+ node->rparenToken = loc(8);
+ sym(1).Node = node;
+} break;
+./
+
+IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::LocalForStatement *node = makeAstNode<AST::LocalForStatement> (driver->nodePool(),
+ sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
+ sym(8).Expression, sym(10).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->varToken = loc(3);
+ node->firstSemicolonToken = loc(5);
+ node->secondSemicolonToken = loc(7);
+ node->rparenToken = loc(9);
+ sym(1).Node = node;
+} break;
+./
+
+IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST:: ForEachStatement *node = makeAstNode<AST::ForEachStatement> (driver->nodePool(), sym(3).Expression,
+ sym(5).Expression, sym(7).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->inToken = loc(4);
+ node->rparenToken = loc(6);
+ sym(1).Node = node;
+} break;
+./
+
+IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::LocalForEachStatement *node = makeAstNode<AST::LocalForEachStatement> (driver->nodePool(),
+ sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->varToken = loc(3);
+ node->inToken = loc(5);
+ node->rparenToken = loc(7);
+ sym(1).Node = node;
+} break;
+./
+
+ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+ContinueStatement: T_CONTINUE T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool());
+ node->continueToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ContinueStatement: T_CONTINUE JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+ContinueStatement: T_CONTINUE JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool(), sym(2).sval);
+ node->continueToken = loc(1);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+BreakStatement: T_BREAK T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool());
+ node->breakToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BreakStatement: T_BREAK JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+BreakStatement: T_BREAK JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool(), sym(2).sval);
+ node->breakToken = loc(1);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::ReturnStatement *node = makeAstNode<AST::ReturnStatement> (driver->nodePool(), sym(2).Expression);
+ node->returnToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::WithStatement *node = makeAstNode<AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
+ node->withToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ;
+/.
+case $rule_number: {
+ AST::SwitchStatement *node = makeAstNode<AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock);
+ node->switchToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+CaseClauses: CaseClause ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClause);
+} break;
+./
+
+CaseClauses: CaseClauses CaseClause ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClauses, sym(2).CaseClause);
+} break;
+./
+
+CaseClausesOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+CaseClausesOpt: CaseClauses ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).CaseClauses->finish ();
+} break;
+./
+
+CaseClause: T_CASE Expression T_COLON StatementListOpt ;
+/.
+case $rule_number: {
+ AST::CaseClause *node = makeAstNode<AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList);
+ node->caseToken = loc(1);
+ node->colonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+DefaultClause: T_DEFAULT T_COLON StatementListOpt ;
+/.
+case $rule_number: {
+ AST::DefaultClause *node = makeAstNode<AST::DefaultClause> (driver->nodePool(), sym(3).StatementList);
+ node->defaultToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LabelledStatement: T_SIGNAL T_COLON Statement ;
+/.case $rule_number:./
+
+LabelledStatement: T_PROPERTY T_COLON Statement ;
+/.
+case $rule_number: {
+ AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()), sym(3).Statement);
+ node->identifierToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LabelledStatement: T_IDENTIFIER T_COLON Statement ;
+/.
+case $rule_number: {
+ AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement);
+ node->identifierToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+ThrowStatement: T_THROW Expression T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::ThrowStatement *node = makeAstNode<AST::ThrowStatement> (driver->nodePool(), sym(2).Expression);
+ node->throwToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+TryStatement: T_TRY Block Catch ;
+/.
+case $rule_number: {
+ AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+TryStatement: T_TRY Block Finally ;
+/.
+case $rule_number: {
+ AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+TryStatement: T_TRY Block Catch Finally ;
+/.
+case $rule_number: {
+ AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+Catch: T_CATCH T_LPAREN JsIdentifier T_RPAREN Block ;
+/.
+case $rule_number: {
+ AST::Catch *node = makeAstNode<AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Block);
+ node->catchToken = loc(1);
+ node->lparenToken = loc(2);
+ node->identifierToken = loc(3);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+Finally: T_FINALLY Block ;
+/.
+case $rule_number: {
+ AST::Finally *node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Block);
+ node->finallyToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+DebuggerStatement: T_DEBUGGER T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::DebuggerStatement *node = makeAstNode<AST::DebuggerStatement> (driver->nodePool());
+ node->debuggerToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+FunctionDeclaration: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::FunctionDeclaration *node = makeAstNode<AST::FunctionDeclaration> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody);
+ node->functionToken = loc(1);
+ node->identifierToken = loc(2);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ sym(1).Node = node;
+} break;
+./
+
+FunctionExpression: T_FUNCTION IdentifierOpt T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::FunctionExpression *node = makeAstNode<AST::FunctionExpression> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody);
+ node->functionToken = loc(1);
+ if (sym(2).sval)
+ node->identifierToken = loc(2);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ sym(1).Node = node;
+} break;
+./
+
+FormalParameterList: JsIdentifier ;
+/.
+case $rule_number: {
+ AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).sval);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+FormalParameterList: FormalParameterList T_COMMA JsIdentifier ;
+/.
+case $rule_number: {
+ AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).FormalParameterList, sym(3).sval);
+ node->commaToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+FormalParameterListOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+FormalParameterListOpt: FormalParameterList ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).FormalParameterList->finish ();
+} break;
+./
+
+FunctionBodyOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+FunctionBodyOpt: FunctionBody ;
+
+FunctionBody: SourceElements ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::FunctionBody> (driver->nodePool(), sym(1).SourceElements->finish ());
+} break;
+./
+
+Program: SourceElements ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::Program> (driver->nodePool(), sym(1).SourceElements->finish ());
+} break;
+./
+
+SourceElements: SourceElement ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElement);
+} break;
+./
+
+SourceElements: SourceElements SourceElement ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElements, sym(2).SourceElement);
+} break;
+./
+
+SourceElement: Statement ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::StatementSourceElement> (driver->nodePool(), sym(1).Statement);
+} break;
+./
+
+SourceElement: FunctionDeclaration ;
+/.
+case $rule_number: {
+ sym(1).Node = makeAstNode<AST::FunctionSourceElement> (driver->nodePool(), sym(1).FunctionDeclaration);
+} break;
+./
+
+IdentifierOpt: ;
+/.
+case $rule_number: {
+ sym(1).sval = 0;
+} break;
+./
+
+IdentifierOpt: JsIdentifier ;
+
+PropertyNameAndValueListOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+PropertyNameAndValueListOpt: PropertyNameAndValueList ;
+
+/.
+ } // switch
+ action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
+ } // if
+ } while (action != 0);
+
+ if (first_token == last_token) {
+ const int errorState = state_stack[tos];
+
+ // automatic insertion of `;'
+ if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && automatic(driver, yytoken)) {
+ SavedToken &tk = token_buffer[0];
+ tk.token = yytoken;
+ tk.dval = yylval;
+ tk.loc = yylloc;
+
+ yylloc = yyprevlloc;
+ yylloc.offset += yylloc.length;
+ yylloc.startColumn += yylloc.length;
+ yylloc.length = 0;
+
+ //const QString msg = qApp->translate("QDeclarativeParser", "Missing `;'");
+ //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
+
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[1];
+
+ yytoken = T_SEMICOLON;
+ yylval = 0;
+
+ action = errorState;
+
+ goto _Lcheck_token;
+ }
+
+ hadErrors = true;
+
+ token_buffer[0].token = yytoken;
+ token_buffer[0].dval = yylval;
+ token_buffer[0].loc = yylloc;
+
+ token_buffer[1].token = yytoken = lexer->lex();
+ token_buffer[1].dval = yylval = lexer->dval();
+ token_buffer[1].loc = yylloc = location(lexer);
+
+ if (t_action(errorState, yytoken)) {
+ QString msg;
+ int token = token_buffer[0].token;
+ if (token < 0 || token >= TERMINAL_COUNT)
+ msg = qApp->translate("QDeclarativeParser", "Syntax error");
+ else
+ msg = qApp->translate("QDeclarativeParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+
+ static int tokens[] = {
+ T_PLUS,
+ T_EQ,
+
+ T_COMMA,
+ T_COLON,
+ T_SEMICOLON,
+
+ T_RPAREN, T_RBRACKET, T_RBRACE,
+
+ T_NUMERIC_LITERAL,
+ T_IDENTIFIER,
+
+ T_LPAREN, T_LBRACKET, T_LBRACE,
+
+ EOF_SYMBOL
+ };
+
+ for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
+ int a = t_action(errorState, *tk);
+ if (a > 0 && t_action(a, yytoken)) {
+ const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ yytoken = *tk;
+ yylval = 0;
+ yylloc = token_buffer[0].loc;
+ yylloc.length = 0;
+
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[2];
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+ }
+
+ for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
+ if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
+ tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
+ tk == T_FEED_JS_SOURCE_ELEMENT)
+ continue;
+
+ int a = t_action(errorState, tk);
+ if (a > 0 && t_action(a, yytoken)) {
+ const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ yytoken = tk;
+ yylval = 0;
+ yylloc = token_buffer[0].loc;
+ yylloc.length = 0;
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+ }
+
+ const QString msg = qApp->translate("QDeclarativeParser", "Syntax error");
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+ }
+
+ return false;
+}
+
+QT_QML_END_NAMESPACE
+
+
+./
+/:
+QT_QML_END_NAMESPACE
+
+
+
+#endif // QDECLARATIVEJSPARSER_P_H
+:/
diff --git a/src/declarative/qml/parser/qdeclarativejsast.cpp b/src/declarative/qml/parser/qdeclarativejsast.cpp
new file mode 100644
index 0000000..3b569a7
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsast.cpp
@@ -0,0 +1,955 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativejsast_p.h"
+
+#include "qdeclarativejsastvisitor_p.h"
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS { namespace AST {
+
+void Node::accept(Visitor *visitor)
+{
+ if (visitor->preVisit(this)) {
+ accept0(visitor);
+ }
+ visitor->postVisit(this);
+}
+
+void Node::accept(Node *node, Visitor *visitor)
+{
+ if (node)
+ node->accept(visitor);
+}
+
+ExpressionNode *Node::expressionCast()
+{
+ return 0;
+}
+
+BinaryExpression *Node::binaryExpressionCast()
+{
+ return 0;
+}
+
+Statement *Node::statementCast()
+{
+ return 0;
+}
+
+UiObjectMember *Node::uiObjectMemberCast()
+{
+ return 0;
+}
+
+ExpressionNode *ExpressionNode::expressionCast()
+{
+ return this;
+}
+
+BinaryExpression *BinaryExpression::binaryExpressionCast()
+{
+ return this;
+}
+
+Statement *Statement::statementCast()
+{
+ return this;
+}
+
+UiObjectMember *UiObjectMember::uiObjectMemberCast()
+{
+ return this;
+}
+
+void NestedExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+ visitor->endVisit(this);
+}
+
+void ThisExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void IdentifierExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void NullExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void TrueLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void FalseLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void StringLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void NumericLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void RegExpLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void ArrayLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(elements, visitor);
+ accept(elision, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ObjectLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(properties, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ElementList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (ElementList *it = this; it; it = it->next) {
+ accept(it->elision, visitor);
+ accept(it->expression, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void Elision::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ // ###
+ }
+
+ visitor->endVisit(this);
+}
+
+void PropertyNameAndValueList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (PropertyNameAndValueList *it = this; it; it = it->next) {
+ accept(it->name, visitor);
+ accept(it->value, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void IdentifierPropertyName::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void StringLiteralPropertyName::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void NumericLiteralPropertyName::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void ArrayMemberExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void FieldMemberExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void NewMemberExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ accept(arguments, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void NewExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void CallExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ accept(arguments, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ArgumentList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (ArgumentList *it = this; it; it = it->next) {
+ accept(it->expression, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void PostIncrementExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PostDecrementExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void DeleteExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void VoidExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void TypeOfExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PreIncrementExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PreDecrementExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UnaryPlusExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UnaryMinusExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void TildeExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void NotExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void BinaryExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(left, visitor);
+ accept(right, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ConditionalExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(ok, visitor);
+ accept(ko, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void Expression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(left, visitor);
+ accept(right, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void Block::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void StatementList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (StatementList *it = this; it; it = it->next) {
+ accept(it->statement, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void VariableStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(declarations, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void VariableDeclarationList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (VariableDeclarationList *it = this; it; it = it->next) {
+ accept(it->declaration, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void VariableDeclaration::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void EmptyStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void ExpressionStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void IfStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(ok, visitor);
+ accept(ko, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void DoWhileStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void WhileStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ForStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(initialiser, visitor);
+ accept(condition, visitor);
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void LocalForStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(declarations, visitor);
+ accept(condition, visitor);
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ForEachStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(initialiser, visitor);
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void LocalForEachStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(declaration, visitor);
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ContinueStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void BreakStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void ReturnStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void WithStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void SwitchStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(block, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void CaseBlock::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(clauses, visitor);
+ accept(defaultClause, visitor);
+ accept(moreClauses, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void CaseClauses::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (CaseClauses *it = this; it; it = it->next) {
+ accept(it->clause, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void CaseClause::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(statements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void DefaultClause::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void LabelledStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ThrowStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void TryStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ accept(catchExpression, visitor);
+ accept(finallyExpression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void Catch::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void Finally::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void FunctionDeclaration::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(formals, visitor);
+ accept(body, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void FunctionExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(formals, visitor);
+ accept(body, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void FormalParameterList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ // ###
+ }
+
+ visitor->endVisit(this);
+}
+
+void FunctionBody::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(elements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void Program::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(elements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void SourceElements::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (SourceElements *it = this; it; it = it->next) {
+ accept(it->element, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void FunctionSourceElement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(declaration, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void StatementSourceElement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void DebuggerStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiProgram::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(imports, visitor);
+ accept(members, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiSignature::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(formals, visitor);
+ }
+ visitor->endVisit(this);
+}
+
+void UiFormalList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (UiFormalList *it = this; it; it = it->next) {
+ accept(it->formal, visitor);
+ }
+ }
+ visitor->endVisit(this);
+}
+
+void UiFormal::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+ visitor->endVisit(this);
+}
+
+void UiPublicMember::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiObjectDefinition::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(qualifiedTypeNameId, visitor);
+ accept(initializer, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiObjectInitializer::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(members, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiObjectBinding::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(qualifiedId, visitor);
+ accept(qualifiedTypeNameId, visitor);
+ accept(initializer, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiScriptBinding::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(qualifiedId, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiArrayBinding::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(qualifiedId, visitor);
+ accept(members, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiObjectMemberList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (UiObjectMemberList *it = this; it; it = it->next)
+ accept(it->member, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiArrayMemberList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (UiArrayMemberList *it = this; it; it = it->next)
+ accept(it->member, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiQualifiedId::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiImport::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(importUri, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiImportList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(import, visitor);
+ accept(next, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiSourceElement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(sourceElement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+} } // namespace QDeclarativeJS::AST
+
+QT_QML_END_NAMESPACE
+
+
diff --git a/src/declarative/qml/parser/qdeclarativejsast_p.h b/src/declarative/qml/parser/qdeclarativejsast_p.h
new file mode 100644
index 0000000..0a83fe2
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsast_p.h
@@ -0,0 +1,2678 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEJSAST_P_H
+#define QDECLARATIVEJSAST_P_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 "qdeclarativejsastvisitor_p.h"
+#include "qdeclarativejsglobal_p.h"
+
+#include <QtCore/QString>
+
+QT_QML_BEGIN_NAMESPACE
+
+#define QDECLARATIVEJS_DECLARE_AST_NODE(name) \
+ enum { K = Kind_##name };
+
+namespace QSOperator // ### rename
+{
+
+enum Op {
+ Add,
+ And,
+ InplaceAnd,
+ Assign,
+ BitAnd,
+ BitOr,
+ BitXor,
+ InplaceSub,
+ Div,
+ InplaceDiv,
+ Equal,
+ Ge,
+ Gt,
+ In,
+ InplaceAdd,
+ InstanceOf,
+ Le,
+ LShift,
+ InplaceLeftShift,
+ Lt,
+ Mod,
+ InplaceMod,
+ Mul,
+ InplaceMul,
+ NotEqual,
+ Or,
+ InplaceOr,
+ RShift,
+ InplaceRightShift,
+ StrictEqual,
+ StrictNotEqual,
+ Sub,
+ URShift,
+ InplaceURightShift,
+ InplaceXor
+};
+
+} // namespace QSOperator
+
+namespace QDeclarativeJS {
+class NameId;
+namespace AST {
+
+template <typename _T1, typename _T2>
+_T1 cast(_T2 *ast)
+{
+ if (ast && ast->kind == static_cast<_T1>(0)->K)
+ return static_cast<_T1>(ast);
+
+ return 0;
+}
+
+class QML_PARSER_EXPORT Node
+{
+public:
+ enum Kind {
+ Kind_Undefined,
+
+ Kind_ArgumentList,
+ Kind_ArrayLiteral,
+ Kind_ArrayMemberExpression,
+ Kind_BinaryExpression,
+ Kind_Block,
+ Kind_BreakStatement,
+ Kind_CallExpression,
+ Kind_CaseBlock,
+ Kind_CaseClause,
+ Kind_CaseClauses,
+ Kind_Catch,
+ Kind_ConditionalExpression,
+ Kind_ContinueStatement,
+ Kind_DebuggerStatement,
+ Kind_DefaultClause,
+ Kind_DeleteExpression,
+ Kind_DoWhileStatement,
+ Kind_ElementList,
+ Kind_Elision,
+ Kind_EmptyStatement,
+ Kind_Expression,
+ Kind_ExpressionStatement,
+ Kind_FalseLiteral,
+ Kind_FieldMemberExpression,
+ Kind_Finally,
+ Kind_ForEachStatement,
+ Kind_ForStatement,
+ Kind_FormalParameterList,
+ Kind_FunctionBody,
+ Kind_FunctionDeclaration,
+ Kind_FunctionExpression,
+ Kind_FunctionSourceElement,
+ Kind_IdentifierExpression,
+ Kind_IdentifierPropertyName,
+ Kind_IfStatement,
+ Kind_LabelledStatement,
+ Kind_LocalForEachStatement,
+ Kind_LocalForStatement,
+ Kind_NewExpression,
+ Kind_NewMemberExpression,
+ Kind_NotExpression,
+ Kind_NullExpression,
+ Kind_NumericLiteral,
+ Kind_NumericLiteralPropertyName,
+ Kind_ObjectLiteral,
+ Kind_PostDecrementExpression,
+ Kind_PostIncrementExpression,
+ Kind_PreDecrementExpression,
+ Kind_PreIncrementExpression,
+ Kind_Program,
+ Kind_PropertyName,
+ Kind_PropertyNameAndValueList,
+ Kind_RegExpLiteral,
+ Kind_ReturnStatement,
+ Kind_SourceElement,
+ Kind_SourceElements,
+ Kind_StatementList,
+ Kind_StatementSourceElement,
+ Kind_StringLiteral,
+ Kind_StringLiteralPropertyName,
+ Kind_SwitchStatement,
+ Kind_ThisExpression,
+ Kind_ThrowStatement,
+ Kind_TildeExpression,
+ Kind_TrueLiteral,
+ Kind_TryStatement,
+ Kind_TypeOfExpression,
+ Kind_UnaryMinusExpression,
+ Kind_UnaryPlusExpression,
+ Kind_VariableDeclaration,
+ Kind_VariableDeclarationList,
+ Kind_VariableStatement,
+ Kind_VoidExpression,
+ Kind_WhileStatement,
+ Kind_WithStatement,
+ Kind_NestedExpression,
+
+ Kind_UiArrayBinding,
+ Kind_UiImport,
+ Kind_UiImportList,
+ Kind_UiObjectBinding,
+ Kind_UiObjectDefinition,
+ Kind_UiObjectInitializer,
+ Kind_UiObjectMemberList,
+ Kind_UiArrayMemberList,
+ Kind_UiProgram,
+ Kind_UiParameterList,
+ Kind_UiPublicMember,
+ Kind_UiQualifiedId,
+ Kind_UiScriptBinding,
+ Kind_UiSourceElement,
+ Kind_UiFormal,
+ Kind_UiFormalList,
+ Kind_UiSignature
+ };
+
+ inline Node()
+ : kind(Kind_Undefined) {}
+
+ virtual ~Node() {}
+
+ virtual ExpressionNode *expressionCast();
+ virtual BinaryExpression *binaryExpressionCast();
+ virtual Statement *statementCast();
+ virtual UiObjectMember *uiObjectMemberCast();
+
+ void accept(Visitor *visitor);
+ static void accept(Node *node, Visitor *visitor);
+
+ inline static void acceptChild(Node *node, Visitor *visitor)
+ { return accept(node, visitor); } // ### remove
+
+ virtual void accept0(Visitor *visitor) = 0;
+
+// attributes
+ int kind;
+};
+
+class QML_PARSER_EXPORT ExpressionNode: public Node
+{
+public:
+ ExpressionNode() {}
+ virtual ~ExpressionNode() {}
+
+ virtual ExpressionNode *expressionCast();
+
+ virtual SourceLocation firstSourceLocation() const = 0;
+ virtual SourceLocation lastSourceLocation() const = 0;
+};
+
+class QML_PARSER_EXPORT Statement: public Node
+{
+public:
+ Statement() {}
+ virtual ~Statement() {}
+
+ virtual Statement *statementCast();
+
+ virtual SourceLocation firstSourceLocation() const = 0;
+ virtual SourceLocation lastSourceLocation() const = 0;
+};
+
+class QML_PARSER_EXPORT UiFormal: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiFormal)
+
+ UiFormal(NameId *name, NameId *alias = 0)
+ : name(name), alias(alias)
+ { }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ NameId *name;
+ NameId *alias;
+ SourceLocation identifierToken;
+ SourceLocation asToken;
+ SourceLocation aliasToken;
+};
+
+class QML_PARSER_EXPORT UiFormalList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiFormalList)
+
+ UiFormalList(UiFormal *formal)
+ : formal(formal), next(this) {}
+
+ UiFormalList(UiFormalList *previous, UiFormal *formal)
+ : formal(formal)
+ {
+ next = previous->next;
+ previous->next = this;
+ }
+
+ UiFormalList *finish()
+ {
+ UiFormalList *head = next;
+ next = 0;
+ return head;
+ }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiFormal *formal;
+ UiFormalList *next;
+};
+
+class QML_PARSER_EXPORT UiSignature: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiSignature)
+
+ UiSignature(UiFormalList *formals = 0)
+ : formals(formals)
+ { }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return SourceLocation(); }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ SourceLocation lparenToken;
+ UiFormalList *formals;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT NestedExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(NestedExpression)
+
+ NestedExpression(ExpressionNode *expression)
+ : expression(expression)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return lparenToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rparenToken; }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT ThisExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ThisExpression)
+
+ ThisExpression() { kind = K; }
+ virtual ~ThisExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return thisToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return thisToken; }
+
+// attributes
+ SourceLocation thisToken;
+};
+
+class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(IdentifierExpression)
+
+ IdentifierExpression(NameId *n):
+ name (n) { kind = K; }
+
+ virtual ~IdentifierExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return identifierToken; }
+
+// attributes
+ NameId *name;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT NullExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(NullExpression)
+
+ NullExpression() { kind = K; }
+ virtual ~NullExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return nullToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return nullToken; }
+
+// attributes
+ SourceLocation nullToken;
+};
+
+class QML_PARSER_EXPORT TrueLiteral: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(TrueLiteral)
+
+ TrueLiteral() { kind = K; }
+ virtual ~TrueLiteral() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return trueToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return trueToken; }
+
+// attributes
+ SourceLocation trueToken;
+};
+
+class QML_PARSER_EXPORT FalseLiteral: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(FalseLiteral)
+
+ FalseLiteral() { kind = K; }
+ virtual ~FalseLiteral() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return falseToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return falseToken; }
+
+// attributes
+ SourceLocation falseToken;
+};
+
+class QML_PARSER_EXPORT NumericLiteral: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(NumericLiteral)
+
+ NumericLiteral(double v):
+ value(v) { kind = K; }
+ virtual ~NumericLiteral() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return literalToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return literalToken; }
+
+// attributes:
+ double value;
+ SourceLocation literalToken;
+};
+
+class QML_PARSER_EXPORT StringLiteral: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(StringLiteral)
+
+ StringLiteral(NameId *v):
+ value (v) { kind = K; }
+
+ virtual ~StringLiteral() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return literalToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return literalToken; }
+
+// attributes:
+ NameId *value;
+ SourceLocation literalToken;
+};
+
+class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(RegExpLiteral)
+
+ RegExpLiteral(NameId *p, int f):
+ pattern (p), flags (f) { kind = K; }
+
+ virtual ~RegExpLiteral() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return literalToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return literalToken; }
+
+// attributes:
+ NameId *pattern;
+ int flags;
+ SourceLocation literalToken;
+};
+
+class QML_PARSER_EXPORT ArrayLiteral: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ArrayLiteral)
+
+ ArrayLiteral(Elision *e):
+ elements (0), elision (e)
+ { kind = K; }
+
+ ArrayLiteral(ElementList *elts):
+ elements (elts), elision (0)
+ { kind = K; }
+
+ ArrayLiteral(ElementList *elts, Elision *e):
+ elements (elts), elision (e)
+ { kind = K; }
+
+ virtual ~ArrayLiteral() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return lbracketToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbracketToken; }
+
+// attributes
+ ElementList *elements;
+ Elision *elision;
+ SourceLocation lbracketToken;
+ SourceLocation commaToken;
+ SourceLocation rbracketToken;
+};
+
+class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ObjectLiteral)
+
+ ObjectLiteral():
+ properties (0) { kind = K; }
+
+ ObjectLiteral(PropertyNameAndValueList *plist):
+ properties (plist) { kind = K; }
+
+ virtual ~ObjectLiteral() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return lbraceToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbraceToken; }
+
+// attributes
+ PropertyNameAndValueList *properties;
+ SourceLocation lbraceToken;
+ SourceLocation rbraceToken;
+};
+
+class QML_PARSER_EXPORT ElementList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ElementList)
+
+ ElementList(Elision *e, ExpressionNode *expr):
+ elision (e), expression (expr), next (this)
+ { kind = K; }
+
+ ElementList(ElementList *previous, Elision *e, ExpressionNode *expr):
+ elision (e), expression (expr)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~ElementList() {}
+
+ inline ElementList *finish ()
+ {
+ ElementList *front = next;
+ next = 0;
+ return front;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ Elision *elision;
+ ExpressionNode *expression;
+ ElementList *next;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT Elision: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(Elision)
+
+ Elision():
+ next (this) { kind = K; }
+
+ Elision(Elision *previous)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~Elision() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ inline Elision *finish ()
+ {
+ Elision *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ Elision *next;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT PropertyNameAndValueList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(PropertyNameAndValueList)
+
+ PropertyNameAndValueList(PropertyName *n, ExpressionNode *v):
+ name (n), value (v), next (this)
+ { kind = K; }
+
+ PropertyNameAndValueList(PropertyNameAndValueList *previous, PropertyName *n, ExpressionNode *v):
+ name (n), value (v)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~PropertyNameAndValueList() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ inline PropertyNameAndValueList *finish ()
+ {
+ PropertyNameAndValueList *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ PropertyName *name;
+ ExpressionNode *value;
+ PropertyNameAndValueList *next;
+ SourceLocation colonToken;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT PropertyName: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(PropertyName)
+
+ PropertyName() { kind = K; }
+ virtual ~PropertyName() {}
+
+// attributes
+ SourceLocation propertyNameToken;
+};
+
+class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(IdentifierPropertyName)
+
+ IdentifierPropertyName(NameId *n):
+ id (n) { kind = K; }
+
+ virtual ~IdentifierPropertyName() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ NameId *id;
+};
+
+class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(StringLiteralPropertyName)
+
+ StringLiteralPropertyName(NameId *n):
+ id (n) { kind = K; }
+ virtual ~StringLiteralPropertyName() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ NameId *id;
+};
+
+class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(NumericLiteralPropertyName)
+
+ NumericLiteralPropertyName(double n):
+ id (n) { kind = K; }
+ virtual ~NumericLiteralPropertyName() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ double id;
+};
+
+class QML_PARSER_EXPORT ArrayMemberExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ArrayMemberExpression)
+
+ ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e):
+ base (b), expression (e)
+ { kind = K; }
+
+ virtual ~ArrayMemberExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return base->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbracketToken; }
+
+// attributes
+ ExpressionNode *base;
+ ExpressionNode *expression;
+ SourceLocation lbracketToken;
+ SourceLocation rbracketToken;
+};
+
+class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(FieldMemberExpression)
+
+ FieldMemberExpression(ExpressionNode *b, NameId *n):
+ base (b), name (n)
+ { kind = K; }
+
+ virtual ~FieldMemberExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return base->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return identifierToken; }
+
+ // attributes
+ ExpressionNode *base;
+ NameId *name;
+ SourceLocation dotToken;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT NewMemberExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(NewMemberExpression)
+
+ NewMemberExpression(ExpressionNode *b, ArgumentList *a):
+ base (b), arguments (a)
+ { kind = K; }
+
+ virtual ~NewMemberExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return newToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rparenToken; }
+
+ // attributes
+ ExpressionNode *base;
+ ArgumentList *arguments;
+ SourceLocation newToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT NewExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(NewExpression)
+
+ NewExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~NewExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return newToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation newToken;
+};
+
+class QML_PARSER_EXPORT CallExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(CallExpression)
+
+ CallExpression(ExpressionNode *b, ArgumentList *a):
+ base (b), arguments (a)
+ { kind = K; }
+
+ virtual ~CallExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return base->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rparenToken; }
+
+// attributes
+ ExpressionNode *base;
+ ArgumentList *arguments;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT ArgumentList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ArgumentList)
+
+ ArgumentList(ExpressionNode *e):
+ expression (e), next (this)
+ { kind = K; }
+
+ ArgumentList(ArgumentList *previous, ExpressionNode *e):
+ expression (e)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~ArgumentList() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ inline ArgumentList *finish ()
+ {
+ ArgumentList *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ ExpressionNode *expression;
+ ArgumentList *next;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(PostIncrementExpression)
+
+ PostIncrementExpression(ExpressionNode *b):
+ base (b) { kind = K; }
+
+ virtual ~PostIncrementExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return base->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return incrementToken; }
+
+// attributes
+ ExpressionNode *base;
+ SourceLocation incrementToken;
+};
+
+class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(PostDecrementExpression)
+
+ PostDecrementExpression(ExpressionNode *b):
+ base (b) { kind = K; }
+
+ virtual ~PostDecrementExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return base->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return decrementToken; }
+
+// attributes
+ ExpressionNode *base;
+ SourceLocation decrementToken;
+};
+
+class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(DeleteExpression)
+
+ DeleteExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+ virtual ~DeleteExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return deleteToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation deleteToken;
+};
+
+class QML_PARSER_EXPORT VoidExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(VoidExpression)
+
+ VoidExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~VoidExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return voidToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation voidToken;
+};
+
+class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(TypeOfExpression)
+
+ TypeOfExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~TypeOfExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return typeofToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation typeofToken;
+};
+
+class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(PreIncrementExpression)
+
+ PreIncrementExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~PreIncrementExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return incrementToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation incrementToken;
+};
+
+class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(PreDecrementExpression)
+
+ PreDecrementExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~PreDecrementExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return decrementToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation decrementToken;
+};
+
+class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UnaryPlusExpression)
+
+ UnaryPlusExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~UnaryPlusExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return plusToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation plusToken;
+};
+
+class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UnaryMinusExpression)
+
+ UnaryMinusExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~UnaryMinusExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return minusToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation minusToken;
+};
+
+class QML_PARSER_EXPORT TildeExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(TildeExpression)
+
+ TildeExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~TildeExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return tildeToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation tildeToken;
+};
+
+class QML_PARSER_EXPORT NotExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(NotExpression)
+
+ NotExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~NotExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return notToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation notToken;
+};
+
+class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(BinaryExpression)
+
+ BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r):
+ left (l), op (o), right (r)
+ { kind = K; }
+
+ virtual ~BinaryExpression() {}
+
+ virtual BinaryExpression *binaryExpressionCast();
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return left->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return right->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *left;
+ int op;
+ ExpressionNode *right;
+ SourceLocation operatorToken;
+};
+
+class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ConditionalExpression)
+
+ ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f):
+ expression (e), ok (t), ko (f)
+ { kind = K; }
+
+ virtual ~ConditionalExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return expression->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return ko->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ ExpressionNode *ok;
+ ExpressionNode *ko;
+ SourceLocation questionToken;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(Expression)
+
+ Expression(ExpressionNode *l, ExpressionNode *r):
+ left (l), right (r) { kind = K; }
+
+ virtual ~Expression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return left->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return right->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *left;
+ ExpressionNode *right;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT Block: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(Block)
+
+ Block(StatementList *slist):
+ statements (slist) { kind = K; }
+
+ virtual ~Block() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return lbraceToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbraceToken; }
+
+ // attributes
+ StatementList *statements;
+ SourceLocation lbraceToken;
+ SourceLocation rbraceToken;
+};
+
+class QML_PARSER_EXPORT StatementList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(StatementList)
+
+ StatementList(Statement *stmt):
+ statement (stmt), next (this)
+ { kind = K; }
+
+ StatementList(StatementList *previous, Statement *stmt):
+ statement (stmt)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~StatementList() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ inline StatementList *finish ()
+ {
+ StatementList *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ Statement *statement;
+ StatementList *next;
+};
+
+class QML_PARSER_EXPORT VariableStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(VariableStatement)
+
+ VariableStatement(VariableDeclarationList *vlist):
+ declarations (vlist)
+ { kind = K; }
+
+ virtual ~VariableStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return declarationKindToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ VariableDeclarationList *declarations;
+ SourceLocation declarationKindToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT VariableDeclaration: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(VariableDeclaration)
+
+ VariableDeclaration(NameId *n, ExpressionNode *e):
+ name (n), expression (e), readOnly(false)
+ { kind = K; }
+
+ virtual ~VariableDeclaration() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ NameId *name;
+ ExpressionNode *expression;
+ bool readOnly;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT VariableDeclarationList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(VariableDeclarationList)
+
+ VariableDeclarationList(VariableDeclaration *decl):
+ declaration (decl), next (this)
+ { kind = K; }
+
+ VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl):
+ declaration (decl)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~VariableDeclarationList() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ inline VariableDeclarationList *finish (bool readOnly)
+ {
+ VariableDeclarationList *front = next;
+ next = 0;
+ if (readOnly) {
+ VariableDeclarationList *vdl;
+ for (vdl = front; vdl != 0; vdl = vdl->next)
+ vdl->declaration->readOnly = true;
+ }
+ return front;
+ }
+
+// attributes
+ VariableDeclaration *declaration;
+ VariableDeclarationList *next;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT EmptyStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(EmptyStatement)
+
+ EmptyStatement() { kind = K; }
+ virtual ~EmptyStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return semicolonToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT ExpressionStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ExpressionStatement)
+
+ ExpressionStatement(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~ExpressionStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return expression->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT IfStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(IfStatement)
+
+ IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0):
+ expression (e), ok (t), ko (f)
+ { kind = K; }
+
+ virtual ~IfStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return ifToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (ko)
+ return ko->lastSourceLocation();
+
+ return ok->lastSourceLocation();
+ }
+
+// attributes
+ ExpressionNode *expression;
+ Statement *ok;
+ Statement *ko;
+ SourceLocation ifToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+ SourceLocation elseToken;
+};
+
+class QML_PARSER_EXPORT DoWhileStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(DoWhileStatement)
+
+ DoWhileStatement(Statement *stmt, ExpressionNode *e):
+ statement (stmt), expression (e)
+ { kind = K; }
+
+ virtual ~DoWhileStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return doToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ Statement *statement;
+ ExpressionNode *expression;
+ SourceLocation doToken;
+ SourceLocation whileToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT WhileStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(WhileStatement)
+
+ WhileStatement(ExpressionNode *e, Statement *stmt):
+ expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual ~WhileStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return whileToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation whileToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT ForStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ForStatement)
+
+ ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
+ initialiser (i), condition (c), expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual ~ForStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return forToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *initialiser;
+ ExpressionNode *condition;
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation forToken;
+ SourceLocation lparenToken;
+ SourceLocation firstSemicolonToken;
+ SourceLocation secondSemicolonToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT LocalForStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(LocalForStatement)
+
+ LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
+ declarations (vlist), condition (c), expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual ~LocalForStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return forToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ VariableDeclarationList *declarations;
+ ExpressionNode *condition;
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation forToken;
+ SourceLocation lparenToken;
+ SourceLocation varToken;
+ SourceLocation firstSemicolonToken;
+ SourceLocation secondSemicolonToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT ForEachStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ForEachStatement)
+
+ ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt):
+ initialiser (i), expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual ~ForEachStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return forToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *initialiser;
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation forToken;
+ SourceLocation lparenToken;
+ SourceLocation inToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT LocalForEachStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(LocalForEachStatement)
+
+ LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt):
+ declaration (v), expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual ~LocalForEachStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return forToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ VariableDeclaration *declaration;
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation forToken;
+ SourceLocation lparenToken;
+ SourceLocation varToken;
+ SourceLocation inToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT ContinueStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ContinueStatement)
+
+ ContinueStatement(NameId *l = 0):
+ label (l) { kind = K; }
+
+ virtual ~ContinueStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return continueToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ NameId *label;
+ SourceLocation continueToken;
+ SourceLocation identifierToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT BreakStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(BreakStatement)
+
+ BreakStatement(NameId *l = 0):
+ label (l) { kind = K; }
+
+ virtual ~BreakStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return breakToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+ // attributes
+ NameId *label;
+ SourceLocation breakToken;
+ SourceLocation identifierToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT ReturnStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ReturnStatement)
+
+ ReturnStatement(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~ReturnStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return returnToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation returnToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT WithStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(WithStatement)
+
+ WithStatement(ExpressionNode *e, Statement *stmt):
+ expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual ~WithStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return withToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation withToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT CaseBlock: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(CaseBlock)
+
+ CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0):
+ clauses (c), defaultClause (d), moreClauses (r)
+ { kind = K; }
+
+ virtual ~CaseBlock() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ CaseClauses *clauses;
+ DefaultClause *defaultClause;
+ CaseClauses *moreClauses;
+ SourceLocation lbraceToken;
+ SourceLocation rbraceToken;
+};
+
+class QML_PARSER_EXPORT SwitchStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(SwitchStatement)
+
+ SwitchStatement(ExpressionNode *e, CaseBlock *b):
+ expression (e), block (b)
+ { kind = K; }
+
+ virtual ~SwitchStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return switchToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return block->rbraceToken; }
+
+// attributes
+ ExpressionNode *expression;
+ CaseBlock *block;
+ SourceLocation switchToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT CaseClauses: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(CaseClauses)
+
+ CaseClauses(CaseClause *c):
+ clause (c), next (this)
+ { kind = K; }
+
+ CaseClauses(CaseClauses *previous, CaseClause *c):
+ clause (c)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~CaseClauses() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ inline CaseClauses *finish ()
+ {
+ CaseClauses *front = next;
+ next = 0;
+ return front;
+ }
+
+//attributes
+ CaseClause *clause;
+ CaseClauses *next;
+};
+
+class QML_PARSER_EXPORT CaseClause: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(CaseClause)
+
+ CaseClause(ExpressionNode *e, StatementList *slist):
+ expression (e), statements (slist)
+ { kind = K; }
+
+ virtual ~CaseClause() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ ExpressionNode *expression;
+ StatementList *statements;
+ SourceLocation caseToken;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT DefaultClause: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(DefaultClause)
+
+ DefaultClause(StatementList *slist):
+ statements (slist)
+ { kind = K; }
+
+ virtual ~DefaultClause() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ StatementList *statements;
+ SourceLocation defaultToken;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT LabelledStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(LabelledStatement)
+
+ LabelledStatement(NameId *l, Statement *stmt):
+ label (l), statement (stmt)
+ { kind = K; }
+
+ virtual ~LabelledStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ NameId *label;
+ Statement *statement;
+ SourceLocation identifierToken;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT ThrowStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(ThrowStatement)
+
+ ThrowStatement(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual ~ThrowStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return throwToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+ // attributes
+ ExpressionNode *expression;
+ SourceLocation throwToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT Catch: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(Catch)
+
+ Catch(NameId *n, Block *stmt):
+ name (n), statement (stmt)
+ { kind = K; }
+
+ virtual ~Catch() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ NameId *name;
+ Block *statement;
+ SourceLocation catchToken;
+ SourceLocation lparenToken;
+ SourceLocation identifierToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT Finally: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(Finally)
+
+ Finally(Block *stmt):
+ statement (stmt)
+ { kind = K; }
+
+ virtual ~Finally() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ Block *statement;
+ SourceLocation finallyToken;
+};
+
+class QML_PARSER_EXPORT TryStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(TryStatement)
+
+ TryStatement(Statement *stmt, Catch *c, Finally *f):
+ statement (stmt), catchExpression (c), finallyExpression (f)
+ { kind = K; }
+
+ TryStatement(Statement *stmt, Finally *f):
+ statement (stmt), catchExpression (0), finallyExpression (f)
+ { kind = K; }
+
+ TryStatement(Statement *stmt, Catch *c):
+ statement (stmt), catchExpression (c), finallyExpression (0)
+ { kind = K; }
+
+ virtual ~TryStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return tryToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (finallyExpression)
+ return finallyExpression->statement->rbraceToken;
+ else if (catchExpression)
+ return catchExpression->statement->rbraceToken;
+
+ return statement->lastSourceLocation();
+ }
+
+// attributes
+ Statement *statement;
+ Catch *catchExpression;
+ Finally *finallyExpression;
+ SourceLocation tryToken;
+};
+
+class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(FunctionExpression)
+
+ FunctionExpression(NameId *n, FormalParameterList *f, FunctionBody *b):
+ name (n), formals (f), body (b)
+ { kind = K; }
+
+ virtual ~FunctionExpression() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return functionToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbraceToken; }
+
+// attributes
+ NameId *name;
+ FormalParameterList *formals;
+ FunctionBody *body;
+ SourceLocation functionToken;
+ SourceLocation identifierToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+ SourceLocation lbraceToken;
+ SourceLocation rbraceToken;
+};
+
+class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(FunctionDeclaration)
+
+ FunctionDeclaration(NameId *n, FormalParameterList *f, FunctionBody *b):
+ FunctionExpression(n, f, b)
+ { kind = K; }
+
+ virtual ~FunctionDeclaration() {}
+
+ virtual void accept0(Visitor *visitor);
+};
+
+class QML_PARSER_EXPORT FormalParameterList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(FormalParameterList)
+
+ FormalParameterList(NameId *n):
+ name (n), next (this)
+ { kind = K; }
+
+ FormalParameterList(FormalParameterList *previous, NameId *n):
+ name (n)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~FormalParameterList() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ inline FormalParameterList *finish ()
+ {
+ FormalParameterList *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ NameId *name;
+ FormalParameterList *next;
+ SourceLocation commaToken;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT FunctionBody: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(FunctionBody)
+
+ FunctionBody(SourceElements *elts):
+ elements (elts)
+ { kind = K; }
+
+ virtual ~FunctionBody() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ SourceElements *elements;
+};
+
+class QML_PARSER_EXPORT Program: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(Program)
+
+ Program(SourceElements *elts):
+ elements (elts)
+ { kind = K; }
+
+ virtual ~Program() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ SourceElements *elements;
+};
+
+class QML_PARSER_EXPORT SourceElements: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(SourceElements)
+
+ SourceElements(SourceElement *elt):
+ element (elt), next (this)
+ { kind = K; }
+
+ SourceElements(SourceElements *previous, SourceElement *elt):
+ element (elt)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~SourceElements() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ inline SourceElements *finish ()
+ {
+ SourceElements *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ SourceElement *element;
+ SourceElements *next;
+};
+
+class QML_PARSER_EXPORT SourceElement: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(SourceElement)
+
+ inline SourceElement()
+ { kind = K; }
+
+ virtual ~SourceElement() {}
+};
+
+class QML_PARSER_EXPORT FunctionSourceElement: public SourceElement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(FunctionSourceElement)
+
+ FunctionSourceElement(FunctionDeclaration *f):
+ declaration (f)
+ { kind = K; }
+
+ virtual ~FunctionSourceElement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ FunctionDeclaration *declaration;
+};
+
+class QML_PARSER_EXPORT StatementSourceElement: public SourceElement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(StatementSourceElement)
+
+ StatementSourceElement(Statement *stmt):
+ statement (stmt)
+ { kind = K; }
+
+ virtual ~StatementSourceElement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ Statement *statement;
+};
+
+class QML_PARSER_EXPORT DebuggerStatement: public Statement
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(DebuggerStatement)
+
+ DebuggerStatement()
+ { kind = K; }
+
+ virtual ~DebuggerStatement() {}
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return debuggerToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ SourceLocation debuggerToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT UiProgram: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiProgram)
+
+ UiProgram(UiImportList *imports, UiObjectMemberList *members)
+ : imports(imports), members(members)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiImportList *imports;
+ UiObjectMemberList *members;
+};
+
+class QML_PARSER_EXPORT UiQualifiedId: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiQualifiedId)
+
+ UiQualifiedId(NameId *name)
+ : next(this), name(name)
+ { kind = K; }
+
+ UiQualifiedId(UiQualifiedId *previous, NameId *name)
+ : name(name)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~UiQualifiedId() {}
+
+ UiQualifiedId *finish()
+ {
+ UiQualifiedId *head = next;
+ next = 0;
+ return head;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiQualifiedId *next;
+ NameId *name;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT UiImport: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiImport)
+
+ UiImport(NameId *fileName)
+ : fileName(fileName), importUri(0), importId(0)
+ { kind = K; }
+
+ UiImport(UiQualifiedId *uri)
+ : fileName(0), importUri(uri), importId(0)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return importToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ NameId *fileName;
+ UiQualifiedId *importUri;
+ NameId *importId;
+ SourceLocation importToken;
+ SourceLocation fileNameToken;
+ SourceLocation versionToken;
+ SourceLocation asToken;
+ SourceLocation importIdToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT UiImportList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiImportList)
+
+ UiImportList(UiImport *import)
+ : import(import),
+ next(this)
+ { kind = K; }
+
+ UiImportList(UiImportList *previous, UiImport *import)
+ : import(import)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual SourceLocation firstSourceLocation() const
+ {
+ if (import) return import->firstSourceLocation();
+ else return SourceLocation();
+ }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ for (const UiImportList *it = this; it; it = it->next)
+ if (!it->next && it->import)
+ return it->import->lastSourceLocation();
+
+ return SourceLocation();
+ }
+
+ UiImportList *finish()
+ {
+ UiImportList *head = next;
+ next = 0;
+ return head;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiImport *import;
+ UiImportList *next;
+};
+
+class QML_PARSER_EXPORT UiObjectMember: public Node
+{
+public:
+ virtual SourceLocation firstSourceLocation() const = 0;
+ virtual SourceLocation lastSourceLocation() const = 0;
+
+ virtual UiObjectMember *uiObjectMemberCast();
+};
+
+class QML_PARSER_EXPORT UiObjectMemberList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectMemberList)
+
+ UiObjectMemberList(UiObjectMember *member)
+ : next(this), member(member)
+ { kind = K; }
+
+ UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member)
+ : member(member)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ UiObjectMemberList *finish()
+ {
+ UiObjectMemberList *head = next;
+ next = 0;
+ return head;
+ }
+
+// attributes
+ UiObjectMemberList *next;
+ UiObjectMember *member;
+};
+
+class QML_PARSER_EXPORT UiArrayMemberList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiArrayMemberList)
+
+ UiArrayMemberList(UiObjectMember *member)
+ : next(this), member(member)
+ { kind = K; }
+
+ UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member)
+ : member(member)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ UiArrayMemberList *finish()
+ {
+ UiArrayMemberList *head = next;
+ next = 0;
+ return head;
+ }
+
+// attributes
+ UiArrayMemberList *next;
+ UiObjectMember *member;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT UiObjectInitializer: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectInitializer)
+
+ UiObjectInitializer(UiObjectMemberList *members)
+ : members(members)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ SourceLocation lbraceToken;
+ UiObjectMemberList *members;
+ SourceLocation rbraceToken;
+};
+
+class QML_PARSER_EXPORT UiParameterList: public Node
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiParameterList)
+
+ UiParameterList(NameId *t, NameId *n):
+ type (t), name (n), next (this)
+ { kind = K; }
+
+ UiParameterList(UiParameterList *previous, NameId *t, NameId *n):
+ type (t), name (n)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual ~UiParameterList() {}
+
+ virtual void accept0(Visitor *) {}
+
+ inline UiParameterList *finish ()
+ {
+ UiParameterList *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ NameId *type;
+ NameId *name;
+ UiParameterList *next;
+ SourceLocation commaToken;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiPublicMember)
+
+ UiPublicMember(NameId *memberType,
+ NameId *name)
+ : type(Property), typeModifier(0), memberType(memberType), name(name), expression(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
+ { kind = K; }
+
+ UiPublicMember(NameId *memberType,
+ NameId *name,
+ ExpressionNode *expression)
+ : type(Property), typeModifier(0), memberType(memberType), name(name), expression(expression), isDefaultMember(false), isReadonlyMember(false), parameters(0)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ {
+ if (defaultToken.isValid())
+ return defaultToken;
+ else if (readonlyToken.isValid())
+ return readonlyToken;
+
+ return propertyToken;
+ }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ return semicolonToken;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ enum { Signal, Property } type;
+ NameId *typeModifier;
+ NameId *memberType;
+ NameId *name;
+ ExpressionNode *expression;
+ bool isDefaultMember;
+ bool isReadonlyMember;
+ UiParameterList *parameters;
+ SourceLocation defaultToken;
+ SourceLocation readonlyToken;
+ SourceLocation propertyToken;
+ SourceLocation typeModifierToken;
+ SourceLocation typeToken;
+ SourceLocation identifierToken;
+ SourceLocation colonToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectDefinition)
+
+ UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId,
+ UiObjectInitializer *initializer)
+ : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return qualifiedTypeNameId->identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return initializer->rbraceToken; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiQualifiedId *qualifiedTypeNameId;
+ UiObjectInitializer *initializer;
+};
+
+class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiSourceElement)
+
+ UiSourceElement(Node *sourceElement)
+ : sourceElement(sourceElement)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ {
+ if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
+ return funDecl->firstSourceLocation();
+ else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
+ return varStmt->firstSourceLocation();
+
+ return SourceLocation();
+ }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
+ return funDecl->lastSourceLocation();
+ else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
+ return varStmt->lastSourceLocation();
+
+ return SourceLocation();
+ }
+
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ Node *sourceElement;
+};
+
+class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectBinding)
+
+ UiObjectBinding(UiQualifiedId *qualifiedId,
+ UiQualifiedId *qualifiedTypeNameId,
+ UiObjectInitializer *initializer)
+ : qualifiedId(qualifiedId),
+ qualifiedTypeNameId(qualifiedTypeNameId),
+ initializer(initializer)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return qualifiedId->identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return initializer->rbraceToken; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiQualifiedId *qualifiedId;
+ UiQualifiedId *qualifiedTypeNameId;
+ UiObjectInitializer *initializer;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiScriptBinding)
+
+ UiScriptBinding(UiQualifiedId *qualifiedId,
+ Statement *statement)
+ : qualifiedId(qualifiedId),
+ statement(statement)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return qualifiedId->identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiQualifiedId *qualifiedId;
+ Statement *statement;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember
+{
+public:
+ QDECLARATIVEJS_DECLARE_AST_NODE(UiArrayBinding)
+
+ UiArrayBinding(UiQualifiedId *qualifiedId,
+ UiArrayMemberList *members)
+ : qualifiedId(qualifiedId),
+ members(members)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return qualifiedId->identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbracketToken; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiQualifiedId *qualifiedId;
+ UiArrayMemberList *members;
+ SourceLocation colonToken;
+ SourceLocation lbracketToken;
+ SourceLocation rbracketToken;
+};
+
+} } // namespace AST
+
+
+
+QT_QML_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/qml/parser/qdeclarativejsastfwd_p.h b/src/declarative/qml/parser/qdeclarativejsastfwd_p.h
new file mode 100644
index 0000000..5a444b7
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsastfwd_p.h
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEJSAST_FWD_P_H
+#define QDECLARATIVEJSAST_FWD_P_H
+
+#include "qdeclarativejsglobal_p.h"
+
+#include <QtCore/qglobal.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.
+//
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS { namespace AST {
+
+class SourceLocation
+{
+public:
+ SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
+ : offset(offset), length(length),
+ startLine(line), startColumn(column)
+ { }
+
+ bool isValid() const { return length != 0; }
+
+ quint32 begin() const { return offset; }
+ quint32 end() const { return offset + length; }
+
+// attributes
+ // ### encode
+ quint32 offset;
+ quint32 length;
+ quint32 startLine;
+ quint32 startColumn;
+};
+
+class Visitor;
+class Node;
+class ExpressionNode;
+class Statement;
+class ThisExpression;
+class IdentifierExpression;
+class NullExpression;
+class TrueLiteral;
+class FalseLiteral;
+class NumericLiteral;
+class StringLiteral;
+class RegExpLiteral;
+class ArrayLiteral;
+class ObjectLiteral;
+class ElementList;
+class Elision;
+class PropertyNameAndValueList;
+class PropertyName;
+class IdentifierPropertyName;
+class StringLiteralPropertyName;
+class NumericLiteralPropertyName;
+class ArrayMemberExpression;
+class FieldMemberExpression;
+class NewMemberExpression;
+class NewExpression;
+class CallExpression;
+class ArgumentList;
+class PostIncrementExpression;
+class PostDecrementExpression;
+class DeleteExpression;
+class VoidExpression;
+class TypeOfExpression;
+class PreIncrementExpression;
+class PreDecrementExpression;
+class UnaryPlusExpression;
+class UnaryMinusExpression;
+class TildeExpression;
+class NotExpression;
+class BinaryExpression;
+class ConditionalExpression;
+class Expression; // ### rename
+class Block;
+class StatementList;
+class VariableStatement;
+class VariableDeclarationList;
+class VariableDeclaration;
+class EmptyStatement;
+class ExpressionStatement;
+class IfStatement;
+class DoWhileStatement;
+class WhileStatement;
+class ForStatement;
+class LocalForStatement;
+class ForEachStatement;
+class LocalForEachStatement;
+class ContinueStatement;
+class BreakStatement;
+class ReturnStatement;
+class WithStatement;
+class SwitchStatement;
+class CaseBlock;
+class CaseClauses;
+class CaseClause;
+class DefaultClause;
+class LabelledStatement;
+class ThrowStatement;
+class TryStatement;
+class Catch;
+class Finally;
+class FunctionDeclaration;
+class FunctionExpression;
+class FormalParameterList;
+class FunctionBody;
+class Program;
+class SourceElements;
+class SourceElement;
+class FunctionSourceElement;
+class StatementSourceElement;
+class DebuggerStatement;
+class NestedExpression;
+
+// ui elements
+class UiProgram;
+class UiImportList;
+class UiImport;
+class UiPublicMember;
+class UiObjectDefinition;
+class UiObjectInitializer;
+class UiObjectBinding;
+class UiScriptBinding;
+class UiSourceElement;
+class UiArrayBinding;
+class UiObjectMember;
+class UiObjectMemberList;
+class UiArrayMemberList;
+class UiQualifiedId;
+class UiFormalList;
+class UiFormal;
+class UiSignature;
+
+} } // namespace AST
+
+QT_QML_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp b/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp
new file mode 100644
index 0000000..d8002cf
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativejsastvisitor_p.h"
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS { namespace AST {
+
+Visitor::Visitor()
+{
+}
+
+Visitor::~Visitor()
+{
+}
+
+} } // namespace QDeclarativeJS::AST
+
+QT_QML_END_NAMESPACE
diff --git a/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h b/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h
new file mode 100644
index 0000000..82abbcf
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h
@@ -0,0 +1,335 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEJSASTVISITOR_P_H
+#define QDECLARATIVEJSASTVISITOR_P_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 "qdeclarativejsastfwd_p.h"
+#include "qdeclarativejsglobal_p.h"
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS { namespace AST {
+
+class QML_PARSER_EXPORT Visitor
+{
+public:
+ Visitor();
+ virtual ~Visitor();
+
+ virtual bool preVisit(Node *) { return true; }
+ virtual void postVisit(Node *) {}
+
+ // Ui
+ virtual bool visit(UiProgram *) { return true; }
+ virtual bool visit(UiImportList *) { return true; }
+ virtual bool visit(UiImport *) { return true; }
+ virtual bool visit(UiPublicMember *) { return true; }
+ virtual bool visit(UiSourceElement *) { return true; }
+ virtual bool visit(UiObjectDefinition *) { return true; }
+ virtual bool visit(UiObjectInitializer *) { return true; }
+ virtual bool visit(UiObjectBinding *) { return true; }
+ virtual bool visit(UiScriptBinding *) { return true; }
+ virtual bool visit(UiArrayBinding *) { return true; }
+ virtual bool visit(UiObjectMemberList *) { return true; }
+ virtual bool visit(UiArrayMemberList *) { return true; }
+ virtual bool visit(UiQualifiedId *) { return true; }
+ virtual bool visit(UiSignature *) { return true; }
+ virtual bool visit(UiFormalList *) { return true; }
+ virtual bool visit(UiFormal *) { return true; }
+
+ virtual void endVisit(UiProgram *) {}
+ virtual void endVisit(UiImportList *) {}
+ virtual void endVisit(UiImport *) {}
+ virtual void endVisit(UiPublicMember *) {}
+ virtual void endVisit(UiSourceElement *) {}
+ virtual void endVisit(UiObjectDefinition *) {}
+ virtual void endVisit(UiObjectInitializer *) {}
+ virtual void endVisit(UiObjectBinding *) {}
+ virtual void endVisit(UiScriptBinding *) {}
+ virtual void endVisit(UiArrayBinding *) {}
+ virtual void endVisit(UiObjectMemberList *) {}
+ virtual void endVisit(UiArrayMemberList *) {}
+ virtual void endVisit(UiQualifiedId *) {}
+ virtual void endVisit(UiSignature *) {}
+ virtual void endVisit(UiFormalList *) {}
+ virtual void endVisit(UiFormal *) {}
+
+ // QDeclarativeJS
+ virtual bool visit(ThisExpression *) { return true; }
+ virtual void endVisit(ThisExpression *) {}
+
+ virtual bool visit(IdentifierExpression *) { return true; }
+ virtual void endVisit(IdentifierExpression *) {}
+
+ virtual bool visit(NullExpression *) { return true; }
+ virtual void endVisit(NullExpression *) {}
+
+ virtual bool visit(TrueLiteral *) { return true; }
+ virtual void endVisit(TrueLiteral *) {}
+
+ virtual bool visit(FalseLiteral *) { return true; }
+ virtual void endVisit(FalseLiteral *) {}
+
+ virtual bool visit(StringLiteral *) { return true; }
+ virtual void endVisit(StringLiteral *) {}
+
+ virtual bool visit(NumericLiteral *) { return true; }
+ virtual void endVisit(NumericLiteral *) {}
+
+ virtual bool visit(RegExpLiteral *) { return true; }
+ virtual void endVisit(RegExpLiteral *) {}
+
+ virtual bool visit(ArrayLiteral *) { return true; }
+ virtual void endVisit(ArrayLiteral *) {}
+
+ virtual bool visit(ObjectLiteral *) { return true; }
+ virtual void endVisit(ObjectLiteral *) {}
+
+ virtual bool visit(ElementList *) { return true; }
+ virtual void endVisit(ElementList *) {}
+
+ virtual bool visit(Elision *) { return true; }
+ virtual void endVisit(Elision *) {}
+
+ virtual bool visit(PropertyNameAndValueList *) { return true; }
+ virtual void endVisit(PropertyNameAndValueList *) {}
+
+ virtual bool visit(NestedExpression *) { return true; }
+ virtual void endVisit(NestedExpression *) {}
+
+ virtual bool visit(IdentifierPropertyName *) { return true; }
+ virtual void endVisit(IdentifierPropertyName *) {}
+
+ virtual bool visit(StringLiteralPropertyName *) { return true; }
+ virtual void endVisit(StringLiteralPropertyName *) {}
+
+ virtual bool visit(NumericLiteralPropertyName *) { return true; }
+ virtual void endVisit(NumericLiteralPropertyName *) {}
+
+ virtual bool visit(ArrayMemberExpression *) { return true; }
+ virtual void endVisit(ArrayMemberExpression *) {}
+
+ virtual bool visit(FieldMemberExpression *) { return true; }
+ virtual void endVisit(FieldMemberExpression *) {}
+
+ virtual bool visit(NewMemberExpression *) { return true; }
+ virtual void endVisit(NewMemberExpression *) {}
+
+ virtual bool visit(NewExpression *) { return true; }
+ virtual void endVisit(NewExpression *) {}
+
+ virtual bool visit(CallExpression *) { return true; }
+ virtual void endVisit(CallExpression *) {}
+
+ virtual bool visit(ArgumentList *) { return true; }
+ virtual void endVisit(ArgumentList *) {}
+
+ virtual bool visit(PostIncrementExpression *) { return true; }
+ virtual void endVisit(PostIncrementExpression *) {}
+
+ virtual bool visit(PostDecrementExpression *) { return true; }
+ virtual void endVisit(PostDecrementExpression *) {}
+
+ virtual bool visit(DeleteExpression *) { return true; }
+ virtual void endVisit(DeleteExpression *) {}
+
+ virtual bool visit(VoidExpression *) { return true; }
+ virtual void endVisit(VoidExpression *) {}
+
+ virtual bool visit(TypeOfExpression *) { return true; }
+ virtual void endVisit(TypeOfExpression *) {}
+
+ virtual bool visit(PreIncrementExpression *) { return true; }
+ virtual void endVisit(PreIncrementExpression *) {}
+
+ virtual bool visit(PreDecrementExpression *) { return true; }
+ virtual void endVisit(PreDecrementExpression *) {}
+
+ virtual bool visit(UnaryPlusExpression *) { return true; }
+ virtual void endVisit(UnaryPlusExpression *) {}
+
+ virtual bool visit(UnaryMinusExpression *) { return true; }
+ virtual void endVisit(UnaryMinusExpression *) {}
+
+ virtual bool visit(TildeExpression *) { return true; }
+ virtual void endVisit(TildeExpression *) {}
+
+ virtual bool visit(NotExpression *) { return true; }
+ virtual void endVisit(NotExpression *) {}
+
+ virtual bool visit(BinaryExpression *) { return true; }
+ virtual void endVisit(BinaryExpression *) {}
+
+ virtual bool visit(ConditionalExpression *) { return true; }
+ virtual void endVisit(ConditionalExpression *) {}
+
+ virtual bool visit(Expression *) { return true; }
+ virtual void endVisit(Expression *) {}
+
+ virtual bool visit(Block *) { return true; }
+ virtual void endVisit(Block *) {}
+
+ virtual bool visit(StatementList *) { return true; }
+ virtual void endVisit(StatementList *) {}
+
+ virtual bool visit(VariableStatement *) { return true; }
+ virtual void endVisit(VariableStatement *) {}
+
+ virtual bool visit(VariableDeclarationList *) { return true; }
+ virtual void endVisit(VariableDeclarationList *) {}
+
+ virtual bool visit(VariableDeclaration *) { return true; }
+ virtual void endVisit(VariableDeclaration *) {}
+
+ virtual bool visit(EmptyStatement *) { return true; }
+ virtual void endVisit(EmptyStatement *) {}
+
+ virtual bool visit(ExpressionStatement *) { return true; }
+ virtual void endVisit(ExpressionStatement *) {}
+
+ virtual bool visit(IfStatement *) { return true; }
+ virtual void endVisit(IfStatement *) {}
+
+ virtual bool visit(DoWhileStatement *) { return true; }
+ virtual void endVisit(DoWhileStatement *) {}
+
+ virtual bool visit(WhileStatement *) { return true; }
+ virtual void endVisit(WhileStatement *) {}
+
+ virtual bool visit(ForStatement *) { return true; }
+ virtual void endVisit(ForStatement *) {}
+
+ virtual bool visit(LocalForStatement *) { return true; }
+ virtual void endVisit(LocalForStatement *) {}
+
+ virtual bool visit(ForEachStatement *) { return true; }
+ virtual void endVisit(ForEachStatement *) {}
+
+ virtual bool visit(LocalForEachStatement *) { return true; }
+ virtual void endVisit(LocalForEachStatement *) {}
+
+ virtual bool visit(ContinueStatement *) { return true; }
+ virtual void endVisit(ContinueStatement *) {}
+
+ virtual bool visit(BreakStatement *) { return true; }
+ virtual void endVisit(BreakStatement *) {}
+
+ virtual bool visit(ReturnStatement *) { return true; }
+ virtual void endVisit(ReturnStatement *) {}
+
+ virtual bool visit(WithStatement *) { return true; }
+ virtual void endVisit(WithStatement *) {}
+
+ virtual bool visit(SwitchStatement *) { return true; }
+ virtual void endVisit(SwitchStatement *) {}
+
+ virtual bool visit(CaseBlock *) { return true; }
+ virtual void endVisit(CaseBlock *) {}
+
+ virtual bool visit(CaseClauses *) { return true; }
+ virtual void endVisit(CaseClauses *) {}
+
+ virtual bool visit(CaseClause *) { return true; }
+ virtual void endVisit(CaseClause *) {}
+
+ virtual bool visit(DefaultClause *) { return true; }
+ virtual void endVisit(DefaultClause *) {}
+
+ virtual bool visit(LabelledStatement *) { return true; }
+ virtual void endVisit(LabelledStatement *) {}
+
+ virtual bool visit(ThrowStatement *) { return true; }
+ virtual void endVisit(ThrowStatement *) {}
+
+ virtual bool visit(TryStatement *) { return true; }
+ virtual void endVisit(TryStatement *) {}
+
+ virtual bool visit(Catch *) { return true; }
+ virtual void endVisit(Catch *) {}
+
+ virtual bool visit(Finally *) { return true; }
+ virtual void endVisit(Finally *) {}
+
+ virtual bool visit(FunctionDeclaration *) { return true; }
+ virtual void endVisit(FunctionDeclaration *) {}
+
+ virtual bool visit(FunctionExpression *) { return true; }
+ virtual void endVisit(FunctionExpression *) {}
+
+ virtual bool visit(FormalParameterList *) { return true; }
+ virtual void endVisit(FormalParameterList *) {}
+
+ virtual bool visit(FunctionBody *) { return true; }
+ virtual void endVisit(FunctionBody *) {}
+
+ virtual bool visit(Program *) { return true; }
+ virtual void endVisit(Program *) {}
+
+ virtual bool visit(SourceElements *) { return true; }
+ virtual void endVisit(SourceElements *) {}
+
+ virtual bool visit(FunctionSourceElement *) { return true; }
+ virtual void endVisit(FunctionSourceElement *) {}
+
+ virtual bool visit(StatementSourceElement *) { return true; }
+ virtual void endVisit(StatementSourceElement *) {}
+
+ virtual bool visit(DebuggerStatement *) { return true; }
+ virtual void endVisit(DebuggerStatement *) {}
+};
+
+} } // namespace AST
+
+QT_QML_END_NAMESPACE
+
+#endif // QDECLARATIVEJSASTVISITOR_P_H
diff --git a/src/declarative/qml/parser/qdeclarativejsengine_p.cpp b/src/declarative/qml/parser/qdeclarativejsengine_p.cpp
new file mode 100644
index 0000000..7d39134
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsengine_p.cpp
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativejsengine_p.h"
+
+#include "qdeclarativejsglobal_p.h"
+#include "qdeclarativejsnodepool_p.h"
+
+#include <qnumeric.h>
+#include <QHash>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS {
+
+uint qHash(const QDeclarativeJS::NameId &id)
+{ return qHash(id.asString()); }
+
+QString numberToString(double value)
+{ return QString::number(value); }
+
+int Ecma::RegExp::flagFromChar(const QChar &ch)
+{
+ static QHash<QChar, int> flagsHash;
+ if (flagsHash.isEmpty()) {
+ flagsHash[QLatin1Char('g')] = Global;
+ flagsHash[QLatin1Char('i')] = IgnoreCase;
+ flagsHash[QLatin1Char('m')] = Multiline;
+ }
+ QHash<QChar, int>::const_iterator it;
+ it = flagsHash.constFind(ch);
+ if (it == flagsHash.constEnd())
+ return 0;
+ return it.value();
+}
+
+QString Ecma::RegExp::flagsToString(int flags)
+{
+ QString result;
+ if (flags & Global)
+ result += QLatin1Char('g');
+ if (flags & IgnoreCase)
+ result += QLatin1Char('i');
+ if (flags & Multiline)
+ result += QLatin1Char('m');
+ return result;
+}
+
+NodePool::NodePool(const QString &fileName, Engine *engine)
+ : m_fileName(fileName), m_engine(engine)
+{
+ m_engine->setNodePool(this);
+}
+
+NodePool::~NodePool()
+{
+}
+
+Code *NodePool::createCompiledCode(AST::Node *, CompilationUnit &)
+{
+ Q_ASSERT(0);
+ return 0;
+}
+
+static int toDigit(char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return c - '0';
+ else if ((c >= 'a') && (c <= 'z'))
+ return 10 + c - 'a';
+ else if ((c >= 'A') && (c <= 'Z'))
+ return 10 + c - 'A';
+ return -1;
+}
+
+double integerFromString(const char *buf, int size, int radix)
+{
+ if (size == 0)
+ return qSNaN();
+
+ double sign = 1.0;
+ int i = 0;
+ if (buf[0] == '+') {
+ ++i;
+ } else if (buf[0] == '-') {
+ sign = -1.0;
+ ++i;
+ }
+
+ if (((size-i) >= 2) && (buf[i] == '0')) {
+ if (((buf[i+1] == 'x') || (buf[i+1] == 'X'))
+ && (radix < 34)) {
+ if ((radix != 0) && (radix != 16))
+ return 0;
+ radix = 16;
+ i += 2;
+ } else {
+ if (radix == 0) {
+ radix = 8;
+ ++i;
+ }
+ }
+ } else if (radix == 0) {
+ radix = 10;
+ }
+
+ int j = i;
+ for ( ; i < size; ++i) {
+ int d = toDigit(buf[i]);
+ if ((d == -1) || (d >= radix))
+ break;
+ }
+ double result;
+ if (j == i) {
+ if (!qstrcmp(buf, "Infinity"))
+ result = qInf();
+ else
+ result = qSNaN();
+ } else {
+ result = 0;
+ double multiplier = 1;
+ for (--i ; i >= j; --i, multiplier *= radix)
+ result += toDigit(buf[i]) * multiplier;
+ }
+ result *= sign;
+ return result;
+}
+
+double integerFromString(const QString &str, int radix)
+{
+ QByteArray ba = str.trimmed().toLatin1();
+ return integerFromString(ba.constData(), ba.size(), radix);
+}
+
+
+Engine::Engine()
+ : _lexer(0), _nodePool(0)
+{ }
+
+Engine::~Engine()
+{ }
+
+QSet<NameId> Engine::literals() const
+{ return _literals; }
+
+void Engine::addComment(int pos, int len, int line, int col)
+{ if (len > 0) _comments.append(QDeclarativeJS::AST::SourceLocation(pos, len, line, col)); }
+
+QList<QDeclarativeJS::AST::SourceLocation> Engine::comments() const
+{ return _comments; }
+
+NameId *Engine::intern(const QChar *u, int s)
+{ return const_cast<NameId *>(&*_literals.insert(NameId(u, s))); }
+
+QString Engine::toString(NameId *id)
+{ return id->asString(); }
+
+Lexer *Engine::lexer() const
+{ return _lexer; }
+
+void Engine::setLexer(Lexer *lexer)
+{ _lexer = lexer; }
+
+NodePool *Engine::nodePool() const
+{ return _nodePool; }
+
+void Engine::setNodePool(NodePool *nodePool)
+{ _nodePool = nodePool; }
+
+
+
+} // end of namespace QDeclarativeJS
+
+QT_QML_END_NAMESPACE
diff --git a/src/declarative/qml/parser/qdeclarativejsengine_p.h b/src/declarative/qml/parser/qdeclarativejsengine_p.h
new file mode 100644
index 0000000..61188f7
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsengine_p.h
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEJSENGINE_P_H
+#define QDECLARATIVEJSENGINE_P_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 "qdeclarativejsglobal_p.h"
+#include "qdeclarativejsastfwd_p.h"
+
+#include <QString>
+#include <QSet>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS {
+class QML_PARSER_EXPORT NameId
+{
+ QString _text;
+
+public:
+ NameId(const QChar *u, int s)
+ : _text(u, s)
+ { }
+
+ const QString asString() const
+ { return _text; }
+
+ bool operator == (const NameId &other) const
+ { return _text == other._text; }
+
+ bool operator != (const NameId &other) const
+ { return _text != other._text; }
+
+ bool operator < (const NameId &other) const
+ { return _text < other._text; }
+};
+
+uint qHash(const QDeclarativeJS::NameId &id);
+
+} // end of namespace QDeclarativeJS
+
+#if defined(Q_CC_MSVC) && _MSC_VER <= 1300
+//this ensures that code outside QDeclarativeJS can use the hash function
+//it also a workaround for some compilers
+inline uint qHash(const QDeclarativeJS::NameId &nameId) { return QDeclarativeJS::qHash(nameId); }
+#endif
+
+namespace QDeclarativeJS {
+
+class Lexer;
+class NodePool;
+
+namespace Ecma {
+
+class QML_PARSER_EXPORT RegExp
+{
+public:
+ enum RegExpFlag {
+ Global = 0x01,
+ IgnoreCase = 0x02,
+ Multiline = 0x04
+ };
+
+public:
+ static int flagFromChar(const QChar &);
+ static QString flagsToString(int flags);
+};
+
+} // end of namespace Ecma
+
+class QML_PARSER_EXPORT DiagnosticMessage
+{
+public:
+ enum Kind { Warning, Error };
+
+ DiagnosticMessage()
+ : kind(Error) {}
+
+ DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message)
+ : kind(kind), loc(loc), message(message) {}
+
+ bool isWarning() const
+ { return kind == Warning; }
+
+ bool isError() const
+ { return kind == Error; }
+
+ Kind kind;
+ AST::SourceLocation loc;
+ QString message;
+};
+
+class QML_PARSER_EXPORT Engine
+{
+ Lexer *_lexer;
+ NodePool *_nodePool;
+ QSet<NameId> _literals;
+ QList<QDeclarativeJS::AST::SourceLocation> _comments;
+
+public:
+ Engine();
+ ~Engine();
+
+ QSet<NameId> literals() const;
+
+ void addComment(int pos, int len, int line, int col);
+ QList<QDeclarativeJS::AST::SourceLocation> comments() const;
+
+ NameId *intern(const QChar *u, int s);
+
+ static QString toString(NameId *id);
+
+ Lexer *lexer() const;
+ void setLexer(Lexer *lexer);
+
+ NodePool *nodePool() const;
+ void setNodePool(NodePool *nodePool);
+};
+
+} // end of namespace QDeclarativeJS
+
+QT_QML_END_NAMESPACE
+
+#endif // QDECLARATIVEJSENGINE_P_H
diff --git a/src/declarative/qml/parser/qdeclarativejsglobal_p.h b/src/declarative/qml/parser/qdeclarativejsglobal_p.h
new file mode 100644
index 0000000..7c901ae
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsglobal_p.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QDECLARATIVEJSGLOBAL_P_H
+#define QDECLARATIVEJSGLOBAL_P_H
+
+#include <QtCore/qglobal.h>
+
+#ifdef QT_CREATOR
+# define QT_QML_BEGIN_NAMESPACE
+# define QT_QML_END_NAMESPACE
+
+# ifdef QDECLARATIVEJS_BUILD_DIR
+# define QML_PARSER_EXPORT Q_DECL_EXPORT
+# elif QML_BUILD_STATIC_LIB
+# define QML_PARSER_EXPORT
+# else
+# define QML_PARSER_EXPORT Q_DECL_IMPORT
+# endif // QDECLARATIVEJS_BUILD_DIR
+
+#else // !QT_CREATOR
+# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
+# define QT_QML_END_NAMESPACE QT_END_NAMESPACE
+# define QML_PARSER_EXPORT
+#endif // QT_CREATOR
+
+#endif // QDECLARATIVEJSGLOBAL_P_H
diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
new file mode 100644
index 0000000..aadb432
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
@@ -0,0 +1,939 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This file was generated by qlalr - DO NOT EDIT!
+#include "qdeclarativejsgrammar_p.h"
+
+QT_BEGIN_NAMESPACE
+
+const char *const QDeclarativeJSGrammar::spell [] = {
+ "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ";", "continue",
+ "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===",
+ "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier",
+ "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=",
+ "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=",
+ "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return",
+ ")", ";", 0, "*", "*=", "string literal", "property", "signal", "readonly", "switch",
+ "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^",
+ "^=", "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "comment", "public",
+ "import", "as", 0, 0, 0, 0, 0, 0, 0, 0};
+
+const short QDeclarativeJSGrammar::lhs [] = {
+ 100, 100, 100, 100, 100, 100, 101, 107, 107, 110,
+ 110, 112, 111, 111, 111, 111, 111, 111, 111, 111,
+ 114, 109, 108, 117, 117, 118, 118, 119, 119, 116,
+ 105, 105, 105, 105, 105, 105, 105, 125, 125, 125,
+ 126, 126, 127, 127, 105, 105, 105, 105, 105, 105,
+ 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
+ 105, 105, 115, 115, 115, 115, 130, 130, 130, 130,
+ 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
+ 130, 130, 130, 130, 120, 132, 132, 132, 132, 131,
+ 131, 134, 134, 136, 136, 136, 136, 136, 136, 137,
+ 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
+ 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
+ 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
+ 138, 138, 113, 113, 113, 113, 113, 141, 141, 142,
+ 142, 142, 142, 140, 140, 143, 143, 144, 144, 145,
+ 145, 145, 146, 146, 146, 146, 146, 146, 146, 146,
+ 146, 146, 147, 147, 147, 147, 148, 148, 148, 149,
+ 149, 149, 149, 150, 150, 150, 150, 150, 150, 150,
+ 151, 151, 151, 151, 151, 151, 152, 152, 152, 152,
+ 152, 153, 153, 153, 153, 153, 154, 154, 155, 155,
+ 156, 156, 157, 157, 158, 158, 159, 159, 160, 160,
+ 161, 161, 162, 162, 163, 163, 164, 164, 165, 165,
+ 135, 135, 166, 166, 167, 167, 167, 167, 167, 167,
+ 167, 167, 167, 167, 167, 167, 103, 103, 168, 168,
+ 169, 169, 170, 170, 102, 102, 102, 102, 102, 102,
+ 102, 102, 102, 102, 102, 102, 102, 102, 102, 121,
+ 182, 182, 181, 181, 129, 129, 183, 183, 184, 184,
+ 186, 186, 185, 187, 190, 188, 188, 191, 189, 189,
+ 122, 123, 123, 124, 124, 171, 171, 171, 171, 171,
+ 171, 171, 172, 172, 172, 172, 173, 173, 173, 173,
+ 174, 174, 175, 177, 192, 192, 195, 195, 193, 193,
+ 196, 194, 176, 176, 176, 178, 178, 179, 179, 179,
+ 197, 198, 180, 180, 128, 139, 202, 202, 199, 199,
+ 200, 200, 203, 106, 204, 204, 104, 104, 201, 201,
+ 133, 133, 205};
+
+const short QDeclarativeJSGrammar::rhs [] = {
+ 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
+ 2, 1, 2, 2, 3, 3, 5, 5, 4, 4,
+ 2, 0, 1, 1, 2, 1, 3, 2, 3, 2,
+ 1, 5, 4, 3, 3, 3, 3, 1, 1, 1,
+ 0, 1, 2, 4, 6, 6, 3, 3, 7, 7,
+ 4, 4, 5, 5, 6, 6, 7, 7, 7, 7,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 2, 3, 3, 4,
+ 5, 3, 4, 3, 1, 1, 2, 3, 4, 1,
+ 2, 3, 5, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 4, 3, 5, 1, 2, 4,
+ 4, 4, 3, 0, 1, 1, 3, 1, 1, 1,
+ 2, 2, 1, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 1, 3, 3, 3, 1, 3, 3, 1,
+ 3, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 1, 3, 3, 3, 3, 3, 1, 3, 3, 3,
+ 3, 1, 3, 3, 3, 3, 1, 3, 1, 3,
+ 1, 3, 1, 3, 1, 3, 1, 3, 1, 3,
+ 1, 3, 1, 3, 1, 3, 1, 5, 1, 5,
+ 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 3, 0, 1,
+ 1, 3, 0, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
+ 1, 2, 0, 1, 3, 3, 1, 1, 1, 3,
+ 1, 3, 2, 2, 2, 0, 1, 2, 0, 1,
+ 1, 2, 2, 7, 5, 7, 7, 5, 9, 10,
+ 7, 8, 2, 2, 3, 3, 2, 2, 3, 3,
+ 3, 3, 5, 5, 3, 5, 1, 2, 0, 1,
+ 4, 3, 3, 3, 3, 3, 3, 3, 3, 4,
+ 5, 2, 2, 2, 8, 8, 1, 3, 0, 1,
+ 0, 1, 1, 1, 1, 2, 1, 1, 0, 1,
+ 0, 1, 2};
+
+const short QDeclarativeJSGrammar::action_default [] = {
+ 0, 0, 0, 0, 0, 0, 22, 0, 170, 237,
+ 201, 209, 205, 149, 221, 197, 3, 134, 68, 150,
+ 213, 217, 138, 167, 148, 153, 133, 187, 174, 0,
+ 75, 76, 71, 339, 63, 341, 0, 0, 0, 0,
+ 73, 0, 0, 69, 72, 0, 0, 64, 66, 65,
+ 74, 67, 0, 70, 0, 0, 163, 0, 0, 150,
+ 169, 152, 151, 0, 0, 0, 165, 166, 164, 168,
+ 0, 198, 0, 0, 0, 0, 188, 0, 0, 0,
+ 0, 0, 0, 178, 0, 0, 0, 172, 173, 171,
+ 176, 180, 179, 177, 175, 190, 189, 191, 0, 206,
+ 0, 202, 0, 0, 144, 131, 143, 132, 100, 101,
+ 102, 127, 103, 128, 104, 105, 106, 107, 108, 109,
+ 110, 111, 112, 113, 114, 115, 116, 129, 117, 118,
+ 119, 120, 121, 122, 123, 124, 125, 126, 130, 0,
+ 0, 142, 238, 145, 0, 146, 0, 147, 141, 0,
+ 234, 227, 225, 232, 233, 231, 230, 236, 229, 228,
+ 226, 235, 222, 0, 210, 0, 0, 214, 0, 0,
+ 218, 0, 0, 144, 136, 0, 135, 0, 140, 154,
+ 0, 340, 329, 330, 0, 327, 0, 328, 0, 331,
+ 245, 252, 251, 259, 247, 0, 248, 332, 0, 338,
+ 249, 250, 255, 253, 335, 333, 337, 256, 0, 267,
+ 0, 0, 0, 0, 339, 63, 0, 341, 64, 239,
+ 281, 65, 0, 0, 0, 268, 0, 0, 257, 258,
+ 0, 246, 254, 282, 283, 326, 336, 0, 297, 298,
+ 299, 300, 0, 293, 294, 295, 296, 323, 324, 0,
+ 0, 0, 0, 0, 286, 287, 243, 241, 203, 211,
+ 207, 223, 199, 244, 0, 150, 215, 219, 192, 181,
+ 0, 0, 200, 0, 0, 0, 0, 193, 0, 0,
+ 0, 0, 0, 185, 183, 186, 184, 182, 195, 194,
+ 196, 0, 208, 0, 204, 0, 242, 150, 0, 224,
+ 239, 240, 0, 239, 0, 0, 289, 0, 0, 0,
+ 291, 0, 212, 0, 0, 216, 0, 0, 220, 279,
+ 0, 271, 280, 274, 0, 278, 0, 239, 272, 0,
+ 239, 0, 0, 290, 0, 0, 0, 292, 340, 329,
+ 0, 0, 331, 0, 325, 0, 315, 0, 0, 0,
+ 285, 0, 284, 0, 342, 0, 99, 261, 264, 0,
+ 100, 267, 103, 128, 105, 106, 71, 110, 111, 63,
+ 112, 115, 69, 72, 64, 239, 65, 74, 118, 67,
+ 120, 70, 122, 123, 268, 125, 126, 130, 0, 92,
+ 0, 0, 94, 98, 96, 83, 95, 97, 0, 93,
+ 82, 262, 260, 138, 139, 144, 0, 137, 0, 314,
+ 0, 301, 302, 0, 313, 0, 0, 0, 304, 309,
+ 307, 310, 0, 0, 308, 309, 0, 305, 0, 306,
+ 263, 312, 0, 263, 311, 0, 316, 317, 0, 263,
+ 318, 319, 0, 0, 320, 0, 0, 0, 321, 322,
+ 156, 155, 0, 0, 0, 288, 0, 0, 0, 303,
+ 276, 269, 0, 277, 273, 0, 275, 265, 0, 266,
+ 270, 86, 0, 0, 90, 77, 0, 79, 88, 0,
+ 80, 89, 91, 81, 87, 78, 0, 84, 160, 158,
+ 162, 159, 157, 161, 6, 334, 4, 2, 61, 85,
+ 0, 0, 64, 66, 65, 31, 5, 0, 62, 0,
+ 40, 39, 38, 0, 0, 53, 0, 54, 0, 59,
+ 60, 0, 40, 0, 0, 0, 0, 0, 49, 50,
+ 0, 51, 0, 52, 0, 55, 56, 0, 0, 0,
+ 0, 0, 57, 58, 0, 47, 41, 48, 42, 0,
+ 0, 0, 0, 44, 0, 45, 46, 43, 0, 0,
+ 30, 34, 35, 36, 37, 138, 263, 0, 0, 100,
+ 267, 103, 128, 105, 106, 71, 110, 111, 63, 112,
+ 115, 69, 72, 64, 239, 65, 74, 118, 67, 120,
+ 70, 122, 123, 268, 125, 126, 130, 138, 0, 26,
+ 0, 0, 32, 27, 33, 28, 24, 0, 29, 25,
+ 8, 0, 10, 0, 9, 0, 1, 21, 12, 0,
+ 13, 0, 14, 0, 19, 20, 0, 15, 16, 0,
+ 17, 18, 11, 23, 7, 343};
+
+const short QDeclarativeJSGrammar::goto_default [] = {
+ 7, 616, 206, 195, 204, 506, 494, 615, 634, 610,
+ 614, 612, 617, 22, 613, 18, 505, 607, 598, 560,
+ 507, 190, 194, 196, 200, 523, 549, 548, 199, 231,
+ 26, 473, 472, 355, 354, 9, 353, 356, 106, 17,
+ 144, 24, 13, 143, 19, 25, 56, 23, 8, 28,
+ 27, 268, 15, 262, 10, 258, 12, 260, 11, 259,
+ 20, 266, 21, 267, 14, 261, 257, 298, 410, 263,
+ 264, 201, 192, 191, 203, 232, 202, 207, 228, 229,
+ 193, 359, 358, 230, 462, 461, 320, 321, 464, 323,
+ 463, 322, 418, 422, 425, 421, 420, 440, 441, 184,
+ 198, 180, 183, 197, 205, 0};
+
+const short QDeclarativeJSGrammar::action_index [] = {
+ 439, 1109, 2228, 2228, 2132, 814, -74, 18, 147, -100,
+ 31, -17, -49, 232, -100, 318, 85, -100, -100, 554,
+ 33, 94, 331, 215, -100, -100, -100, 448, 231, 1109,
+ -100, -100, -100, 320, -100, 1940, 1472, 1109, 1109, 1109,
+ -100, 724, 1109, -100, -100, 1109, 1109, -100, -100, -100,
+ -100, -100, 1109, -100, 1109, 1109, -100, 1109, 1109, 129,
+ 157, -100, -100, 1109, 1109, 1109, -100, -100, -100, 200,
+ 1109, 293, 1109, 1109, 1109, 1109, 466, 1109, 1109, 1109,
+ 1109, 1109, 1109, 179, 1109, 1109, 1109, 119, 125, 95,
+ 188, 198, 184, 203, 178, 567, 567, 484, 1109, -5,
+ 1109, 67, 1844, 1109, 1109, -100, -100, -100, -100, -100,
+ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
+ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
+ -100, -100, -100, -100, -100, -100, -100, -100, -100, 110,
+ 1109, -100, -100, 70, 61, -100, 1109, -100, -100, 1109,
+ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
+ -100, -100, -100, 1109, 55, 1109, 1109, 73, 63, 1109,
+ -100, 1844, 1109, 1109, -100, 141, -100, 41, -100, -100,
+ 87, -100, 255, 80, 78, -100, 287, -100, 83, 2228,
+ -100, -100, -100, -100, -100, 225, -100, -100, 52, -100,
+ -100, -100, -100, -100, -100, 2228, -100, -100, 420, -100,
+ 408, 113, 2132, 50, 330, 65, 46, 2420, 72, 1109,
+ -100, 74, 75, 1109, 77, -100, 53, 56, -100, -100,
+ 323, -100, -100, -100, -100, -100, -100, 96, -100, -100,
+ -100, -100, 99, -100, -100, -100, -100, -100, -100, 60,
+ 47, 1109, 118, 93, -100, -100, 1291, -100, 79, 66,
+ 64, -100, 413, 76, 51, 664, 89, 97, 393, 183,
+ 337, 1109, 413, 1109, 1109, 1109, 1109, 411, 1109, 1109,
+ 1109, 1109, 1109, 252, 272, 212, 217, 221, 490, 490,
+ 383, 1109, 64, 1109, 84, 1109, -100, 536, 1109, -100,
+ 1109, 69, 68, 1109, 44, 2132, -100, 1109, 124, 2132,
+ -100, 1109, 54, 1109, 1109, 71, 88, 1109, -100, 82,
+ 122, 154, -100, -100, 1109, -100, 343, 1109, -100, 81,
+ 1109, 90, 2132, -100, 1109, 112, 2132, -100, 86, 333,
+ -39, -10, 2228, -33, -100, 2132, -100, 1109, 246, 2132,
+ 4, 2132, -100, 10, 16, -21, -100, -100, 2132, -26,
+ 480, 19, 462, 128, 1109, 2132, 6, -9, 400, 8,
+ -22, 840, -3, -6, -100, 1202, -100, -7, -28, 5,
+ 1109, 2, -23, 1109, 0, 1109, -34, -30, 1109, -100,
+ 2036, 21, -100, -100, -100, -100, -100, -100, 1109, -100,
+ -100, -100, -100, 209, -100, 1109, 40, -100, 2132, -100,
+ 101, -100, -100, 2132, -100, 1109, 120, 43, -100, 62,
+ -100, 59, 109, 1109, -100, 57, 58, -100, 39, -100,
+ 2132, -100, 117, 2132, -100, 199, -100, -100, 107, 2132,
+ 34, -100, 24, 11, -100, 346, -19, 14, -100, -100,
+ -100, -100, 1109, 133, 2132, -100, 1109, 126, 2132, -100,
+ 20, -100, 173, -100, -100, 1109, -100, -100, 303, -100,
+ -100, -100, 100, 1656, -100, -100, 1564, -100, -100, 1748,
+ -100, -100, -100, -100, -100, -100, 131, -100, -100, -100,
+ -100, -100, -100, -100, -100, 2228, -100, -100, -100, 158,
+ -20, 752, 165, -16, 22, -100, -100, 98, -100, 189,
+ -100, -100, -100, 28, 170, -100, 1109, -100, 230, -100,
+ -100, 247, 1, 13, 238, 37, -24, 106, -100, -100,
+ 273, -100, 1109, -100, 265, -100, -100, 242, -4, 12,
+ 1109, 241, -100, -100, 234, -100, 245, -100, 3, 9,
+ 311, 190, 316, -100, 134, -100, -100, -100, 1380, 1020,
+ -100, -100, -100, -100, -100, 359, 2324, 1472, 15, 444,
+ 38, 394, 138, 1109, 2132, 36, 17, 397, 42, 23,
+ 840, 32, 29, -100, 1202, -100, 26, 35, 48, 1109,
+ 45, 25, 1109, 49, 1109, 27, 30, 314, 132, -100,
+ 7, 752, -100, -100, -100, -100, -100, 930, -100, -100,
+ -100, 752, -100, 253, -87, 617, -100, -100, 102, 290,
+ -100, 191, -100, 140, -100, -100, 275, -100, -100, 91,
+ -100, -100, -100, -100, -100, -100,
+
+ -106, 12, -87, 18, 17, 212, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -53,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, 162,
+ -106, -106, -106, -4, -106, -106, -11, 24, 75, 76,
+ -106, 83, 55, -106, -106, 157, 158, -106, -106, -106,
+ -106, -106, 150, -106, 172, 176, -106, 168, 167, -106,
+ -106, -106, -106, 173, 154, 115, -106, -106, -106, -106,
+ 147, -106, 121, 113, 112, 125, -106, 128, 143, 146,
+ 140, 139, 136, -106, 122, 138, 130, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, 149, -106,
+ 153, -106, 110, 82, 46, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ 35, -106, -106, -106, -106, -106, 37, -106, -106, 45,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, 92, -106, 88, 58, -106, -106, 51,
+ -106, 209, 72, 78, -106, -106, -106, -106, -106, -106,
+ -106, -106, 27, -106, -106, -106, 63, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, 50, -106, -106, 28, -106,
+ 29, -106, 47, -106, 33, -106, -106, 66, -106, 73,
+ -106, -106, -106, 81, 53, -106, -106, -106, -106, -106,
+ -13, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, 9, -106, -106, -106, -106, 111, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ 3, 186, -106, 220, 228, 234, 204, -106, 90, 91,
+ 94, 97, 93, -106, -106, -106, -106, -106, -106, -106,
+ -106, 210, -106, 187, -106, 214, -106, -106, 208, -106,
+ 207, -106, -106, 155, -106, 8, -106, 4, -106, -1,
+ -106, 217, -106, 177, 185, -106, -106, 184, -106, -106,
+ -106, -106, -106, -106, 183, -106, 194, 105, -106, -106,
+ 99, -106, 71, -106, 74, -106, 65, -106, -106, 114,
+ -106, -106, -55, -106, -106, 64, -106, 44, -106, 30,
+ -106, 31, -106, -106, -106, -106, -106, -106, 57, -106,
+ 36, -106, 40, -106, 70, 59, -106, -106, 42, -106,
+ -106, 104, -106, -106, -106, 38, -106, -106, -106, -106,
+ 79, -106, 69, 108, -106, 84, -106, -106, 56, -106,
+ 68, -106, -106, -106, -106, -106, -106, -106, 52, -106,
+ -106, -106, -106, -106, -106, 109, -106, -106, 77, -106,
+ -106, -106, -106, 86, -106, 80, -106, -106, -106, -106,
+ -106, -59, -106, 43, -106, -63, -106, -106, -106, -106,
+ 98, -106, -106, 95, -106, -106, -106, -106, -106, 60,
+ -34, -106, -106, 32, -106, 41, -106, 39, -106, -106,
+ -106, -106, 49, -106, 61, -106, 62, -106, 48, -106,
+ -106, -106, -106, -106, -106, 23, -106, -106, 96, -106,
+ -106, -106, -106, 34, -106, -106, 133, -106, -106, 54,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, 67, -106, -106, -106, -106,
+ -106, 22, -106, -106, -106, -106, -106, -106, -106, -22,
+ -106, -106, -106, -106, -106, -106, 2, -106, -106, -106,
+ -106, -106, -106, -106, -19, -106, -106, -106, -106, -106,
+ -106, -106, 100, -106, -106, -106, -106, -21, -106, -106,
+ -3, -106, -106, -106, -106, -106, 13, -106, -106, -106,
+ 11, 14, 10, -106, -106, -106, -106, -106, 279, 283,
+ -106, -106, -106, -106, -106, -106, 19, 273, 15, 16,
+ -106, 21, -106, 224, 6, -106, -106, 25, -106, -106,
+ 85, -106, -106, -106, 26, -106, -106, -106, -106, 20,
+ -106, 7, 87, -106, 107, -106, -106, -106, -106, -106,
+ -106, 317, -106, -106, -106, -106, -106, 277, -106, -106,
+ -106, 0, -106, -106, -2, 271, -106, -106, -106, 1,
+ -106, -106, -106, -106, -106, -106, 5, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106};
+
+const short QDeclarativeJSGrammar::action_info [] = {
+ -97, -98, 452, 611, -116, 527, 456, -124, 415, -121,
+ 439, 551, -119, -108, 347, -94, 611, 388, 635, 540,
+ 351, 341, 344, 342, 390, 539, -127, 256, 398, 402,
+ 100, 98, 70, -97, 400, 163, -98, 465, 524, -116,
+ 559, 447, 530, -108, 439, -127, 509, 439, 559, -94,
+ 537, 544, -121, 256, 443, -119, -124, 514, 439, 347,
+ 445, 526, 423, 452, 423, 430, 456, 423, 70, 554,
+ 169, 415, 345, 311, 100, 163, 419, 140, 146, 408,
+ 271, 413, 347, 251, 295, 271, 256, 0, 186, 452,
+ 0, 311, 456, 140, 429, 317, 0, 0, 0, 324,
+ 407, 178, 291, 98, 305, 558, 0, 235, 476, 0,
+ 439, 415, 300, 442, 291, 0, 189, 171, 140, 426,
+ 140, 148, 339, 182, 433, 140, 140, 443, 140, 303,
+ 326, 559, 140, 0, 140, 57, 172, 250, 188, 140,
+ 601, 140, 330, 293, 165, 0, 58, 313, 166, 140,
+ 332, 314, 631, 630, 255, 254, 477, 241, 240, 57,
+ 246, 245, 412, 411, 427, 57, 141, 529, 528, 63,
+ 58, 61, 336, 171, 248, 247, 58, 516, 253, 0,
+ 417, 468, 62, 327, 309, 334, 458, 57, 602, 248,
+ 247, 487, 172, 454, 522, 556, 555, 176, 58, 248,
+ 247, 625, 624, 84, 84, 85, 85, 140, 84, 84,
+ 85, 85, 63, 84, 64, 85, 86, 86, 510, 510,
+ 65, 86, 86, 84, 171, 85, 86, 63, 84, 0,
+ 85, 517, 515, 140, 469, 467, 86, 84, 140, 85,
+ 512, 86, 84, 172, 85, 405, 84, 102, 85, 140,
+ 86, 511, 628, 627, 140, 86, 84, 64, 85, 86,
+ 437, 436, 171, 65, 512, 512, 103, 510, 104, 86,
+ 546, 510, 64, 140, 510, 511, 511, 84, 65, 85,
+ 532, 172, 626, 405, 34, 0, 234, 233, 0, 0,
+ 86, 520, 519, 0, 0, 547, 545, 84, 0, 85,
+ 621, 0, 543, 542, 34, 0, 349, 0, 0, 0,
+ 86, 72, 73, 512, 622, 620, 34, 512, 0, 34,
+ 512, 47, 49, 48, 511, 0, 536, 535, 511, 171,
+ 0, 511, 34, 0, 533, 531, 72, 73, 74, 75,
+ 34, 47, 49, 48, 619, 34, 171, -85, 172, 34,
+ 173, 0, 34, 47, 49, 48, 47, 49, 48, 34,
+ 0, 0, 34, 74, 75, 172, 34, 173, 0, 47,
+ 49, 48, 34, 0, 171, 34, 0, 47, 49, 48,
+ 0, 0, 47, 49, 48, 0, 47, 49, 48, 47,
+ 49, 48, -85, 172, 0, 173, 47, 49, 48, 47,
+ 49, 48, 0, 47, 49, 48, 278, 279, 0, 47,
+ 49, 48, 47, 49, 48, 280, 278, 279, 281, 0,
+ 282, 0, 0, 34, 0, 280, 34, 0, 281, 34,
+ 282, 273, 274, -339, 278, 279, -339, 34, 0, 0,
+ 0, 0, 0, 280, 0, 0, 281, 0, 282, 34,
+ 0, 0, 0, 0, 0, 244, 243, 0, 275, 276,
+ 47, 49, 48, 47, 49, 48, 47, 49, 48, 244,
+ 243, 77, 78, 34, 47, 49, 48, 0, 0, 79,
+ 80, 239, 238, 81, 0, 82, 47, 49, 48, 77,
+ 78, 34, 0, 0, 0, 0, 0, 79, 80, 0,
+ 0, 81, 0, 82, 0, 239, 238, 77, 78, 34,
+ 47, 49, 48, 278, 279, 79, 80, 0, 0, 81,
+ 0, 82, 280, 244, 243, 281, 0, 282, 47, 49,
+ 48, 6, 5, 4, 1, 3, 2, 0, 0, 150,
+ 0, 239, 238, 0, 0, 0, 47, 49, 48, 151,
+ 0, 0, 0, 152, 0, 0, 0, 150, 0, 0,
+ 0, 0, 153, 0, 154, 0, 0, 151, 0, 0,
+ 0, 152, 0, 0, 0, 155, 0, 156, 61, 0,
+ 153, 0, 154, 0, 0, 157, 0, 0, 158, 62,
+ 77, 78, 0, 155, 159, 156, 61, 0, 79, 80,
+ 160, 0, 81, 157, 82, 0, 158, 62, 0, 0,
+ 0, 0, 159, 0, 0, 0, 161, 0, 160, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 30,
+ 31, 0, 0, 0, 161, 0, 0, 0, 0, 33,
+ 0, 0, 0, 0, 0, 0, 34, 0, 0, 0,
+ 35, 36, 0, 37, 0, 0, 0, 0, 0, 0,
+ 501, 0, 0, 0, 44, 0, 0, 150, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 151, 0, 0,
+ 0, 152, 50, 47, 49, 48, 0, 51, 0, 0,
+ 153, 0, 154, 0, 0, 307, 0, 0, 43, 53,
+ 32, 0, 0, 155, 40, 156, 61, 0, 0, 0,
+ 0, 0, 0, 157, 0, 0, 158, 62, 0, 0,
+ 0, 0, 159, 0, 0, 0, 0, 0, 160, 0,
+ 0, 0, 0, 0, 0, 0, 30, 31, 0, 0,
+ 0, 0, 0, 0, 161, 0, 33, 0, 0, 0,
+ 0, 0, 0, 34, 0, 0, 0, 35, 36, 0,
+ 37, 0, 0, 0, 30, 31, 0, 41, 0, 0,
+ 0, 44, 0, 0, 33, 0, 0, 0, 0, 0,
+ 0, 34, 0, 0, 0, 35, 36, 0, 37, 50,
+ 47, 49, 48, 0, 51, 501, 0, 0, 0, 44,
+ 0, 0, 0, 0, 0, 43, 53, 32, 0, 0,
+ 0, 40, 0, 0, 0, 0, 0, 50, 47, 49,
+ 48, 0, 51, 0, 500, 0, 30, 31, 0, 0,
+ 0, 0, 0, 43, 53, 32, 214, 0, 0, 40,
+ 0, 0, 0, 34, 0, 0, 0, 35, 36, 0,
+ 37, 0, 30, 31, 0, 0, 0, 501, 0, 0,
+ 0, 44, 33, 0, 0, 0, 0, 0, 0, 34,
+ 0, 0, 0, 35, 36, 0, 37, 0, 0, 50,
+ 502, 504, 503, 41, 51, 0, 0, 44, 0, 225,
+ 0, 0, 0, 0, 0, 43, 53, 32, 209, 0,
+ 0, 40, 0, 0, 0, 50, 47, 49, 48, 0,
+ 51, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 43, 53, 32, 0, 0, 0, 40, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 500, 0, 30, 31, 0, 0, 0, 0, 0, 0,
+ 0, 0, 214, 0, 0, 0, 0, 0, 0, 34,
+ 0, 0, 0, 35, 36, 0, 37, 0, 0, 0,
+ 0, 0, 0, 501, 0, 0, 0, 44, 0, 0,
+ 0, 0, 0, 0, 0, 608, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 50, 502, 504, 503, 0,
+ 51, 0, 0, 0, 0, 225, 0, 0, 0, 0,
+ 0, 43, 53, 32, 209, 0, 0, 40, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 500, 0, 30, 31, 0, 0, 0, 0, 0, 0,
+ 0, 0, 214, 0, 0, 0, 0, 0, 0, 34,
+ 0, 0, 0, 35, 36, 0, 37, 0, 0, 0,
+ 0, 0, 0, 501, 0, 0, 0, 44, 0, 0,
+ 0, 0, 0, 0, 0, 605, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 50, 502, 504, 503, 0,
+ 51, 0, 0, 0, 0, 225, 0, 0, 0, 0,
+ 0, 43, 53, 32, 209, 0, 0, 40, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 29, 30, 31, 0, 0, 0, 0, 0, 0, 0,
+ 0, 33, 0, 0, 0, 0, 0, 0, 34, 0,
+ 0, 0, 35, 36, 0, 37, 0, 0, 0, 38,
+ 0, 39, 41, 42, 0, 0, 44, 0, 0, 0,
+ 45, 0, 46, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 50, 47, 49, 48, 0, 51,
+ 0, 52, 0, 54, 0, 55, 0, 0, 0, 0,
+ 43, 53, 32, 0, 0, 0, 40, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, -117,
+ 0, 0, 0, 29, 30, 31, 0, 0, 0, 0,
+ 0, 0, 0, 0, 33, 0, 0, 0, 0, 0,
+ 0, 34, 0, 0, 0, 35, 36, 0, 37, 0,
+ 0, 0, 38, 0, 39, 41, 42, 0, 0, 44,
+ 0, 0, 0, 45, 0, 46, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 50, 47, 49,
+ 48, 0, 51, 0, 52, 0, 54, 0, 55, 0,
+ 0, 0, 0, 43, 53, 32, 0, 0, 0, 40,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 29, 30, 31, 0, 0, 0, 0, 0,
+ 0, 0, 0, 33, 0, 0, 0, 0, 0, 0,
+ 34, 0, 0, 0, 35, 36, 0, 37, 0, 0,
+ 0, 38, 0, 39, 41, 42, 0, 0, 44, 0,
+ 0, 0, 45, 0, 46, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 50, 47, 49, 48,
+ 0, 51, 0, 52, 0, 54, 270, 55, 0, 0,
+ 0, 0, 43, 53, 32, 0, 0, 0, 40, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 29, 30, 31, 0, 0, 0, 0, 0, 0,
+ 0, 0, 33, 0, 0, 0, 0, 0, 0, 34,
+ 216, 0, 0, 566, 567, 0, 37, 0, 0, 0,
+ 38, 0, 39, 41, 42, 0, 0, 44, 0, 0,
+ 0, 45, 0, 46, 0, 0, 0, 0, 0, 0,
+ 0, 220, 0, 0, 0, 50, 47, 49, 48, 0,
+ 51, 0, 52, 0, 54, 0, 55, 0, 0, 0,
+ 0, 43, 53, 32, 0, 0, 0, 40, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 474, 0, 0, 29, 30, 31, 0, 0, 0, 0,
+ 0, 0, 0, 0, 33, 0, 0, 0, 0, 0,
+ 0, 34, 0, 0, 0, 35, 36, 0, 37, 0,
+ 0, 0, 38, 0, 39, 41, 42, 0, 0, 44,
+ 0, 0, 0, 45, 0, 46, 0, 0, 475, 0,
+ 0, 0, 0, 0, 0, 0, 0, 50, 47, 49,
+ 48, 0, 51, 0, 52, 0, 54, 0, 55, 0,
+ 0, 0, 0, 43, 53, 32, 0, 0, 0, 40,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 474, 0, 0, 29, 30, 31, 0, 0,
+ 0, 0, 0, 0, 0, 0, 33, 0, 0, 0,
+ 0, 0, 0, 34, 0, 0, 0, 35, 36, 0,
+ 37, 0, 0, 0, 38, 0, 39, 41, 42, 0,
+ 0, 44, 0, 0, 0, 45, 0, 46, 0, 0,
+ 480, 0, 0, 0, 0, 0, 0, 0, 0, 50,
+ 47, 49, 48, 0, 51, 0, 52, 0, 54, 0,
+ 55, 0, 0, 0, 0, 43, 53, 32, 0, 0,
+ 0, 40, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 482, 0, 0, 29, 30, 31,
+ 0, 0, 0, 0, 0, 0, 0, 0, 33, 0,
+ 0, 0, 0, 0, 0, 34, 0, 0, 0, 35,
+ 36, 0, 37, 0, 0, 0, 38, 0, 39, 41,
+ 42, 0, 0, 44, 0, 0, 0, 45, 0, 46,
+ 0, 0, 485, 0, 0, 0, 0, 0, 0, 0,
+ 0, 50, 47, 49, 48, 0, 51, 0, 52, 0,
+ 54, 0, 55, 0, 0, 0, 0, 43, 53, 32,
+ 0, 0, 0, 40, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 482, 0, 0, 29,
+ 30, 31, 0, 0, 0, 0, 0, 0, 0, 0,
+ 33, 0, 0, 0, 0, 0, 0, 34, 0, 0,
+ 0, 35, 36, 0, 37, 0, 0, 0, 38, 0,
+ 39, 41, 42, 0, 0, 44, 0, 0, 0, 45,
+ 0, 46, 0, 0, 483, 0, 0, 0, 0, 0,
+ 0, 0, 0, 50, 47, 49, 48, 0, 51, 0,
+ 52, 0, 54, 0, 55, 0, 0, 0, 0, 43,
+ 53, 32, 0, 0, 0, 40, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 108, 109,
+ 110, 0, 0, 112, 114, 115, 0, 0, 116, 0,
+ 117, 0, 0, 0, 119, 120, 121, 0, 0, 0,
+ 0, 0, 0, 34, 122, 123, 124, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 125, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 128, 0, 0, 0, 0, 0, 0,
+ 47, 49, 48, 129, 130, 131, 0, 133, 134, 135,
+ 136, 137, 138, 0, 0, 126, 132, 118, 111, 113,
+ 127, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 108, 109, 110, 0, 0, 112,
+ 114, 115, 0, 0, 116, 0, 117, 0, 0, 0,
+ 119, 120, 121, 0, 0, 0, 0, 0, 0, 392,
+ 122, 123, 124, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 125, 0, 0, 0, 393, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 128,
+ 0, 0, 0, 0, 0, 397, 394, 396, 0, 129,
+ 130, 131, 0, 133, 134, 135, 136, 137, 138, 0,
+ 0, 126, 132, 118, 111, 113, 127, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 108, 109, 110, 0, 0, 112, 114, 115, 0, 0,
+ 116, 0, 117, 0, 0, 0, 119, 120, 121, 0,
+ 0, 0, 0, 0, 0, 392, 122, 123, 124, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 125,
+ 0, 0, 0, 393, 0, 0, 0, 0, 0, 0,
+ 0, 395, 0, 0, 0, 128, 0, 0, 0, 0,
+ 0, 397, 394, 396, 0, 129, 130, 131, 0, 133,
+ 134, 135, 136, 137, 138, 0, 0, 126, 132, 118,
+ 111, 113, 127, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 208, 0, 0, 0,
+ 0, 210, 0, 29, 30, 31, 212, 0, 0, 0,
+ 0, 0, 0, 213, 33, 0, 0, 0, 0, 0,
+ 0, 215, 216, 0, 0, 217, 36, 0, 37, 0,
+ 0, 0, 38, 0, 39, 41, 42, 0, 0, 44,
+ 0, 0, 0, 45, 0, 46, 0, 0, 0, 0,
+ 0, 219, 0, 220, 0, 0, 0, 50, 218, 221,
+ 48, 222, 51, 223, 52, 224, 54, 225, 55, 226,
+ 227, 0, 0, 43, 53, 32, 209, 211, 0, 40,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 208, 0, 0, 0, 0, 210, 0, 29,
+ 30, 31, 212, 0, 0, 0, 0, 0, 0, 213,
+ 214, 0, 0, 0, 0, 0, 0, 215, 216, 0,
+ 0, 217, 36, 0, 37, 0, 0, 0, 38, 0,
+ 39, 41, 42, 0, 0, 44, 0, 0, 0, 45,
+ 0, 46, 0, 0, 0, 0, 0, 219, 0, 220,
+ 0, 0, 0, 50, 218, 221, 48, 222, 51, 223,
+ 52, 224, 54, 225, 55, 226, 227, 0, 0, 43,
+ 53, 32, 209, 211, 0, 40, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 569, 109,
+ 110, 0, 0, 571, 114, 573, 30, 31, 574, 0,
+ 117, 0, 0, 0, 119, 576, 577, 0, 0, 0,
+ 0, 0, 0, 578, 579, 123, 124, 217, 36, 0,
+ 37, 0, 0, 0, 38, 0, 39, 580, 42, 0,
+ 0, 582, 0, 0, 0, 45, 0, 46, 0, 0,
+ 0, 0, 0, 584, 0, 220, 0, 0, 0, 586,
+ 583, 585, 48, 587, 588, 589, 52, 591, 592, 593,
+ 594, 595, 596, 0, 0, 581, 590, 575, 570, 572,
+ 127, 40, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 360, 109, 110, 0, 0, 362,
+ 114, 364, 30, 31, 365, 0, 117, 0, 0, 0,
+ 119, 367, 368, 0, 0, 0, 0, 0, 0, 369,
+ 370, 123, 124, 217, 36, 0, 37, 0, 0, 0,
+ 38, 0, 39, 371, 42, 0, 0, 373, 0, 0,
+ 0, 45, 0, 46, 0, -263, 0, 0, 0, 375,
+ 0, 220, 0, 0, 0, 377, 374, 376, 48, 378,
+ 379, 380, 52, 382, 383, 384, 385, 386, 387, 0,
+ 0, 372, 381, 366, 361, 363, 127, 40, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 541, 310, 460, 513, 538, 518, 525, 308, 249, 632,
+ 306, 181, 252, 618, 149, 16, 623, 495, 319, 497,
+ 629, 357, 496, 435, 471, 553, 557, 486, 438, 301,
+ 428, 237, 350, 352, 604, 521, 242, 424, 550, 552,
+ 181, 301, 185, 237, 242, 343, 432, 348, 338, 249,
+ 459, 237, 453, 449, 236, 242, 446, 181, 466, 401,
+ 448, 249, 357, 455, 444, 457, 346, 337, 357, 484,
+ 142, 236, 147, 333, 438, 175, 301, 335, 187, 409,
+ 162, 145, 435, 416, 435, 139, 170, 399, 414, 481,
+ 438, 389, 0, 168, 0, 0, 403, 357, 403, 59,
+ 357, 490, 301, 534, 391, 0, 0, 0, 301, 0,
+ 0, 460, 0, 145, 59, 0, 179, 403, 177, 59,
+ 59, 488, 489, 0, 404, 105, 404, 0, 59, 185,
+ 451, 59, 59, 450, 59, 59, 59, 59, 59, 283,
+ 284, 59, 287, 285, 145, 404, 286, 107, 167, 406,
+ 164, 59, 59, 451, 450, 265, 59, 59, 301, 59,
+ 269, 68, 96, 95, 479, 59, 59, 331, 478, 59,
+ 87, 76, 59, 329, 59, 97, 434, 83, 89, 431,
+ 59, 470, 59, 59, 59, 94, 88, 59, 93, 92,
+ 59, 59, 90, 59, 59, 91, 493, 59, 59, 71,
+ 67, 59, 59, 491, 492, 99, 59, 101, 179, 319,
+ 301, 59, 59, 340, 69, 60, 59, 59, 450, 66,
+ 59, 59, 451, 304, 105, 499, 269, 297, 297, 297,
+ 59, 59, 269, 269, 269, 269, 269, 0, 315, 272,
+ 498, 508, 294, 0, 0, 0, 107, 174, 59, 325,
+ 318, 316, 297, 269, 59, 290, 0, 269, 297, 269,
+ 0, 59, 0, 269, 59, 0, 269, 292, 59, 269,
+ 179, 277, 59, 0, 299, 302, 312, 269, 59, 288,
+ 296, 328, 609, 269, 499, 289, 597, 633, 606, 599,
+ 499, 600, 565, 600, 0, 0, 499, 0, 0, 568,
+ 561, 562, 563, 564, 0, 498, 508, 0, 471, 0,
+ 0, 498, 508, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 499, 0, 0, 603, 0, 0, 0, 600, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0};
+
+const short QDeclarativeJSGrammar::action_check [] = {
+ 7, 7, 36, 90, 7, 29, 36, 7, 36, 7,
+ 33, 8, 7, 7, 36, 7, 90, 7, 0, 7,
+ 16, 60, 55, 33, 8, 29, 7, 36, 7, 55,
+ 79, 48, 1, 7, 55, 2, 7, 17, 37, 7,
+ 33, 60, 29, 7, 33, 7, 66, 33, 33, 7,
+ 66, 29, 7, 36, 20, 7, 7, 29, 33, 36,
+ 36, 24, 5, 36, 5, 7, 36, 5, 1, 60,
+ 7, 36, 7, 2, 79, 2, 33, 8, 8, 7,
+ 1, 7, 36, 36, 8, 1, 36, -1, 8, 36,
+ -1, 2, 36, 8, 55, 7, -1, -1, -1, 17,
+ 60, 60, 48, 48, 60, 7, -1, 55, 8, -1,
+ 33, 36, 61, 6, 48, -1, 33, 15, 8, 10,
+ 8, 60, 36, 36, 7, 8, 8, 20, 8, 61,
+ 8, 33, 8, -1, 8, 40, 34, 77, 60, 8,
+ 8, 8, 61, 79, 50, -1, 51, 50, 54, 8,
+ 60, 54, 61, 62, 61, 62, 56, 61, 62, 40,
+ 61, 62, 61, 62, 55, 40, 56, 61, 62, 12,
+ 51, 42, 60, 15, 61, 62, 51, 7, 60, -1,
+ 60, 8, 53, 61, 60, 31, 60, 40, 56, 61,
+ 62, 60, 34, 60, 29, 61, 62, 56, 51, 61,
+ 62, 61, 62, 25, 25, 27, 27, 8, 25, 25,
+ 27, 27, 12, 25, 57, 27, 38, 38, 29, 29,
+ 63, 38, 38, 25, 15, 27, 38, 12, 25, -1,
+ 27, 61, 62, 8, 61, 62, 38, 25, 8, 27,
+ 75, 38, 25, 34, 27, 36, 25, 15, 27, 8,
+ 38, 86, 61, 62, 8, 38, 25, 57, 27, 38,
+ 61, 62, 15, 63, 75, 75, 34, 29, 36, 38,
+ 36, 29, 57, 8, 29, 86, 86, 25, 63, 27,
+ 7, 34, 91, 36, 29, -1, 61, 62, -1, -1,
+ 38, 61, 62, -1, -1, 61, 62, 25, -1, 27,
+ 47, -1, 61, 62, 29, -1, 60, -1, -1, -1,
+ 38, 18, 19, 75, 61, 62, 29, 75, -1, 29,
+ 75, 66, 67, 68, 86, -1, 61, 62, 86, 15,
+ -1, 86, 29, -1, 61, 62, 18, 19, 45, 46,
+ 29, 66, 67, 68, 91, 29, 15, 33, 34, 29,
+ 36, -1, 29, 66, 67, 68, 66, 67, 68, 29,
+ -1, -1, 29, 45, 46, 34, 29, 36, -1, 66,
+ 67, 68, 29, -1, 15, 29, -1, 66, 67, 68,
+ -1, -1, 66, 67, 68, -1, 66, 67, 68, 66,
+ 67, 68, 33, 34, -1, 36, 66, 67, 68, 66,
+ 67, 68, -1, 66, 67, 68, 23, 24, -1, 66,
+ 67, 68, 66, 67, 68, 32, 23, 24, 35, -1,
+ 37, -1, -1, 29, -1, 32, 29, -1, 35, 29,
+ 37, 18, 19, 36, 23, 24, 36, 29, -1, -1,
+ -1, -1, -1, 32, -1, -1, 35, -1, 37, 29,
+ -1, -1, -1, -1, -1, 61, 62, -1, 45, 46,
+ 66, 67, 68, 66, 67, 68, 66, 67, 68, 61,
+ 62, 23, 24, 29, 66, 67, 68, -1, -1, 31,
+ 32, 61, 62, 35, -1, 37, 66, 67, 68, 23,
+ 24, 29, -1, -1, -1, -1, -1, 31, 32, -1,
+ -1, 35, -1, 37, -1, 61, 62, 23, 24, 29,
+ 66, 67, 68, 23, 24, 31, 32, -1, -1, 35,
+ -1, 37, 32, 61, 62, 35, -1, 37, 66, 67,
+ 68, 92, 93, 94, 95, 96, 97, -1, -1, 3,
+ -1, 61, 62, -1, -1, -1, 66, 67, 68, 13,
+ -1, -1, -1, 17, -1, -1, -1, 3, -1, -1,
+ -1, -1, 26, -1, 28, -1, -1, 13, -1, -1,
+ -1, 17, -1, -1, -1, 39, -1, 41, 42, -1,
+ 26, -1, 28, -1, -1, 49, -1, -1, 52, 53,
+ 23, 24, -1, 39, 58, 41, 42, -1, 31, 32,
+ 64, -1, 35, 49, 37, -1, 52, 53, -1, -1,
+ -1, -1, 58, -1, -1, -1, 80, -1, 64, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 12,
+ 13, -1, -1, -1, 80, -1, -1, -1, -1, 22,
+ -1, -1, -1, -1, -1, -1, 29, -1, -1, -1,
+ 33, 34, -1, 36, -1, -1, -1, -1, -1, -1,
+ 43, -1, -1, -1, 47, -1, -1, 3, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 13, -1, -1,
+ -1, 17, 65, 66, 67, 68, -1, 70, -1, -1,
+ 26, -1, 28, -1, -1, 31, -1, -1, 81, 82,
+ 83, -1, -1, 39, 87, 41, 42, -1, -1, -1,
+ -1, -1, -1, 49, -1, -1, 52, 53, -1, -1,
+ -1, -1, 58, -1, -1, -1, -1, -1, 64, -1,
+ -1, -1, -1, -1, -1, -1, 12, 13, -1, -1,
+ -1, -1, -1, -1, 80, -1, 22, -1, -1, -1,
+ -1, -1, -1, 29, -1, -1, -1, 33, 34, -1,
+ 36, -1, -1, -1, 12, 13, -1, 43, -1, -1,
+ -1, 47, -1, -1, 22, -1, -1, -1, -1, -1,
+ -1, 29, -1, -1, -1, 33, 34, -1, 36, 65,
+ 66, 67, 68, -1, 70, 43, -1, -1, -1, 47,
+ -1, -1, -1, -1, -1, 81, 82, 83, -1, -1,
+ -1, 87, -1, -1, -1, -1, -1, 65, 66, 67,
+ 68, -1, 70, -1, 10, -1, 12, 13, -1, -1,
+ -1, -1, -1, 81, 82, 83, 22, -1, -1, 87,
+ -1, -1, -1, 29, -1, -1, -1, 33, 34, -1,
+ 36, -1, 12, 13, -1, -1, -1, 43, -1, -1,
+ -1, 47, 22, -1, -1, -1, -1, -1, -1, 29,
+ -1, -1, -1, 33, 34, -1, 36, -1, -1, 65,
+ 66, 67, 68, 43, 70, -1, -1, 47, -1, 75,
+ -1, -1, -1, -1, -1, 81, 82, 83, 84, -1,
+ -1, 87, -1, -1, -1, 65, 66, 67, 68, -1,
+ 70, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 10, -1, 12, 13, -1, -1, -1, -1, -1, -1,
+ -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
+ -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
+ -1, -1, -1, 43, -1, -1, -1, 47, -1, -1,
+ -1, -1, -1, -1, -1, 55, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 65, 66, 67, 68, -1,
+ 70, -1, -1, -1, -1, 75, -1, -1, -1, -1,
+ -1, 81, 82, 83, 84, -1, -1, 87, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 10, -1, 12, 13, -1, -1, -1, -1, -1, -1,
+ -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
+ -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
+ -1, -1, -1, 43, -1, -1, -1, 47, -1, -1,
+ -1, -1, -1, -1, -1, 55, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 65, 66, 67, 68, -1,
+ 70, -1, -1, -1, -1, 75, -1, -1, -1, -1,
+ -1, 81, 82, 83, 84, -1, -1, 87, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 11, 12, 13, -1, -1, -1, -1, -1, -1, -1,
+ -1, 22, -1, -1, -1, -1, -1, -1, 29, -1,
+ -1, -1, 33, 34, -1, 36, -1, -1, -1, 40,
+ -1, 42, 43, 44, -1, -1, 47, -1, -1, -1,
+ 51, -1, 53, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 65, 66, 67, 68, -1, 70,
+ -1, 72, -1, 74, -1, 76, -1, -1, -1, -1,
+ 81, 82, 83, -1, -1, -1, 87, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
+ -1, -1, -1, 11, 12, 13, -1, -1, -1, -1,
+ -1, -1, -1, -1, 22, -1, -1, -1, -1, -1,
+ -1, 29, -1, -1, -1, 33, 34, -1, 36, -1,
+ -1, -1, 40, -1, 42, 43, 44, -1, -1, 47,
+ -1, -1, -1, 51, -1, 53, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 65, 66, 67,
+ 68, -1, 70, -1, 72, -1, 74, -1, 76, -1,
+ -1, -1, -1, 81, 82, 83, -1, -1, -1, 87,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 11, 12, 13, -1, -1, -1, -1, -1,
+ -1, -1, -1, 22, -1, -1, -1, -1, -1, -1,
+ 29, -1, -1, -1, 33, 34, -1, 36, -1, -1,
+ -1, 40, -1, 42, 43, 44, -1, -1, 47, -1,
+ -1, -1, 51, -1, 53, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 65, 66, 67, 68,
+ -1, 70, -1, 72, -1, 74, 75, 76, -1, -1,
+ -1, -1, 81, 82, 83, -1, -1, -1, 87, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 11, 12, 13, -1, -1, -1, -1, -1, -1,
+ -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
+ 30, -1, -1, 33, 34, -1, 36, -1, -1, -1,
+ 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
+ -1, 51, -1, 53, -1, -1, -1, -1, -1, -1,
+ -1, 61, -1, -1, -1, 65, 66, 67, 68, -1,
+ 70, -1, 72, -1, 74, -1, 76, -1, -1, -1,
+ -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 8, -1, -1, 11, 12, 13, -1, -1, -1, -1,
+ -1, -1, -1, -1, 22, -1, -1, -1, -1, -1,
+ -1, 29, -1, -1, -1, 33, 34, -1, 36, -1,
+ -1, -1, 40, -1, 42, 43, 44, -1, -1, 47,
+ -1, -1, -1, 51, -1, 53, -1, -1, 56, -1,
+ -1, -1, -1, -1, -1, -1, -1, 65, 66, 67,
+ 68, -1, 70, -1, 72, -1, 74, -1, 76, -1,
+ -1, -1, -1, 81, 82, 83, -1, -1, -1, 87,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 8, -1, -1, 11, 12, 13, -1, -1,
+ -1, -1, -1, -1, -1, -1, 22, -1, -1, -1,
+ -1, -1, -1, 29, -1, -1, -1, 33, 34, -1,
+ 36, -1, -1, -1, 40, -1, 42, 43, 44, -1,
+ -1, 47, -1, -1, -1, 51, -1, 53, -1, -1,
+ 56, -1, -1, -1, -1, -1, -1, -1, -1, 65,
+ 66, 67, 68, -1, 70, -1, 72, -1, 74, -1,
+ 76, -1, -1, -1, -1, 81, 82, 83, -1, -1,
+ -1, 87, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 8, -1, -1, 11, 12, 13,
+ -1, -1, -1, -1, -1, -1, -1, -1, 22, -1,
+ -1, -1, -1, -1, -1, 29, -1, -1, -1, 33,
+ 34, -1, 36, -1, -1, -1, 40, -1, 42, 43,
+ 44, -1, -1, 47, -1, -1, -1, 51, -1, 53,
+ -1, -1, 56, -1, -1, -1, -1, -1, -1, -1,
+ -1, 65, 66, 67, 68, -1, 70, -1, 72, -1,
+ 74, -1, 76, -1, -1, -1, -1, 81, 82, 83,
+ -1, -1, -1, 87, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 8, -1, -1, 11,
+ 12, 13, -1, -1, -1, -1, -1, -1, -1, -1,
+ 22, -1, -1, -1, -1, -1, -1, 29, -1, -1,
+ -1, 33, 34, -1, 36, -1, -1, -1, 40, -1,
+ 42, 43, 44, -1, -1, 47, -1, -1, -1, 51,
+ -1, 53, -1, -1, 56, -1, -1, -1, -1, -1,
+ -1, -1, -1, 65, 66, 67, 68, -1, 70, -1,
+ 72, -1, 74, -1, 76, -1, -1, -1, -1, 81,
+ 82, 83, -1, -1, -1, 87, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 4, 5,
+ 6, -1, -1, 9, 10, 11, -1, -1, 14, -1,
+ 16, -1, -1, -1, 20, 21, 22, -1, -1, -1,
+ -1, -1, -1, 29, 30, 31, 32, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 43, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 59, -1, -1, -1, -1, -1, -1,
+ 66, 67, 68, 69, 70, 71, -1, 73, 74, 75,
+ 76, 77, 78, -1, -1, 81, 82, 83, 84, 85,
+ 86, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 4, 5, 6, -1, -1, 9,
+ 10, 11, -1, -1, 14, -1, 16, -1, -1, -1,
+ 20, 21, 22, -1, -1, -1, -1, -1, -1, 29,
+ 30, 31, 32, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 43, -1, -1, -1, 47, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 59,
+ -1, -1, -1, -1, -1, 65, 66, 67, -1, 69,
+ 70, 71, -1, 73, 74, 75, 76, 77, 78, -1,
+ -1, 81, 82, 83, 84, 85, 86, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 4, 5, 6, -1, -1, 9, 10, 11, -1, -1,
+ 14, -1, 16, -1, -1, -1, 20, 21, 22, -1,
+ -1, -1, -1, -1, -1, 29, 30, 31, 32, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 43,
+ -1, -1, -1, 47, -1, -1, -1, -1, -1, -1,
+ -1, 55, -1, -1, -1, 59, -1, -1, -1, -1,
+ -1, 65, 66, 67, -1, 69, 70, 71, -1, 73,
+ 74, 75, 76, 77, 78, -1, -1, 81, 82, 83,
+ 84, 85, 86, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 4, -1, -1, -1,
+ -1, 9, -1, 11, 12, 13, 14, -1, -1, -1,
+ -1, -1, -1, 21, 22, -1, -1, -1, -1, -1,
+ -1, 29, 30, -1, -1, 33, 34, -1, 36, -1,
+ -1, -1, 40, -1, 42, 43, 44, -1, -1, 47,
+ -1, -1, -1, 51, -1, 53, -1, -1, -1, -1,
+ -1, 59, -1, 61, -1, -1, -1, 65, 66, 67,
+ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
+ 78, -1, -1, 81, 82, 83, 84, 85, -1, 87,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 4, -1, -1, -1, -1, 9, -1, 11,
+ 12, 13, 14, -1, -1, -1, -1, -1, -1, 21,
+ 22, -1, -1, -1, -1, -1, -1, 29, 30, -1,
+ -1, 33, 34, -1, 36, -1, -1, -1, 40, -1,
+ 42, 43, 44, -1, -1, 47, -1, -1, -1, 51,
+ -1, 53, -1, -1, -1, -1, -1, 59, -1, 61,
+ -1, -1, -1, 65, 66, 67, 68, 69, 70, 71,
+ 72, 73, 74, 75, 76, 77, 78, -1, -1, 81,
+ 82, 83, 84, 85, -1, 87, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 4, 5,
+ 6, -1, -1, 9, 10, 11, 12, 13, 14, -1,
+ 16, -1, -1, -1, 20, 21, 22, -1, -1, -1,
+ -1, -1, -1, 29, 30, 31, 32, 33, 34, -1,
+ 36, -1, -1, -1, 40, -1, 42, 43, 44, -1,
+ -1, 47, -1, -1, -1, 51, -1, 53, -1, -1,
+ -1, -1, -1, 59, -1, 61, -1, -1, -1, 65,
+ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
+ 76, 77, 78, -1, -1, 81, 82, 83, 84, 85,
+ 86, 87, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 4, 5, 6, -1, -1, 9,
+ 10, 11, 12, 13, 14, -1, 16, -1, -1, -1,
+ 20, 21, 22, -1, -1, -1, -1, -1, -1, 29,
+ 30, 31, 32, 33, 34, -1, 36, -1, -1, -1,
+ 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
+ -1, 51, -1, 53, -1, 55, -1, -1, -1, 59,
+ -1, 61, -1, -1, -1, 65, 66, 67, 68, 69,
+ 70, 71, 72, 73, 74, 75, 76, 77, 78, -1,
+ -1, 81, 82, 83, 84, 85, 86, 87, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+
+ 3, 2, 15, 25, 25, 3, 25, 3, 2, 11,
+ 2, 15, 3, 13, 67, 3, 15, 104, 15, 2,
+ 15, 2, 4, 3, 35, 15, 15, 3, 21, 3,
+ 93, 15, 2, 2, 19, 13, 15, 96, 25, 25,
+ 15, 3, 15, 15, 15, 100, 3, 3, 15, 2,
+ 2, 15, 3, 21, 4, 15, 15, 15, 35, 2,
+ 21, 2, 2, 2, 98, 3, 2, 2, 2, 35,
+ 35, 4, 35, 2, 21, 3, 3, 3, 15, 2,
+ 35, 35, 3, 3, 3, 3, 35, 35, 2, 35,
+ 21, 35, -1, 35, -1, -1, 13, 2, 13, 44,
+ 2, 46, 3, 3, 36, -1, -1, -1, 3, -1,
+ -1, 15, -1, 35, 44, -1, 46, 13, 40, 44,
+ 44, 46, 46, -1, 41, 15, 41, -1, 44, 15,
+ 46, 44, 44, 46, 44, 44, 44, 44, 44, 49,
+ 49, 44, 49, 49, 35, 41, 49, 37, 60, 40,
+ 58, 44, 44, 46, 46, 44, 44, 44, 3, 44,
+ 49, 46, 50, 50, 31, 44, 44, 68, 35, 44,
+ 48, 50, 44, 68, 44, 50, 81, 49, 48, 81,
+ 44, 85, 44, 44, 44, 49, 48, 44, 49, 49,
+ 44, 44, 49, 44, 44, 49, 46, 44, 44, 52,
+ 46, 44, 44, 46, 46, 56, 44, 54, 46, 15,
+ 3, 44, 44, 99, 47, 47, 44, 44, 46, 46,
+ 44, 44, 46, 68, 15, 13, 49, 44, 44, 44,
+ 44, 44, 49, 49, 49, 49, 49, -1, 61, 53,
+ 28, 29, 55, -1, -1, -1, 37, 38, 44, 66,
+ 66, 66, 44, 49, 44, 51, -1, 49, 44, 49,
+ -1, 44, -1, 49, 44, -1, 49, 57, 44, 49,
+ 46, 51, 44, -1, 66, 68, 59, 49, 44, 51,
+ 66, 87, 5, 49, 13, 51, 13, 16, 5, 16,
+ 13, 20, 13, 20, -1, -1, 13, -1, -1, 20,
+ 21, 22, 23, 24, -1, 28, 29, -1, 35, -1,
+ -1, 28, 29, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 13, -1, -1, 16, -1, -1, -1, 20, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1};
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
new file mode 100644
index 0000000..d6c3d6b
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+// This file was generated by qlalr - DO NOT EDIT!
+#ifndef QDECLARATIVEJSGRAMMAR_P_H
+#define QDECLARATIVEJSGRAMMAR_P_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeJSGrammar
+{
+public:
+ enum VariousConstants {
+ EOF_SYMBOL = 0,
+ REDUCE_HERE = 99,
+ SHIFT_THERE = 98,
+ T_AND = 1,
+ T_AND_AND = 2,
+ T_AND_EQ = 3,
+ T_AS = 91,
+ T_AUTOMATIC_SEMICOLON = 62,
+ T_BREAK = 4,
+ T_CASE = 5,
+ T_CATCH = 6,
+ T_COLON = 7,
+ T_COMMA = 8,
+ T_COMMENT = 88,
+ T_CONST = 84,
+ T_CONTINUE = 9,
+ T_DEBUGGER = 85,
+ T_DEFAULT = 10,
+ T_DELETE = 11,
+ T_DIVIDE_ = 12,
+ T_DIVIDE_EQ = 13,
+ T_DO = 14,
+ T_DOT = 15,
+ T_ELSE = 16,
+ T_EQ = 17,
+ T_EQ_EQ = 18,
+ T_EQ_EQ_EQ = 19,
+ T_FALSE = 83,
+ T_FEED_JS_EXPRESSION = 95,
+ T_FEED_JS_PROGRAM = 97,
+ T_FEED_JS_SOURCE_ELEMENT = 96,
+ T_FEED_JS_STATEMENT = 94,
+ T_FEED_UI_OBJECT_MEMBER = 93,
+ T_FEED_UI_PROGRAM = 92,
+ T_FINALLY = 20,
+ T_FOR = 21,
+ T_FUNCTION = 22,
+ T_GE = 23,
+ T_GT = 24,
+ T_GT_GT = 25,
+ T_GT_GT_EQ = 26,
+ T_GT_GT_GT = 27,
+ T_GT_GT_GT_EQ = 28,
+ T_IDENTIFIER = 29,
+ T_IF = 30,
+ T_IMPORT = 90,
+ T_IN = 31,
+ T_INSTANCEOF = 32,
+ T_LBRACE = 33,
+ T_LBRACKET = 34,
+ T_LE = 35,
+ T_LPAREN = 36,
+ T_LT = 37,
+ T_LT_LT = 38,
+ T_LT_LT_EQ = 39,
+ T_MINUS = 40,
+ T_MINUS_EQ = 41,
+ T_MINUS_MINUS = 42,
+ T_MULTILINE_STRING_LITERAL = 87,
+ T_NEW = 43,
+ T_NOT = 44,
+ T_NOT_EQ = 45,
+ T_NOT_EQ_EQ = 46,
+ T_NULL = 81,
+ T_NUMERIC_LITERAL = 47,
+ T_OR = 48,
+ T_OR_EQ = 49,
+ T_OR_OR = 50,
+ T_PLUS = 51,
+ T_PLUS_EQ = 52,
+ T_PLUS_PLUS = 53,
+ T_PROPERTY = 66,
+ T_PUBLIC = 89,
+ T_QUESTION = 54,
+ T_RBRACE = 55,
+ T_RBRACKET = 56,
+ T_READONLY = 68,
+ T_REMAINDER = 57,
+ T_REMAINDER_EQ = 58,
+ T_RESERVED_WORD = 86,
+ T_RETURN = 59,
+ T_RPAREN = 60,
+ T_SEMICOLON = 61,
+ T_SIGNAL = 67,
+ T_STAR = 63,
+ T_STAR_EQ = 64,
+ T_STRING_LITERAL = 65,
+ T_SWITCH = 69,
+ T_THIS = 70,
+ T_THROW = 71,
+ T_TILDE = 72,
+ T_TRUE = 82,
+ T_TRY = 73,
+ T_TYPEOF = 74,
+ T_VAR = 75,
+ T_VOID = 76,
+ T_WHILE = 77,
+ T_WITH = 78,
+ T_XOR = 79,
+ T_XOR_EQ = 80,
+
+ ACCEPT_STATE = 635,
+ RULE_COUNT = 343,
+ STATE_COUNT = 636,
+ TERMINAL_COUNT = 100,
+ NON_TERMINAL_COUNT = 106,
+
+ GOTO_INDEX_OFFSET = 636,
+ GOTO_INFO_OFFSET = 2520,
+ GOTO_CHECK_OFFSET = 2520
+ };
+
+ static const char *const spell [];
+ static const short lhs [];
+ static const short rhs [];
+ static const short goto_default [];
+ static const short action_default [];
+ static const short action_index [];
+ static const short action_info [];
+ static const short action_check [];
+
+ static inline int nt_action (int state, int nt)
+ {
+ const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt;
+ if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt)
+ return goto_default [nt];
+
+ return action_info [GOTO_INFO_OFFSET + yyn];
+ }
+
+ static inline int t_action (int state, int token)
+ {
+ const int yyn = action_index [state] + token;
+
+ if (yyn < 0 || action_check [yyn] != token)
+ return - action_default [state];
+
+ return action_info [yyn];
+ }
+};
+
+
+QT_END_NAMESPACE
+#endif // QDECLARATIVEJSGRAMMAR_P_H
+
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp
new file mode 100644
index 0000000..384d00c
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp
@@ -0,0 +1,1161 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "qdeclarativejslexer_p.h"
+
+#include "qdeclarativejsglobal_p.h"
+#include "qdeclarativejsengine_p.h"
+#include "qdeclarativejsgrammar_p.h"
+
+#include <QtCore/qcoreapplication.h>
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+QT_QML_BEGIN_NAMESPACE
+
+extern double qstrtod(const char *s00, char const **se, bool *ok);
+
+#define shiftWindowsLineBreak() \
+ do { \
+ if (((current == '\r') && (next1 == '\n')) \
+ || ((current == '\n') && (next1 == '\r'))) { \
+ shift(1); \
+ } \
+ } \
+ while (0)
+
+namespace QDeclarativeJS {
+extern double integerFromString(const char *buf, int size, int radix);
+}
+
+using namespace QDeclarativeJS;
+
+Lexer::Lexer(Engine *eng, bool tokenizeComments)
+ : driver(eng),
+ yylineno(0),
+ done(false),
+ size8(128), size16(128),
+ pos8(0), pos16(0),
+ terminator(false),
+ restrKeyword(false),
+ delimited(false),
+ stackToken(-1),
+ state(Start),
+ pos(0),
+ code(0), length(0),
+ yycolumn(0),
+ startpos(0),
+ startlineno(0), startcolumn(0),
+ bol(true),
+ current(0), next1(0), next2(0), next3(0),
+ err(NoError),
+ wantRx(false),
+ check_reserved(true),
+ parenthesesState(IgnoreParentheses),
+ parenthesesCount(0),
+ prohibitAutomaticSemicolon(false),
+ tokenizeComments(tokenizeComments)
+{
+ driver->setLexer(this);
+ // allocate space for read buffers
+ buffer8 = new char[size8];
+ buffer16 = new QChar[size16];
+ pattern = 0;
+ flags = 0;
+
+}
+
+Lexer::~Lexer()
+{
+ delete [] buffer8;
+ delete [] buffer16;
+}
+
+void Lexer::setCode(const QString &c, int lineno)
+{
+ errmsg = QString();
+ yylineno = lineno;
+ yycolumn = 1;
+ restrKeyword = false;
+ delimited = false;
+ stackToken = -1;
+ pos = 0;
+ code = c.unicode();
+ length = c.length();
+ bol = true;
+
+ // read first characters
+ current = (length > 0) ? code[0].unicode() : 0;
+ next1 = (length > 1) ? code[1].unicode() : 0;
+ next2 = (length > 2) ? code[2].unicode() : 0;
+ next3 = (length > 3) ? code[3].unicode() : 0;
+}
+
+void Lexer::shift(uint p)
+{
+ while (p--) {
+ ++pos;
+ ++yycolumn;
+ current = next1;
+ next1 = next2;
+ next2 = next3;
+ next3 = (pos + 3 < length) ? code[pos+3].unicode() : 0;
+ }
+}
+
+void Lexer::setDone(State s)
+{
+ state = s;
+ done = true;
+}
+
+int Lexer::findReservedWord(const QChar *c, int size) const
+{
+ switch (size) {
+ case 2: {
+ if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('o'))
+ return QDeclarativeJSGrammar::T_DO;
+ else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('f'))
+ return QDeclarativeJSGrammar::T_IF;
+ else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n'))
+ return QDeclarativeJSGrammar::T_IN;
+ else if (c[0] == QLatin1Char('a') && c[1] == QLatin1Char('s'))
+ return QDeclarativeJSGrammar::T_AS;
+ } break;
+
+ case 3: {
+ if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('r'))
+ return QDeclarativeJSGrammar::T_FOR;
+ else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('e') && c[2] == QLatin1Char('w'))
+ return QDeclarativeJSGrammar::T_NEW;
+ else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('y'))
+ return QDeclarativeJSGrammar::T_TRY;
+ else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('a') && c[2] == QLatin1Char('r'))
+ return QDeclarativeJSGrammar::T_VAR;
+ else if (check_reserved) {
+ if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n') && c[2] == QLatin1Char('t'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ }
+ } break;
+
+ case 4: {
+ if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('a')
+ && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_CASE;
+ else if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('l')
+ && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_ELSE;
+ else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h')
+ && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('s'))
+ return QDeclarativeJSGrammar::T_THIS;
+ else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('o')
+ && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('d'))
+ return QDeclarativeJSGrammar::T_VOID;
+ else if (c[0] == QLatin1Char('w') && c[1] == QLatin1Char('i')
+ && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('h'))
+ return QDeclarativeJSGrammar::T_WITH;
+ else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r')
+ && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_TRUE;
+ else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('u')
+ && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('l'))
+ return QDeclarativeJSGrammar::T_NULL;
+ else if (check_reserved) {
+ if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('n')
+ && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('m'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('y')
+ && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('l') && c[1] == QLatin1Char('o')
+ && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('g'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('h')
+ && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('r'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('g') && c[1] == QLatin1Char('o')
+ && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('o'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ }
+ } break;
+
+ case 5: {
+ if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('r')
+ && c[2] == QLatin1Char('e') && c[3] == QLatin1Char('a')
+ && c[4] == QLatin1Char('k'))
+ return QDeclarativeJSGrammar::T_BREAK;
+ else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('a')
+ && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('c')
+ && c[4] == QLatin1Char('h'))
+ return QDeclarativeJSGrammar::T_CATCH;
+ else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h')
+ && c[2] == QLatin1Char('r') && c[3] == QLatin1Char('o')
+ && c[4] == QLatin1Char('w'))
+ return QDeclarativeJSGrammar::T_THROW;
+ else if (c[0] == QLatin1Char('w') && c[1] == QLatin1Char('h')
+ && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('l')
+ && c[4] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_WHILE;
+ else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('o')
+ && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('s')
+ && c[4] == QLatin1Char('t'))
+ return QDeclarativeJSGrammar::T_CONST;
+ else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('a')
+ && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('s')
+ && c[4] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_FALSE;
+ else if (check_reserved) {
+ if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('h')
+ && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('r')
+ && c[4] == QLatin1Char('t'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('u')
+ && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('e')
+ && c[4] == QLatin1Char('r'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('i')
+ && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('a')
+ && c[4] == QLatin1Char('l'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('l')
+ && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('s')
+ && c[4] == QLatin1Char('s'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('l')
+ && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('a')
+ && c[4] == QLatin1Char('t'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ }
+ } break;
+
+ case 6: {
+ if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e')
+ && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('e')
+ && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_DELETE;
+ else if (c[0] == QLatin1Char('r') && c[1] == QLatin1Char('e')
+ && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('u')
+ && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('n'))
+ return QDeclarativeJSGrammar::T_RETURN;
+ else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('w')
+ && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('t')
+ && c[4] == QLatin1Char('c') && c[5] == QLatin1Char('h'))
+ return QDeclarativeJSGrammar::T_SWITCH;
+ else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('y')
+ && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('e')
+ && c[4] == QLatin1Char('o') && c[5] == QLatin1Char('f'))
+ return QDeclarativeJSGrammar::T_TYPEOF;
+ else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m')
+ && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o')
+ && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t'))
+ return QDeclarativeJSGrammar::T_IMPORT;
+ else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('i')
+ && c[2] == QLatin1Char('g') && c[3] == QLatin1Char('n')
+ && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('l'))
+ return QDeclarativeJSGrammar::T_SIGNAL;
+ else if (check_reserved) {
+ if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('x')
+ && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o')
+ && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('t')
+ && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('t')
+ && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('c'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('o')
+ && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('b')
+ && c[4] == QLatin1Char('l') && c[5] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m')
+ && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o')
+ && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('u')
+ && c[2] == QLatin1Char('b') && c[3] == QLatin1Char('l')
+ && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('c'))
+ return QDeclarativeJSGrammar::T_PUBLIC;
+ else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('a')
+ && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('i')
+ && c[4] == QLatin1Char('v') && c[5] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h')
+ && c[2] == QLatin1Char('r') && c[3] == QLatin1Char('o')
+ && c[4] == QLatin1Char('w') && c[5] == QLatin1Char('s'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ }
+ } break;
+
+ case 7: {
+ if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e')
+ && c[2] == QLatin1Char('f') && c[3] == QLatin1Char('a')
+ && c[4] == QLatin1Char('u') && c[5] == QLatin1Char('l')
+ && c[6] == QLatin1Char('t'))
+ return QDeclarativeJSGrammar::T_DEFAULT;
+ else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('i')
+ && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('a')
+ && c[4] == QLatin1Char('l') && c[5] == QLatin1Char('l')
+ && c[6] == QLatin1Char('y'))
+ return QDeclarativeJSGrammar::T_FINALLY;
+ else if (check_reserved) {
+ if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('o')
+ && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('l')
+ && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('a')
+ && c[6] == QLatin1Char('n'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('x')
+ && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e')
+ && c[4] == QLatin1Char('n') && c[5] == QLatin1Char('d')
+ && c[6] == QLatin1Char('s'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('a')
+ && c[2] == QLatin1Char('c') && c[3] == QLatin1Char('k')
+ && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('g')
+ && c[6] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r')
+ && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('v')
+ && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('t')
+ && c[6] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ }
+ } break;
+
+ case 8: {
+ if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('o')
+ && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('t')
+ && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('n')
+ && c[6] == QLatin1Char('u') && c[7] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_CONTINUE;
+ else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('u')
+ && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('c')
+ && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('i')
+ && c[6] == QLatin1Char('o') && c[7] == QLatin1Char('n'))
+ return QDeclarativeJSGrammar::T_FUNCTION;
+ else if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e')
+ && c[2] == QLatin1Char('b') && c[3] == QLatin1Char('u')
+ && c[4] == QLatin1Char('g') && c[5] == QLatin1Char('g')
+ && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('r'))
+ return QDeclarativeJSGrammar::T_DEBUGGER;
+ else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r')
+ && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('p')
+ && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('r')
+ && c[6] == QLatin1Char('t') && c[7] == QLatin1Char('y'))
+ return QDeclarativeJSGrammar::T_PROPERTY;
+ else if (c[0] == QLatin1Char('r') && c[1] == QLatin1Char('e')
+ && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('d')
+ && c[4] == QLatin1Char('o') && c[5] == QLatin1Char('n')
+ && c[6] == QLatin1Char('l') && c[7] == QLatin1Char('y'))
+ return QDeclarativeJSGrammar::T_READONLY;
+ else if (check_reserved) {
+ if (c[0] == QLatin1Char('a') && c[1] == QLatin1Char('b')
+ && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('t')
+ && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('a')
+ && c[6] == QLatin1Char('c') && c[7] == QLatin1Char('t'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('o')
+ && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('a')
+ && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('i')
+ && c[6] == QLatin1Char('l') && c[7] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ }
+ } break;
+
+ case 9: {
+ if (check_reserved) {
+ if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n')
+ && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e')
+ && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('f')
+ && c[6] == QLatin1Char('a') && c[7] == QLatin1Char('c')
+ && c[8] == QLatin1Char('e'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r')
+ && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('n')
+ && c[4] == QLatin1Char('s') && c[5] == QLatin1Char('i')
+ && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('n')
+ && c[8] == QLatin1Char('t'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r')
+ && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('t')
+ && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('c')
+ && c[6] == QLatin1Char('t') && c[7] == QLatin1Char('e')
+ && c[8] == QLatin1Char('d'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ }
+ } break;
+
+ case 10: {
+ if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n')
+ && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('t')
+ && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('n')
+ && c[6] == QLatin1Char('c') && c[7] == QLatin1Char('e')
+ && c[8] == QLatin1Char('o') && c[9] == QLatin1Char('f'))
+ return QDeclarativeJSGrammar::T_INSTANCEOF;
+ else if (check_reserved) {
+ if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m')
+ && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('l')
+ && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('m')
+ && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('n')
+ && c[8] == QLatin1Char('t') && c[9] == QLatin1Char('s'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ }
+ } break;
+
+ case 12: {
+ if (check_reserved) {
+ if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('y')
+ && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('c')
+ && c[4] == QLatin1Char('h') && c[5] == QLatin1Char('r')
+ && c[6] == QLatin1Char('o') && c[7] == QLatin1Char('n')
+ && c[8] == QLatin1Char('i') && c[9] == QLatin1Char('z')
+ && c[10] == QLatin1Char('e') && c[11] == QLatin1Char('d'))
+ return QDeclarativeJSGrammar::T_RESERVED_WORD;
+ }
+ } break;
+
+ } // switch
+
+ return -1;
+}
+
+int Lexer::lex()
+{
+ int token = 0;
+ state = Start;
+ ushort stringType = 0; // either single or double quotes
+ bool multiLineString = false;
+ pos8 = pos16 = 0;
+ done = false;
+ terminator = false;
+
+ // did we push a token on the stack previously ?
+ // (after an automatic semicolon insertion)
+ if (stackToken >= 0) {
+ setDone(Other);
+ token = stackToken;
+ stackToken = -1;
+ }
+
+ while (!done) {
+ switch (state) {
+ case Start:
+ if (isWhiteSpace()) {
+ // do nothing
+ } else if (current == '/' && next1 == '/') {
+ recordStartPos();
+ shift(1);
+ state = InSingleLineComment;
+ } else if (current == '/' && next1 == '*') {
+ recordStartPos();
+ shift(1);
+ state = InMultiLineComment;
+ } else if (current == 0) {
+ syncProhibitAutomaticSemicolon();
+ if (!terminator && !delimited && !prohibitAutomaticSemicolon) {
+ // automatic semicolon insertion if program incomplete
+ token = QDeclarativeJSGrammar::T_SEMICOLON;
+ stackToken = 0;
+ setDone(Other);
+ } else {
+ setDone(Eof);
+ }
+ } else if (isLineTerminator()) {
+ shiftWindowsLineBreak();
+ yylineno++;
+ yycolumn = 0;
+ bol = true;
+ terminator = true;
+ syncProhibitAutomaticSemicolon();
+ if (restrKeyword) {
+ token = QDeclarativeJSGrammar::T_SEMICOLON;
+ setDone(Other);
+ }
+ } else if (current == '"' || current == '\'') {
+ recordStartPos();
+ state = InString;
+ multiLineString = false;
+ stringType = current;
+ } else if (isIdentLetter(current)) {
+ recordStartPos();
+ record16(current);
+ state = InIdentifier;
+ } else if (current == '0') {
+ recordStartPos();
+ record8(current);
+ state = InNum0;
+ } else if (isDecimalDigit(current)) {
+ recordStartPos();
+ record8(current);
+ state = InNum;
+ } else if (current == '.' && isDecimalDigit(next1)) {
+ recordStartPos();
+ record8(current);
+ state = InDecimal;
+ } else {
+ recordStartPos();
+ token = matchPunctuator(current, next1, next2, next3);
+ if (token != -1) {
+ if (terminator && !delimited && !prohibitAutomaticSemicolon
+ && (token == QDeclarativeJSGrammar::T_PLUS_PLUS
+ || token == QDeclarativeJSGrammar::T_MINUS_MINUS)) {
+ // automatic semicolon insertion
+ stackToken = token;
+ token = QDeclarativeJSGrammar::T_SEMICOLON;
+ }
+ setDone(Other);
+ }
+ else {
+ setDone(Bad);
+ err = IllegalCharacter;
+ errmsg = QCoreApplication::translate("QDeclarativeParser", "Illegal character");
+ }
+ }
+ break;
+ case InString:
+ if (current == stringType) {
+ shift(1);
+ setDone(String);
+ } else if (isLineTerminator()) {
+ multiLineString = true;
+ record16(current);
+ } else if (current == 0 || isLineTerminator()) {
+ setDone(Bad);
+ err = UnclosedStringLiteral;
+ errmsg = QCoreApplication::translate("QDeclarativeParser", "Unclosed string at end of line");
+ } else if (current == '\\') {
+ state = InEscapeSequence;
+ } else {
+ record16(current);
+ }
+ break;
+ // Escape Sequences inside of strings
+ case InEscapeSequence:
+ if (isOctalDigit(current)) {
+ if (current >= '0' && current <= '3' &&
+ isOctalDigit(next1) && isOctalDigit(next2)) {
+ record16(convertOctal(current, next1, next2));
+ shift(2);
+ state = InString;
+ } else if (isOctalDigit(current) &&
+ isOctalDigit(next1)) {
+ record16(convertOctal('0', current, next1));
+ shift(1);
+ state = InString;
+ } else if (isOctalDigit(current)) {
+ record16(convertOctal('0', '0', current));
+ state = InString;
+ } else {
+ setDone(Bad);
+ err = IllegalEscapeSequence;
+ errmsg = QCoreApplication::translate("QDeclarativeParser", "Illegal escape squence");
+ }
+ } else if (current == 'x')
+ state = InHexEscape;
+ else if (current == 'u')
+ state = InUnicodeEscape;
+ else {
+ if (isLineTerminator()) {
+ shiftWindowsLineBreak();
+ yylineno++;
+ yycolumn = 0;
+ bol = true;
+ } else {
+ record16(singleEscape(current));
+ }
+ state = InString;
+ }
+ break;
+ case InHexEscape:
+ if (isHexDigit(current) && isHexDigit(next1)) {
+ state = InString;
+ record16(QLatin1Char(convertHex(current, next1)));
+ shift(1);
+ } else if (current == stringType) {
+ record16(QLatin1Char('x'));
+ shift(1);
+ setDone(String);
+ } else {
+ record16(QLatin1Char('x'));
+ record16(current);
+ state = InString;
+ }
+ break;
+ case InUnicodeEscape:
+ if (isHexDigit(current) && isHexDigit(next1) &&
+ isHexDigit(next2) && isHexDigit(next3)) {
+ record16(convertUnicode(current, next1, next2, next3));
+ shift(3);
+ state = InString;
+ } else if (current == stringType) {
+ record16(QLatin1Char('u'));
+ shift(1);
+ setDone(String);
+ } else {
+ setDone(Bad);
+ err = IllegalUnicodeEscapeSequence;
+ errmsg = QCoreApplication::translate("QDeclarativeParser", "Illegal unicode escape sequence");
+ }
+ break;
+ case InSingleLineComment:
+ if (isLineTerminator()) {
+ shiftWindowsLineBreak();
+ yylineno++;
+ yycolumn = 0;
+ terminator = true;
+ bol = true;
+ if (restrKeyword) {
+ token = QDeclarativeJSGrammar::T_SEMICOLON;
+ setDone(Other);
+ } else
+ state = Start;
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ } else if (current == 0) {
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ setDone(Eof);
+ }
+
+ break;
+ case InMultiLineComment:
+ if (current == 0) {
+ setDone(Bad);
+ err = UnclosedComment;
+ errmsg = QCoreApplication::translate("QDeclarativeParser", "Unclosed comment at end of file");
+ 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);
+ }
+
+ break;
+ case InIdentifier:
+ if (isIdentLetter(current) || isDecimalDigit(current)) {
+ record16(current);
+ break;
+ }
+ setDone(Identifier);
+ break;
+ case InNum0:
+ if (current == 'x' || current == 'X') {
+ record8(current);
+ state = InHex;
+ } else if (current == '.') {
+ record8(current);
+ state = InDecimal;
+ } else if (current == 'e' || current == 'E') {
+ record8(current);
+ state = InExponentIndicator;
+ } else if (isOctalDigit(current)) {
+ record8(current);
+ state = InOctal;
+ } else if (isDecimalDigit(current)) {
+ record8(current);
+ state = InDecimal;
+ } else {
+ setDone(Number);
+ }
+ break;
+ case InHex:
+ if (isHexDigit(current))
+ record8(current);
+ else
+ setDone(Hex);
+ break;
+ case InOctal:
+ if (isOctalDigit(current)) {
+ record8(current);
+ } else if (isDecimalDigit(current)) {
+ record8(current);
+ state = InDecimal;
+ } else {
+ setDone(Octal);
+ }
+ break;
+ case InNum:
+ if (isDecimalDigit(current)) {
+ record8(current);
+ } else if (current == '.') {
+ record8(current);
+ state = InDecimal;
+ } else if (current == 'e' || current == 'E') {
+ record8(current);
+ state = InExponentIndicator;
+ } else {
+ setDone(Number);
+ }
+ break;
+ case InDecimal:
+ if (isDecimalDigit(current)) {
+ record8(current);
+ } else if (current == 'e' || current == 'E') {
+ record8(current);
+ state = InExponentIndicator;
+ } else {
+ setDone(Number);
+ }
+ break;
+ case InExponentIndicator:
+ if (current == '+' || current == '-') {
+ record8(current);
+ } else if (isDecimalDigit(current)) {
+ record8(current);
+ state = InExponent;
+ } else {
+ setDone(Bad);
+ err = IllegalExponentIndicator;
+ errmsg = QCoreApplication::translate("QDeclarativeParser", "Illegal syntax for exponential number");
+ }
+ break;
+ case InExponent:
+ if (isDecimalDigit(current)) {
+ record8(current);
+ } else {
+ setDone(Number);
+ }
+ break;
+ default:
+ Q_ASSERT_X(0, "Lexer::lex", "Unhandled state in switch statement");
+ }
+
+ // move on to the next character
+ if (!done)
+ shift(1);
+ if (state != Start && state != InSingleLineComment)
+ bol = false;
+ }
+
+ // no identifiers allowed directly after numeric literal, e.g. "3in" is bad
+ if ((state == Number || state == Octal || state == Hex)
+ && isIdentLetter(current)) {
+ state = Bad;
+ err = IllegalIdentifier;
+ errmsg = QCoreApplication::translate("QDeclarativeParser", "Identifier cannot start with numeric literal");
+ }
+
+ // terminate string
+ buffer8[pos8] = '\0';
+
+ double dval = 0;
+ if (state == Number) {
+ dval = qstrtod(buffer8, 0, 0);
+ } else if (state == Hex) { // scan hex numbers
+ dval = integerFromString(buffer8, pos8, 16);
+ state = Number;
+ } else if (state == Octal) { // scan octal number
+ dval = integerFromString(buffer8, pos8, 8);
+ state = Number;
+ }
+
+ restrKeyword = false;
+ delimited = false;
+
+ switch (parenthesesState) {
+ case IgnoreParentheses:
+ break;
+ case CountParentheses:
+ if (token == QDeclarativeJSGrammar::T_RPAREN) {
+ --parenthesesCount;
+ if (parenthesesCount == 0)
+ parenthesesState = BalancedParentheses;
+ } else if (token == QDeclarativeJSGrammar::T_LPAREN) {
+ ++parenthesesCount;
+ }
+ break;
+ case BalancedParentheses:
+ parenthesesState = IgnoreParentheses;
+ break;
+ }
+
+ switch (state) {
+ case Eof:
+ return 0;
+ case Other:
+ if (token == QDeclarativeJSGrammar::T_RBRACE || token == QDeclarativeJSGrammar::T_SEMICOLON)
+ delimited = true;
+ return token;
+ case Identifier:
+ if ((token = findReservedWord(buffer16, pos16)) < 0) {
+ /* TODO: close leak on parse error. same holds true for String */
+ if (driver)
+ qsyylval.ustr = driver->intern(buffer16, pos16);
+ else
+ qsyylval.ustr = 0;
+ return QDeclarativeJSGrammar::T_IDENTIFIER;
+ }
+ if (token == QDeclarativeJSGrammar::T_CONTINUE || token == QDeclarativeJSGrammar::T_BREAK
+ || token == QDeclarativeJSGrammar::T_RETURN || token == QDeclarativeJSGrammar::T_THROW) {
+ restrKeyword = true;
+ } else if (token == QDeclarativeJSGrammar::T_IF || token == QDeclarativeJSGrammar::T_FOR
+ || token == QDeclarativeJSGrammar::T_WHILE || token == QDeclarativeJSGrammar::T_WITH) {
+ parenthesesState = CountParentheses;
+ parenthesesCount = 0;
+ } else if (token == QDeclarativeJSGrammar::T_DO) {
+ parenthesesState = BalancedParentheses;
+ }
+ return token;
+ case String:
+ if (driver)
+ qsyylval.ustr = driver->intern(buffer16, pos16);
+ else
+ qsyylval.ustr = 0;
+ return multiLineString?QDeclarativeJSGrammar::T_MULTILINE_STRING_LITERAL:QDeclarativeJSGrammar::T_STRING_LITERAL;
+ case Number:
+ qsyylval.dval = dval;
+ return QDeclarativeJSGrammar::T_NUMERIC_LITERAL;
+ case Bad:
+ return -1;
+ default:
+ Q_ASSERT(!"unhandled numeration value in switch");
+ return -1;
+ }
+}
+
+bool Lexer::isWhiteSpace() const
+{
+ return (current == ' ' || current == '\t' ||
+ current == 0x0b || current == 0x0c);
+}
+
+bool Lexer::isLineTerminator() const
+{
+ return (current == '\n' || current == '\r');
+}
+
+bool Lexer::isIdentLetter(ushort c)
+{
+ // ASCII-biased, since all reserved words are ASCII, aand hence the
+ // bulk of content to be parsed.
+ if ((c >= 'a' && c <= 'z')
+ || (c >= 'A' && c <= 'Z')
+ || c == '$'
+ || c == '_')
+ return true;
+ if (c < 128)
+ return false;
+ return QChar(c).isLetterOrNumber();
+}
+
+bool Lexer::isDecimalDigit(ushort c)
+{
+ return (c >= '0' && c <= '9');
+}
+
+bool Lexer::isHexDigit(ushort c) const
+{
+ return ((c >= '0' && c <= '9')
+ || (c >= 'a' && c <= 'f')
+ || (c >= 'A' && c <= 'F'));
+}
+
+bool Lexer::isOctalDigit(ushort c) const
+{
+ return (c >= '0' && c <= '7');
+}
+
+int Lexer::matchPunctuator(ushort c1, ushort c2,
+ ushort c3, ushort c4)
+{
+ if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') {
+ shift(4);
+ return QDeclarativeJSGrammar::T_GT_GT_GT_EQ;
+ } else if (c1 == '=' && c2 == '=' && c3 == '=') {
+ shift(3);
+ return QDeclarativeJSGrammar::T_EQ_EQ_EQ;
+ } else if (c1 == '!' && c2 == '=' && c3 == '=') {
+ shift(3);
+ return QDeclarativeJSGrammar::T_NOT_EQ_EQ;
+ } else if (c1 == '>' && c2 == '>' && c3 == '>') {
+ shift(3);
+ return QDeclarativeJSGrammar::T_GT_GT_GT;
+ } else if (c1 == '<' && c2 == '<' && c3 == '=') {
+ shift(3);
+ return QDeclarativeJSGrammar::T_LT_LT_EQ;
+ } else if (c1 == '>' && c2 == '>' && c3 == '=') {
+ shift(3);
+ return QDeclarativeJSGrammar::T_GT_GT_EQ;
+ } else if (c1 == '<' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_LE;
+ } else if (c1 == '>' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_GE;
+ } else if (c1 == '!' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_NOT_EQ;
+ } else if (c1 == '+' && c2 == '+') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_PLUS_PLUS;
+ } else if (c1 == '-' && c2 == '-') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_MINUS_MINUS;
+ } else if (c1 == '=' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_EQ_EQ;
+ } else if (c1 == '+' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_PLUS_EQ;
+ } else if (c1 == '-' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_MINUS_EQ;
+ } else if (c1 == '*' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_STAR_EQ;
+ } else if (c1 == '/' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_DIVIDE_EQ;
+ } else if (c1 == '&' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_AND_EQ;
+ } else if (c1 == '^' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_XOR_EQ;
+ } else if (c1 == '%' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_REMAINDER_EQ;
+ } else if (c1 == '|' && c2 == '=') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_OR_EQ;
+ } else if (c1 == '<' && c2 == '<') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_LT_LT;
+ } else if (c1 == '>' && c2 == '>') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_GT_GT;
+ } else if (c1 == '&' && c2 == '&') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_AND_AND;
+ } else if (c1 == '|' && c2 == '|') {
+ shift(2);
+ return QDeclarativeJSGrammar::T_OR_OR;
+ }
+
+ switch(c1) {
+ case '=': shift(1); return QDeclarativeJSGrammar::T_EQ;
+ case '>': shift(1); return QDeclarativeJSGrammar::T_GT;
+ case '<': shift(1); return QDeclarativeJSGrammar::T_LT;
+ case ',': shift(1); return QDeclarativeJSGrammar::T_COMMA;
+ case '!': shift(1); return QDeclarativeJSGrammar::T_NOT;
+ case '~': shift(1); return QDeclarativeJSGrammar::T_TILDE;
+ case '?': shift(1); return QDeclarativeJSGrammar::T_QUESTION;
+ case ':': shift(1); return QDeclarativeJSGrammar::T_COLON;
+ case '.': shift(1); return QDeclarativeJSGrammar::T_DOT;
+ case '+': shift(1); return QDeclarativeJSGrammar::T_PLUS;
+ case '-': shift(1); return QDeclarativeJSGrammar::T_MINUS;
+ case '*': shift(1); return QDeclarativeJSGrammar::T_STAR;
+ case '/': shift(1); return QDeclarativeJSGrammar::T_DIVIDE_;
+ case '&': shift(1); return QDeclarativeJSGrammar::T_AND;
+ case '|': shift(1); return QDeclarativeJSGrammar::T_OR;
+ case '^': shift(1); return QDeclarativeJSGrammar::T_XOR;
+ case '%': shift(1); return QDeclarativeJSGrammar::T_REMAINDER;
+ case '(': shift(1); return QDeclarativeJSGrammar::T_LPAREN;
+ case ')': shift(1); return QDeclarativeJSGrammar::T_RPAREN;
+ case '{': shift(1); return QDeclarativeJSGrammar::T_LBRACE;
+ case '}': shift(1); return QDeclarativeJSGrammar::T_RBRACE;
+ case '[': shift(1); return QDeclarativeJSGrammar::T_LBRACKET;
+ case ']': shift(1); return QDeclarativeJSGrammar::T_RBRACKET;
+ case ';': shift(1); return QDeclarativeJSGrammar::T_SEMICOLON;
+
+ default: return -1;
+ }
+}
+
+ushort Lexer::singleEscape(ushort c) const
+{
+ switch(c) {
+ case 'b':
+ return 0x08;
+ case 't':
+ return 0x09;
+ case 'n':
+ return 0x0A;
+ case 'v':
+ return 0x0B;
+ case 'f':
+ return 0x0C;
+ case 'r':
+ return 0x0D;
+ case '"':
+ return 0x22;
+ case '\'':
+ return 0x27;
+ case '\\':
+ return 0x5C;
+ default:
+ return c;
+ }
+}
+
+ushort Lexer::convertOctal(ushort c1, ushort c2,
+ ushort c3) const
+{
+ return ((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0');
+}
+
+unsigned char Lexer::convertHex(ushort c)
+{
+ if (c >= '0' && c <= '9')
+ return (c - '0');
+ else if (c >= 'a' && c <= 'f')
+ return (c - 'a' + 10);
+ else
+ return (c - 'A' + 10);
+}
+
+unsigned char Lexer::convertHex(ushort c1, ushort c2)
+{
+ return ((convertHex(c1) << 4) + convertHex(c2));
+}
+
+QChar Lexer::convertUnicode(ushort c1, ushort c2,
+ ushort c3, ushort c4)
+{
+ return QChar((convertHex(c3) << 4) + convertHex(c4),
+ (convertHex(c1) << 4) + convertHex(c2));
+}
+
+void Lexer::record8(ushort c)
+{
+ Q_ASSERT(c <= 0xff);
+
+ // enlarge buffer if full
+ if (pos8 >= size8 - 1) {
+ char *tmp = new char[2 * size8];
+ memcpy(tmp, buffer8, size8 * sizeof(char));
+ delete [] buffer8;
+ buffer8 = tmp;
+ size8 *= 2;
+ }
+
+ buffer8[pos8++] = (char) c;
+}
+
+void Lexer::record16(QChar c)
+{
+ // enlarge buffer if full
+ if (pos16 >= size16 - 1) {
+ QChar *tmp = new QChar[2 * size16];
+ memcpy(tmp, buffer16, size16 * sizeof(QChar));
+ delete [] buffer16;
+ buffer16 = tmp;
+ size16 *= 2;
+ }
+
+ buffer16[pos16++] = c;
+}
+
+void Lexer::recordStartPos()
+{
+ startpos = pos;
+ startlineno = yylineno;
+ startcolumn = yycolumn;
+}
+
+bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
+{
+ pos16 = 0;
+ bool lastWasEscape = false;
+
+ if (prefix == EqualPrefix)
+ record16(QLatin1Char('='));
+
+ while (1) {
+ if (isLineTerminator() || current == 0) {
+ errmsg = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression literal");
+ return false;
+ }
+ else if (current != '/' || lastWasEscape == true)
+ {
+ record16(current);
+ lastWasEscape = !lastWasEscape && (current == '\\');
+ }
+ else {
+ if (driver)
+ pattern = driver->intern(buffer16, pos16);
+ else
+ pattern = 0;
+ pos16 = 0;
+ shift(1);
+ break;
+ }
+ shift(1);
+ }
+
+ flags = 0;
+ while (isIdentLetter(current)) {
+ int flag = Ecma::RegExp::flagFromChar(current);
+ if (flag == 0) {
+ errmsg = QCoreApplication::translate("QDeclarativeParser", "Invalid regular expression flag '%0'")
+ .arg(QChar(current));
+ return false;
+ }
+ flags |= flag;
+ record16(current);
+ shift(1);
+ }
+
+ return true;
+}
+
+void Lexer::syncProhibitAutomaticSemicolon()
+{
+ if (parenthesesState == BalancedParentheses) {
+ // we have seen something like "if (foo)", which means we should
+ // never insert an automatic semicolon at this point, since it would
+ // then be expanded into an empty statement (ECMA-262 7.9.1)
+ prohibitAutomaticSemicolon = true;
+ parenthesesState = IgnoreParentheses;
+ } else {
+ prohibitAutomaticSemicolon = false;
+ }
+}
+
+QT_QML_END_NAMESPACE
+
+
diff --git a/src/declarative/qml/parser/qdeclarativejslexer_p.h b/src/declarative/qml/parser/qdeclarativejslexer_p.h
new file mode 100644
index 0000000..71bd08c
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejslexer_p.h
@@ -0,0 +1,249 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEJSLEXER_P_H
+#define QDECLARATIVEJSLEXER_P_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 "qdeclarativejsglobal_p.h"
+
+#include <QtCore/QString>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS {
+
+class Engine;
+class NameId;
+
+class QML_PARSER_EXPORT Lexer
+{
+public:
+ Lexer(Engine *eng, bool tokenizeComments = false);
+ ~Lexer();
+
+ void setCode(const QString &c, int lineno);
+ int lex();
+
+ int currentLineNo() const { return yylineno; }
+ int currentColumnNo() const { return yycolumn; }
+
+ int tokenOffset() const { return startpos; }
+ int tokenLength() const { return pos - startpos; }
+
+ int startLineNo() const { return startlineno; }
+ int startColumnNo() const { return startcolumn; }
+
+ int endLineNo() const { return currentLineNo(); }
+ int endColumnNo() const
+ { int col = currentColumnNo(); return (col > 0) ? col - 1 : col; }
+
+ bool prevTerminator() const { return terminator; }
+
+ enum State { Start,
+ Identifier,
+ InIdentifier,
+ InSingleLineComment,
+ InMultiLineComment,
+ InNum,
+ InNum0,
+ InHex,
+ InOctal,
+ InDecimal,
+ InExponentIndicator,
+ InExponent,
+ Hex,
+ Octal,
+ Number,
+ String,
+ Eof,
+ InString,
+ InEscapeSequence,
+ InHexEscape,
+ InUnicodeEscape,
+ Other,
+ Bad };
+
+ enum Error {
+ NoError,
+ IllegalCharacter,
+ UnclosedStringLiteral,
+ IllegalEscapeSequence,
+ IllegalUnicodeEscapeSequence,
+ UnclosedComment,
+ IllegalExponentIndicator,
+ IllegalIdentifier
+ };
+
+ enum ParenthesesState {
+ IgnoreParentheses,
+ CountParentheses,
+ BalancedParentheses
+ };
+
+ enum RegExpBodyPrefix {
+ NoPrefix,
+ EqualPrefix
+ };
+
+ bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix);
+
+ NameId *pattern;
+ int flags;
+
+ State lexerState() const
+ { return state; }
+
+ QString errorMessage() const
+ { return errmsg; }
+ void setErrorMessage(const QString &err)
+ { errmsg = err; }
+ void setErrorMessage(const char *err)
+ { setErrorMessage(QString::fromLatin1(err)); }
+
+ Error error() const
+ { return err; }
+ void clearError()
+ { err = NoError; }
+
+private:
+ Engine *driver;
+ int yylineno;
+ bool done;
+ char *buffer8;
+ QChar *buffer16;
+ uint size8, size16;
+ uint pos8, pos16;
+ bool terminator;
+ bool restrKeyword;
+ // encountered delimiter like "'" and "}" on last run
+ bool delimited;
+ int stackToken;
+
+ State state;
+ void setDone(State s);
+ uint pos;
+ void shift(uint p);
+ int lookupKeyword(const char *);
+
+ bool isWhiteSpace() const;
+ bool isLineTerminator() const;
+ bool isHexDigit(ushort c) const;
+ bool isOctalDigit(ushort c) const;
+
+ int matchPunctuator(ushort c1, ushort c2,
+ ushort c3, ushort c4);
+ ushort singleEscape(ushort c) const;
+ ushort convertOctal(ushort c1, ushort c2,
+ ushort c3) const;
+public:
+ static unsigned char convertHex(ushort c1);
+ static unsigned char convertHex(ushort c1, ushort c2);
+ static QChar convertUnicode(ushort c1, ushort c2,
+ ushort c3, ushort c4);
+ static bool isIdentLetter(ushort c);
+ static bool isDecimalDigit(ushort c);
+
+ inline int ival() const { return qsyylval.ival; }
+ inline double dval() const { return qsyylval.dval; }
+ inline NameId *ustr() const { return qsyylval.ustr; }
+
+ const QChar *characterBuffer() const { return buffer16; }
+ int characterCount() const { return pos16; }
+
+private:
+ void record8(ushort c);
+ void record16(QChar c);
+ void recordStartPos();
+
+ int findReservedWord(const QChar *buffer, int size) const;
+
+ void syncProhibitAutomaticSemicolon();
+
+ const QChar *code;
+ uint length;
+ int yycolumn;
+ int startpos;
+ int startlineno;
+ int startcolumn;
+ int bol; // begin of line
+
+ union {
+ int ival;
+ double dval;
+ NameId *ustr;
+ } qsyylval;
+
+ // current and following unicode characters
+ ushort current, next1, next2, next3;
+
+ struct keyword {
+ const char *name;
+ int token;
+ };
+
+ QString errmsg;
+ Error err;
+
+ bool wantRx;
+ bool check_reserved;
+
+ ParenthesesState parenthesesState;
+ int parenthesesCount;
+ bool prohibitAutomaticSemicolon;
+ bool tokenizeComments;
+};
+
+} // namespace QDeclarativeJS
+
+QT_QML_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h b/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h
new file mode 100644
index 0000000..c8d52d0
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEJSMEMORYPOOL_P_H
+#define QDECLARATIVEJSMEMORYPOOL_P_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 "qdeclarativejsglobal_p.h"
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qshareddata.h>
+
+#include <string.h>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS {
+
+class QML_PARSER_EXPORT MemoryPool : public QSharedData
+{
+public:
+ enum { maxBlockCount = -1 };
+ enum { defaultBlockSize = 1 << 12 };
+
+ MemoryPool() {
+ m_blockIndex = maxBlockCount;
+ m_currentIndex = 0;
+ m_storage = 0;
+ m_currentBlock = 0;
+ m_currentBlockSize = 0;
+ }
+
+ virtual ~MemoryPool() {
+ for (int index = 0; index < m_blockIndex + 1; ++index)
+ qFree(m_storage[index]);
+
+ qFree(m_storage);
+ }
+
+ char *allocate(int bytes) {
+ bytes += (8 - bytes) & 7; // ensure multiple of 8 bytes (maintain alignment)
+ if (m_currentBlock == 0 || m_currentBlockSize < m_currentIndex + bytes) {
+ ++m_blockIndex;
+ m_currentBlockSize = defaultBlockSize << m_blockIndex;
+
+ m_storage = reinterpret_cast<char**>(qRealloc(m_storage, sizeof(char*) * (1 + m_blockIndex)));
+ m_currentBlock = m_storage[m_blockIndex] = reinterpret_cast<char*>(qMalloc(m_currentBlockSize));
+ ::memset(m_currentBlock, 0, m_currentBlockSize);
+
+ m_currentIndex = (8 - quintptr(m_currentBlock)) & 7; // ensure first chunk is 64-bit aligned
+ Q_ASSERT(m_currentIndex + bytes <= m_currentBlockSize);
+ }
+
+ char *p = reinterpret_cast<char *>
+ (m_currentBlock + m_currentIndex);
+
+ m_currentIndex += bytes;
+
+ return p;
+ }
+
+ int bytesAllocated() const {
+ int bytes = 0;
+ for (int index = 0; index < m_blockIndex; ++index)
+ bytes += (defaultBlockSize << index);
+ bytes += m_currentIndex;
+ return bytes;
+ }
+
+private:
+ int m_blockIndex;
+ int m_currentIndex;
+ char *m_currentBlock;
+ int m_currentBlockSize;
+ char **m_storage;
+
+private:
+ Q_DISABLE_COPY(MemoryPool)
+};
+
+} // namespace QDeclarativeJS
+
+QT_QML_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/qml/parser/qdeclarativejsnodepool_p.h b/src/declarative/qml/parser/qdeclarativejsnodepool_p.h
new file mode 100644
index 0000000..94637fd
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsnodepool_p.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEJSNODEPOOL_P_H
+#define QDECLARATIVEJSNODEPOOL_P_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 "qdeclarativejsglobal_p.h"
+#include "qdeclarativejsmemorypool_p.h"
+
+#include <QtCore/QHash>
+#include <QtCore/QString>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS {
+
+namespace AST {
+class Node;
+} // namespace AST
+
+class Code;
+class CompilationUnit;
+class Engine;
+
+template <typename NodeType>
+inline NodeType *makeAstNode(MemoryPool *storage)
+{
+ NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType();
+ return node;
+}
+
+template <typename NodeType, typename Arg1>
+inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1)
+{
+ NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1);
+ return node;
+}
+
+template <typename NodeType, typename Arg1, typename Arg2>
+inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1, Arg2 arg2)
+{
+ NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2);
+ return node;
+}
+
+template <typename NodeType, typename Arg1, typename Arg2, typename Arg3>
+inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1, Arg2 arg2, Arg3 arg3)
+{
+ NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2, arg3);
+ return node;
+}
+
+template <typename NodeType, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
+{
+ NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2, arg3, arg4);
+ return node;
+}
+
+class QML_PARSER_EXPORT NodePool : public MemoryPool
+{
+public:
+ NodePool(const QString &fileName, Engine *engine);
+ virtual ~NodePool();
+
+ Code *createCompiledCode(AST::Node *node, CompilationUnit &compilation);
+
+ inline QString fileName() const { return m_fileName; }
+ inline Engine *engine() const { return m_engine; }
+#ifndef J_SCRIPT_NO_EVENT_NOTIFY
+ inline qint64 id() const { return m_id; }
+#endif
+
+private:
+ QHash<AST::Node*, Code*> m_codeCache;
+ QString m_fileName;
+ Engine *m_engine;
+#ifndef J_SCRIPT_NO_EVENT_NOTIFY
+ qint64 m_id;
+#endif
+
+private:
+ Q_DISABLE_COPY(NodePool)
+};
+
+} // namespace QDeclarativeJS
+
+QT_QML_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp
new file mode 100644
index 0000000..4aa4960
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp
@@ -0,0 +1,1843 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtDebug>
+#include <QtGui/QApplication>
+
+#include <string.h>
+
+#include "qdeclarativejsengine_p.h"
+#include "qdeclarativejslexer_p.h"
+#include "qdeclarativejsast_p.h"
+#include "qdeclarativejsnodepool_p.h"
+
+
+
+#include "qdeclarativejsparser_p.h"
+#include <QVarLengthArray>
+
+//
+// This file is automatically generated from qmljs.g.
+// Changes will be lost.
+//
+
+using namespace QDeclarativeJS;
+
+QT_QML_BEGIN_NAMESPACE
+
+void Parser::reallocateStack()
+{
+ if (! stack_size)
+ stack_size = 128;
+ else
+ stack_size <<= 1;
+
+ sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
+ state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
+ location_stack = reinterpret_cast<AST::SourceLocation*> (qRealloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
+}
+
+inline static bool automatic(Engine *driver, int token)
+{
+ return token == QDeclarativeJSGrammar::T_RBRACE
+ || token == 0
+ || driver->lexer()->prevTerminator();
+}
+
+
+Parser::Parser(Engine *engine):
+ driver(engine),
+ tos(0),
+ stack_size(0),
+ sym_stack(0),
+ state_stack(0),
+ location_stack(0),
+ first_token(0),
+ last_token(0)
+{
+}
+
+Parser::~Parser()
+{
+ if (stack_size) {
+ qFree(sym_stack);
+ qFree(state_stack);
+ qFree(location_stack);
+ }
+}
+
+static inline AST::SourceLocation location(Lexer *lexer)
+{
+ AST::SourceLocation loc;
+ loc.offset = lexer->tokenOffset();
+ loc.length = lexer->tokenLength();
+ loc.startLine = lexer->startLineNo();
+ loc.startColumn = lexer->startColumnNo();
+ return loc;
+}
+
+AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
+{
+ QVarLengthArray<NameId *, 4> nameIds;
+ QVarLengthArray<AST::SourceLocation, 4> locations;
+
+ AST::ExpressionNode *it = expr;
+ while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
+ nameIds.append(m->name);
+ locations.append(m->identifierToken);
+ it = m->base;
+ }
+
+ if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
+ AST::UiQualifiedId *q = makeAstNode<AST::UiQualifiedId>(driver->nodePool(), idExpr->name);
+ q->identifierToken = idExpr->identifierToken;
+
+ AST::UiQualifiedId *currentId = q;
+ for (int i = nameIds.size() - 1; i != -1; --i) {
+ currentId = makeAstNode<AST::UiQualifiedId>(driver->nodePool(), currentId, nameIds[i]);
+ currentId->identifierToken = locations[i];
+ }
+
+ return currentId->finish();
+ }
+
+ return 0;
+}
+
+bool Parser::parse(int startToken)
+{
+ Lexer *lexer = driver->lexer();
+ bool hadErrors = false;
+ int yytoken = -1;
+ int action = 0;
+
+ token_buffer[0].token = startToken;
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[1];
+
+ tos = -1;
+ program = 0;
+
+ do {
+ if (++tos == stack_size)
+ reallocateStack();
+
+ state_stack[tos] = action;
+
+ _Lcheck_token:
+ if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
+ yyprevlloc = yylloc;
+
+ if (first_token == last_token) {
+ yytoken = lexer->lex();
+ yylval = lexer->dval();
+ yylloc = location(lexer);
+ } else {
+ yytoken = first_token->token;
+ yylval = first_token->dval;
+ yylloc = first_token->loc;
+ ++first_token;
+ }
+ }
+
+ action = t_action(action, yytoken);
+ if (action > 0) {
+ if (action != ACCEPT_STATE) {
+ yytoken = -1;
+ sym(1).dval = yylval;
+ loc(1) = yylloc;
+ } else {
+ --tos;
+ return ! hadErrors;
+ }
+ } else if (action < 0) {
+ const int r = -action - 1;
+ tos -= rhs[r];
+
+ switch (r) {
+
+case 0: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 1: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 2: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 3: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 4: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 5: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 6: {
+ sym(1).UiProgram = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList,
+ sym(2).UiObjectMemberList->finish());
+} break;
+
+case 8: {
+ sym(1).Node = sym(1).UiImportList->finish();
+} break;
+
+case 9: {
+ sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(), sym(1).UiImport);
+} break;
+
+case 10: {
+ sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(),
+ sym(1).UiImportList, sym(2).UiImport);
+} break;
+
+case 13: {
+ sym(1).UiImport->semicolonToken = loc(2);
+} break;
+
+case 15: {
+ sym(1).UiImport->versionToken = loc(2);
+ sym(1).UiImport->semicolonToken = loc(3);
+} break;
+
+case 17: {
+ sym(1).UiImport->versionToken = loc(2);
+ sym(1).UiImport->asToken = loc(3);
+ sym(1).UiImport->importIdToken = loc(4);
+ sym(1).UiImport->importId = sym(4).sval;
+ sym(1).UiImport->semicolonToken = loc(5);
+} break;
+
+case 19: {
+ sym(1).UiImport->asToken = loc(2);
+ sym(1).UiImport->importIdToken = loc(3);
+ sym(1).UiImport->importId = sym(3).sval;
+ sym(1).UiImport->semicolonToken = loc(4);
+} break;
+
+case 20: {
+ AST::UiImport *node = 0;
+
+ if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
+ node = makeAstNode<AST::UiImport>(driver->nodePool(), importIdLiteral->value);
+ node->fileNameToken = loc(2);
+ } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
+ QString text;
+ for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) {
+ text += q->name->asString();
+ if (q->next) text += QLatin1String(".");
+ }
+ node = makeAstNode<AST::UiImport>(driver->nodePool(), qualifiedId);
+ node->fileNameToken = loc(2);
+ }
+
+ sym(1).Node = node;
+
+ if (! node) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
+ QLatin1String("Expected a qualified name id or a string literal")));
+
+ return false; // ### remove me
+ }
+} break;
+
+case 21: {
+ sym(1).Node = 0;
+} break;
+
+case 22: {
+ sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
+} break;
+
+case 23: {
+ sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
+} break;
+
+case 24: {
+ AST::UiObjectMemberList *node = makeAstNode<AST:: UiObjectMemberList> (driver->nodePool(),
+ sym(1).UiObjectMemberList, sym(2).UiObjectMember);
+ sym(1).Node = node;
+} break;
+
+case 25: {
+ sym(1).Node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(), sym(1).UiObjectMember);
+} break;
+
+case 26: {
+ AST::UiArrayMemberList *node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(),
+ sym(1).UiArrayMemberList, sym(3).UiObjectMember);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 27: {
+ AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), (AST::UiObjectMemberList*)0);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 28: {
+ AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), sym(2).UiObjectMemberList->finish());
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 29: {
+ AST::UiObjectDefinition *node = makeAstNode<AST::UiObjectDefinition> (driver->nodePool(), sym(1).UiQualifiedId,
+ sym(2).UiObjectInitializer);
+ sym(1).Node = node;
+} break;
+
+case 31: {
+ AST::UiArrayBinding *node = makeAstNode<AST::UiArrayBinding> (driver->nodePool(),
+ sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
+ node->colonToken = loc(2);
+ node->lbracketToken = loc(3);
+ node->rbracketToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 32: {
+ AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
+ sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+case 33:case 34:case 35:case 36:
+{
+ AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
+ sym(1).UiQualifiedId, sym(3).Statement);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 37:
+
+case 38: {
+ sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
+ break;
+}
+
+case 40: {
+ sym(1).Node = 0;
+} break;
+
+case 41: {
+ sym(1).Node = sym(1).UiParameterList->finish ();
+} break;
+
+case 42: {
+ AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).sval, sym(2).sval);
+ node->identifierToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 43: {
+ AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).UiParameterList, sym(3).sval, sym(4).sval);
+ node->commaToken = loc(2);
+ node->identifierToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 45: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
+ node->type = AST::UiPublicMember::Signal;
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(2);
+ node->parameters = sym(4).UiParameterList;
+ node->semicolonToken = loc(6);
+ sym(1).Node = node;
+} break;
+
+case 47: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
+ node->type = AST::UiPublicMember::Signal;
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 49: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(4).sval, sym(6).sval);
+ node->typeModifier = sym(2).sval;
+ node->propertyToken = loc(1);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(6);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+
+case 51: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval);
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->semicolonToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 53: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval);
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->semicolonToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 55: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval,
+ sym(5).Expression);
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->colonToken = loc(4);
+ node->semicolonToken = loc(6);
+ sym(1).Node = node;
+} break;
+
+case 57: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
+ sym(6).Expression);
+ node->isReadonlyMember = true;
+ node->readonlyToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->colonToken = loc(5);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+
+case 59: {
+ AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
+ sym(6).Expression);
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->colonToken = loc(5);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+
+case 60: {
+ sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
+} break;
+
+case 61: {
+ sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
+} break;
+
+case 63: {
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_PROPERTY]);
+ sym(1).sval = driver->intern(s.constData(), s.length());
+ break;
+}
+
+case 64: {
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_SIGNAL]);
+ sym(1).sval = driver->intern(s.constData(), s.length());
+ break;
+}
+
+case 65: {
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_READONLY]);
+ sym(1).sval = driver->intern(s.constData(), s.length());
+ break;
+}
+
+case 66: {
+ AST::ThisExpression *node = makeAstNode<AST::ThisExpression> (driver->nodePool());
+ node->thisToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 67: {
+ AST::IdentifierExpression *node = makeAstNode<AST::IdentifierExpression> (driver->nodePool(), sym(1).sval);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 68: {
+ AST::NullExpression *node = makeAstNode<AST::NullExpression> (driver->nodePool());
+ node->nullToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 69: {
+ AST::TrueLiteral *node = makeAstNode<AST::TrueLiteral> (driver->nodePool());
+ node->trueToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 70: {
+ AST::FalseLiteral *node = makeAstNode<AST::FalseLiteral> (driver->nodePool());
+ node->falseToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 71: {
+ AST::NumericLiteral *node = makeAstNode<AST::NumericLiteral> (driver->nodePool(), sym(1).dval);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+case 72:
+case 73: {
+ AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 74: {
+ bool rx = lexer->scanRegExp(Lexer::NoPrefix);
+ if (!rx) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
+ return false; // ### remove me
+ }
+ AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 75: {
+ bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
+ if (!rx) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
+ return false;
+ }
+ AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 76: {
+ AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), (AST::Elision *) 0);
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 77: {
+ AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).Elision->finish());
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 78: {
+ AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish ());
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 79: {
+ AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (),
+ (AST::Elision *) 0);
+ node->lbracketToken = loc(1);
+ node->commaToken = loc(3);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 80: {
+ AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (),
+ sym(4).Elision->finish());
+ node->lbracketToken = loc(1);
+ node->commaToken = loc(3);
+ node->rbracketToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 81: {
+ AST::ObjectLiteral *node = 0;
+ if (sym(2).Node)
+ node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
+ sym(2).PropertyNameAndValueList->finish ());
+ else
+ node = makeAstNode<AST::ObjectLiteral> (driver->nodePool());
+ node->lbraceToken = loc(1);
+ node->lbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 82: {
+ AST::ObjectLiteral *node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
+ sym(2).PropertyNameAndValueList->finish ());
+ node->lbraceToken = loc(1);
+ node->lbraceToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 83: {
+ AST::NestedExpression *node = makeAstNode<AST::NestedExpression>(driver->nodePool(), sym(2).Expression);
+ node->lparenToken = loc(1);
+ node->rparenToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 84: {
+ if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
+ QLatin1String("Ignored annotation")));
+
+ sym(1).Expression = mem->base;
+ }
+
+ if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
+ sym(1).UiQualifiedId = qualifiedId;
+ } else {
+ sym(1).UiQualifiedId = 0;
+
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
+ QLatin1String("Expected a qualified name id")));
+
+ return false; // ### recover
+ }
+} break;
+
+case 85: {
+ sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), (AST::Elision *) 0, sym(1).Expression);
+} break;
+
+case 86: {
+ sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).Elision->finish(), sym(2).Expression);
+} break;
+
+case 87: {
+ AST::ElementList *node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).ElementList,
+ (AST::Elision *) 0, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 88: {
+ AST::ElementList *node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).ElementList, sym(3).Elision->finish(),
+ sym(4).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 89: {
+ AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool());
+ node->commaToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 90: {
+ AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool(), sym(1).Elision);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 91: {
+ AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
+ sym(1).PropertyName, sym(3).Expression);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 92: {
+ AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
+ sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
+ node->commaToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 93: {
+ AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+case 94:
+case 95: {
+ AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 96: {
+ AST::StringLiteralPropertyName *node = makeAstNode<AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 97: {
+ AST::NumericLiteralPropertyName *node = makeAstNode<AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 98: {
+ AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 99:
+
+case 100:
+
+case 101:
+
+case 102:
+
+case 103:
+
+case 104:
+
+case 105:
+
+case 106:
+
+case 107:
+
+case 108:
+
+case 109:
+
+case 110:
+
+case 111:
+
+case 112:
+
+case 113:
+
+case 114:
+
+case 115:
+
+case 116:
+
+case 117:
+
+case 118:
+
+case 119:
+
+case 120:
+
+case 121:
+
+case 122:
+
+case 123:
+
+case 124:
+
+case 125:
+
+case 126:
+
+case 127:
+
+case 128:
+
+case 129:
+{
+ sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
+} break;
+
+case 134: {
+ AST::ArrayMemberExpression *node = makeAstNode<AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
+ node->lbracketToken = loc(2);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 135: {
+ AST::FieldMemberExpression *node = makeAstNode<AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 136: {
+ AST::NewMemberExpression *node = makeAstNode<AST::NewMemberExpression> (driver->nodePool(), sym(2).Expression, sym(4).ArgumentList);
+ node->newToken = loc(1);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 138: {
+ AST::NewExpression *node = makeAstNode<AST::NewExpression> (driver->nodePool(), sym(2).Expression);
+ node->newToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 139: {
+ AST::CallExpression *node = makeAstNode<AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(3).ArgumentList);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 140: {
+ AST::CallExpression *node = makeAstNode<AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(3).ArgumentList);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 141: {
+ AST::ArrayMemberExpression *node = makeAstNode<AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
+ node->lbracketToken = loc(2);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 142: {
+ AST::FieldMemberExpression *node = makeAstNode<AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 143: {
+ sym(1).Node = 0;
+} break;
+
+case 144: {
+ sym(1).Node = sym(1).ArgumentList->finish();
+} break;
+
+case 145: {
+ sym(1).Node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).Expression);
+} break;
+
+case 146: {
+ AST::ArgumentList *node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).ArgumentList, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 150: {
+ AST::PostIncrementExpression *node = makeAstNode<AST::PostIncrementExpression> (driver->nodePool(), sym(1).Expression);
+ node->incrementToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 151: {
+ AST::PostDecrementExpression *node = makeAstNode<AST::PostDecrementExpression> (driver->nodePool(), sym(1).Expression);
+ node->decrementToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 153: {
+ AST::DeleteExpression *node = makeAstNode<AST::DeleteExpression> (driver->nodePool(), sym(2).Expression);
+ node->deleteToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 154: {
+ AST::VoidExpression *node = makeAstNode<AST::VoidExpression> (driver->nodePool(), sym(2).Expression);
+ node->voidToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 155: {
+ AST::TypeOfExpression *node = makeAstNode<AST::TypeOfExpression> (driver->nodePool(), sym(2).Expression);
+ node->typeofToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 156: {
+ AST::PreIncrementExpression *node = makeAstNode<AST::PreIncrementExpression> (driver->nodePool(), sym(2).Expression);
+ node->incrementToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 157: {
+ AST::PreDecrementExpression *node = makeAstNode<AST::PreDecrementExpression> (driver->nodePool(), sym(2).Expression);
+ node->decrementToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 158: {
+ AST::UnaryPlusExpression *node = makeAstNode<AST::UnaryPlusExpression> (driver->nodePool(), sym(2).Expression);
+ node->plusToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 159: {
+ AST::UnaryMinusExpression *node = makeAstNode<AST::UnaryMinusExpression> (driver->nodePool(), sym(2).Expression);
+ node->minusToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 160: {
+ AST::TildeExpression *node = makeAstNode<AST::TildeExpression> (driver->nodePool(), sym(2).Expression);
+ node->tildeToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 161: {
+ AST::NotExpression *node = makeAstNode<AST::NotExpression> (driver->nodePool(), sym(2).Expression);
+ node->notToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 163: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Mul, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 164: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Div, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 165: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Mod, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 167: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Add, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 168: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Sub, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 170: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::LShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 171: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::RShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 172: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::URShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 174: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Lt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 175: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Gt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 176: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Le, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 177: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Ge, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 178: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::InstanceOf, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 179: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::In, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 181: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Lt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 182: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Gt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 183: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Le, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 184: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Ge, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 185: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::InstanceOf, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 187: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Equal, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 188: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::NotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 189: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::StrictEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 190: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::StrictNotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 192: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Equal, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 193: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::NotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 194: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::StrictEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 195: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::StrictNotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 197: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitAnd, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 199: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitAnd, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 201: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitXor, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 203: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitXor, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 205: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitOr, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 207: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::BitOr, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 209: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::And, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 211: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::And, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 213: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Or, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 215: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ QSOperator::Or, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 217: {
+ AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression,
+ sym(3).Expression, sym(5).Expression);
+ node->questionToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 219: {
+ AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression,
+ sym(3).Expression, sym(5).Expression);
+ node->questionToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 221: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 223: {
+ AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
+ sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 224: {
+ sym(1).ival = QSOperator::Assign;
+} break;
+
+case 225: {
+ sym(1).ival = QSOperator::InplaceMul;
+} break;
+
+case 226: {
+ sym(1).ival = QSOperator::InplaceDiv;
+} break;
+
+case 227: {
+ sym(1).ival = QSOperator::InplaceMod;
+} break;
+
+case 228: {
+ sym(1).ival = QSOperator::InplaceAdd;
+} break;
+
+case 229: {
+ sym(1).ival = QSOperator::InplaceSub;
+} break;
+
+case 230: {
+ sym(1).ival = QSOperator::InplaceLeftShift;
+} break;
+
+case 231: {
+ sym(1).ival = QSOperator::InplaceRightShift;
+} break;
+
+case 232: {
+ sym(1).ival = QSOperator::InplaceURightShift;
+} break;
+
+case 233: {
+ sym(1).ival = QSOperator::InplaceAnd;
+} break;
+
+case 234: {
+ sym(1).ival = QSOperator::InplaceXor;
+} break;
+
+case 235: {
+ sym(1).ival = QSOperator::InplaceOr;
+} break;
+
+case 237: {
+ AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 238: {
+ sym(1).Node = 0;
+} break;
+
+case 241: {
+ AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 242: {
+ sym(1).Node = 0;
+} break;
+
+case 259: {
+ AST::Block *node = makeAstNode<AST::Block> (driver->nodePool(), sym(2).StatementList);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 260: {
+ sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).Statement);
+} break;
+
+case 261: {
+ sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).StatementList, sym(2).Statement);
+} break;
+
+case 262: {
+ sym(1).Node = 0;
+} break;
+
+case 263: {
+ sym(1).Node = sym(1).StatementList->finish ();
+} break;
+
+case 265: {
+ AST::VariableStatement *node = makeAstNode<AST::VariableStatement> (driver->nodePool(),
+ sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
+ node->declarationKindToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 266: {
+ sym(1).ival = T_CONST;
+} break;
+
+case 267: {
+ sym(1).ival = T_VAR;
+} break;
+
+case 268: {
+ sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
+} break;
+
+case 269: {
+ AST::VariableDeclarationList *node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(),
+ sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 270: {
+ sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
+} break;
+
+case 271: {
+ sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
+} break;
+
+case 272: {
+ AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 273: {
+ AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 274: {
+ // ### TODO: AST for initializer
+ sym(1) = sym(2);
+} break;
+
+case 275: {
+ sym(1).Node = 0;
+} break;
+
+case 277: {
+ // ### TODO: AST for initializer
+ sym(1) = sym(2);
+} break;
+
+case 278: {
+ sym(1).Node = 0;
+} break;
+
+case 280: {
+ AST::EmptyStatement *node = makeAstNode<AST::EmptyStatement> (driver->nodePool());
+ node->semicolonToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 282: {
+ AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 283: {
+ AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement);
+ node->ifToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ node->elseToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 284: {
+ AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
+ node->ifToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 286: {
+ AST::DoWhileStatement *node = makeAstNode<AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression);
+ node->doToken = loc(1);
+ node->whileToken = loc(3);
+ node->lparenToken = loc(4);
+ node->rparenToken = loc(6);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+
+case 287: {
+ AST::WhileStatement *node = makeAstNode<AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
+ node->whileToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 288: {
+ AST::ForStatement *node = makeAstNode<AST::ForStatement> (driver->nodePool(), sym(3).Expression,
+ sym(5).Expression, sym(7).Expression, sym(9).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->firstSemicolonToken = loc(4);
+ node->secondSemicolonToken = loc(6);
+ node->rparenToken = loc(8);
+ sym(1).Node = node;
+} break;
+
+case 289: {
+ AST::LocalForStatement *node = makeAstNode<AST::LocalForStatement> (driver->nodePool(),
+ sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
+ sym(8).Expression, sym(10).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->varToken = loc(3);
+ node->firstSemicolonToken = loc(5);
+ node->secondSemicolonToken = loc(7);
+ node->rparenToken = loc(9);
+ sym(1).Node = node;
+} break;
+
+case 290: {
+ AST:: ForEachStatement *node = makeAstNode<AST::ForEachStatement> (driver->nodePool(), sym(3).Expression,
+ sym(5).Expression, sym(7).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->inToken = loc(4);
+ node->rparenToken = loc(6);
+ sym(1).Node = node;
+} break;
+
+case 291: {
+ AST::LocalForEachStatement *node = makeAstNode<AST::LocalForEachStatement> (driver->nodePool(),
+ sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->varToken = loc(3);
+ node->inToken = loc(5);
+ node->rparenToken = loc(7);
+ sym(1).Node = node;
+} break;
+
+case 293: {
+ AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool());
+ node->continueToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 295: {
+ AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool(), sym(2).sval);
+ node->continueToken = loc(1);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 297: {
+ AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool());
+ node->breakToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 299: {
+ AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool(), sym(2).sval);
+ node->breakToken = loc(1);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 301: {
+ AST::ReturnStatement *node = makeAstNode<AST::ReturnStatement> (driver->nodePool(), sym(2).Expression);
+ node->returnToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 302: {
+ AST::WithStatement *node = makeAstNode<AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
+ node->withToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 303: {
+ AST::SwitchStatement *node = makeAstNode<AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock);
+ node->switchToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 304: {
+ AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 305: {
+ AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 306: {
+ sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClause);
+} break;
+
+case 307: {
+ sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClauses, sym(2).CaseClause);
+} break;
+
+case 308: {
+ sym(1).Node = 0;
+} break;
+
+case 309: {
+ sym(1).Node = sym(1).CaseClauses->finish ();
+} break;
+
+case 310: {
+ AST::CaseClause *node = makeAstNode<AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList);
+ node->caseToken = loc(1);
+ node->colonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 311: {
+ AST::DefaultClause *node = makeAstNode<AST::DefaultClause> (driver->nodePool(), sym(3).StatementList);
+ node->defaultToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+case 312:
+case 313: {
+ AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()), sym(3).Statement);
+ node->identifierToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 314: {
+ AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement);
+ node->identifierToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 316: {
+ AST::ThrowStatement *node = makeAstNode<AST::ThrowStatement> (driver->nodePool(), sym(2).Expression);
+ node->throwToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 317: {
+ AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 318: {
+ AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 319: {
+ AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 320: {
+ AST::Catch *node = makeAstNode<AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Block);
+ node->catchToken = loc(1);
+ node->lparenToken = loc(2);
+ node->identifierToken = loc(3);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 321: {
+ AST::Finally *node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Block);
+ node->finallyToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 323: {
+ AST::DebuggerStatement *node = makeAstNode<AST::DebuggerStatement> (driver->nodePool());
+ node->debuggerToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 324: {
+ AST::FunctionDeclaration *node = makeAstNode<AST::FunctionDeclaration> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody);
+ node->functionToken = loc(1);
+ node->identifierToken = loc(2);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ sym(1).Node = node;
+} break;
+
+case 325: {
+ AST::FunctionExpression *node = makeAstNode<AST::FunctionExpression> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody);
+ node->functionToken = loc(1);
+ if (sym(2).sval)
+ node->identifierToken = loc(2);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ sym(1).Node = node;
+} break;
+
+case 326: {
+ AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).sval);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 327: {
+ AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).FormalParameterList, sym(3).sval);
+ node->commaToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 328: {
+ sym(1).Node = 0;
+} break;
+
+case 329: {
+ sym(1).Node = sym(1).FormalParameterList->finish ();
+} break;
+
+case 330: {
+ sym(1).Node = 0;
+} break;
+
+case 332: {
+ sym(1).Node = makeAstNode<AST::FunctionBody> (driver->nodePool(), sym(1).SourceElements->finish ());
+} break;
+
+case 333: {
+ sym(1).Node = makeAstNode<AST::Program> (driver->nodePool(), sym(1).SourceElements->finish ());
+} break;
+
+case 334: {
+ sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElement);
+} break;
+
+case 335: {
+ sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElements, sym(2).SourceElement);
+} break;
+
+case 336: {
+ sym(1).Node = makeAstNode<AST::StatementSourceElement> (driver->nodePool(), sym(1).Statement);
+} break;
+
+case 337: {
+ sym(1).Node = makeAstNode<AST::FunctionSourceElement> (driver->nodePool(), sym(1).FunctionDeclaration);
+} break;
+
+case 338: {
+ sym(1).sval = 0;
+} break;
+
+case 340: {
+ sym(1).Node = 0;
+} break;
+
+ } // switch
+ action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
+ } // if
+ } while (action != 0);
+
+ if (first_token == last_token) {
+ const int errorState = state_stack[tos];
+
+ // automatic insertion of `;'
+ if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && automatic(driver, yytoken)) {
+ SavedToken &tk = token_buffer[0];
+ tk.token = yytoken;
+ tk.dval = yylval;
+ tk.loc = yylloc;
+
+ yylloc = yyprevlloc;
+ yylloc.offset += yylloc.length;
+ yylloc.startColumn += yylloc.length;
+ yylloc.length = 0;
+
+ //const QString msg = qApp->translate("QDeclarativeParser", "Missing `;'");
+ //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
+
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[1];
+
+ yytoken = T_SEMICOLON;
+ yylval = 0;
+
+ action = errorState;
+
+ goto _Lcheck_token;
+ }
+
+ hadErrors = true;
+
+ token_buffer[0].token = yytoken;
+ token_buffer[0].dval = yylval;
+ token_buffer[0].loc = yylloc;
+
+ token_buffer[1].token = yytoken = lexer->lex();
+ token_buffer[1].dval = yylval = lexer->dval();
+ token_buffer[1].loc = yylloc = location(lexer);
+
+ if (t_action(errorState, yytoken)) {
+ QString msg;
+ int token = token_buffer[0].token;
+ if (token < 0 || token >= TERMINAL_COUNT)
+ msg = qApp->translate("QDeclarativeParser", "Syntax error");
+ else
+ msg = qApp->translate("QDeclarativeParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+
+ static int tokens[] = {
+ T_PLUS,
+ T_EQ,
+
+ T_COMMA,
+ T_COLON,
+ T_SEMICOLON,
+
+ T_RPAREN, T_RBRACKET, T_RBRACE,
+
+ T_NUMERIC_LITERAL,
+ T_IDENTIFIER,
+
+ T_LPAREN, T_LBRACKET, T_LBRACE,
+
+ EOF_SYMBOL
+ };
+
+ for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
+ int a = t_action(errorState, *tk);
+ if (a > 0 && t_action(a, yytoken)) {
+ const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ yytoken = *tk;
+ yylval = 0;
+ yylloc = token_buffer[0].loc;
+ yylloc.length = 0;
+
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[2];
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+ }
+
+ for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
+ if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
+ tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
+ tk == T_FEED_JS_SOURCE_ELEMENT)
+ continue;
+
+ int a = t_action(errorState, tk);
+ if (a > 0 && t_action(a, yytoken)) {
+ const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ yytoken = tk;
+ yylval = 0;
+ yylloc = token_buffer[0].loc;
+ yylloc.length = 0;
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+ }
+
+ const QString msg = qApp->translate("QDeclarativeParser", "Syntax error");
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+ }
+
+ return false;
+}
+
+QT_QML_END_NAMESPACE
+
+
diff --git a/src/declarative/qml/parser/qdeclarativejsparser_p.h b/src/declarative/qml/parser/qdeclarativejsparser_p.h
new file mode 100644
index 0000000..c7e097a
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsparser_p.h
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+//
+// 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.
+//
+
+//
+// This file is automatically generated from qmljs.g.
+// Changes will be lost.
+//
+
+#ifndef QDECLARATIVEJSPARSER_P_H
+#define QDECLARATIVEJSPARSER_P_H
+
+#include "qdeclarativejsglobal_p.h"
+#include "qdeclarativejsgrammar_p.h"
+#include "qdeclarativejsast_p.h"
+#include "qdeclarativejsengine_p.h"
+
+#include <QtCore/QList>
+#include <QtCore/QString>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QDeclarativeJS {
+
+class Engine;
+class NameId;
+
+class QML_PARSER_EXPORT Parser: protected QDeclarativeJSGrammar
+{
+public:
+ union Value {
+ int ival;
+ double dval;
+ NameId *sval;
+ AST::ArgumentList *ArgumentList;
+ AST::CaseBlock *CaseBlock;
+ AST::CaseClause *CaseClause;
+ AST::CaseClauses *CaseClauses;
+ AST::Catch *Catch;
+ AST::DefaultClause *DefaultClause;
+ AST::ElementList *ElementList;
+ AST::Elision *Elision;
+ AST::ExpressionNode *Expression;
+ AST::Finally *Finally;
+ AST::FormalParameterList *FormalParameterList;
+ AST::FunctionBody *FunctionBody;
+ AST::FunctionDeclaration *FunctionDeclaration;
+ AST::Node *Node;
+ AST::PropertyName *PropertyName;
+ AST::PropertyNameAndValueList *PropertyNameAndValueList;
+ AST::SourceElement *SourceElement;
+ AST::SourceElements *SourceElements;
+ AST::Statement *Statement;
+ AST::StatementList *StatementList;
+ AST::Block *Block;
+ AST::VariableDeclaration *VariableDeclaration;
+ AST::VariableDeclarationList *VariableDeclarationList;
+
+ AST::UiProgram *UiProgram;
+ AST::UiImportList *UiImportList;
+ AST::UiImport *UiImport;
+ AST::UiParameterList *UiParameterList;
+ AST::UiPublicMember *UiPublicMember;
+ AST::UiObjectDefinition *UiObjectDefinition;
+ AST::UiObjectInitializer *UiObjectInitializer;
+ AST::UiObjectBinding *UiObjectBinding;
+ AST::UiScriptBinding *UiScriptBinding;
+ AST::UiArrayBinding *UiArrayBinding;
+ AST::UiObjectMember *UiObjectMember;
+ AST::UiObjectMemberList *UiObjectMemberList;
+ AST::UiArrayMemberList *UiArrayMemberList;
+ AST::UiQualifiedId *UiQualifiedId;
+ AST::UiSignature *UiSignature;
+ AST::UiFormalList *UiFormalList;
+ AST::UiFormal *UiFormal;
+ };
+
+public:
+ Parser(Engine *engine);
+ ~Parser();
+
+ // parse a UI program
+ bool parse() { return parse(T_FEED_UI_PROGRAM); }
+ bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
+ bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
+ bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
+ bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
+ bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
+
+ AST::UiProgram *ast() const
+ { return AST::cast<AST::UiProgram *>(program); }
+
+ AST::Statement *statement() const
+ {
+ if (! program)
+ return 0;
+
+ return program->statementCast();
+ }
+
+ AST::ExpressionNode *expression() const
+ {
+ if (! program)
+ return 0;
+
+ return program->expressionCast();
+ }
+
+ AST::UiObjectMember *uiObjectMember() const
+ {
+ if (! program)
+ return 0;
+
+ return program->uiObjectMemberCast();
+ }
+
+ AST::Node *rootNode() const
+ { return program; }
+
+ QList<DiagnosticMessage> diagnosticMessages() const
+ { return diagnostic_messages; }
+
+ inline DiagnosticMessage diagnosticMessage() const
+ {
+ foreach (const DiagnosticMessage &d, diagnostic_messages) {
+ if (! d.kind == DiagnosticMessage::Warning)
+ return d;
+ }
+
+ return DiagnosticMessage();
+ }
+
+ inline QString errorMessage() const
+ { return diagnosticMessage().message; }
+
+ inline int errorLineNumber() const
+ { return diagnosticMessage().loc.startLine; }
+
+ inline int errorColumnNumber() const
+ { return diagnosticMessage().loc.startColumn; }
+
+protected:
+ bool parse(int startToken);
+
+ void reallocateStack();
+
+ inline Value &sym(int index)
+ { return sym_stack [tos + index - 1]; }
+
+ inline AST::SourceLocation &loc(int index)
+ { return location_stack [tos + index - 1]; }
+
+ AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
+
+protected:
+ Engine *driver;
+ int tos;
+ int stack_size;
+ Value *sym_stack;
+ int *state_stack;
+ AST::SourceLocation *location_stack;
+
+ AST::Node *program;
+
+ // error recovery
+ enum { TOKEN_BUFFER_SIZE = 3 };
+
+ struct SavedToken {
+ int token;
+ double dval;
+ AST::SourceLocation loc;
+ };
+
+ double yylval;
+ AST::SourceLocation yylloc;
+ AST::SourceLocation yyprevlloc;
+
+ SavedToken token_buffer[TOKEN_BUFFER_SIZE];
+ SavedToken *first_token;
+ SavedToken *last_token;
+
+ QList<DiagnosticMessage> diagnostic_messages;
+};
+
+} // end of namespace QDeclarativeJS
+
+
+
+#define J_SCRIPT_REGEXPLITERAL_RULE1 74
+
+#define J_SCRIPT_REGEXPLITERAL_RULE2 75
+
+QT_QML_END_NAMESPACE
+
+
+
+#endif // QDECLARATIVEJSPARSER_P_H
diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g
deleted file mode 100644
index 90949d5..0000000
--- a/src/declarative/qml/parser/qmljs.g
+++ /dev/null
@@ -1,3075 +0,0 @@
-----------------------------------------------------------------------------
---
--- Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
--- All rights reserved.
--- Contact: Nokia Corporation (qt-info@nokia.com)
---
--- This file is part of the QtDeclarative module of the Qt Toolkit.
---
--- $QT_BEGIN_LICENSE:LGPL-ONLY$
--- GNU Lesser General Public License Usage
--- This file may be used under the terms of the GNU Lesser
--- General Public License version 2.1 as published by the Free Software
--- Foundation and appearing in the file LICENSE.LGPL included in the
--- packaging of this file. Please review the following information to
--- ensure the GNU Lesser General Public License version 2.1 requirements
--- will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
---
--- If you have questions regarding the use of this file, please contact
--- Nokia at qt-info@nokia.com.
--- $QT_END_LICENSE$
---
-----------------------------------------------------------------------------
-
-%parser QmlJSGrammar
-%decl qmljsparser_p.h
-%impl qmljsparser.cpp
-%expect 2
-%expect-rr 2
-
-%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&="
-%token T_BREAK "break" T_CASE "case" T_CATCH "catch"
-%token T_COLON ":" T_COMMA ";" T_CONTINUE "continue"
-%token T_DEFAULT "default" T_DELETE "delete" T_DIVIDE_ "/"
-%token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "."
-%token T_ELSE "else" T_EQ "=" T_EQ_EQ "=="
-%token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for"
-%token T_FUNCTION "function" T_GE ">=" T_GT ">"
-%token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>"
-%token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if"
-%token T_IN "in" T_INSTANCEOF "instanceof" T_LBRACE "{"
-%token T_LBRACKET "[" T_LE "<=" T_LPAREN "("
-%token T_LT "<" T_LT_LT "<<" T_LT_LT_EQ "<<="
-%token T_MINUS "-" T_MINUS_EQ "-=" T_MINUS_MINUS "--"
-%token T_NEW "new" T_NOT "!" T_NOT_EQ "!="
-%token T_NOT_EQ_EQ "!==" T_NUMERIC_LITERAL "numeric literal" T_OR "|"
-%token T_OR_EQ "|=" T_OR_OR "||" T_PLUS "+"
-%token T_PLUS_EQ "+=" T_PLUS_PLUS "++" T_QUESTION "?"
-%token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%"
-%token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")"
-%token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*"
-%token T_STAR_EQ "*=" T_STRING_LITERAL "string literal"
-%token T_PROPERTY "property" T_SIGNAL "signal" T_READONLY "readonly"
-%token T_SWITCH "switch" T_THIS "this" T_THROW "throw"
-%token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof"
-%token T_VAR "var" T_VOID "void" T_WHILE "while"
-%token T_WITH "with" T_XOR "^" T_XOR_EQ "^="
-%token T_NULL "null" T_TRUE "true" T_FALSE "false"
-%token T_CONST "const"
-%token T_DEBUGGER "debugger"
-%token T_RESERVED_WORD "reserved word"
-%token T_MULTILINE_STRING_LITERAL "multiline string literal"
-%token T_COMMENT "comment"
-
---- context keywords.
-%token T_PUBLIC "public"
-%token T_IMPORT "import"
-%token T_AS "as"
-
---- feed tokens
-%token T_FEED_UI_PROGRAM
-%token T_FEED_UI_OBJECT_MEMBER
-%token T_FEED_JS_STATEMENT
-%token T_FEED_JS_EXPRESSION
-%token T_FEED_JS_SOURCE_ELEMENT
-%token T_FEED_JS_PROGRAM
-
-%nonassoc SHIFT_THERE
-%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY
-%nonassoc REDUCE_HERE
-
-%start TopLevel
-
-/./****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QtDebug>
-#include <QtGui/QApplication>
-
-#include <string.h>
-
-#include "qmljsengine_p.h"
-#include "qmljslexer_p.h"
-#include "qmljsast_p.h"
-#include "qmljsnodepool_p.h"
-
-./
-
-/:/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-//
-// 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.
-//
-
-//
-// This file is automatically generated from qmljs.g.
-// Changes will be lost.
-//
-
-#ifndef QMLJSPARSER_P_H
-#define QMLJSPARSER_P_H
-
-#include "qmljsglobal_p.h"
-#include "qmljsgrammar_p.h"
-#include "qmljsast_p.h"
-#include "qmljsengine_p.h"
-
-#include <QtCore/QList>
-#include <QtCore/QString>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS {
-
-class Engine;
-class NameId;
-
-class QML_PARSER_EXPORT Parser: protected $table
-{
-public:
- union Value {
- int ival;
- double dval;
- NameId *sval;
- AST::ArgumentList *ArgumentList;
- AST::CaseBlock *CaseBlock;
- AST::CaseClause *CaseClause;
- AST::CaseClauses *CaseClauses;
- AST::Catch *Catch;
- AST::DefaultClause *DefaultClause;
- AST::ElementList *ElementList;
- AST::Elision *Elision;
- AST::ExpressionNode *Expression;
- AST::Finally *Finally;
- AST::FormalParameterList *FormalParameterList;
- AST::FunctionBody *FunctionBody;
- AST::FunctionDeclaration *FunctionDeclaration;
- AST::Node *Node;
- AST::PropertyName *PropertyName;
- AST::PropertyNameAndValueList *PropertyNameAndValueList;
- AST::SourceElement *SourceElement;
- AST::SourceElements *SourceElements;
- AST::Statement *Statement;
- AST::StatementList *StatementList;
- AST::Block *Block;
- AST::VariableDeclaration *VariableDeclaration;
- AST::VariableDeclarationList *VariableDeclarationList;
-
- AST::UiProgram *UiProgram;
- AST::UiImportList *UiImportList;
- AST::UiImport *UiImport;
- AST::UiParameterList *UiParameterList;
- AST::UiPublicMember *UiPublicMember;
- AST::UiObjectDefinition *UiObjectDefinition;
- AST::UiObjectInitializer *UiObjectInitializer;
- AST::UiObjectBinding *UiObjectBinding;
- AST::UiScriptBinding *UiScriptBinding;
- AST::UiArrayBinding *UiArrayBinding;
- AST::UiObjectMember *UiObjectMember;
- AST::UiObjectMemberList *UiObjectMemberList;
- AST::UiArrayMemberList *UiArrayMemberList;
- AST::UiQualifiedId *UiQualifiedId;
- AST::UiSignature *UiSignature;
- AST::UiFormalList *UiFormalList;
- AST::UiFormal *UiFormal;
- };
-
-public:
- Parser(Engine *engine);
- ~Parser();
-
- // parse a UI program
- bool parse() { return parse(T_FEED_UI_PROGRAM); }
- bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
- bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
- bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
- bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
- bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
-
- AST::UiProgram *ast() const
- { return AST::cast<AST::UiProgram *>(program); }
-
- AST::Statement *statement() const
- {
- if (! program)
- return 0;
-
- return program->statementCast();
- }
-
- AST::ExpressionNode *expression() const
- {
- if (! program)
- return 0;
-
- return program->expressionCast();
- }
-
- AST::UiObjectMember *uiObjectMember() const
- {
- if (! program)
- return 0;
-
- return program->uiObjectMemberCast();
- }
-
- AST::Node *rootNode() const
- { return program; }
-
- QList<DiagnosticMessage> diagnosticMessages() const
- { return diagnostic_messages; }
-
- inline DiagnosticMessage diagnosticMessage() const
- {
- foreach (const DiagnosticMessage &d, diagnostic_messages) {
- if (! d.kind == DiagnosticMessage::Warning)
- return d;
- }
-
- return DiagnosticMessage();
- }
-
- inline QString errorMessage() const
- { return diagnosticMessage().message; }
-
- inline int errorLineNumber() const
- { return diagnosticMessage().loc.startLine; }
-
- inline int errorColumnNumber() const
- { return diagnosticMessage().loc.startColumn; }
-
-protected:
- bool parse(int startToken);
-
- void reallocateStack();
-
- inline Value &sym(int index)
- { return sym_stack [tos + index - 1]; }
-
- inline AST::SourceLocation &loc(int index)
- { return location_stack [tos + index - 1]; }
-
- AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
-
-protected:
- Engine *driver;
- int tos;
- int stack_size;
- Value *sym_stack;
- int *state_stack;
- AST::SourceLocation *location_stack;
-
- AST::Node *program;
-
- // error recovery
- enum { TOKEN_BUFFER_SIZE = 3 };
-
- struct SavedToken {
- int token;
- double dval;
- AST::SourceLocation loc;
- };
-
- double yylval;
- AST::SourceLocation yylloc;
- AST::SourceLocation yyprevlloc;
-
- SavedToken token_buffer[TOKEN_BUFFER_SIZE];
- SavedToken *first_token;
- SavedToken *last_token;
-
- QList<DiagnosticMessage> diagnostic_messages;
-};
-
-} // end of namespace QmlJS
-
-
-:/
-
-
-/.
-
-#include "qmljsparser_p.h"
-#include <QVarLengthArray>
-
-//
-// This file is automatically generated from qmljs.g.
-// Changes will be lost.
-//
-
-using namespace QmlJS;
-
-QT_QML_BEGIN_NAMESPACE
-
-void Parser::reallocateStack()
-{
- if (! stack_size)
- stack_size = 128;
- else
- stack_size <<= 1;
-
- sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
- state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
- location_stack = reinterpret_cast<AST::SourceLocation*> (qRealloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
-}
-
-inline static bool automatic(Engine *driver, int token)
-{
- return token == $table::T_RBRACE
- || token == 0
- || driver->lexer()->prevTerminator();
-}
-
-
-Parser::Parser(Engine *engine):
- driver(engine),
- tos(0),
- stack_size(0),
- sym_stack(0),
- state_stack(0),
- location_stack(0),
- first_token(0),
- last_token(0)
-{
-}
-
-Parser::~Parser()
-{
- if (stack_size) {
- qFree(sym_stack);
- qFree(state_stack);
- qFree(location_stack);
- }
-}
-
-static inline AST::SourceLocation location(Lexer *lexer)
-{
- AST::SourceLocation loc;
- loc.offset = lexer->tokenOffset();
- loc.length = lexer->tokenLength();
- loc.startLine = lexer->startLineNo();
- loc.startColumn = lexer->startColumnNo();
- return loc;
-}
-
-AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
-{
- QVarLengthArray<NameId *, 4> nameIds;
- QVarLengthArray<AST::SourceLocation, 4> locations;
-
- AST::ExpressionNode *it = expr;
- while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
- nameIds.append(m->name);
- locations.append(m->identifierToken);
- it = m->base;
- }
-
- if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
- AST::UiQualifiedId *q = makeAstNode<AST::UiQualifiedId>(driver->nodePool(), idExpr->name);
- q->identifierToken = idExpr->identifierToken;
-
- AST::UiQualifiedId *currentId = q;
- for (int i = nameIds.size() - 1; i != -1; --i) {
- currentId = makeAstNode<AST::UiQualifiedId>(driver->nodePool(), currentId, nameIds[i]);
- currentId->identifierToken = locations[i];
- }
-
- return currentId->finish();
- }
-
- return 0;
-}
-
-bool Parser::parse(int startToken)
-{
- Lexer *lexer = driver->lexer();
- bool hadErrors = false;
- int yytoken = -1;
- int action = 0;
-
- token_buffer[0].token = startToken;
- first_token = &token_buffer[0];
- last_token = &token_buffer[1];
-
- tos = -1;
- program = 0;
-
- do {
- if (++tos == stack_size)
- reallocateStack();
-
- state_stack[tos] = action;
-
- _Lcheck_token:
- if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
- yyprevlloc = yylloc;
-
- if (first_token == last_token) {
- yytoken = lexer->lex();
- yylval = lexer->dval();
- yylloc = location(lexer);
- } else {
- yytoken = first_token->token;
- yylval = first_token->dval;
- yylloc = first_token->loc;
- ++first_token;
- }
- }
-
- action = t_action(action, yytoken);
- if (action > 0) {
- if (action != ACCEPT_STATE) {
- yytoken = -1;
- sym(1).dval = yylval;
- loc(1) = yylloc;
- } else {
- --tos;
- return ! hadErrors;
- }
- } else if (action < 0) {
- const int r = -action - 1;
- tos -= rhs[r];
-
- switch (r) {
-./
-
---------------------------------------------------------------------------------------------------------
--- Declarative UI
---------------------------------------------------------------------------------------------------------
-
-TopLevel: T_FEED_UI_PROGRAM UiProgram ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-TopLevel: T_FEED_JS_STATEMENT Statement ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-TopLevel: T_FEED_JS_EXPRESSION Expression ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-TopLevel: T_FEED_JS_SOURCE_ELEMENT SourceElement ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-TopLevel: T_FEED_JS_PROGRAM Program ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-UiProgram: UiImportListOpt UiRootMember ;
-/.
-case $rule_number: {
- sym(1).UiProgram = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList,
- sym(2).UiObjectMemberList->finish());
-} break;
-./
-
-UiImportListOpt: Empty ;
-UiImportListOpt: UiImportList ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).UiImportList->finish();
-} break;
-./
-
-UiImportList: UiImport ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(), sym(1).UiImport);
-} break;
-./
-
-UiImportList: UiImportList UiImport ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(),
- sym(1).UiImportList, sym(2).UiImport);
-} break;
-./
-
-ImportId: MemberExpression ;
-
-UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_SEMICOLON ;
-/.
-case $rule_number: {
- sym(1).UiImport->semicolonToken = loc(2);
-} break;
-./
-
-UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ;
-/.
-case $rule_number: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->semicolonToken = loc(3);
-} break;
-./
-
-UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->asToken = loc(3);
- sym(1).UiImport->importIdToken = loc(4);
- sym(1).UiImport->importId = sym(4).sval;
- sym(1).UiImport->semicolonToken = loc(5);
-} break;
-./
-
-UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- sym(1).UiImport->asToken = loc(2);
- sym(1).UiImport->importIdToken = loc(3);
- sym(1).UiImport->importId = sym(3).sval;
- sym(1).UiImport->semicolonToken = loc(4);
-} break;
-./
-
-
-UiImportHead: T_IMPORT ImportId ;
-/.
-case $rule_number: {
- AST::UiImport *node = 0;
-
- if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
- node = makeAstNode<AST::UiImport>(driver->nodePool(), importIdLiteral->value);
- node->fileNameToken = loc(2);
- } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
- QString text;
- for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) {
- text += q->name->asString();
- if (q->next) text += QLatin1String(".");
- }
- node = makeAstNode<AST::UiImport>(driver->nodePool(), qualifiedId);
- node->fileNameToken = loc(2);
- }
-
- sym(1).Node = node;
-
- if (! node) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id or a string literal")));
-
- return false; // ### remove me
- }
-} break;
-./
-
-Empty: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-UiRootMember: UiObjectDefinition ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
-} break;
-./
-
-UiObjectMemberList: UiObjectMember ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
-} break;
-./
-
-UiObjectMemberList: UiObjectMemberList UiObjectMember ;
-/.
-case $rule_number: {
- AST::UiObjectMemberList *node = makeAstNode<AST:: UiObjectMemberList> (driver->nodePool(),
- sym(1).UiObjectMemberList, sym(2).UiObjectMember);
- sym(1).Node = node;
-} break;
-./
-
-UiArrayMemberList: UiObjectDefinition ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(), sym(1).UiObjectMember);
-} break;
-./
-
-UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ;
-/.
-case $rule_number: {
- AST::UiArrayMemberList *node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(),
- sym(1).UiArrayMemberList, sym(3).UiObjectMember);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectInitializer: T_LBRACE T_RBRACE ;
-/.
-case $rule_number: {
- AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), (AST::UiObjectMemberList*)0);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE ;
-/.
-case $rule_number: {
- AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), sym(2).UiObjectMemberList->finish());
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectDefinition: UiQualifiedId UiObjectInitializer ;
-/.
-case $rule_number: {
- AST::UiObjectDefinition *node = makeAstNode<AST::UiObjectDefinition> (driver->nodePool(), sym(1).UiQualifiedId,
- sym(2).UiObjectInitializer);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: UiObjectDefinition ;
-
-UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
-/.
-case $rule_number: {
- AST::UiArrayBinding *node = makeAstNode<AST::UiArrayBinding> (driver->nodePool(),
- sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
- node->colonToken = loc(2);
- node->lbracketToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ;
-/.
-case $rule_number: {
- AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
- sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: UiQualifiedId T_COLON Block ;
-/.case $rule_number:./
-
-UiObjectMember: UiQualifiedId T_COLON EmptyStatement ;
-/.case $rule_number:./
-
-UiObjectMember: UiQualifiedId T_COLON ExpressionStatement ;
-/.case $rule_number:./
-
-UiObjectMember: UiQualifiedId T_COLON IfStatement ; --- ### do we really want if statement in a binding?
-/.case $rule_number:./
-
-/.
-{
- AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
- sym(1).UiQualifiedId, sym(3).Statement);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UiPropertyType: T_VAR ;
-/.
-case $rule_number:
-./
-UiPropertyType: T_RESERVED_WORD ;
-/.
-case $rule_number: {
- sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
- break;
-}
-./
-
-UiPropertyType: T_IDENTIFIER ;
-
-UiParameterListOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-UiParameterListOpt: UiParameterList ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).UiParameterList->finish ();
-} break;
-./
-
-UiParameterList: UiPropertyType JsIdentifier ;
-/.
-case $rule_number: {
- AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).sval, sym(2).sval);
- node->identifierToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ;
-/.
-case $rule_number: {
- AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).UiParameterList, sym(3).sval, sym(4).sval);
- node->commaToken = loc(2);
- node->identifierToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->parameters = sym(4).UiParameterList;
- node->semicolonToken = loc(6);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT T_IDENTIFIER T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(4).sval, sym(6).sval);
- node->typeModifier = sym(2).sval;
- node->propertyToken = loc(1);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval);
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->semicolonToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval);
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->semicolonToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval,
- sym(5).Expression);
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->colonToken = loc(4);
- node->semicolonToken = loc(6);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_READONLY T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_READONLY T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
- sym(6).Expression);
- node->isReadonlyMember = true;
- node->readonlyToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
- sym(6).Expression);
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: FunctionDeclaration ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
-} break;
-./
-
-UiObjectMember: VariableStatement ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
-} break;
-./
-
-JsIdentifier: T_IDENTIFIER;
-
-JsIdentifier: T_PROPERTY ;
-/.
-case $rule_number: {
- QString s = QLatin1String(QmlJSGrammar::spell[T_PROPERTY]);
- sym(1).sval = driver->intern(s.constData(), s.length());
- break;
-}
-./
-
-JsIdentifier: T_SIGNAL ;
-/.
-case $rule_number: {
- QString s = QLatin1String(QmlJSGrammar::spell[T_SIGNAL]);
- sym(1).sval = driver->intern(s.constData(), s.length());
- break;
-}
-./
-
-JsIdentifier: T_READONLY ;
-/.
-case $rule_number: {
- QString s = QLatin1String(QmlJSGrammar::spell[T_READONLY]);
- sym(1).sval = driver->intern(s.constData(), s.length());
- break;
-}
-./
-
---------------------------------------------------------------------------------------------------------
--- Expressions
---------------------------------------------------------------------------------------------------------
-
-PrimaryExpression: T_THIS ;
-/.
-case $rule_number: {
- AST::ThisExpression *node = makeAstNode<AST::ThisExpression> (driver->nodePool());
- node->thisToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: JsIdentifier ;
-/.
-case $rule_number: {
- AST::IdentifierExpression *node = makeAstNode<AST::IdentifierExpression> (driver->nodePool(), sym(1).sval);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_NULL ;
-/.
-case $rule_number: {
- AST::NullExpression *node = makeAstNode<AST::NullExpression> (driver->nodePool());
- node->nullToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_TRUE ;
-/.
-case $rule_number: {
- AST::TrueLiteral *node = makeAstNode<AST::TrueLiteral> (driver->nodePool());
- node->trueToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_FALSE ;
-/.
-case $rule_number: {
- AST::FalseLiteral *node = makeAstNode<AST::FalseLiteral> (driver->nodePool());
- node->falseToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_NUMERIC_LITERAL ;
-/.
-case $rule_number: {
- AST::NumericLiteral *node = makeAstNode<AST::NumericLiteral> (driver->nodePool(), sym(1).dval);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_MULTILINE_STRING_LITERAL ;
-/.case $rule_number:./
-
-PrimaryExpression: T_STRING_LITERAL ;
-/.
-case $rule_number: {
- AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_DIVIDE_ ;
-/:
-#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number
-:/
-/.
-case $rule_number: {
- bool rx = lexer->scanRegExp(Lexer::NoPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false; // ### remove me
- }
- AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_DIVIDE_EQ ;
-/:
-#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number
-:/
-/.
-case $rule_number: {
- bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false;
- }
- AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACKET T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), (AST::Elision *) 0);
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACKET Elision T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).Elision->finish());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish ());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACKET ElementList T_COMMA T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (),
- (AST::Elision *) 0);
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACKET ElementList T_COMMA Elision T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (),
- sym(4).Elision->finish());
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
--- PrimaryExpression: T_LBRACE T_RBRACE ;
--- /.
--- case $rule_number: {
--- sym(1).Node = makeAstNode<AST::ObjectLiteral> (driver->nodePool());
--- } break;
--- ./
-
-PrimaryExpression: T_LBRACE PropertyNameAndValueListOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::ObjectLiteral *node = 0;
- if (sym(2).Node)
- node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
- sym(2).PropertyNameAndValueList->finish ());
- else
- node = makeAstNode<AST::ObjectLiteral> (driver->nodePool());
- node->lbraceToken = loc(1);
- node->lbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACE PropertyNameAndValueList T_COMMA T_RBRACE ;
-/.
-case $rule_number: {
- AST::ObjectLiteral *node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
- sym(2).PropertyNameAndValueList->finish ());
- node->lbraceToken = loc(1);
- node->lbraceToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LPAREN Expression T_RPAREN ;
-/.
-case $rule_number: {
- AST::NestedExpression *node = makeAstNode<AST::NestedExpression>(driver->nodePool(), sym(2).Expression);
- node->lparenToken = loc(1);
- node->rparenToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-UiQualifiedId: MemberExpression ;
-/.
-case $rule_number: {
- if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
- QLatin1String("Ignored annotation")));
-
- sym(1).Expression = mem->base;
- }
-
- if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
- sym(1).UiQualifiedId = qualifiedId;
- } else {
- sym(1).UiQualifiedId = 0;
-
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id")));
-
- return false; // ### recover
- }
-} break;
-./
-
-ElementList: AssignmentExpression ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), (AST::Elision *) 0, sym(1).Expression);
-} break;
-./
-
-ElementList: Elision AssignmentExpression ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).Elision->finish(), sym(2).Expression);
-} break;
-./
-
-ElementList: ElementList T_COMMA AssignmentExpression ;
-/.
-case $rule_number: {
- AST::ElementList *node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).ElementList,
- (AST::Elision *) 0, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ElementList: ElementList T_COMMA Elision AssignmentExpression ;
-/.
-case $rule_number: {
- AST::ElementList *node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).ElementList, sym(3).Elision->finish(),
- sym(4).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-Elision: T_COMMA ;
-/.
-case $rule_number: {
- AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool());
- node->commaToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-Elision: Elision T_COMMA ;
-/.
-case $rule_number: {
- AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool(), sym(1).Elision);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-PropertyNameAndValueList: PropertyName T_COLON AssignmentExpression ;
-/.
-case $rule_number: {
- AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
- sym(1).PropertyName, sym(3).Expression);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-PropertyNameAndValueList: PropertyNameAndValueList T_COMMA PropertyName T_COLON AssignmentExpression ;
-/.
-case $rule_number: {
- AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
- sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
- node->commaToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-PropertyName: T_IDENTIFIER %prec REDUCE_HERE ;
-/.
-case $rule_number: {
- AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PropertyName: T_SIGNAL ;
-/.case $rule_number:./
-
-PropertyName: T_PROPERTY ;
-/.
-case $rule_number: {
- AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PropertyName: T_STRING_LITERAL ;
-/.
-case $rule_number: {
- AST::StringLiteralPropertyName *node = makeAstNode<AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PropertyName: T_NUMERIC_LITERAL ;
-/.
-case $rule_number: {
- AST::NumericLiteralPropertyName *node = makeAstNode<AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PropertyName: ReservedIdentifier ;
-/.
-case $rule_number: {
- AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-ReservedIdentifier: T_BREAK ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_CASE ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_CATCH ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_CONTINUE ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_DEFAULT ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_DELETE ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_DO ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_ELSE ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_FALSE ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_FINALLY ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_FOR ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_FUNCTION ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_IF ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_IN ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_INSTANCEOF ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_NEW ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_NULL ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_RETURN ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_SWITCH ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_THIS ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_THROW ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_TRUE ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_TRY ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_TYPEOF ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_VAR ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_VOID ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_WHILE ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_CONST ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_DEBUGGER ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_RESERVED_WORD ;
-/.
-case $rule_number:
-./
-ReservedIdentifier: T_WITH ;
-/.
-case $rule_number:
-{
- sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
-} break;
-./
-
-PropertyIdentifier: JsIdentifier ;
-PropertyIdentifier: ReservedIdentifier ;
-
-MemberExpression: PrimaryExpression ;
-MemberExpression: FunctionExpression ;
-
-MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayMemberExpression *node = makeAstNode<AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-MemberExpression: MemberExpression T_DOT PropertyIdentifier ;
-/.
-case $rule_number: {
- AST::FieldMemberExpression *node = makeAstNode<AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-MemberExpression: T_NEW MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ;
-/.
-case $rule_number: {
- AST::NewMemberExpression *node = makeAstNode<AST::NewMemberExpression> (driver->nodePool(), sym(2).Expression, sym(4).ArgumentList);
- node->newToken = loc(1);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-NewExpression: MemberExpression ;
-
-NewExpression: T_NEW NewExpression ;
-/.
-case $rule_number: {
- AST::NewExpression *node = makeAstNode<AST::NewExpression> (driver->nodePool(), sym(2).Expression);
- node->newToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-CallExpression: MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ;
-/.
-case $rule_number: {
- AST::CallExpression *node = makeAstNode<AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-CallExpression: CallExpression T_LPAREN ArgumentListOpt T_RPAREN ;
-/.
-case $rule_number: {
- AST::CallExpression *node = makeAstNode<AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayMemberExpression *node = makeAstNode<AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-CallExpression: CallExpression T_DOT PropertyIdentifier ;
-/.
-case $rule_number: {
- AST::FieldMemberExpression *node = makeAstNode<AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-ArgumentListOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-ArgumentListOpt: ArgumentList ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).ArgumentList->finish();
-} break;
-./
-
-ArgumentList: AssignmentExpression ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).Expression);
-} break;
-./
-
-ArgumentList: ArgumentList T_COMMA AssignmentExpression ;
-/.
-case $rule_number: {
- AST::ArgumentList *node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).ArgumentList, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LeftHandSideExpression: NewExpression ;
-LeftHandSideExpression: CallExpression ;
-PostfixExpression: LeftHandSideExpression ;
-
-PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ;
-/.
-case $rule_number: {
- AST::PostIncrementExpression *node = makeAstNode<AST::PostIncrementExpression> (driver->nodePool(), sym(1).Expression);
- node->incrementToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ;
-/.
-case $rule_number: {
- AST::PostDecrementExpression *node = makeAstNode<AST::PostDecrementExpression> (driver->nodePool(), sym(1).Expression);
- node->decrementToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: PostfixExpression ;
-
-UnaryExpression: T_DELETE UnaryExpression ;
-/.
-case $rule_number: {
- AST::DeleteExpression *node = makeAstNode<AST::DeleteExpression> (driver->nodePool(), sym(2).Expression);
- node->deleteToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_VOID UnaryExpression ;
-/.
-case $rule_number: {
- AST::VoidExpression *node = makeAstNode<AST::VoidExpression> (driver->nodePool(), sym(2).Expression);
- node->voidToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_TYPEOF UnaryExpression ;
-/.
-case $rule_number: {
- AST::TypeOfExpression *node = makeAstNode<AST::TypeOfExpression> (driver->nodePool(), sym(2).Expression);
- node->typeofToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_PLUS_PLUS UnaryExpression ;
-/.
-case $rule_number: {
- AST::PreIncrementExpression *node = makeAstNode<AST::PreIncrementExpression> (driver->nodePool(), sym(2).Expression);
- node->incrementToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_MINUS_MINUS UnaryExpression ;
-/.
-case $rule_number: {
- AST::PreDecrementExpression *node = makeAstNode<AST::PreDecrementExpression> (driver->nodePool(), sym(2).Expression);
- node->decrementToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_PLUS UnaryExpression ;
-/.
-case $rule_number: {
- AST::UnaryPlusExpression *node = makeAstNode<AST::UnaryPlusExpression> (driver->nodePool(), sym(2).Expression);
- node->plusToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_MINUS UnaryExpression ;
-/.
-case $rule_number: {
- AST::UnaryMinusExpression *node = makeAstNode<AST::UnaryMinusExpression> (driver->nodePool(), sym(2).Expression);
- node->minusToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_TILDE UnaryExpression ;
-/.
-case $rule_number: {
- AST::TildeExpression *node = makeAstNode<AST::TildeExpression> (driver->nodePool(), sym(2).Expression);
- node->tildeToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_NOT UnaryExpression ;
-/.
-case $rule_number: {
- AST::NotExpression *node = makeAstNode<AST::NotExpression> (driver->nodePool(), sym(2).Expression);
- node->notToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-MultiplicativeExpression: UnaryExpression ;
-
-MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Mul, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Div, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Mod, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-AdditiveExpression: MultiplicativeExpression ;
-
-AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Add, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Sub, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ShiftExpression: AdditiveExpression ;
-
-ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::LShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::RShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::URShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: ShiftExpression ;
-
-RelationalExpression: RelationalExpression T_LT ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: RelationalExpression T_GT ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: RelationalExpression T_LE ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: RelationalExpression T_GE ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: RelationalExpression T_IN ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::In, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpressionNotIn: ShiftExpression ;
-
-RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpression: RelationalExpression ;
-
-EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpressionNotIn: RelationalExpressionNotIn ;
-
-EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseANDExpression: EqualityExpression ;
-
-BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseANDExpressionNotIn: EqualityExpressionNotIn ;
-
-BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseXORExpression: BitwiseANDExpression ;
-
-BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ;
-
-BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseORExpression: BitwiseXORExpression ;
-
-BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ;
-
-BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LogicalANDExpression: BitwiseORExpression ;
-
-LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ;
-
-LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LogicalORExpression: LogicalANDExpression ;
-
-LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LogicalORExpressionNotIn: LogicalANDExpressionNotIn ;
-
-LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ConditionalExpression: LogicalORExpression ;
-
-ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ;
-/.
-case $rule_number: {
- AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-ConditionalExpressionNotIn: LogicalORExpressionNotIn ;
-
-ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ;
-/.
-case $rule_number: {
- AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-AssignmentExpression: ConditionalExpression ;
-
-AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-AssignmentExpressionNotIn: ConditionalExpressionNotIn ;
-
-AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-AssignmentOperator: T_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::Assign;
-} break;
-./
-
-AssignmentOperator: T_STAR_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceMul;
-} break;
-./
-
-AssignmentOperator: T_DIVIDE_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceDiv;
-} break;
-./
-
-AssignmentOperator: T_REMAINDER_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceMod;
-} break;
-./
-
-AssignmentOperator: T_PLUS_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceAdd;
-} break;
-./
-
-AssignmentOperator: T_MINUS_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceSub;
-} break;
-./
-
-AssignmentOperator: T_LT_LT_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceLeftShift;
-} break;
-./
-
-AssignmentOperator: T_GT_GT_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceRightShift;
-} break;
-./
-
-AssignmentOperator: T_GT_GT_GT_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceURightShift;
-} break;
-./
-
-AssignmentOperator: T_AND_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceAnd;
-} break;
-./
-
-AssignmentOperator: T_XOR_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceXor;
-} break;
-./
-
-AssignmentOperator: T_OR_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceOr;
-} break;
-./
-
-Expression: AssignmentExpression ;
-
-Expression: Expression T_COMMA AssignmentExpression ;
-/.
-case $rule_number: {
- AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ExpressionOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-ExpressionOpt: Expression ;
-
-ExpressionNotIn: AssignmentExpressionNotIn ;
-
-ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ;
-/.
-case $rule_number: {
- AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ExpressionNotInOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-ExpressionNotInOpt: ExpressionNotIn ;
-
-Statement: Block ;
-Statement: VariableStatement ;
-Statement: EmptyStatement ;
-Statement: ExpressionStatement ;
-Statement: IfStatement ;
-Statement: IterationStatement ;
-Statement: ContinueStatement ;
-Statement: BreakStatement ;
-Statement: ReturnStatement ;
-Statement: WithStatement ;
-Statement: LabelledStatement ;
-Statement: SwitchStatement ;
-Statement: ThrowStatement ;
-Statement: TryStatement ;
-Statement: DebuggerStatement ;
-
-
-Block: T_LBRACE StatementListOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::Block *node = makeAstNode<AST::Block> (driver->nodePool(), sym(2).StatementList);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-StatementList: Statement ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).Statement);
-} break;
-./
-
-StatementList: StatementList Statement ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).StatementList, sym(2).Statement);
-} break;
-./
-
-StatementListOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-StatementListOpt: StatementList ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).StatementList->finish ();
-} break;
-./
-
-VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::VariableStatement *node = makeAstNode<AST::VariableStatement> (driver->nodePool(),
- sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
- node->declarationKindToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-VariableDeclarationKind: T_CONST ;
-/.
-case $rule_number: {
- sym(1).ival = T_CONST;
-} break;
-./
-
-VariableDeclarationKind: T_VAR ;
-/.
-case $rule_number: {
- sym(1).ival = T_VAR;
-} break;
-./
-
-VariableDeclarationList: VariableDeclaration ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
-} break;
-./
-
-VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ;
-/.
-case $rule_number: {
- AST::VariableDeclarationList *node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(),
- sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-VariableDeclarationListNotIn: VariableDeclarationNotIn ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
-} break;
-./
-
-VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
-} break;
-./
-
-VariableDeclaration: JsIdentifier InitialiserOpt ;
-/.
-case $rule_number: {
- AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-VariableDeclarationNotIn: JsIdentifier InitialiserNotInOpt ;
-/.
-case $rule_number: {
- AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-Initialiser: T_EQ AssignmentExpression ;
-/.
-case $rule_number: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
-./
-
-InitialiserOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-InitialiserOpt: Initialiser ;
-
-InitialiserNotIn: T_EQ AssignmentExpressionNotIn ;
-/.
-case $rule_number: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
-./
-
-InitialiserNotInOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-InitialiserNotInOpt: InitialiserNotIn ;
-
-EmptyStatement: T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::EmptyStatement *node = makeAstNode<AST::EmptyStatement> (driver->nodePool());
- node->semicolonToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ExpressionStatement: Expression T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ;
-/.
-case $rule_number: {
- AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- node->elseToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-
-IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::DoWhileStatement *node = makeAstNode<AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression);
- node->doToken = loc(1);
- node->whileToken = loc(3);
- node->lparenToken = loc(4);
- node->rparenToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-./
-
-IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::WhileStatement *node = makeAstNode<AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
- node->whileToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::ForStatement *node = makeAstNode<AST::ForStatement> (driver->nodePool(), sym(3).Expression,
- sym(5).Expression, sym(7).Expression, sym(9).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->firstSemicolonToken = loc(4);
- node->secondSemicolonToken = loc(6);
- node->rparenToken = loc(8);
- sym(1).Node = node;
-} break;
-./
-
-IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::LocalForStatement *node = makeAstNode<AST::LocalForStatement> (driver->nodePool(),
- sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
- sym(8).Expression, sym(10).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->firstSemicolonToken = loc(5);
- node->secondSemicolonToken = loc(7);
- node->rparenToken = loc(9);
- sym(1).Node = node;
-} break;
-./
-
-IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST:: ForEachStatement *node = makeAstNode<AST::ForEachStatement> (driver->nodePool(), sym(3).Expression,
- sym(5).Expression, sym(7).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->inToken = loc(4);
- node->rparenToken = loc(6);
- sym(1).Node = node;
-} break;
-./
-
-IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::LocalForEachStatement *node = makeAstNode<AST::LocalForEachStatement> (driver->nodePool(),
- sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->inToken = loc(5);
- node->rparenToken = loc(7);
- sym(1).Node = node;
-} break;
-./
-
-ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ContinueStatement: T_CONTINUE T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool());
- node->continueToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ContinueStatement: T_CONTINUE JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ContinueStatement: T_CONTINUE JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool(), sym(2).sval);
- node->continueToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-BreakStatement: T_BREAK T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool());
- node->breakToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BreakStatement: T_BREAK JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-BreakStatement: T_BREAK JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool(), sym(2).sval);
- node->breakToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ReturnStatement *node = makeAstNode<AST::ReturnStatement> (driver->nodePool(), sym(2).Expression);
- node->returnToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::WithStatement *node = makeAstNode<AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
- node->withToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ;
-/.
-case $rule_number: {
- AST::SwitchStatement *node = makeAstNode<AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock);
- node->switchToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-CaseClauses: CaseClause ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClause);
-} break;
-./
-
-CaseClauses: CaseClauses CaseClause ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClauses, sym(2).CaseClause);
-} break;
-./
-
-CaseClausesOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-CaseClausesOpt: CaseClauses ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).CaseClauses->finish ();
-} break;
-./
-
-CaseClause: T_CASE Expression T_COLON StatementListOpt ;
-/.
-case $rule_number: {
- AST::CaseClause *node = makeAstNode<AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList);
- node->caseToken = loc(1);
- node->colonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-DefaultClause: T_DEFAULT T_COLON StatementListOpt ;
-/.
-case $rule_number: {
- AST::DefaultClause *node = makeAstNode<AST::DefaultClause> (driver->nodePool(), sym(3).StatementList);
- node->defaultToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LabelledStatement: T_SIGNAL T_COLON Statement ;
-/.case $rule_number:./
-
-LabelledStatement: T_PROPERTY T_COLON Statement ;
-/.
-case $rule_number: {
- AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()), sym(3).Statement);
- node->identifierToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LabelledStatement: T_IDENTIFIER T_COLON Statement ;
-/.
-case $rule_number: {
- AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement);
- node->identifierToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ThrowStatement: T_THROW Expression T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ThrowStatement *node = makeAstNode<AST::ThrowStatement> (driver->nodePool(), sym(2).Expression);
- node->throwToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-TryStatement: T_TRY Block Catch ;
-/.
-case $rule_number: {
- AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-TryStatement: T_TRY Block Finally ;
-/.
-case $rule_number: {
- AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-TryStatement: T_TRY Block Catch Finally ;
-/.
-case $rule_number: {
- AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-Catch: T_CATCH T_LPAREN JsIdentifier T_RPAREN Block ;
-/.
-case $rule_number: {
- AST::Catch *node = makeAstNode<AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Block);
- node->catchToken = loc(1);
- node->lparenToken = loc(2);
- node->identifierToken = loc(3);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-Finally: T_FINALLY Block ;
-/.
-case $rule_number: {
- AST::Finally *node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Block);
- node->finallyToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-DebuggerStatement: T_DEBUGGER T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::DebuggerStatement *node = makeAstNode<AST::DebuggerStatement> (driver->nodePool());
- node->debuggerToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-FunctionDeclaration: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::FunctionDeclaration *node = makeAstNode<AST::FunctionDeclaration> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-./
-
-FunctionExpression: T_FUNCTION IdentifierOpt T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::FunctionExpression *node = makeAstNode<AST::FunctionExpression> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- if (sym(2).sval)
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-./
-
-FormalParameterList: JsIdentifier ;
-/.
-case $rule_number: {
- AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).sval);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-FormalParameterList: FormalParameterList T_COMMA JsIdentifier ;
-/.
-case $rule_number: {
- AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).FormalParameterList, sym(3).sval);
- node->commaToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-FormalParameterListOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-FormalParameterListOpt: FormalParameterList ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).FormalParameterList->finish ();
-} break;
-./
-
-FunctionBodyOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-FunctionBodyOpt: FunctionBody ;
-
-FunctionBody: SourceElements ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::FunctionBody> (driver->nodePool(), sym(1).SourceElements->finish ());
-} break;
-./
-
-Program: SourceElements ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::Program> (driver->nodePool(), sym(1).SourceElements->finish ());
-} break;
-./
-
-SourceElements: SourceElement ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElement);
-} break;
-./
-
-SourceElements: SourceElements SourceElement ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElements, sym(2).SourceElement);
-} break;
-./
-
-SourceElement: Statement ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::StatementSourceElement> (driver->nodePool(), sym(1).Statement);
-} break;
-./
-
-SourceElement: FunctionDeclaration ;
-/.
-case $rule_number: {
- sym(1).Node = makeAstNode<AST::FunctionSourceElement> (driver->nodePool(), sym(1).FunctionDeclaration);
-} break;
-./
-
-IdentifierOpt: ;
-/.
-case $rule_number: {
- sym(1).sval = 0;
-} break;
-./
-
-IdentifierOpt: JsIdentifier ;
-
-PropertyNameAndValueListOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-PropertyNameAndValueListOpt: PropertyNameAndValueList ;
-
-/.
- } // switch
- action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
- } // if
- } while (action != 0);
-
- if (first_token == last_token) {
- const int errorState = state_stack[tos];
-
- // automatic insertion of `;'
- if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && automatic(driver, yytoken)) {
- SavedToken &tk = token_buffer[0];
- tk.token = yytoken;
- tk.dval = yylval;
- tk.loc = yylloc;
-
- yylloc = yyprevlloc;
- yylloc.offset += yylloc.length;
- yylloc.startColumn += yylloc.length;
- yylloc.length = 0;
-
- //const QString msg = qApp->translate("QmlParser", "Missing `;'");
- //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
-
- first_token = &token_buffer[0];
- last_token = &token_buffer[1];
-
- yytoken = T_SEMICOLON;
- yylval = 0;
-
- action = errorState;
-
- goto _Lcheck_token;
- }
-
- hadErrors = true;
-
- token_buffer[0].token = yytoken;
- token_buffer[0].dval = yylval;
- token_buffer[0].loc = yylloc;
-
- token_buffer[1].token = yytoken = lexer->lex();
- token_buffer[1].dval = yylval = lexer->dval();
- token_buffer[1].loc = yylloc = location(lexer);
-
- if (t_action(errorState, yytoken)) {
- QString msg;
- int token = token_buffer[0].token;
- if (token < 0 || token >= TERMINAL_COUNT)
- msg = qApp->translate("QmlParser", "Syntax error");
- else
- msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- action = errorState;
- goto _Lcheck_token;
- }
-
- static int tokens[] = {
- T_PLUS,
- T_EQ,
-
- T_COMMA,
- T_COLON,
- T_SEMICOLON,
-
- T_RPAREN, T_RBRACKET, T_RBRACE,
-
- T_NUMERIC_LITERAL,
- T_IDENTIFIER,
-
- T_LPAREN, T_LBRACKET, T_LBRACE,
-
- EOF_SYMBOL
- };
-
- for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
- int a = t_action(errorState, *tk);
- if (a > 0 && t_action(a, yytoken)) {
- const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- yytoken = *tk;
- yylval = 0;
- yylloc = token_buffer[0].loc;
- yylloc.length = 0;
-
- first_token = &token_buffer[0];
- last_token = &token_buffer[2];
-
- action = errorState;
- goto _Lcheck_token;
- }
- }
-
- for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
- if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
- tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
- tk == T_FEED_JS_SOURCE_ELEMENT)
- continue;
-
- int a = t_action(errorState, tk);
- if (a > 0 && t_action(a, yytoken)) {
- const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- yytoken = tk;
- yylval = 0;
- yylloc = token_buffer[0].loc;
- yylloc.length = 0;
-
- action = errorState;
- goto _Lcheck_token;
- }
- }
-
- const QString msg = qApp->translate("QmlParser", "Syntax error");
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
- }
-
- return false;
-}
-
-QT_QML_END_NAMESPACE
-
-
-./
-/:
-QT_QML_END_NAMESPACE
-
-
-
-#endif // QMLJSPARSER_P_H
-:/
diff --git a/src/declarative/qml/parser/qmljsast.cpp b/src/declarative/qml/parser/qmljsast.cpp
deleted file mode 100644
index d3ceba6..0000000
--- a/src/declarative/qml/parser/qmljsast.cpp
+++ /dev/null
@@ -1,955 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmljsast_p.h"
-
-#include "qmljsastvisitor_p.h"
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS { namespace AST {
-
-void Node::accept(Visitor *visitor)
-{
- if (visitor->preVisit(this)) {
- accept0(visitor);
- }
- visitor->postVisit(this);
-}
-
-void Node::accept(Node *node, Visitor *visitor)
-{
- if (node)
- node->accept(visitor);
-}
-
-ExpressionNode *Node::expressionCast()
-{
- return 0;
-}
-
-BinaryExpression *Node::binaryExpressionCast()
-{
- return 0;
-}
-
-Statement *Node::statementCast()
-{
- return 0;
-}
-
-UiObjectMember *Node::uiObjectMemberCast()
-{
- return 0;
-}
-
-ExpressionNode *ExpressionNode::expressionCast()
-{
- return this;
-}
-
-BinaryExpression *BinaryExpression::binaryExpressionCast()
-{
- return this;
-}
-
-Statement *Statement::statementCast()
-{
- return this;
-}
-
-UiObjectMember *UiObjectMember::uiObjectMemberCast()
-{
- return this;
-}
-
-void NestedExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
- visitor->endVisit(this);
-}
-
-void ThisExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void IdentifierExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void NullExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void TrueLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void FalseLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void StringLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void NumericLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void RegExpLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void ArrayLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(elements, visitor);
- accept(elision, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ObjectLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(properties, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ElementList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (ElementList *it = this; it; it = it->next) {
- accept(it->elision, visitor);
- accept(it->expression, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void Elision::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- // ###
- }
-
- visitor->endVisit(this);
-}
-
-void PropertyNameAndValueList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (PropertyNameAndValueList *it = this; it; it = it->next) {
- accept(it->name, visitor);
- accept(it->value, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void IdentifierPropertyName::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void StringLiteralPropertyName::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void NumericLiteralPropertyName::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void ArrayMemberExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void FieldMemberExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void NewMemberExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- accept(arguments, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void NewExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void CallExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- accept(arguments, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ArgumentList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (ArgumentList *it = this; it; it = it->next) {
- accept(it->expression, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void PostIncrementExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void PostDecrementExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void DeleteExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void VoidExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void TypeOfExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void PreIncrementExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void PreDecrementExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UnaryPlusExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UnaryMinusExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void TildeExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void NotExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void BinaryExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(left, visitor);
- accept(right, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ConditionalExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(ok, visitor);
- accept(ko, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void Expression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(left, visitor);
- accept(right, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void Block::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statements, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void StatementList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (StatementList *it = this; it; it = it->next) {
- accept(it->statement, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void VariableStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(declarations, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void VariableDeclarationList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (VariableDeclarationList *it = this; it; it = it->next) {
- accept(it->declaration, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void VariableDeclaration::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void EmptyStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void ExpressionStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void IfStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(ok, visitor);
- accept(ko, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void DoWhileStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void WhileStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ForStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(initialiser, visitor);
- accept(condition, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void LocalForStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(declarations, visitor);
- accept(condition, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ForEachStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(initialiser, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void LocalForEachStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(declaration, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ContinueStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void BreakStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void ReturnStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void WithStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void SwitchStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(block, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void CaseBlock::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(clauses, visitor);
- accept(defaultClause, visitor);
- accept(moreClauses, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void CaseClauses::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (CaseClauses *it = this; it; it = it->next) {
- accept(it->clause, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void CaseClause::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(statements, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void DefaultClause::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statements, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void LabelledStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ThrowStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void TryStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- accept(catchExpression, visitor);
- accept(finallyExpression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void Catch::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void Finally::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void FunctionDeclaration::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(formals, visitor);
- accept(body, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void FunctionExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(formals, visitor);
- accept(body, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void FormalParameterList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- // ###
- }
-
- visitor->endVisit(this);
-}
-
-void FunctionBody::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(elements, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void Program::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(elements, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void SourceElements::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (SourceElements *it = this; it; it = it->next) {
- accept(it->element, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void FunctionSourceElement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(declaration, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void StatementSourceElement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void DebuggerStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void UiProgram::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(imports, visitor);
- accept(members, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiSignature::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(formals, visitor);
- }
- visitor->endVisit(this);
-}
-
-void UiFormalList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (UiFormalList *it = this; it; it = it->next) {
- accept(it->formal, visitor);
- }
- }
- visitor->endVisit(this);
-}
-
-void UiFormal::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
- visitor->endVisit(this);
-}
-
-void UiPublicMember::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiObjectDefinition::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(qualifiedTypeNameId, visitor);
- accept(initializer, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiObjectInitializer::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(members, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiObjectBinding::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(qualifiedId, visitor);
- accept(qualifiedTypeNameId, visitor);
- accept(initializer, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiScriptBinding::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(qualifiedId, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiArrayBinding::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(qualifiedId, visitor);
- accept(members, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiObjectMemberList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (UiObjectMemberList *it = this; it; it = it->next)
- accept(it->member, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiArrayMemberList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (UiArrayMemberList *it = this; it; it = it->next)
- accept(it->member, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiQualifiedId::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void UiImport::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(importUri, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiImportList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(import, visitor);
- accept(next, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiSourceElement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(sourceElement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-} } // namespace QmlJS::AST
-
-QT_QML_END_NAMESPACE
-
-
diff --git a/src/declarative/qml/parser/qmljsast_p.h b/src/declarative/qml/parser/qmljsast_p.h
deleted file mode 100644
index 9de733c..0000000
--- a/src/declarative/qml/parser/qmljsast_p.h
+++ /dev/null
@@ -1,2678 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLJSAST_P_H
-#define QMLJSAST_P_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 "qmljsastvisitor_p.h"
-#include "qmljsglobal_p.h"
-
-#include <QtCore/QString>
-
-QT_QML_BEGIN_NAMESPACE
-
-#define QMLJS_DECLARE_AST_NODE(name) \
- enum { K = Kind_##name };
-
-namespace QSOperator // ### rename
-{
-
-enum Op {
- Add,
- And,
- InplaceAnd,
- Assign,
- BitAnd,
- BitOr,
- BitXor,
- InplaceSub,
- Div,
- InplaceDiv,
- Equal,
- Ge,
- Gt,
- In,
- InplaceAdd,
- InstanceOf,
- Le,
- LShift,
- InplaceLeftShift,
- Lt,
- Mod,
- InplaceMod,
- Mul,
- InplaceMul,
- NotEqual,
- Or,
- InplaceOr,
- RShift,
- InplaceRightShift,
- StrictEqual,
- StrictNotEqual,
- Sub,
- URShift,
- InplaceURightShift,
- InplaceXor
-};
-
-} // namespace QSOperator
-
-namespace QmlJS {
-class NameId;
-namespace AST {
-
-template <typename _T1, typename _T2>
-_T1 cast(_T2 *ast)
-{
- if (ast && ast->kind == static_cast<_T1>(0)->K)
- return static_cast<_T1>(ast);
-
- return 0;
-}
-
-class QML_PARSER_EXPORT Node
-{
-public:
- enum Kind {
- Kind_Undefined,
-
- Kind_ArgumentList,
- Kind_ArrayLiteral,
- Kind_ArrayMemberExpression,
- Kind_BinaryExpression,
- Kind_Block,
- Kind_BreakStatement,
- Kind_CallExpression,
- Kind_CaseBlock,
- Kind_CaseClause,
- Kind_CaseClauses,
- Kind_Catch,
- Kind_ConditionalExpression,
- Kind_ContinueStatement,
- Kind_DebuggerStatement,
- Kind_DefaultClause,
- Kind_DeleteExpression,
- Kind_DoWhileStatement,
- Kind_ElementList,
- Kind_Elision,
- Kind_EmptyStatement,
- Kind_Expression,
- Kind_ExpressionStatement,
- Kind_FalseLiteral,
- Kind_FieldMemberExpression,
- Kind_Finally,
- Kind_ForEachStatement,
- Kind_ForStatement,
- Kind_FormalParameterList,
- Kind_FunctionBody,
- Kind_FunctionDeclaration,
- Kind_FunctionExpression,
- Kind_FunctionSourceElement,
- Kind_IdentifierExpression,
- Kind_IdentifierPropertyName,
- Kind_IfStatement,
- Kind_LabelledStatement,
- Kind_LocalForEachStatement,
- Kind_LocalForStatement,
- Kind_NewExpression,
- Kind_NewMemberExpression,
- Kind_NotExpression,
- Kind_NullExpression,
- Kind_NumericLiteral,
- Kind_NumericLiteralPropertyName,
- Kind_ObjectLiteral,
- Kind_PostDecrementExpression,
- Kind_PostIncrementExpression,
- Kind_PreDecrementExpression,
- Kind_PreIncrementExpression,
- Kind_Program,
- Kind_PropertyName,
- Kind_PropertyNameAndValueList,
- Kind_RegExpLiteral,
- Kind_ReturnStatement,
- Kind_SourceElement,
- Kind_SourceElements,
- Kind_StatementList,
- Kind_StatementSourceElement,
- Kind_StringLiteral,
- Kind_StringLiteralPropertyName,
- Kind_SwitchStatement,
- Kind_ThisExpression,
- Kind_ThrowStatement,
- Kind_TildeExpression,
- Kind_TrueLiteral,
- Kind_TryStatement,
- Kind_TypeOfExpression,
- Kind_UnaryMinusExpression,
- Kind_UnaryPlusExpression,
- Kind_VariableDeclaration,
- Kind_VariableDeclarationList,
- Kind_VariableStatement,
- Kind_VoidExpression,
- Kind_WhileStatement,
- Kind_WithStatement,
- Kind_NestedExpression,
-
- Kind_UiArrayBinding,
- Kind_UiImport,
- Kind_UiImportList,
- Kind_UiObjectBinding,
- Kind_UiObjectDefinition,
- Kind_UiObjectInitializer,
- Kind_UiObjectMemberList,
- Kind_UiArrayMemberList,
- Kind_UiProgram,
- Kind_UiParameterList,
- Kind_UiPublicMember,
- Kind_UiQualifiedId,
- Kind_UiScriptBinding,
- Kind_UiSourceElement,
- Kind_UiFormal,
- Kind_UiFormalList,
- Kind_UiSignature
- };
-
- inline Node()
- : kind(Kind_Undefined) {}
-
- virtual ~Node() {}
-
- virtual ExpressionNode *expressionCast();
- virtual BinaryExpression *binaryExpressionCast();
- virtual Statement *statementCast();
- virtual UiObjectMember *uiObjectMemberCast();
-
- void accept(Visitor *visitor);
- static void accept(Node *node, Visitor *visitor);
-
- inline static void acceptChild(Node *node, Visitor *visitor)
- { return accept(node, visitor); } // ### remove
-
- virtual void accept0(Visitor *visitor) = 0;
-
-// attributes
- int kind;
-};
-
-class QML_PARSER_EXPORT ExpressionNode: public Node
-{
-public:
- ExpressionNode() {}
- virtual ~ExpressionNode() {}
-
- virtual ExpressionNode *expressionCast();
-
- virtual SourceLocation firstSourceLocation() const = 0;
- virtual SourceLocation lastSourceLocation() const = 0;
-};
-
-class QML_PARSER_EXPORT Statement: public Node
-{
-public:
- Statement() {}
- virtual ~Statement() {}
-
- virtual Statement *statementCast();
-
- virtual SourceLocation firstSourceLocation() const = 0;
- virtual SourceLocation lastSourceLocation() const = 0;
-};
-
-class QML_PARSER_EXPORT UiFormal: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiFormal)
-
- UiFormal(NameId *name, NameId *alias = 0)
- : name(name), alias(alias)
- { }
-
- virtual SourceLocation firstSourceLocation() const
- { return SourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return SourceLocation(); }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- NameId *name;
- NameId *alias;
- SourceLocation identifierToken;
- SourceLocation asToken;
- SourceLocation aliasToken;
-};
-
-class QML_PARSER_EXPORT UiFormalList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiFormalList)
-
- UiFormalList(UiFormal *formal)
- : formal(formal), next(this) {}
-
- UiFormalList(UiFormalList *previous, UiFormal *formal)
- : formal(formal)
- {
- next = previous->next;
- previous->next = this;
- }
-
- UiFormalList *finish()
- {
- UiFormalList *head = next;
- next = 0;
- return head;
- }
-
- virtual SourceLocation firstSourceLocation() const
- { return SourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return SourceLocation(); }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- UiFormal *formal;
- UiFormalList *next;
-};
-
-class QML_PARSER_EXPORT UiSignature: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiSignature)
-
- UiSignature(UiFormalList *formals = 0)
- : formals(formals)
- { }
-
- virtual SourceLocation firstSourceLocation() const
- { return SourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return SourceLocation(); }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- SourceLocation lparenToken;
- UiFormalList *formals;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT NestedExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(NestedExpression)
-
- NestedExpression(ExpressionNode *expression)
- : expression(expression)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return lparenToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rparenToken; }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT ThisExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(ThisExpression)
-
- ThisExpression() { kind = K; }
- virtual ~ThisExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return thisToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return thisToken; }
-
-// attributes
- SourceLocation thisToken;
-};
-
-class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(IdentifierExpression)
-
- IdentifierExpression(NameId *n):
- name (n) { kind = K; }
-
- virtual ~IdentifierExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return identifierToken; }
-
-// attributes
- NameId *name;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT NullExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(NullExpression)
-
- NullExpression() { kind = K; }
- virtual ~NullExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return nullToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return nullToken; }
-
-// attributes
- SourceLocation nullToken;
-};
-
-class QML_PARSER_EXPORT TrueLiteral: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(TrueLiteral)
-
- TrueLiteral() { kind = K; }
- virtual ~TrueLiteral() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return trueToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return trueToken; }
-
-// attributes
- SourceLocation trueToken;
-};
-
-class QML_PARSER_EXPORT FalseLiteral: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(FalseLiteral)
-
- FalseLiteral() { kind = K; }
- virtual ~FalseLiteral() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return falseToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return falseToken; }
-
-// attributes
- SourceLocation falseToken;
-};
-
-class QML_PARSER_EXPORT NumericLiteral: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(NumericLiteral)
-
- NumericLiteral(double v):
- value(v) { kind = K; }
- virtual ~NumericLiteral() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return literalToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return literalToken; }
-
-// attributes:
- double value;
- SourceLocation literalToken;
-};
-
-class QML_PARSER_EXPORT StringLiteral: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(StringLiteral)
-
- StringLiteral(NameId *v):
- value (v) { kind = K; }
-
- virtual ~StringLiteral() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return literalToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return literalToken; }
-
-// attributes:
- NameId *value;
- SourceLocation literalToken;
-};
-
-class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(RegExpLiteral)
-
- RegExpLiteral(NameId *p, int f):
- pattern (p), flags (f) { kind = K; }
-
- virtual ~RegExpLiteral() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return literalToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return literalToken; }
-
-// attributes:
- NameId *pattern;
- int flags;
- SourceLocation literalToken;
-};
-
-class QML_PARSER_EXPORT ArrayLiteral: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(ArrayLiteral)
-
- ArrayLiteral(Elision *e):
- elements (0), elision (e)
- { kind = K; }
-
- ArrayLiteral(ElementList *elts):
- elements (elts), elision (0)
- { kind = K; }
-
- ArrayLiteral(ElementList *elts, Elision *e):
- elements (elts), elision (e)
- { kind = K; }
-
- virtual ~ArrayLiteral() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return lbracketToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbracketToken; }
-
-// attributes
- ElementList *elements;
- Elision *elision;
- SourceLocation lbracketToken;
- SourceLocation commaToken;
- SourceLocation rbracketToken;
-};
-
-class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(ObjectLiteral)
-
- ObjectLiteral():
- properties (0) { kind = K; }
-
- ObjectLiteral(PropertyNameAndValueList *plist):
- properties (plist) { kind = K; }
-
- virtual ~ObjectLiteral() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return lbraceToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbraceToken; }
-
-// attributes
- PropertyNameAndValueList *properties;
- SourceLocation lbraceToken;
- SourceLocation rbraceToken;
-};
-
-class QML_PARSER_EXPORT ElementList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(ElementList)
-
- ElementList(Elision *e, ExpressionNode *expr):
- elision (e), expression (expr), next (this)
- { kind = K; }
-
- ElementList(ElementList *previous, Elision *e, ExpressionNode *expr):
- elision (e), expression (expr)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~ElementList() {}
-
- inline ElementList *finish ()
- {
- ElementList *front = next;
- next = 0;
- return front;
- }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- Elision *elision;
- ExpressionNode *expression;
- ElementList *next;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT Elision: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(Elision)
-
- Elision():
- next (this) { kind = K; }
-
- Elision(Elision *previous)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~Elision() {}
-
- virtual void accept0(Visitor *visitor);
-
- inline Elision *finish ()
- {
- Elision *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- Elision *next;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT PropertyNameAndValueList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(PropertyNameAndValueList)
-
- PropertyNameAndValueList(PropertyName *n, ExpressionNode *v):
- name (n), value (v), next (this)
- { kind = K; }
-
- PropertyNameAndValueList(PropertyNameAndValueList *previous, PropertyName *n, ExpressionNode *v):
- name (n), value (v)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~PropertyNameAndValueList() {}
-
- virtual void accept0(Visitor *visitor);
-
- inline PropertyNameAndValueList *finish ()
- {
- PropertyNameAndValueList *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- PropertyName *name;
- ExpressionNode *value;
- PropertyNameAndValueList *next;
- SourceLocation colonToken;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT PropertyName: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(PropertyName)
-
- PropertyName() { kind = K; }
- virtual ~PropertyName() {}
-
-// attributes
- SourceLocation propertyNameToken;
-};
-
-class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
-{
-public:
- QMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
-
- IdentifierPropertyName(NameId *n):
- id (n) { kind = K; }
-
- virtual ~IdentifierPropertyName() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- NameId *id;
-};
-
-class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
-{
-public:
- QMLJS_DECLARE_AST_NODE(StringLiteralPropertyName)
-
- StringLiteralPropertyName(NameId *n):
- id (n) { kind = K; }
- virtual ~StringLiteralPropertyName() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- NameId *id;
-};
-
-class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName
-{
-public:
- QMLJS_DECLARE_AST_NODE(NumericLiteralPropertyName)
-
- NumericLiteralPropertyName(double n):
- id (n) { kind = K; }
- virtual ~NumericLiteralPropertyName() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- double id;
-};
-
-class QML_PARSER_EXPORT ArrayMemberExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(ArrayMemberExpression)
-
- ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e):
- base (b), expression (e)
- { kind = K; }
-
- virtual ~ArrayMemberExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return base->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbracketToken; }
-
-// attributes
- ExpressionNode *base;
- ExpressionNode *expression;
- SourceLocation lbracketToken;
- SourceLocation rbracketToken;
-};
-
-class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(FieldMemberExpression)
-
- FieldMemberExpression(ExpressionNode *b, NameId *n):
- base (b), name (n)
- { kind = K; }
-
- virtual ~FieldMemberExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return base->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return identifierToken; }
-
- // attributes
- ExpressionNode *base;
- NameId *name;
- SourceLocation dotToken;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT NewMemberExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(NewMemberExpression)
-
- NewMemberExpression(ExpressionNode *b, ArgumentList *a):
- base (b), arguments (a)
- { kind = K; }
-
- virtual ~NewMemberExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return newToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rparenToken; }
-
- // attributes
- ExpressionNode *base;
- ArgumentList *arguments;
- SourceLocation newToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT NewExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(NewExpression)
-
- NewExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~NewExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return newToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation newToken;
-};
-
-class QML_PARSER_EXPORT CallExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(CallExpression)
-
- CallExpression(ExpressionNode *b, ArgumentList *a):
- base (b), arguments (a)
- { kind = K; }
-
- virtual ~CallExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return base->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return rparenToken; }
-
-// attributes
- ExpressionNode *base;
- ArgumentList *arguments;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT ArgumentList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(ArgumentList)
-
- ArgumentList(ExpressionNode *e):
- expression (e), next (this)
- { kind = K; }
-
- ArgumentList(ArgumentList *previous, ExpressionNode *e):
- expression (e)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~ArgumentList() {}
-
- virtual void accept0(Visitor *visitor);
-
- inline ArgumentList *finish ()
- {
- ArgumentList *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- ExpressionNode *expression;
- ArgumentList *next;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(PostIncrementExpression)
-
- PostIncrementExpression(ExpressionNode *b):
- base (b) { kind = K; }
-
- virtual ~PostIncrementExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return base->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return incrementToken; }
-
-// attributes
- ExpressionNode *base;
- SourceLocation incrementToken;
-};
-
-class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(PostDecrementExpression)
-
- PostDecrementExpression(ExpressionNode *b):
- base (b) { kind = K; }
-
- virtual ~PostDecrementExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return base->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return decrementToken; }
-
-// attributes
- ExpressionNode *base;
- SourceLocation decrementToken;
-};
-
-class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(DeleteExpression)
-
- DeleteExpression(ExpressionNode *e):
- expression (e) { kind = K; }
- virtual ~DeleteExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return deleteToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation deleteToken;
-};
-
-class QML_PARSER_EXPORT VoidExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(VoidExpression)
-
- VoidExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~VoidExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return voidToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation voidToken;
-};
-
-class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(TypeOfExpression)
-
- TypeOfExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~TypeOfExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return typeofToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation typeofToken;
-};
-
-class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(PreIncrementExpression)
-
- PreIncrementExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~PreIncrementExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return incrementToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation incrementToken;
-};
-
-class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(PreDecrementExpression)
-
- PreDecrementExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~PreDecrementExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return decrementToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation decrementToken;
-};
-
-class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(UnaryPlusExpression)
-
- UnaryPlusExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~UnaryPlusExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return plusToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation plusToken;
-};
-
-class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(UnaryMinusExpression)
-
- UnaryMinusExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~UnaryMinusExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return minusToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation minusToken;
-};
-
-class QML_PARSER_EXPORT TildeExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(TildeExpression)
-
- TildeExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~TildeExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return tildeToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation tildeToken;
-};
-
-class QML_PARSER_EXPORT NotExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(NotExpression)
-
- NotExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~NotExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return notToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation notToken;
-};
-
-class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(BinaryExpression)
-
- BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r):
- left (l), op (o), right (r)
- { kind = K; }
-
- virtual ~BinaryExpression() {}
-
- virtual BinaryExpression *binaryExpressionCast();
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return left->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return right->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *left;
- int op;
- ExpressionNode *right;
- SourceLocation operatorToken;
-};
-
-class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(ConditionalExpression)
-
- ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f):
- expression (e), ok (t), ko (f)
- { kind = K; }
-
- virtual ~ConditionalExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return expression->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return ko->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- ExpressionNode *ok;
- ExpressionNode *ko;
- SourceLocation questionToken;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename
-{
-public:
- QMLJS_DECLARE_AST_NODE(Expression)
-
- Expression(ExpressionNode *l, ExpressionNode *r):
- left (l), right (r) { kind = K; }
-
- virtual ~Expression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return left->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return right->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *left;
- ExpressionNode *right;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT Block: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(Block)
-
- Block(StatementList *slist):
- statements (slist) { kind = K; }
-
- virtual ~Block() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return lbraceToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbraceToken; }
-
- // attributes
- StatementList *statements;
- SourceLocation lbraceToken;
- SourceLocation rbraceToken;
-};
-
-class QML_PARSER_EXPORT StatementList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(StatementList)
-
- StatementList(Statement *stmt):
- statement (stmt), next (this)
- { kind = K; }
-
- StatementList(StatementList *previous, Statement *stmt):
- statement (stmt)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~StatementList() {}
-
- virtual void accept0(Visitor *visitor);
-
- inline StatementList *finish ()
- {
- StatementList *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- Statement *statement;
- StatementList *next;
-};
-
-class QML_PARSER_EXPORT VariableStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(VariableStatement)
-
- VariableStatement(VariableDeclarationList *vlist):
- declarations (vlist)
- { kind = K; }
-
- virtual ~VariableStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return declarationKindToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- VariableDeclarationList *declarations;
- SourceLocation declarationKindToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT VariableDeclaration: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(VariableDeclaration)
-
- VariableDeclaration(NameId *n, ExpressionNode *e):
- name (n), expression (e), readOnly(false)
- { kind = K; }
-
- virtual ~VariableDeclaration() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- NameId *name;
- ExpressionNode *expression;
- bool readOnly;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT VariableDeclarationList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(VariableDeclarationList)
-
- VariableDeclarationList(VariableDeclaration *decl):
- declaration (decl), next (this)
- { kind = K; }
-
- VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl):
- declaration (decl)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~VariableDeclarationList() {}
-
- virtual void accept0(Visitor *visitor);
-
- inline VariableDeclarationList *finish (bool readOnly)
- {
- VariableDeclarationList *front = next;
- next = 0;
- if (readOnly) {
- VariableDeclarationList *vdl;
- for (vdl = front; vdl != 0; vdl = vdl->next)
- vdl->declaration->readOnly = true;
- }
- return front;
- }
-
-// attributes
- VariableDeclaration *declaration;
- VariableDeclarationList *next;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT EmptyStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(EmptyStatement)
-
- EmptyStatement() { kind = K; }
- virtual ~EmptyStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return semicolonToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT ExpressionStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(ExpressionStatement)
-
- ExpressionStatement(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~ExpressionStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return expression->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT IfStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(IfStatement)
-
- IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0):
- expression (e), ok (t), ko (f)
- { kind = K; }
-
- virtual ~IfStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return ifToken; }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (ko)
- return ko->lastSourceLocation();
-
- return ok->lastSourceLocation();
- }
-
-// attributes
- ExpressionNode *expression;
- Statement *ok;
- Statement *ko;
- SourceLocation ifToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
- SourceLocation elseToken;
-};
-
-class QML_PARSER_EXPORT DoWhileStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(DoWhileStatement)
-
- DoWhileStatement(Statement *stmt, ExpressionNode *e):
- statement (stmt), expression (e)
- { kind = K; }
-
- virtual ~DoWhileStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return doToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- Statement *statement;
- ExpressionNode *expression;
- SourceLocation doToken;
- SourceLocation whileToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT WhileStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(WhileStatement)
-
- WhileStatement(ExpressionNode *e, Statement *stmt):
- expression (e), statement (stmt)
- { kind = K; }
-
- virtual ~WhileStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return whileToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation whileToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT ForStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(ForStatement)
-
- ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
- initialiser (i), condition (c), expression (e), statement (stmt)
- { kind = K; }
-
- virtual ~ForStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return forToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *initialiser;
- ExpressionNode *condition;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation firstSemicolonToken;
- SourceLocation secondSemicolonToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT LocalForStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(LocalForStatement)
-
- LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
- declarations (vlist), condition (c), expression (e), statement (stmt)
- { kind = K; }
-
- virtual ~LocalForStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return forToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- VariableDeclarationList *declarations;
- ExpressionNode *condition;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation varToken;
- SourceLocation firstSemicolonToken;
- SourceLocation secondSemicolonToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT ForEachStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(ForEachStatement)
-
- ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt):
- initialiser (i), expression (e), statement (stmt)
- { kind = K; }
-
- virtual ~ForEachStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return forToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *initialiser;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation inToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT LocalForEachStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(LocalForEachStatement)
-
- LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt):
- declaration (v), expression (e), statement (stmt)
- { kind = K; }
-
- virtual ~LocalForEachStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return forToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- VariableDeclaration *declaration;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation varToken;
- SourceLocation inToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT ContinueStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(ContinueStatement)
-
- ContinueStatement(NameId *l = 0):
- label (l) { kind = K; }
-
- virtual ~ContinueStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return continueToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- NameId *label;
- SourceLocation continueToken;
- SourceLocation identifierToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT BreakStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(BreakStatement)
-
- BreakStatement(NameId *l = 0):
- label (l) { kind = K; }
-
- virtual ~BreakStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return breakToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
- // attributes
- NameId *label;
- SourceLocation breakToken;
- SourceLocation identifierToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT ReturnStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(ReturnStatement)
-
- ReturnStatement(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~ReturnStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return returnToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation returnToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT WithStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(WithStatement)
-
- WithStatement(ExpressionNode *e, Statement *stmt):
- expression (e), statement (stmt)
- { kind = K; }
-
- virtual ~WithStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return withToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation withToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT CaseBlock: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(CaseBlock)
-
- CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0):
- clauses (c), defaultClause (d), moreClauses (r)
- { kind = K; }
-
- virtual ~CaseBlock() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- CaseClauses *clauses;
- DefaultClause *defaultClause;
- CaseClauses *moreClauses;
- SourceLocation lbraceToken;
- SourceLocation rbraceToken;
-};
-
-class QML_PARSER_EXPORT SwitchStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(SwitchStatement)
-
- SwitchStatement(ExpressionNode *e, CaseBlock *b):
- expression (e), block (b)
- { kind = K; }
-
- virtual ~SwitchStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return switchToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return block->rbraceToken; }
-
-// attributes
- ExpressionNode *expression;
- CaseBlock *block;
- SourceLocation switchToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT CaseClauses: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(CaseClauses)
-
- CaseClauses(CaseClause *c):
- clause (c), next (this)
- { kind = K; }
-
- CaseClauses(CaseClauses *previous, CaseClause *c):
- clause (c)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~CaseClauses() {}
-
- virtual void accept0(Visitor *visitor);
-
- inline CaseClauses *finish ()
- {
- CaseClauses *front = next;
- next = 0;
- return front;
- }
-
-//attributes
- CaseClause *clause;
- CaseClauses *next;
-};
-
-class QML_PARSER_EXPORT CaseClause: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(CaseClause)
-
- CaseClause(ExpressionNode *e, StatementList *slist):
- expression (e), statements (slist)
- { kind = K; }
-
- virtual ~CaseClause() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- ExpressionNode *expression;
- StatementList *statements;
- SourceLocation caseToken;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT DefaultClause: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(DefaultClause)
-
- DefaultClause(StatementList *slist):
- statements (slist)
- { kind = K; }
-
- virtual ~DefaultClause() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- StatementList *statements;
- SourceLocation defaultToken;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT LabelledStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(LabelledStatement)
-
- LabelledStatement(NameId *l, Statement *stmt):
- label (l), statement (stmt)
- { kind = K; }
-
- virtual ~LabelledStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- NameId *label;
- Statement *statement;
- SourceLocation identifierToken;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT ThrowStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(ThrowStatement)
-
- ThrowStatement(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual ~ThrowStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return throwToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
- // attributes
- ExpressionNode *expression;
- SourceLocation throwToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT Catch: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(Catch)
-
- Catch(NameId *n, Block *stmt):
- name (n), statement (stmt)
- { kind = K; }
-
- virtual ~Catch() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- NameId *name;
- Block *statement;
- SourceLocation catchToken;
- SourceLocation lparenToken;
- SourceLocation identifierToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT Finally: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(Finally)
-
- Finally(Block *stmt):
- statement (stmt)
- { kind = K; }
-
- virtual ~Finally() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- Block *statement;
- SourceLocation finallyToken;
-};
-
-class QML_PARSER_EXPORT TryStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(TryStatement)
-
- TryStatement(Statement *stmt, Catch *c, Finally *f):
- statement (stmt), catchExpression (c), finallyExpression (f)
- { kind = K; }
-
- TryStatement(Statement *stmt, Finally *f):
- statement (stmt), catchExpression (0), finallyExpression (f)
- { kind = K; }
-
- TryStatement(Statement *stmt, Catch *c):
- statement (stmt), catchExpression (c), finallyExpression (0)
- { kind = K; }
-
- virtual ~TryStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return tryToken; }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (finallyExpression)
- return finallyExpression->statement->rbraceToken;
- else if (catchExpression)
- return catchExpression->statement->rbraceToken;
-
- return statement->lastSourceLocation();
- }
-
-// attributes
- Statement *statement;
- Catch *catchExpression;
- Finally *finallyExpression;
- SourceLocation tryToken;
-};
-
-class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
-{
-public:
- QMLJS_DECLARE_AST_NODE(FunctionExpression)
-
- FunctionExpression(NameId *n, FormalParameterList *f, FunctionBody *b):
- name (n), formals (f), body (b)
- { kind = K; }
-
- virtual ~FunctionExpression() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return functionToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbraceToken; }
-
-// attributes
- NameId *name;
- FormalParameterList *formals;
- FunctionBody *body;
- SourceLocation functionToken;
- SourceLocation identifierToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
- SourceLocation lbraceToken;
- SourceLocation rbraceToken;
-};
-
-class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
-{
-public:
- QMLJS_DECLARE_AST_NODE(FunctionDeclaration)
-
- FunctionDeclaration(NameId *n, FormalParameterList *f, FunctionBody *b):
- FunctionExpression(n, f, b)
- { kind = K; }
-
- virtual ~FunctionDeclaration() {}
-
- virtual void accept0(Visitor *visitor);
-};
-
-class QML_PARSER_EXPORT FormalParameterList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(FormalParameterList)
-
- FormalParameterList(NameId *n):
- name (n), next (this)
- { kind = K; }
-
- FormalParameterList(FormalParameterList *previous, NameId *n):
- name (n)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~FormalParameterList() {}
-
- virtual void accept0(Visitor *visitor);
-
- inline FormalParameterList *finish ()
- {
- FormalParameterList *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- NameId *name;
- FormalParameterList *next;
- SourceLocation commaToken;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT FunctionBody: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(FunctionBody)
-
- FunctionBody(SourceElements *elts):
- elements (elts)
- { kind = K; }
-
- virtual ~FunctionBody() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- SourceElements *elements;
-};
-
-class QML_PARSER_EXPORT Program: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(Program)
-
- Program(SourceElements *elts):
- elements (elts)
- { kind = K; }
-
- virtual ~Program() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- SourceElements *elements;
-};
-
-class QML_PARSER_EXPORT SourceElements: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(SourceElements)
-
- SourceElements(SourceElement *elt):
- element (elt), next (this)
- { kind = K; }
-
- SourceElements(SourceElements *previous, SourceElement *elt):
- element (elt)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~SourceElements() {}
-
- virtual void accept0(Visitor *visitor);
-
- inline SourceElements *finish ()
- {
- SourceElements *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- SourceElement *element;
- SourceElements *next;
-};
-
-class QML_PARSER_EXPORT SourceElement: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(SourceElement)
-
- inline SourceElement()
- { kind = K; }
-
- virtual ~SourceElement() {}
-};
-
-class QML_PARSER_EXPORT FunctionSourceElement: public SourceElement
-{
-public:
- QMLJS_DECLARE_AST_NODE(FunctionSourceElement)
-
- FunctionSourceElement(FunctionDeclaration *f):
- declaration (f)
- { kind = K; }
-
- virtual ~FunctionSourceElement() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- FunctionDeclaration *declaration;
-};
-
-class QML_PARSER_EXPORT StatementSourceElement: public SourceElement
-{
-public:
- QMLJS_DECLARE_AST_NODE(StatementSourceElement)
-
- StatementSourceElement(Statement *stmt):
- statement (stmt)
- { kind = K; }
-
- virtual ~StatementSourceElement() {}
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- Statement *statement;
-};
-
-class QML_PARSER_EXPORT DebuggerStatement: public Statement
-{
-public:
- QMLJS_DECLARE_AST_NODE(DebuggerStatement)
-
- DebuggerStatement()
- { kind = K; }
-
- virtual ~DebuggerStatement() {}
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return debuggerToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- SourceLocation debuggerToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT UiProgram: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiProgram)
-
- UiProgram(UiImportList *imports, UiObjectMemberList *members)
- : imports(imports), members(members)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- UiImportList *imports;
- UiObjectMemberList *members;
-};
-
-class QML_PARSER_EXPORT UiQualifiedId: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiQualifiedId)
-
- UiQualifiedId(NameId *name)
- : next(this), name(name)
- { kind = K; }
-
- UiQualifiedId(UiQualifiedId *previous, NameId *name)
- : name(name)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~UiQualifiedId() {}
-
- UiQualifiedId *finish()
- {
- UiQualifiedId *head = next;
- next = 0;
- return head;
- }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- UiQualifiedId *next;
- NameId *name;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT UiImport: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiImport)
-
- UiImport(NameId *fileName)
- : fileName(fileName), importUri(0), importId(0)
- { kind = K; }
-
- UiImport(UiQualifiedId *uri)
- : fileName(0), importUri(uri), importId(0)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- { return importToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- NameId *fileName;
- UiQualifiedId *importUri;
- NameId *importId;
- SourceLocation importToken;
- SourceLocation fileNameToken;
- SourceLocation versionToken;
- SourceLocation asToken;
- SourceLocation importIdToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT UiImportList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiImportList)
-
- UiImportList(UiImport *import)
- : import(import),
- next(this)
- { kind = K; }
-
- UiImportList(UiImportList *previous, UiImport *import)
- : import(import)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual SourceLocation firstSourceLocation() const
- {
- if (import) return import->firstSourceLocation();
- else return SourceLocation();
- }
-
- virtual SourceLocation lastSourceLocation() const
- {
- for (const UiImportList *it = this; it; it = it->next)
- if (!it->next && it->import)
- return it->import->lastSourceLocation();
-
- return SourceLocation();
- }
-
- UiImportList *finish()
- {
- UiImportList *head = next;
- next = 0;
- return head;
- }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- UiImport *import;
- UiImportList *next;
-};
-
-class QML_PARSER_EXPORT UiObjectMember: public Node
-{
-public:
- virtual SourceLocation firstSourceLocation() const = 0;
- virtual SourceLocation lastSourceLocation() const = 0;
-
- virtual UiObjectMember *uiObjectMemberCast();
-};
-
-class QML_PARSER_EXPORT UiObjectMemberList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiObjectMemberList)
-
- UiObjectMemberList(UiObjectMember *member)
- : next(this), member(member)
- { kind = K; }
-
- UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member)
- : member(member)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- UiObjectMemberList *finish()
- {
- UiObjectMemberList *head = next;
- next = 0;
- return head;
- }
-
-// attributes
- UiObjectMemberList *next;
- UiObjectMember *member;
-};
-
-class QML_PARSER_EXPORT UiArrayMemberList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiArrayMemberList)
-
- UiArrayMemberList(UiObjectMember *member)
- : next(this), member(member)
- { kind = K; }
-
- UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member)
- : member(member)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- UiArrayMemberList *finish()
- {
- UiArrayMemberList *head = next;
- next = 0;
- return head;
- }
-
-// attributes
- UiArrayMemberList *next;
- UiObjectMember *member;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT UiObjectInitializer: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiObjectInitializer)
-
- UiObjectInitializer(UiObjectMemberList *members)
- : members(members)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- SourceLocation lbraceToken;
- UiObjectMemberList *members;
- SourceLocation rbraceToken;
-};
-
-class QML_PARSER_EXPORT UiParameterList: public Node
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiParameterList)
-
- UiParameterList(NameId *t, NameId *n):
- type (t), name (n), next (this)
- { kind = K; }
-
- UiParameterList(UiParameterList *previous, NameId *t, NameId *n):
- type (t), name (n)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual ~UiParameterList() {}
-
- virtual void accept0(Visitor *) {}
-
- inline UiParameterList *finish ()
- {
- UiParameterList *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- NameId *type;
- NameId *name;
- UiParameterList *next;
- SourceLocation commaToken;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiPublicMember)
-
- UiPublicMember(NameId *memberType,
- NameId *name)
- : type(Property), typeModifier(0), memberType(memberType), name(name), expression(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
- { kind = K; }
-
- UiPublicMember(NameId *memberType,
- NameId *name,
- ExpressionNode *expression)
- : type(Property), typeModifier(0), memberType(memberType), name(name), expression(expression), isDefaultMember(false), isReadonlyMember(false), parameters(0)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- {
- if (defaultToken.isValid())
- return defaultToken;
- else if (readonlyToken.isValid())
- return readonlyToken;
-
- return propertyToken;
- }
-
- virtual SourceLocation lastSourceLocation() const
- {
- return semicolonToken;
- }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- enum { Signal, Property } type;
- NameId *typeModifier;
- NameId *memberType;
- NameId *name;
- ExpressionNode *expression;
- bool isDefaultMember;
- bool isReadonlyMember;
- UiParameterList *parameters;
- SourceLocation defaultToken;
- SourceLocation readonlyToken;
- SourceLocation propertyToken;
- SourceLocation typeModifierToken;
- SourceLocation typeToken;
- SourceLocation identifierToken;
- SourceLocation colonToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiObjectDefinition)
-
- UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId,
- UiObjectInitializer *initializer)
- : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- { return qualifiedTypeNameId->identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return initializer->rbraceToken; }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- UiQualifiedId *qualifiedTypeNameId;
- UiObjectInitializer *initializer;
-};
-
-class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiSourceElement)
-
- UiSourceElement(Node *sourceElement)
- : sourceElement(sourceElement)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- {
- if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
- return funDecl->firstSourceLocation();
- else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
- return varStmt->firstSourceLocation();
-
- return SourceLocation();
- }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
- return funDecl->lastSourceLocation();
- else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
- return varStmt->lastSourceLocation();
-
- return SourceLocation();
- }
-
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- Node *sourceElement;
-};
-
-class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiObjectBinding)
-
- UiObjectBinding(UiQualifiedId *qualifiedId,
- UiQualifiedId *qualifiedTypeNameId,
- UiObjectInitializer *initializer)
- : qualifiedId(qualifiedId),
- qualifiedTypeNameId(qualifiedTypeNameId),
- initializer(initializer)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- { return qualifiedId->identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return initializer->rbraceToken; }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- UiQualifiedId *qualifiedId;
- UiQualifiedId *qualifiedTypeNameId;
- UiObjectInitializer *initializer;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiScriptBinding)
-
- UiScriptBinding(UiQualifiedId *qualifiedId,
- Statement *statement)
- : qualifiedId(qualifiedId),
- statement(statement)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- { return qualifiedId->identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- UiQualifiedId *qualifiedId;
- Statement *statement;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember
-{
-public:
- QMLJS_DECLARE_AST_NODE(UiArrayBinding)
-
- UiArrayBinding(UiQualifiedId *qualifiedId,
- UiArrayMemberList *members)
- : qualifiedId(qualifiedId),
- members(members)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- { return qualifiedId->identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbracketToken; }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- UiQualifiedId *qualifiedId;
- UiArrayMemberList *members;
- SourceLocation colonToken;
- SourceLocation lbracketToken;
- SourceLocation rbracketToken;
-};
-
-} } // namespace AST
-
-
-
-QT_QML_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/parser/qmljsastfwd_p.h b/src/declarative/qml/parser/qmljsastfwd_p.h
deleted file mode 100644
index 2c42fd9..0000000
--- a/src/declarative/qml/parser/qmljsastfwd_p.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLJSAST_FWD_P_H
-#define QMLJSAST_FWD_P_H
-
-#include "qmljsglobal_p.h"
-
-#include <QtCore/qglobal.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.
-//
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS { namespace AST {
-
-class SourceLocation
-{
-public:
- SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
- : offset(offset), length(length),
- startLine(line), startColumn(column)
- { }
-
- bool isValid() const { return length != 0; }
-
- quint32 begin() const { return offset; }
- quint32 end() const { return offset + length; }
-
-// attributes
- // ### encode
- quint32 offset;
- quint32 length;
- quint32 startLine;
- quint32 startColumn;
-};
-
-class Visitor;
-class Node;
-class ExpressionNode;
-class Statement;
-class ThisExpression;
-class IdentifierExpression;
-class NullExpression;
-class TrueLiteral;
-class FalseLiteral;
-class NumericLiteral;
-class StringLiteral;
-class RegExpLiteral;
-class ArrayLiteral;
-class ObjectLiteral;
-class ElementList;
-class Elision;
-class PropertyNameAndValueList;
-class PropertyName;
-class IdentifierPropertyName;
-class StringLiteralPropertyName;
-class NumericLiteralPropertyName;
-class ArrayMemberExpression;
-class FieldMemberExpression;
-class NewMemberExpression;
-class NewExpression;
-class CallExpression;
-class ArgumentList;
-class PostIncrementExpression;
-class PostDecrementExpression;
-class DeleteExpression;
-class VoidExpression;
-class TypeOfExpression;
-class PreIncrementExpression;
-class PreDecrementExpression;
-class UnaryPlusExpression;
-class UnaryMinusExpression;
-class TildeExpression;
-class NotExpression;
-class BinaryExpression;
-class ConditionalExpression;
-class Expression; // ### rename
-class Block;
-class StatementList;
-class VariableStatement;
-class VariableDeclarationList;
-class VariableDeclaration;
-class EmptyStatement;
-class ExpressionStatement;
-class IfStatement;
-class DoWhileStatement;
-class WhileStatement;
-class ForStatement;
-class LocalForStatement;
-class ForEachStatement;
-class LocalForEachStatement;
-class ContinueStatement;
-class BreakStatement;
-class ReturnStatement;
-class WithStatement;
-class SwitchStatement;
-class CaseBlock;
-class CaseClauses;
-class CaseClause;
-class DefaultClause;
-class LabelledStatement;
-class ThrowStatement;
-class TryStatement;
-class Catch;
-class Finally;
-class FunctionDeclaration;
-class FunctionExpression;
-class FormalParameterList;
-class FunctionBody;
-class Program;
-class SourceElements;
-class SourceElement;
-class FunctionSourceElement;
-class StatementSourceElement;
-class DebuggerStatement;
-class NestedExpression;
-
-// ui elements
-class UiProgram;
-class UiImportList;
-class UiImport;
-class UiPublicMember;
-class UiObjectDefinition;
-class UiObjectInitializer;
-class UiObjectBinding;
-class UiScriptBinding;
-class UiSourceElement;
-class UiArrayBinding;
-class UiObjectMember;
-class UiObjectMemberList;
-class UiArrayMemberList;
-class UiQualifiedId;
-class UiFormalList;
-class UiFormal;
-class UiSignature;
-
-} } // namespace AST
-
-QT_QML_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/parser/qmljsastvisitor.cpp b/src/declarative/qml/parser/qmljsastvisitor.cpp
deleted file mode 100644
index bd7439c..0000000
--- a/src/declarative/qml/parser/qmljsastvisitor.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmljsastvisitor_p.h"
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS { namespace AST {
-
-Visitor::Visitor()
-{
-}
-
-Visitor::~Visitor()
-{
-}
-
-} } // namespace QmlJS::AST
-
-QT_QML_END_NAMESPACE
diff --git a/src/declarative/qml/parser/qmljsastvisitor_p.h b/src/declarative/qml/parser/qmljsastvisitor_p.h
deleted file mode 100644
index 9007a2c..0000000
--- a/src/declarative/qml/parser/qmljsastvisitor_p.h
+++ /dev/null
@@ -1,335 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLJSASTVISITOR_P_H
-#define QMLJSASTVISITOR_P_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 "qmljsastfwd_p.h"
-#include "qmljsglobal_p.h"
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS { namespace AST {
-
-class QML_PARSER_EXPORT Visitor
-{
-public:
- Visitor();
- virtual ~Visitor();
-
- virtual bool preVisit(Node *) { return true; }
- virtual void postVisit(Node *) {}
-
- // Ui
- virtual bool visit(UiProgram *) { return true; }
- virtual bool visit(UiImportList *) { return true; }
- virtual bool visit(UiImport *) { return true; }
- virtual bool visit(UiPublicMember *) { return true; }
- virtual bool visit(UiSourceElement *) { return true; }
- virtual bool visit(UiObjectDefinition *) { return true; }
- virtual bool visit(UiObjectInitializer *) { return true; }
- virtual bool visit(UiObjectBinding *) { return true; }
- virtual bool visit(UiScriptBinding *) { return true; }
- virtual bool visit(UiArrayBinding *) { return true; }
- virtual bool visit(UiObjectMemberList *) { return true; }
- virtual bool visit(UiArrayMemberList *) { return true; }
- virtual bool visit(UiQualifiedId *) { return true; }
- virtual bool visit(UiSignature *) { return true; }
- virtual bool visit(UiFormalList *) { return true; }
- virtual bool visit(UiFormal *) { return true; }
-
- virtual void endVisit(UiProgram *) {}
- virtual void endVisit(UiImportList *) {}
- virtual void endVisit(UiImport *) {}
- virtual void endVisit(UiPublicMember *) {}
- virtual void endVisit(UiSourceElement *) {}
- virtual void endVisit(UiObjectDefinition *) {}
- virtual void endVisit(UiObjectInitializer *) {}
- virtual void endVisit(UiObjectBinding *) {}
- virtual void endVisit(UiScriptBinding *) {}
- virtual void endVisit(UiArrayBinding *) {}
- virtual void endVisit(UiObjectMemberList *) {}
- virtual void endVisit(UiArrayMemberList *) {}
- virtual void endVisit(UiQualifiedId *) {}
- virtual void endVisit(UiSignature *) {}
- virtual void endVisit(UiFormalList *) {}
- virtual void endVisit(UiFormal *) {}
-
- // QmlJS
- virtual bool visit(ThisExpression *) { return true; }
- virtual void endVisit(ThisExpression *) {}
-
- virtual bool visit(IdentifierExpression *) { return true; }
- virtual void endVisit(IdentifierExpression *) {}
-
- virtual bool visit(NullExpression *) { return true; }
- virtual void endVisit(NullExpression *) {}
-
- virtual bool visit(TrueLiteral *) { return true; }
- virtual void endVisit(TrueLiteral *) {}
-
- virtual bool visit(FalseLiteral *) { return true; }
- virtual void endVisit(FalseLiteral *) {}
-
- virtual bool visit(StringLiteral *) { return true; }
- virtual void endVisit(StringLiteral *) {}
-
- virtual bool visit(NumericLiteral *) { return true; }
- virtual void endVisit(NumericLiteral *) {}
-
- virtual bool visit(RegExpLiteral *) { return true; }
- virtual void endVisit(RegExpLiteral *) {}
-
- virtual bool visit(ArrayLiteral *) { return true; }
- virtual void endVisit(ArrayLiteral *) {}
-
- virtual bool visit(ObjectLiteral *) { return true; }
- virtual void endVisit(ObjectLiteral *) {}
-
- virtual bool visit(ElementList *) { return true; }
- virtual void endVisit(ElementList *) {}
-
- virtual bool visit(Elision *) { return true; }
- virtual void endVisit(Elision *) {}
-
- virtual bool visit(PropertyNameAndValueList *) { return true; }
- virtual void endVisit(PropertyNameAndValueList *) {}
-
- virtual bool visit(NestedExpression *) { return true; }
- virtual void endVisit(NestedExpression *) {}
-
- virtual bool visit(IdentifierPropertyName *) { return true; }
- virtual void endVisit(IdentifierPropertyName *) {}
-
- virtual bool visit(StringLiteralPropertyName *) { return true; }
- virtual void endVisit(StringLiteralPropertyName *) {}
-
- virtual bool visit(NumericLiteralPropertyName *) { return true; }
- virtual void endVisit(NumericLiteralPropertyName *) {}
-
- virtual bool visit(ArrayMemberExpression *) { return true; }
- virtual void endVisit(ArrayMemberExpression *) {}
-
- virtual bool visit(FieldMemberExpression *) { return true; }
- virtual void endVisit(FieldMemberExpression *) {}
-
- virtual bool visit(NewMemberExpression *) { return true; }
- virtual void endVisit(NewMemberExpression *) {}
-
- virtual bool visit(NewExpression *) { return true; }
- virtual void endVisit(NewExpression *) {}
-
- virtual bool visit(CallExpression *) { return true; }
- virtual void endVisit(CallExpression *) {}
-
- virtual bool visit(ArgumentList *) { return true; }
- virtual void endVisit(ArgumentList *) {}
-
- virtual bool visit(PostIncrementExpression *) { return true; }
- virtual void endVisit(PostIncrementExpression *) {}
-
- virtual bool visit(PostDecrementExpression *) { return true; }
- virtual void endVisit(PostDecrementExpression *) {}
-
- virtual bool visit(DeleteExpression *) { return true; }
- virtual void endVisit(DeleteExpression *) {}
-
- virtual bool visit(VoidExpression *) { return true; }
- virtual void endVisit(VoidExpression *) {}
-
- virtual bool visit(TypeOfExpression *) { return true; }
- virtual void endVisit(TypeOfExpression *) {}
-
- virtual bool visit(PreIncrementExpression *) { return true; }
- virtual void endVisit(PreIncrementExpression *) {}
-
- virtual bool visit(PreDecrementExpression *) { return true; }
- virtual void endVisit(PreDecrementExpression *) {}
-
- virtual bool visit(UnaryPlusExpression *) { return true; }
- virtual void endVisit(UnaryPlusExpression *) {}
-
- virtual bool visit(UnaryMinusExpression *) { return true; }
- virtual void endVisit(UnaryMinusExpression *) {}
-
- virtual bool visit(TildeExpression *) { return true; }
- virtual void endVisit(TildeExpression *) {}
-
- virtual bool visit(NotExpression *) { return true; }
- virtual void endVisit(NotExpression *) {}
-
- virtual bool visit(BinaryExpression *) { return true; }
- virtual void endVisit(BinaryExpression *) {}
-
- virtual bool visit(ConditionalExpression *) { return true; }
- virtual void endVisit(ConditionalExpression *) {}
-
- virtual bool visit(Expression *) { return true; }
- virtual void endVisit(Expression *) {}
-
- virtual bool visit(Block *) { return true; }
- virtual void endVisit(Block *) {}
-
- virtual bool visit(StatementList *) { return true; }
- virtual void endVisit(StatementList *) {}
-
- virtual bool visit(VariableStatement *) { return true; }
- virtual void endVisit(VariableStatement *) {}
-
- virtual bool visit(VariableDeclarationList *) { return true; }
- virtual void endVisit(VariableDeclarationList *) {}
-
- virtual bool visit(VariableDeclaration *) { return true; }
- virtual void endVisit(VariableDeclaration *) {}
-
- virtual bool visit(EmptyStatement *) { return true; }
- virtual void endVisit(EmptyStatement *) {}
-
- virtual bool visit(ExpressionStatement *) { return true; }
- virtual void endVisit(ExpressionStatement *) {}
-
- virtual bool visit(IfStatement *) { return true; }
- virtual void endVisit(IfStatement *) {}
-
- virtual bool visit(DoWhileStatement *) { return true; }
- virtual void endVisit(DoWhileStatement *) {}
-
- virtual bool visit(WhileStatement *) { return true; }
- virtual void endVisit(WhileStatement *) {}
-
- virtual bool visit(ForStatement *) { return true; }
- virtual void endVisit(ForStatement *) {}
-
- virtual bool visit(LocalForStatement *) { return true; }
- virtual void endVisit(LocalForStatement *) {}
-
- virtual bool visit(ForEachStatement *) { return true; }
- virtual void endVisit(ForEachStatement *) {}
-
- virtual bool visit(LocalForEachStatement *) { return true; }
- virtual void endVisit(LocalForEachStatement *) {}
-
- virtual bool visit(ContinueStatement *) { return true; }
- virtual void endVisit(ContinueStatement *) {}
-
- virtual bool visit(BreakStatement *) { return true; }
- virtual void endVisit(BreakStatement *) {}
-
- virtual bool visit(ReturnStatement *) { return true; }
- virtual void endVisit(ReturnStatement *) {}
-
- virtual bool visit(WithStatement *) { return true; }
- virtual void endVisit(WithStatement *) {}
-
- virtual bool visit(SwitchStatement *) { return true; }
- virtual void endVisit(SwitchStatement *) {}
-
- virtual bool visit(CaseBlock *) { return true; }
- virtual void endVisit(CaseBlock *) {}
-
- virtual bool visit(CaseClauses *) { return true; }
- virtual void endVisit(CaseClauses *) {}
-
- virtual bool visit(CaseClause *) { return true; }
- virtual void endVisit(CaseClause *) {}
-
- virtual bool visit(DefaultClause *) { return true; }
- virtual void endVisit(DefaultClause *) {}
-
- virtual bool visit(LabelledStatement *) { return true; }
- virtual void endVisit(LabelledStatement *) {}
-
- virtual bool visit(ThrowStatement *) { return true; }
- virtual void endVisit(ThrowStatement *) {}
-
- virtual bool visit(TryStatement *) { return true; }
- virtual void endVisit(TryStatement *) {}
-
- virtual bool visit(Catch *) { return true; }
- virtual void endVisit(Catch *) {}
-
- virtual bool visit(Finally *) { return true; }
- virtual void endVisit(Finally *) {}
-
- virtual bool visit(FunctionDeclaration *) { return true; }
- virtual void endVisit(FunctionDeclaration *) {}
-
- virtual bool visit(FunctionExpression *) { return true; }
- virtual void endVisit(FunctionExpression *) {}
-
- virtual bool visit(FormalParameterList *) { return true; }
- virtual void endVisit(FormalParameterList *) {}
-
- virtual bool visit(FunctionBody *) { return true; }
- virtual void endVisit(FunctionBody *) {}
-
- virtual bool visit(Program *) { return true; }
- virtual void endVisit(Program *) {}
-
- virtual bool visit(SourceElements *) { return true; }
- virtual void endVisit(SourceElements *) {}
-
- virtual bool visit(FunctionSourceElement *) { return true; }
- virtual void endVisit(FunctionSourceElement *) {}
-
- virtual bool visit(StatementSourceElement *) { return true; }
- virtual void endVisit(StatementSourceElement *) {}
-
- virtual bool visit(DebuggerStatement *) { return true; }
- virtual void endVisit(DebuggerStatement *) {}
-};
-
-} } // namespace AST
-
-QT_QML_END_NAMESPACE
-
-#endif // QMLJSASTVISITOR_P_H
diff --git a/src/declarative/qml/parser/qmljsengine_p.cpp b/src/declarative/qml/parser/qmljsengine_p.cpp
deleted file mode 100644
index 84bb1c5..0000000
--- a/src/declarative/qml/parser/qmljsengine_p.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmljsengine_p.h"
-
-#include "qmljsglobal_p.h"
-#include "qmljsnodepool_p.h"
-
-#include <qnumeric.h>
-#include <QHash>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS {
-
-uint qHash(const QmlJS::NameId &id)
-{ return qHash(id.asString()); }
-
-QString numberToString(double value)
-{ return QString::number(value); }
-
-int Ecma::RegExp::flagFromChar(const QChar &ch)
-{
- static QHash<QChar, int> flagsHash;
- if (flagsHash.isEmpty()) {
- flagsHash[QLatin1Char('g')] = Global;
- flagsHash[QLatin1Char('i')] = IgnoreCase;
- flagsHash[QLatin1Char('m')] = Multiline;
- }
- QHash<QChar, int>::const_iterator it;
- it = flagsHash.constFind(ch);
- if (it == flagsHash.constEnd())
- return 0;
- return it.value();
-}
-
-QString Ecma::RegExp::flagsToString(int flags)
-{
- QString result;
- if (flags & Global)
- result += QLatin1Char('g');
- if (flags & IgnoreCase)
- result += QLatin1Char('i');
- if (flags & Multiline)
- result += QLatin1Char('m');
- return result;
-}
-
-NodePool::NodePool(const QString &fileName, Engine *engine)
- : m_fileName(fileName), m_engine(engine)
-{
- m_engine->setNodePool(this);
-}
-
-NodePool::~NodePool()
-{
-}
-
-Code *NodePool::createCompiledCode(AST::Node *, CompilationUnit &)
-{
- Q_ASSERT(0);
- return 0;
-}
-
-static int toDigit(char c)
-{
- if ((c >= '0') && (c <= '9'))
- return c - '0';
- else if ((c >= 'a') && (c <= 'z'))
- return 10 + c - 'a';
- else if ((c >= 'A') && (c <= 'Z'))
- return 10 + c - 'A';
- return -1;
-}
-
-double integerFromString(const char *buf, int size, int radix)
-{
- if (size == 0)
- return qSNaN();
-
- double sign = 1.0;
- int i = 0;
- if (buf[0] == '+') {
- ++i;
- } else if (buf[0] == '-') {
- sign = -1.0;
- ++i;
- }
-
- if (((size-i) >= 2) && (buf[i] == '0')) {
- if (((buf[i+1] == 'x') || (buf[i+1] == 'X'))
- && (radix < 34)) {
- if ((radix != 0) && (radix != 16))
- return 0;
- radix = 16;
- i += 2;
- } else {
- if (radix == 0) {
- radix = 8;
- ++i;
- }
- }
- } else if (radix == 0) {
- radix = 10;
- }
-
- int j = i;
- for ( ; i < size; ++i) {
- int d = toDigit(buf[i]);
- if ((d == -1) || (d >= radix))
- break;
- }
- double result;
- if (j == i) {
- if (!qstrcmp(buf, "Infinity"))
- result = qInf();
- else
- result = qSNaN();
- } else {
- result = 0;
- double multiplier = 1;
- for (--i ; i >= j; --i, multiplier *= radix)
- result += toDigit(buf[i]) * multiplier;
- }
- result *= sign;
- return result;
-}
-
-double integerFromString(const QString &str, int radix)
-{
- QByteArray ba = str.trimmed().toLatin1();
- return integerFromString(ba.constData(), ba.size(), radix);
-}
-
-
-Engine::Engine()
- : _lexer(0), _nodePool(0)
-{ }
-
-Engine::~Engine()
-{ }
-
-QSet<NameId> Engine::literals() const
-{ return _literals; }
-
-void Engine::addComment(int pos, int len, int line, int col)
-{ if (len > 0) _comments.append(QmlJS::AST::SourceLocation(pos, len, line, col)); }
-
-QList<QmlJS::AST::SourceLocation> Engine::comments() const
-{ return _comments; }
-
-NameId *Engine::intern(const QChar *u, int s)
-{ return const_cast<NameId *>(&*_literals.insert(NameId(u, s))); }
-
-QString Engine::toString(NameId *id)
-{ return id->asString(); }
-
-Lexer *Engine::lexer() const
-{ return _lexer; }
-
-void Engine::setLexer(Lexer *lexer)
-{ _lexer = lexer; }
-
-NodePool *Engine::nodePool() const
-{ return _nodePool; }
-
-void Engine::setNodePool(NodePool *nodePool)
-{ _nodePool = nodePool; }
-
-
-
-} // end of namespace QmlJS
-
-QT_QML_END_NAMESPACE
diff --git a/src/declarative/qml/parser/qmljsengine_p.h b/src/declarative/qml/parser/qmljsengine_p.h
deleted file mode 100644
index ebfeb1b..0000000
--- a/src/declarative/qml/parser/qmljsengine_p.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLJSENGINE_P_H
-#define QMLJSENGINE_P_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 "qmljsglobal_p.h"
-#include "qmljsastfwd_p.h"
-
-#include <QString>
-#include <QSet>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS {
-class QML_PARSER_EXPORT NameId
-{
- QString _text;
-
-public:
- NameId(const QChar *u, int s)
- : _text(u, s)
- { }
-
- const QString asString() const
- { return _text; }
-
- bool operator == (const NameId &other) const
- { return _text == other._text; }
-
- bool operator != (const NameId &other) const
- { return _text != other._text; }
-
- bool operator < (const NameId &other) const
- { return _text < other._text; }
-};
-
-uint qHash(const QmlJS::NameId &id);
-
-} // end of namespace QmlJS
-
-#if defined(Q_CC_MSVC) && _MSC_VER <= 1300
-//this ensures that code outside QmlJS can use the hash function
-//it also a workaround for some compilers
-inline uint qHash(const QmlJS::NameId &nameId) { return QmlJS::qHash(nameId); }
-#endif
-
-namespace QmlJS {
-
-class Lexer;
-class NodePool;
-
-namespace Ecma {
-
-class QML_PARSER_EXPORT RegExp
-{
-public:
- enum RegExpFlag {
- Global = 0x01,
- IgnoreCase = 0x02,
- Multiline = 0x04
- };
-
-public:
- static int flagFromChar(const QChar &);
- static QString flagsToString(int flags);
-};
-
-} // end of namespace Ecma
-
-class QML_PARSER_EXPORT DiagnosticMessage
-{
-public:
- enum Kind { Warning, Error };
-
- DiagnosticMessage()
- : kind(Error) {}
-
- DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message)
- : kind(kind), loc(loc), message(message) {}
-
- bool isWarning() const
- { return kind == Warning; }
-
- bool isError() const
- { return kind == Error; }
-
- Kind kind;
- AST::SourceLocation loc;
- QString message;
-};
-
-class QML_PARSER_EXPORT Engine
-{
- Lexer *_lexer;
- NodePool *_nodePool;
- QSet<NameId> _literals;
- QList<QmlJS::AST::SourceLocation> _comments;
-
-public:
- Engine();
- ~Engine();
-
- QSet<NameId> literals() const;
-
- void addComment(int pos, int len, int line, int col);
- QList<QmlJS::AST::SourceLocation> comments() const;
-
- NameId *intern(const QChar *u, int s);
-
- static QString toString(NameId *id);
-
- Lexer *lexer() const;
- void setLexer(Lexer *lexer);
-
- NodePool *nodePool() const;
- void setNodePool(NodePool *nodePool);
-};
-
-} // end of namespace QmlJS
-
-QT_QML_END_NAMESPACE
-
-#endif // QMLJSENGINE_P_H
diff --git a/src/declarative/qml/parser/qmljsglobal_p.h b/src/declarative/qml/parser/qmljsglobal_p.h
deleted file mode 100644
index 4457450..0000000
--- a/src/declarative/qml/parser/qmljsglobal_p.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QMLJSGLOBAL_P_H
-#define QMLJSGLOBAL_P_H
-
-#include <QtCore/qglobal.h>
-
-#ifdef QT_CREATOR
-# define QT_QML_BEGIN_NAMESPACE
-# define QT_QML_END_NAMESPACE
-
-# ifdef QMLJS_BUILD_DIR
-# define QML_PARSER_EXPORT Q_DECL_EXPORT
-# elif QML_BUILD_STATIC_LIB
-# define QML_PARSER_EXPORT
-# else
-# define QML_PARSER_EXPORT Q_DECL_IMPORT
-# endif // QMLJS_BUILD_DIR
-
-#else // !QT_CREATOR
-# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
-# define QT_QML_END_NAMESPACE QT_END_NAMESPACE
-# define QML_PARSER_EXPORT
-#endif // QT_CREATOR
-
-#endif // QMLJSGLOBAL_P_H
diff --git a/src/declarative/qml/parser/qmljsgrammar.cpp b/src/declarative/qml/parser/qmljsgrammar.cpp
deleted file mode 100644
index 12071db..0000000
--- a/src/declarative/qml/parser/qmljsgrammar.cpp
+++ /dev/null
@@ -1,939 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// This file was generated by qlalr - DO NOT EDIT!
-#include "qmljsgrammar_p.h"
-
-QT_BEGIN_NAMESPACE
-
-const char *const QmlJSGrammar::spell [] = {
- "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ";", "continue",
- "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===",
- "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier",
- "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=",
- "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=",
- "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return",
- ")", ";", 0, "*", "*=", "string literal", "property", "signal", "readonly", "switch",
- "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^",
- "^=", "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "comment", "public",
- "import", "as", 0, 0, 0, 0, 0, 0, 0, 0};
-
-const short QmlJSGrammar::lhs [] = {
- 100, 100, 100, 100, 100, 100, 101, 107, 107, 110,
- 110, 112, 111, 111, 111, 111, 111, 111, 111, 111,
- 114, 109, 108, 117, 117, 118, 118, 119, 119, 116,
- 105, 105, 105, 105, 105, 105, 105, 125, 125, 125,
- 126, 126, 127, 127, 105, 105, 105, 105, 105, 105,
- 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
- 105, 105, 115, 115, 115, 115, 130, 130, 130, 130,
- 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
- 130, 130, 130, 130, 120, 132, 132, 132, 132, 131,
- 131, 134, 134, 136, 136, 136, 136, 136, 136, 137,
- 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
- 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
- 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
- 138, 138, 113, 113, 113, 113, 113, 141, 141, 142,
- 142, 142, 142, 140, 140, 143, 143, 144, 144, 145,
- 145, 145, 146, 146, 146, 146, 146, 146, 146, 146,
- 146, 146, 147, 147, 147, 147, 148, 148, 148, 149,
- 149, 149, 149, 150, 150, 150, 150, 150, 150, 150,
- 151, 151, 151, 151, 151, 151, 152, 152, 152, 152,
- 152, 153, 153, 153, 153, 153, 154, 154, 155, 155,
- 156, 156, 157, 157, 158, 158, 159, 159, 160, 160,
- 161, 161, 162, 162, 163, 163, 164, 164, 165, 165,
- 135, 135, 166, 166, 167, 167, 167, 167, 167, 167,
- 167, 167, 167, 167, 167, 167, 103, 103, 168, 168,
- 169, 169, 170, 170, 102, 102, 102, 102, 102, 102,
- 102, 102, 102, 102, 102, 102, 102, 102, 102, 121,
- 182, 182, 181, 181, 129, 129, 183, 183, 184, 184,
- 186, 186, 185, 187, 190, 188, 188, 191, 189, 189,
- 122, 123, 123, 124, 124, 171, 171, 171, 171, 171,
- 171, 171, 172, 172, 172, 172, 173, 173, 173, 173,
- 174, 174, 175, 177, 192, 192, 195, 195, 193, 193,
- 196, 194, 176, 176, 176, 178, 178, 179, 179, 179,
- 197, 198, 180, 180, 128, 139, 202, 202, 199, 199,
- 200, 200, 203, 106, 204, 204, 104, 104, 201, 201,
- 133, 133, 205};
-
-const short QmlJSGrammar::rhs [] = {
- 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
- 2, 1, 2, 2, 3, 3, 5, 5, 4, 4,
- 2, 0, 1, 1, 2, 1, 3, 2, 3, 2,
- 1, 5, 4, 3, 3, 3, 3, 1, 1, 1,
- 0, 1, 2, 4, 6, 6, 3, 3, 7, 7,
- 4, 4, 5, 5, 6, 6, 7, 7, 7, 7,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 2, 3, 3, 4,
- 5, 3, 4, 3, 1, 1, 2, 3, 4, 1,
- 2, 3, 5, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 4, 3, 5, 1, 2, 4,
- 4, 4, 3, 0, 1, 1, 3, 1, 1, 1,
- 2, 2, 1, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 1, 3, 3, 3, 1, 3, 3, 1,
- 3, 3, 3, 1, 3, 3, 3, 3, 3, 3,
- 1, 3, 3, 3, 3, 3, 1, 3, 3, 3,
- 3, 1, 3, 3, 3, 3, 1, 3, 1, 3,
- 1, 3, 1, 3, 1, 3, 1, 3, 1, 3,
- 1, 3, 1, 3, 1, 3, 1, 5, 1, 5,
- 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 3, 0, 1,
- 1, 3, 0, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
- 1, 2, 0, 1, 3, 3, 1, 1, 1, 3,
- 1, 3, 2, 2, 2, 0, 1, 2, 0, 1,
- 1, 2, 2, 7, 5, 7, 7, 5, 9, 10,
- 7, 8, 2, 2, 3, 3, 2, 2, 3, 3,
- 3, 3, 5, 5, 3, 5, 1, 2, 0, 1,
- 4, 3, 3, 3, 3, 3, 3, 3, 3, 4,
- 5, 2, 2, 2, 8, 8, 1, 3, 0, 1,
- 0, 1, 1, 1, 1, 2, 1, 1, 0, 1,
- 0, 1, 2};
-
-const short QmlJSGrammar::action_default [] = {
- 0, 0, 0, 0, 0, 0, 22, 0, 170, 237,
- 201, 209, 205, 149, 221, 197, 3, 134, 68, 150,
- 213, 217, 138, 167, 148, 153, 133, 187, 174, 0,
- 75, 76, 71, 339, 63, 341, 0, 0, 0, 0,
- 73, 0, 0, 69, 72, 0, 0, 64, 66, 65,
- 74, 67, 0, 70, 0, 0, 163, 0, 0, 150,
- 169, 152, 151, 0, 0, 0, 165, 166, 164, 168,
- 0, 198, 0, 0, 0, 0, 188, 0, 0, 0,
- 0, 0, 0, 178, 0, 0, 0, 172, 173, 171,
- 176, 180, 179, 177, 175, 190, 189, 191, 0, 206,
- 0, 202, 0, 0, 144, 131, 143, 132, 100, 101,
- 102, 127, 103, 128, 104, 105, 106, 107, 108, 109,
- 110, 111, 112, 113, 114, 115, 116, 129, 117, 118,
- 119, 120, 121, 122, 123, 124, 125, 126, 130, 0,
- 0, 142, 238, 145, 0, 146, 0, 147, 141, 0,
- 234, 227, 225, 232, 233, 231, 230, 236, 229, 228,
- 226, 235, 222, 0, 210, 0, 0, 214, 0, 0,
- 218, 0, 0, 144, 136, 0, 135, 0, 140, 154,
- 0, 340, 329, 330, 0, 327, 0, 328, 0, 331,
- 245, 252, 251, 259, 247, 0, 248, 332, 0, 338,
- 249, 250, 255, 253, 335, 333, 337, 256, 0, 267,
- 0, 0, 0, 0, 339, 63, 0, 341, 64, 239,
- 281, 65, 0, 0, 0, 268, 0, 0, 257, 258,
- 0, 246, 254, 282, 283, 326, 336, 0, 297, 298,
- 299, 300, 0, 293, 294, 295, 296, 323, 324, 0,
- 0, 0, 0, 0, 286, 287, 243, 241, 203, 211,
- 207, 223, 199, 244, 0, 150, 215, 219, 192, 181,
- 0, 0, 200, 0, 0, 0, 0, 193, 0, 0,
- 0, 0, 0, 185, 183, 186, 184, 182, 195, 194,
- 196, 0, 208, 0, 204, 0, 242, 150, 0, 224,
- 239, 240, 0, 239, 0, 0, 289, 0, 0, 0,
- 291, 0, 212, 0, 0, 216, 0, 0, 220, 279,
- 0, 271, 280, 274, 0, 278, 0, 239, 272, 0,
- 239, 0, 0, 290, 0, 0, 0, 292, 340, 329,
- 0, 0, 331, 0, 325, 0, 315, 0, 0, 0,
- 285, 0, 284, 0, 342, 0, 99, 261, 264, 0,
- 100, 267, 103, 128, 105, 106, 71, 110, 111, 63,
- 112, 115, 69, 72, 64, 239, 65, 74, 118, 67,
- 120, 70, 122, 123, 268, 125, 126, 130, 0, 92,
- 0, 0, 94, 98, 96, 83, 95, 97, 0, 93,
- 82, 262, 260, 138, 139, 144, 0, 137, 0, 314,
- 0, 301, 302, 0, 313, 0, 0, 0, 304, 309,
- 307, 310, 0, 0, 308, 309, 0, 305, 0, 306,
- 263, 312, 0, 263, 311, 0, 316, 317, 0, 263,
- 318, 319, 0, 0, 320, 0, 0, 0, 321, 322,
- 156, 155, 0, 0, 0, 288, 0, 0, 0, 303,
- 276, 269, 0, 277, 273, 0, 275, 265, 0, 266,
- 270, 86, 0, 0, 90, 77, 0, 79, 88, 0,
- 80, 89, 91, 81, 87, 78, 0, 84, 160, 158,
- 162, 159, 157, 161, 6, 334, 4, 2, 61, 85,
- 0, 0, 64, 66, 65, 31, 5, 0, 62, 0,
- 40, 39, 38, 0, 0, 53, 0, 54, 0, 59,
- 60, 0, 40, 0, 0, 0, 0, 0, 49, 50,
- 0, 51, 0, 52, 0, 55, 56, 0, 0, 0,
- 0, 0, 57, 58, 0, 47, 41, 48, 42, 0,
- 0, 0, 0, 44, 0, 45, 46, 43, 0, 0,
- 30, 34, 35, 36, 37, 138, 263, 0, 0, 100,
- 267, 103, 128, 105, 106, 71, 110, 111, 63, 112,
- 115, 69, 72, 64, 239, 65, 74, 118, 67, 120,
- 70, 122, 123, 268, 125, 126, 130, 138, 0, 26,
- 0, 0, 32, 27, 33, 28, 24, 0, 29, 25,
- 8, 0, 10, 0, 9, 0, 1, 21, 12, 0,
- 13, 0, 14, 0, 19, 20, 0, 15, 16, 0,
- 17, 18, 11, 23, 7, 343};
-
-const short QmlJSGrammar::goto_default [] = {
- 7, 616, 206, 195, 204, 506, 494, 615, 634, 610,
- 614, 612, 617, 22, 613, 18, 505, 607, 598, 560,
- 507, 190, 194, 196, 200, 523, 549, 548, 199, 231,
- 26, 473, 472, 355, 354, 9, 353, 356, 106, 17,
- 144, 24, 13, 143, 19, 25, 56, 23, 8, 28,
- 27, 268, 15, 262, 10, 258, 12, 260, 11, 259,
- 20, 266, 21, 267, 14, 261, 257, 298, 410, 263,
- 264, 201, 192, 191, 203, 232, 202, 207, 228, 229,
- 193, 359, 358, 230, 462, 461, 320, 321, 464, 323,
- 463, 322, 418, 422, 425, 421, 420, 440, 441, 184,
- 198, 180, 183, 197, 205, 0};
-
-const short QmlJSGrammar::action_index [] = {
- 439, 1109, 2228, 2228, 2132, 814, -74, 18, 147, -100,
- 31, -17, -49, 232, -100, 318, 85, -100, -100, 554,
- 33, 94, 331, 215, -100, -100, -100, 448, 231, 1109,
- -100, -100, -100, 320, -100, 1940, 1472, 1109, 1109, 1109,
- -100, 724, 1109, -100, -100, 1109, 1109, -100, -100, -100,
- -100, -100, 1109, -100, 1109, 1109, -100, 1109, 1109, 129,
- 157, -100, -100, 1109, 1109, 1109, -100, -100, -100, 200,
- 1109, 293, 1109, 1109, 1109, 1109, 466, 1109, 1109, 1109,
- 1109, 1109, 1109, 179, 1109, 1109, 1109, 119, 125, 95,
- 188, 198, 184, 203, 178, 567, 567, 484, 1109, -5,
- 1109, 67, 1844, 1109, 1109, -100, -100, -100, -100, -100,
- -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
- -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
- -100, -100, -100, -100, -100, -100, -100, -100, -100, 110,
- 1109, -100, -100, 70, 61, -100, 1109, -100, -100, 1109,
- -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
- -100, -100, -100, 1109, 55, 1109, 1109, 73, 63, 1109,
- -100, 1844, 1109, 1109, -100, 141, -100, 41, -100, -100,
- 87, -100, 255, 80, 78, -100, 287, -100, 83, 2228,
- -100, -100, -100, -100, -100, 225, -100, -100, 52, -100,
- -100, -100, -100, -100, -100, 2228, -100, -100, 420, -100,
- 408, 113, 2132, 50, 330, 65, 46, 2420, 72, 1109,
- -100, 74, 75, 1109, 77, -100, 53, 56, -100, -100,
- 323, -100, -100, -100, -100, -100, -100, 96, -100, -100,
- -100, -100, 99, -100, -100, -100, -100, -100, -100, 60,
- 47, 1109, 118, 93, -100, -100, 1291, -100, 79, 66,
- 64, -100, 413, 76, 51, 664, 89, 97, 393, 183,
- 337, 1109, 413, 1109, 1109, 1109, 1109, 411, 1109, 1109,
- 1109, 1109, 1109, 252, 272, 212, 217, 221, 490, 490,
- 383, 1109, 64, 1109, 84, 1109, -100, 536, 1109, -100,
- 1109, 69, 68, 1109, 44, 2132, -100, 1109, 124, 2132,
- -100, 1109, 54, 1109, 1109, 71, 88, 1109, -100, 82,
- 122, 154, -100, -100, 1109, -100, 343, 1109, -100, 81,
- 1109, 90, 2132, -100, 1109, 112, 2132, -100, 86, 333,
- -39, -10, 2228, -33, -100, 2132, -100, 1109, 246, 2132,
- 4, 2132, -100, 10, 16, -21, -100, -100, 2132, -26,
- 480, 19, 462, 128, 1109, 2132, 6, -9, 400, 8,
- -22, 840, -3, -6, -100, 1202, -100, -7, -28, 5,
- 1109, 2, -23, 1109, 0, 1109, -34, -30, 1109, -100,
- 2036, 21, -100, -100, -100, -100, -100, -100, 1109, -100,
- -100, -100, -100, 209, -100, 1109, 40, -100, 2132, -100,
- 101, -100, -100, 2132, -100, 1109, 120, 43, -100, 62,
- -100, 59, 109, 1109, -100, 57, 58, -100, 39, -100,
- 2132, -100, 117, 2132, -100, 199, -100, -100, 107, 2132,
- 34, -100, 24, 11, -100, 346, -19, 14, -100, -100,
- -100, -100, 1109, 133, 2132, -100, 1109, 126, 2132, -100,
- 20, -100, 173, -100, -100, 1109, -100, -100, 303, -100,
- -100, -100, 100, 1656, -100, -100, 1564, -100, -100, 1748,
- -100, -100, -100, -100, -100, -100, 131, -100, -100, -100,
- -100, -100, -100, -100, -100, 2228, -100, -100, -100, 158,
- -20, 752, 165, -16, 22, -100, -100, 98, -100, 189,
- -100, -100, -100, 28, 170, -100, 1109, -100, 230, -100,
- -100, 247, 1, 13, 238, 37, -24, 106, -100, -100,
- 273, -100, 1109, -100, 265, -100, -100, 242, -4, 12,
- 1109, 241, -100, -100, 234, -100, 245, -100, 3, 9,
- 311, 190, 316, -100, 134, -100, -100, -100, 1380, 1020,
- -100, -100, -100, -100, -100, 359, 2324, 1472, 15, 444,
- 38, 394, 138, 1109, 2132, 36, 17, 397, 42, 23,
- 840, 32, 29, -100, 1202, -100, 26, 35, 48, 1109,
- 45, 25, 1109, 49, 1109, 27, 30, 314, 132, -100,
- 7, 752, -100, -100, -100, -100, -100, 930, -100, -100,
- -100, 752, -100, 253, -87, 617, -100, -100, 102, 290,
- -100, 191, -100, 140, -100, -100, 275, -100, -100, 91,
- -100, -100, -100, -100, -100, -100,
-
- -106, 12, -87, 18, 17, 212, -106, -106, -106, -106,
- -106, -106, -106, -106, -106, -106, -106, -106, -106, -53,
- -106, -106, -106, -106, -106, -106, -106, -106, -106, 162,
- -106, -106, -106, -4, -106, -106, -11, 24, 75, 76,
- -106, 83, 55, -106, -106, 157, 158, -106, -106, -106,
- -106, -106, 150, -106, 172, 176, -106, 168, 167, -106,
- -106, -106, -106, 173, 154, 115, -106, -106, -106, -106,
- 147, -106, 121, 113, 112, 125, -106, 128, 143, 146,
- 140, 139, 136, -106, 122, 138, 130, -106, -106, -106,
- -106, -106, -106, -106, -106, -106, -106, -106, 149, -106,
- 153, -106, 110, 82, 46, -106, -106, -106, -106, -106,
- -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- 35, -106, -106, -106, -106, -106, 37, -106, -106, 45,
- -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- -106, -106, -106, 92, -106, 88, 58, -106, -106, 51,
- -106, 209, 72, 78, -106, -106, -106, -106, -106, -106,
- -106, -106, 27, -106, -106, -106, 63, -106, -106, -106,
- -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- -106, -106, -106, -106, -106, 50, -106, -106, 28, -106,
- 29, -106, 47, -106, 33, -106, -106, 66, -106, 73,
- -106, -106, -106, 81, 53, -106, -106, -106, -106, -106,
- -13, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- -106, 9, -106, -106, -106, -106, 111, -106, -106, -106,
- -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- 3, 186, -106, 220, 228, 234, 204, -106, 90, 91,
- 94, 97, 93, -106, -106, -106, -106, -106, -106, -106,
- -106, 210, -106, 187, -106, 214, -106, -106, 208, -106,
- 207, -106, -106, 155, -106, 8, -106, 4, -106, -1,
- -106, 217, -106, 177, 185, -106, -106, 184, -106, -106,
- -106, -106, -106, -106, 183, -106, 194, 105, -106, -106,
- 99, -106, 71, -106, 74, -106, 65, -106, -106, 114,
- -106, -106, -55, -106, -106, 64, -106, 44, -106, 30,
- -106, 31, -106, -106, -106, -106, -106, -106, 57, -106,
- 36, -106, 40, -106, 70, 59, -106, -106, 42, -106,
- -106, 104, -106, -106, -106, 38, -106, -106, -106, -106,
- 79, -106, 69, 108, -106, 84, -106, -106, 56, -106,
- 68, -106, -106, -106, -106, -106, -106, -106, 52, -106,
- -106, -106, -106, -106, -106, 109, -106, -106, 77, -106,
- -106, -106, -106, 86, -106, 80, -106, -106, -106, -106,
- -106, -59, -106, 43, -106, -63, -106, -106, -106, -106,
- 98, -106, -106, 95, -106, -106, -106, -106, -106, 60,
- -34, -106, -106, 32, -106, 41, -106, 39, -106, -106,
- -106, -106, 49, -106, 61, -106, 62, -106, 48, -106,
- -106, -106, -106, -106, -106, 23, -106, -106, 96, -106,
- -106, -106, -106, 34, -106, -106, 133, -106, -106, 54,
- -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- -106, -106, -106, -106, -106, 67, -106, -106, -106, -106,
- -106, 22, -106, -106, -106, -106, -106, -106, -106, -22,
- -106, -106, -106, -106, -106, -106, 2, -106, -106, -106,
- -106, -106, -106, -106, -19, -106, -106, -106, -106, -106,
- -106, -106, 100, -106, -106, -106, -106, -21, -106, -106,
- -3, -106, -106, -106, -106, -106, 13, -106, -106, -106,
- 11, 14, 10, -106, -106, -106, -106, -106, 279, 283,
- -106, -106, -106, -106, -106, -106, 19, 273, 15, 16,
- -106, 21, -106, 224, 6, -106, -106, 25, -106, -106,
- 85, -106, -106, -106, 26, -106, -106, -106, -106, 20,
- -106, 7, 87, -106, 107, -106, -106, -106, -106, -106,
- -106, 317, -106, -106, -106, -106, -106, 277, -106, -106,
- -106, 0, -106, -106, -2, 271, -106, -106, -106, 1,
- -106, -106, -106, -106, -106, -106, 5, -106, -106, -106,
- -106, -106, -106, -106, -106, -106};
-
-const short QmlJSGrammar::action_info [] = {
- -97, -98, 452, 611, -116, 527, 456, -124, 415, -121,
- 439, 551, -119, -108, 347, -94, 611, 388, 635, 540,
- 351, 341, 344, 342, 390, 539, -127, 256, 398, 402,
- 100, 98, 70, -97, 400, 163, -98, 465, 524, -116,
- 559, 447, 530, -108, 439, -127, 509, 439, 559, -94,
- 537, 544, -121, 256, 443, -119, -124, 514, 439, 347,
- 445, 526, 423, 452, 423, 430, 456, 423, 70, 554,
- 169, 415, 345, 311, 100, 163, 419, 140, 146, 408,
- 271, 413, 347, 251, 295, 271, 256, 0, 186, 452,
- 0, 311, 456, 140, 429, 317, 0, 0, 0, 324,
- 407, 178, 291, 98, 305, 558, 0, 235, 476, 0,
- 439, 415, 300, 442, 291, 0, 189, 171, 140, 426,
- 140, 148, 339, 182, 433, 140, 140, 443, 140, 303,
- 326, 559, 140, 0, 140, 57, 172, 250, 188, 140,
- 601, 140, 330, 293, 165, 0, 58, 313, 166, 140,
- 332, 314, 631, 630, 255, 254, 477, 241, 240, 57,
- 246, 245, 412, 411, 427, 57, 141, 529, 528, 63,
- 58, 61, 336, 171, 248, 247, 58, 516, 253, 0,
- 417, 468, 62, 327, 309, 334, 458, 57, 602, 248,
- 247, 487, 172, 454, 522, 556, 555, 176, 58, 248,
- 247, 625, 624, 84, 84, 85, 85, 140, 84, 84,
- 85, 85, 63, 84, 64, 85, 86, 86, 510, 510,
- 65, 86, 86, 84, 171, 85, 86, 63, 84, 0,
- 85, 517, 515, 140, 469, 467, 86, 84, 140, 85,
- 512, 86, 84, 172, 85, 405, 84, 102, 85, 140,
- 86, 511, 628, 627, 140, 86, 84, 64, 85, 86,
- 437, 436, 171, 65, 512, 512, 103, 510, 104, 86,
- 546, 510, 64, 140, 510, 511, 511, 84, 65, 85,
- 532, 172, 626, 405, 34, 0, 234, 233, 0, 0,
- 86, 520, 519, 0, 0, 547, 545, 84, 0, 85,
- 621, 0, 543, 542, 34, 0, 349, 0, 0, 0,
- 86, 72, 73, 512, 622, 620, 34, 512, 0, 34,
- 512, 47, 49, 48, 511, 0, 536, 535, 511, 171,
- 0, 511, 34, 0, 533, 531, 72, 73, 74, 75,
- 34, 47, 49, 48, 619, 34, 171, -85, 172, 34,
- 173, 0, 34, 47, 49, 48, 47, 49, 48, 34,
- 0, 0, 34, 74, 75, 172, 34, 173, 0, 47,
- 49, 48, 34, 0, 171, 34, 0, 47, 49, 48,
- 0, 0, 47, 49, 48, 0, 47, 49, 48, 47,
- 49, 48, -85, 172, 0, 173, 47, 49, 48, 47,
- 49, 48, 0, 47, 49, 48, 278, 279, 0, 47,
- 49, 48, 47, 49, 48, 280, 278, 279, 281, 0,
- 282, 0, 0, 34, 0, 280, 34, 0, 281, 34,
- 282, 273, 274, -339, 278, 279, -339, 34, 0, 0,
- 0, 0, 0, 280, 0, 0, 281, 0, 282, 34,
- 0, 0, 0, 0, 0, 244, 243, 0, 275, 276,
- 47, 49, 48, 47, 49, 48, 47, 49, 48, 244,
- 243, 77, 78, 34, 47, 49, 48, 0, 0, 79,
- 80, 239, 238, 81, 0, 82, 47, 49, 48, 77,
- 78, 34, 0, 0, 0, 0, 0, 79, 80, 0,
- 0, 81, 0, 82, 0, 239, 238, 77, 78, 34,
- 47, 49, 48, 278, 279, 79, 80, 0, 0, 81,
- 0, 82, 280, 244, 243, 281, 0, 282, 47, 49,
- 48, 6, 5, 4, 1, 3, 2, 0, 0, 150,
- 0, 239, 238, 0, 0, 0, 47, 49, 48, 151,
- 0, 0, 0, 152, 0, 0, 0, 150, 0, 0,
- 0, 0, 153, 0, 154, 0, 0, 151, 0, 0,
- 0, 152, 0, 0, 0, 155, 0, 156, 61, 0,
- 153, 0, 154, 0, 0, 157, 0, 0, 158, 62,
- 77, 78, 0, 155, 159, 156, 61, 0, 79, 80,
- 160, 0, 81, 157, 82, 0, 158, 62, 0, 0,
- 0, 0, 159, 0, 0, 0, 161, 0, 160, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 30,
- 31, 0, 0, 0, 161, 0, 0, 0, 0, 33,
- 0, 0, 0, 0, 0, 0, 34, 0, 0, 0,
- 35, 36, 0, 37, 0, 0, 0, 0, 0, 0,
- 501, 0, 0, 0, 44, 0, 0, 150, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 151, 0, 0,
- 0, 152, 50, 47, 49, 48, 0, 51, 0, 0,
- 153, 0, 154, 0, 0, 307, 0, 0, 43, 53,
- 32, 0, 0, 155, 40, 156, 61, 0, 0, 0,
- 0, 0, 0, 157, 0, 0, 158, 62, 0, 0,
- 0, 0, 159, 0, 0, 0, 0, 0, 160, 0,
- 0, 0, 0, 0, 0, 0, 30, 31, 0, 0,
- 0, 0, 0, 0, 161, 0, 33, 0, 0, 0,
- 0, 0, 0, 34, 0, 0, 0, 35, 36, 0,
- 37, 0, 0, 0, 30, 31, 0, 41, 0, 0,
- 0, 44, 0, 0, 33, 0, 0, 0, 0, 0,
- 0, 34, 0, 0, 0, 35, 36, 0, 37, 50,
- 47, 49, 48, 0, 51, 501, 0, 0, 0, 44,
- 0, 0, 0, 0, 0, 43, 53, 32, 0, 0,
- 0, 40, 0, 0, 0, 0, 0, 50, 47, 49,
- 48, 0, 51, 0, 500, 0, 30, 31, 0, 0,
- 0, 0, 0, 43, 53, 32, 214, 0, 0, 40,
- 0, 0, 0, 34, 0, 0, 0, 35, 36, 0,
- 37, 0, 30, 31, 0, 0, 0, 501, 0, 0,
- 0, 44, 33, 0, 0, 0, 0, 0, 0, 34,
- 0, 0, 0, 35, 36, 0, 37, 0, 0, 50,
- 502, 504, 503, 41, 51, 0, 0, 44, 0, 225,
- 0, 0, 0, 0, 0, 43, 53, 32, 209, 0,
- 0, 40, 0, 0, 0, 50, 47, 49, 48, 0,
- 51, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 43, 53, 32, 0, 0, 0, 40, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 500, 0, 30, 31, 0, 0, 0, 0, 0, 0,
- 0, 0, 214, 0, 0, 0, 0, 0, 0, 34,
- 0, 0, 0, 35, 36, 0, 37, 0, 0, 0,
- 0, 0, 0, 501, 0, 0, 0, 44, 0, 0,
- 0, 0, 0, 0, 0, 608, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 50, 502, 504, 503, 0,
- 51, 0, 0, 0, 0, 225, 0, 0, 0, 0,
- 0, 43, 53, 32, 209, 0, 0, 40, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 500, 0, 30, 31, 0, 0, 0, 0, 0, 0,
- 0, 0, 214, 0, 0, 0, 0, 0, 0, 34,
- 0, 0, 0, 35, 36, 0, 37, 0, 0, 0,
- 0, 0, 0, 501, 0, 0, 0, 44, 0, 0,
- 0, 0, 0, 0, 0, 605, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 50, 502, 504, 503, 0,
- 51, 0, 0, 0, 0, 225, 0, 0, 0, 0,
- 0, 43, 53, 32, 209, 0, 0, 40, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 29, 30, 31, 0, 0, 0, 0, 0, 0, 0,
- 0, 33, 0, 0, 0, 0, 0, 0, 34, 0,
- 0, 0, 35, 36, 0, 37, 0, 0, 0, 38,
- 0, 39, 41, 42, 0, 0, 44, 0, 0, 0,
- 45, 0, 46, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 50, 47, 49, 48, 0, 51,
- 0, 52, 0, 54, 0, 55, 0, 0, 0, 0,
- 43, 53, 32, 0, 0, 0, 40, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -117,
- 0, 0, 0, 29, 30, 31, 0, 0, 0, 0,
- 0, 0, 0, 0, 33, 0, 0, 0, 0, 0,
- 0, 34, 0, 0, 0, 35, 36, 0, 37, 0,
- 0, 0, 38, 0, 39, 41, 42, 0, 0, 44,
- 0, 0, 0, 45, 0, 46, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 50, 47, 49,
- 48, 0, 51, 0, 52, 0, 54, 0, 55, 0,
- 0, 0, 0, 43, 53, 32, 0, 0, 0, 40,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 29, 30, 31, 0, 0, 0, 0, 0,
- 0, 0, 0, 33, 0, 0, 0, 0, 0, 0,
- 34, 0, 0, 0, 35, 36, 0, 37, 0, 0,
- 0, 38, 0, 39, 41, 42, 0, 0, 44, 0,
- 0, 0, 45, 0, 46, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 50, 47, 49, 48,
- 0, 51, 0, 52, 0, 54, 270, 55, 0, 0,
- 0, 0, 43, 53, 32, 0, 0, 0, 40, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 29, 30, 31, 0, 0, 0, 0, 0, 0,
- 0, 0, 33, 0, 0, 0, 0, 0, 0, 34,
- 216, 0, 0, 566, 567, 0, 37, 0, 0, 0,
- 38, 0, 39, 41, 42, 0, 0, 44, 0, 0,
- 0, 45, 0, 46, 0, 0, 0, 0, 0, 0,
- 0, 220, 0, 0, 0, 50, 47, 49, 48, 0,
- 51, 0, 52, 0, 54, 0, 55, 0, 0, 0,
- 0, 43, 53, 32, 0, 0, 0, 40, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 474, 0, 0, 29, 30, 31, 0, 0, 0, 0,
- 0, 0, 0, 0, 33, 0, 0, 0, 0, 0,
- 0, 34, 0, 0, 0, 35, 36, 0, 37, 0,
- 0, 0, 38, 0, 39, 41, 42, 0, 0, 44,
- 0, 0, 0, 45, 0, 46, 0, 0, 475, 0,
- 0, 0, 0, 0, 0, 0, 0, 50, 47, 49,
- 48, 0, 51, 0, 52, 0, 54, 0, 55, 0,
- 0, 0, 0, 43, 53, 32, 0, 0, 0, 40,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 474, 0, 0, 29, 30, 31, 0, 0,
- 0, 0, 0, 0, 0, 0, 33, 0, 0, 0,
- 0, 0, 0, 34, 0, 0, 0, 35, 36, 0,
- 37, 0, 0, 0, 38, 0, 39, 41, 42, 0,
- 0, 44, 0, 0, 0, 45, 0, 46, 0, 0,
- 480, 0, 0, 0, 0, 0, 0, 0, 0, 50,
- 47, 49, 48, 0, 51, 0, 52, 0, 54, 0,
- 55, 0, 0, 0, 0, 43, 53, 32, 0, 0,
- 0, 40, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 482, 0, 0, 29, 30, 31,
- 0, 0, 0, 0, 0, 0, 0, 0, 33, 0,
- 0, 0, 0, 0, 0, 34, 0, 0, 0, 35,
- 36, 0, 37, 0, 0, 0, 38, 0, 39, 41,
- 42, 0, 0, 44, 0, 0, 0, 45, 0, 46,
- 0, 0, 485, 0, 0, 0, 0, 0, 0, 0,
- 0, 50, 47, 49, 48, 0, 51, 0, 52, 0,
- 54, 0, 55, 0, 0, 0, 0, 43, 53, 32,
- 0, 0, 0, 40, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 482, 0, 0, 29,
- 30, 31, 0, 0, 0, 0, 0, 0, 0, 0,
- 33, 0, 0, 0, 0, 0, 0, 34, 0, 0,
- 0, 35, 36, 0, 37, 0, 0, 0, 38, 0,
- 39, 41, 42, 0, 0, 44, 0, 0, 0, 45,
- 0, 46, 0, 0, 483, 0, 0, 0, 0, 0,
- 0, 0, 0, 50, 47, 49, 48, 0, 51, 0,
- 52, 0, 54, 0, 55, 0, 0, 0, 0, 43,
- 53, 32, 0, 0, 0, 40, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 108, 109,
- 110, 0, 0, 112, 114, 115, 0, 0, 116, 0,
- 117, 0, 0, 0, 119, 120, 121, 0, 0, 0,
- 0, 0, 0, 34, 122, 123, 124, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 125, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 128, 0, 0, 0, 0, 0, 0,
- 47, 49, 48, 129, 130, 131, 0, 133, 134, 135,
- 136, 137, 138, 0, 0, 126, 132, 118, 111, 113,
- 127, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 108, 109, 110, 0, 0, 112,
- 114, 115, 0, 0, 116, 0, 117, 0, 0, 0,
- 119, 120, 121, 0, 0, 0, 0, 0, 0, 392,
- 122, 123, 124, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 125, 0, 0, 0, 393, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 128,
- 0, 0, 0, 0, 0, 397, 394, 396, 0, 129,
- 130, 131, 0, 133, 134, 135, 136, 137, 138, 0,
- 0, 126, 132, 118, 111, 113, 127, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 108, 109, 110, 0, 0, 112, 114, 115, 0, 0,
- 116, 0, 117, 0, 0, 0, 119, 120, 121, 0,
- 0, 0, 0, 0, 0, 392, 122, 123, 124, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 125,
- 0, 0, 0, 393, 0, 0, 0, 0, 0, 0,
- 0, 395, 0, 0, 0, 128, 0, 0, 0, 0,
- 0, 397, 394, 396, 0, 129, 130, 131, 0, 133,
- 134, 135, 136, 137, 138, 0, 0, 126, 132, 118,
- 111, 113, 127, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 208, 0, 0, 0,
- 0, 210, 0, 29, 30, 31, 212, 0, 0, 0,
- 0, 0, 0, 213, 33, 0, 0, 0, 0, 0,
- 0, 215, 216, 0, 0, 217, 36, 0, 37, 0,
- 0, 0, 38, 0, 39, 41, 42, 0, 0, 44,
- 0, 0, 0, 45, 0, 46, 0, 0, 0, 0,
- 0, 219, 0, 220, 0, 0, 0, 50, 218, 221,
- 48, 222, 51, 223, 52, 224, 54, 225, 55, 226,
- 227, 0, 0, 43, 53, 32, 209, 211, 0, 40,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 208, 0, 0, 0, 0, 210, 0, 29,
- 30, 31, 212, 0, 0, 0, 0, 0, 0, 213,
- 214, 0, 0, 0, 0, 0, 0, 215, 216, 0,
- 0, 217, 36, 0, 37, 0, 0, 0, 38, 0,
- 39, 41, 42, 0, 0, 44, 0, 0, 0, 45,
- 0, 46, 0, 0, 0, 0, 0, 219, 0, 220,
- 0, 0, 0, 50, 218, 221, 48, 222, 51, 223,
- 52, 224, 54, 225, 55, 226, 227, 0, 0, 43,
- 53, 32, 209, 211, 0, 40, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 569, 109,
- 110, 0, 0, 571, 114, 573, 30, 31, 574, 0,
- 117, 0, 0, 0, 119, 576, 577, 0, 0, 0,
- 0, 0, 0, 578, 579, 123, 124, 217, 36, 0,
- 37, 0, 0, 0, 38, 0, 39, 580, 42, 0,
- 0, 582, 0, 0, 0, 45, 0, 46, 0, 0,
- 0, 0, 0, 584, 0, 220, 0, 0, 0, 586,
- 583, 585, 48, 587, 588, 589, 52, 591, 592, 593,
- 594, 595, 596, 0, 0, 581, 590, 575, 570, 572,
- 127, 40, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 360, 109, 110, 0, 0, 362,
- 114, 364, 30, 31, 365, 0, 117, 0, 0, 0,
- 119, 367, 368, 0, 0, 0, 0, 0, 0, 369,
- 370, 123, 124, 217, 36, 0, 37, 0, 0, 0,
- 38, 0, 39, 371, 42, 0, 0, 373, 0, 0,
- 0, 45, 0, 46, 0, -263, 0, 0, 0, 375,
- 0, 220, 0, 0, 0, 377, 374, 376, 48, 378,
- 379, 380, 52, 382, 383, 384, 385, 386, 387, 0,
- 0, 372, 381, 366, 361, 363, 127, 40, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-
- 541, 310, 460, 513, 538, 518, 525, 308, 249, 632,
- 306, 181, 252, 618, 149, 16, 623, 495, 319, 497,
- 629, 357, 496, 435, 471, 553, 557, 486, 438, 301,
- 428, 237, 350, 352, 604, 521, 242, 424, 550, 552,
- 181, 301, 185, 237, 242, 343, 432, 348, 338, 249,
- 459, 237, 453, 449, 236, 242, 446, 181, 466, 401,
- 448, 249, 357, 455, 444, 457, 346, 337, 357, 484,
- 142, 236, 147, 333, 438, 175, 301, 335, 187, 409,
- 162, 145, 435, 416, 435, 139, 170, 399, 414, 481,
- 438, 389, 0, 168, 0, 0, 403, 357, 403, 59,
- 357, 490, 301, 534, 391, 0, 0, 0, 301, 0,
- 0, 460, 0, 145, 59, 0, 179, 403, 177, 59,
- 59, 488, 489, 0, 404, 105, 404, 0, 59, 185,
- 451, 59, 59, 450, 59, 59, 59, 59, 59, 283,
- 284, 59, 287, 285, 145, 404, 286, 107, 167, 406,
- 164, 59, 59, 451, 450, 265, 59, 59, 301, 59,
- 269, 68, 96, 95, 479, 59, 59, 331, 478, 59,
- 87, 76, 59, 329, 59, 97, 434, 83, 89, 431,
- 59, 470, 59, 59, 59, 94, 88, 59, 93, 92,
- 59, 59, 90, 59, 59, 91, 493, 59, 59, 71,
- 67, 59, 59, 491, 492, 99, 59, 101, 179, 319,
- 301, 59, 59, 340, 69, 60, 59, 59, 450, 66,
- 59, 59, 451, 304, 105, 499, 269, 297, 297, 297,
- 59, 59, 269, 269, 269, 269, 269, 0, 315, 272,
- 498, 508, 294, 0, 0, 0, 107, 174, 59, 325,
- 318, 316, 297, 269, 59, 290, 0, 269, 297, 269,
- 0, 59, 0, 269, 59, 0, 269, 292, 59, 269,
- 179, 277, 59, 0, 299, 302, 312, 269, 59, 288,
- 296, 328, 609, 269, 499, 289, 597, 633, 606, 599,
- 499, 600, 565, 600, 0, 0, 499, 0, 0, 568,
- 561, 562, 563, 564, 0, 498, 508, 0, 471, 0,
- 0, 498, 508, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 499, 0, 0, 603, 0, 0, 0, 600, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0};
-
-const short QmlJSGrammar::action_check [] = {
- 7, 7, 36, 90, 7, 29, 36, 7, 36, 7,
- 33, 8, 7, 7, 36, 7, 90, 7, 0, 7,
- 16, 60, 55, 33, 8, 29, 7, 36, 7, 55,
- 79, 48, 1, 7, 55, 2, 7, 17, 37, 7,
- 33, 60, 29, 7, 33, 7, 66, 33, 33, 7,
- 66, 29, 7, 36, 20, 7, 7, 29, 33, 36,
- 36, 24, 5, 36, 5, 7, 36, 5, 1, 60,
- 7, 36, 7, 2, 79, 2, 33, 8, 8, 7,
- 1, 7, 36, 36, 8, 1, 36, -1, 8, 36,
- -1, 2, 36, 8, 55, 7, -1, -1, -1, 17,
- 60, 60, 48, 48, 60, 7, -1, 55, 8, -1,
- 33, 36, 61, 6, 48, -1, 33, 15, 8, 10,
- 8, 60, 36, 36, 7, 8, 8, 20, 8, 61,
- 8, 33, 8, -1, 8, 40, 34, 77, 60, 8,
- 8, 8, 61, 79, 50, -1, 51, 50, 54, 8,
- 60, 54, 61, 62, 61, 62, 56, 61, 62, 40,
- 61, 62, 61, 62, 55, 40, 56, 61, 62, 12,
- 51, 42, 60, 15, 61, 62, 51, 7, 60, -1,
- 60, 8, 53, 61, 60, 31, 60, 40, 56, 61,
- 62, 60, 34, 60, 29, 61, 62, 56, 51, 61,
- 62, 61, 62, 25, 25, 27, 27, 8, 25, 25,
- 27, 27, 12, 25, 57, 27, 38, 38, 29, 29,
- 63, 38, 38, 25, 15, 27, 38, 12, 25, -1,
- 27, 61, 62, 8, 61, 62, 38, 25, 8, 27,
- 75, 38, 25, 34, 27, 36, 25, 15, 27, 8,
- 38, 86, 61, 62, 8, 38, 25, 57, 27, 38,
- 61, 62, 15, 63, 75, 75, 34, 29, 36, 38,
- 36, 29, 57, 8, 29, 86, 86, 25, 63, 27,
- 7, 34, 91, 36, 29, -1, 61, 62, -1, -1,
- 38, 61, 62, -1, -1, 61, 62, 25, -1, 27,
- 47, -1, 61, 62, 29, -1, 60, -1, -1, -1,
- 38, 18, 19, 75, 61, 62, 29, 75, -1, 29,
- 75, 66, 67, 68, 86, -1, 61, 62, 86, 15,
- -1, 86, 29, -1, 61, 62, 18, 19, 45, 46,
- 29, 66, 67, 68, 91, 29, 15, 33, 34, 29,
- 36, -1, 29, 66, 67, 68, 66, 67, 68, 29,
- -1, -1, 29, 45, 46, 34, 29, 36, -1, 66,
- 67, 68, 29, -1, 15, 29, -1, 66, 67, 68,
- -1, -1, 66, 67, 68, -1, 66, 67, 68, 66,
- 67, 68, 33, 34, -1, 36, 66, 67, 68, 66,
- 67, 68, -1, 66, 67, 68, 23, 24, -1, 66,
- 67, 68, 66, 67, 68, 32, 23, 24, 35, -1,
- 37, -1, -1, 29, -1, 32, 29, -1, 35, 29,
- 37, 18, 19, 36, 23, 24, 36, 29, -1, -1,
- -1, -1, -1, 32, -1, -1, 35, -1, 37, 29,
- -1, -1, -1, -1, -1, 61, 62, -1, 45, 46,
- 66, 67, 68, 66, 67, 68, 66, 67, 68, 61,
- 62, 23, 24, 29, 66, 67, 68, -1, -1, 31,
- 32, 61, 62, 35, -1, 37, 66, 67, 68, 23,
- 24, 29, -1, -1, -1, -1, -1, 31, 32, -1,
- -1, 35, -1, 37, -1, 61, 62, 23, 24, 29,
- 66, 67, 68, 23, 24, 31, 32, -1, -1, 35,
- -1, 37, 32, 61, 62, 35, -1, 37, 66, 67,
- 68, 92, 93, 94, 95, 96, 97, -1, -1, 3,
- -1, 61, 62, -1, -1, -1, 66, 67, 68, 13,
- -1, -1, -1, 17, -1, -1, -1, 3, -1, -1,
- -1, -1, 26, -1, 28, -1, -1, 13, -1, -1,
- -1, 17, -1, -1, -1, 39, -1, 41, 42, -1,
- 26, -1, 28, -1, -1, 49, -1, -1, 52, 53,
- 23, 24, -1, 39, 58, 41, 42, -1, 31, 32,
- 64, -1, 35, 49, 37, -1, 52, 53, -1, -1,
- -1, -1, 58, -1, -1, -1, 80, -1, 64, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 12,
- 13, -1, -1, -1, 80, -1, -1, -1, -1, 22,
- -1, -1, -1, -1, -1, -1, 29, -1, -1, -1,
- 33, 34, -1, 36, -1, -1, -1, -1, -1, -1,
- 43, -1, -1, -1, 47, -1, -1, 3, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 13, -1, -1,
- -1, 17, 65, 66, 67, 68, -1, 70, -1, -1,
- 26, -1, 28, -1, -1, 31, -1, -1, 81, 82,
- 83, -1, -1, 39, 87, 41, 42, -1, -1, -1,
- -1, -1, -1, 49, -1, -1, 52, 53, -1, -1,
- -1, -1, 58, -1, -1, -1, -1, -1, 64, -1,
- -1, -1, -1, -1, -1, -1, 12, 13, -1, -1,
- -1, -1, -1, -1, 80, -1, 22, -1, -1, -1,
- -1, -1, -1, 29, -1, -1, -1, 33, 34, -1,
- 36, -1, -1, -1, 12, 13, -1, 43, -1, -1,
- -1, 47, -1, -1, 22, -1, -1, -1, -1, -1,
- -1, 29, -1, -1, -1, 33, 34, -1, 36, 65,
- 66, 67, 68, -1, 70, 43, -1, -1, -1, 47,
- -1, -1, -1, -1, -1, 81, 82, 83, -1, -1,
- -1, 87, -1, -1, -1, -1, -1, 65, 66, 67,
- 68, -1, 70, -1, 10, -1, 12, 13, -1, -1,
- -1, -1, -1, 81, 82, 83, 22, -1, -1, 87,
- -1, -1, -1, 29, -1, -1, -1, 33, 34, -1,
- 36, -1, 12, 13, -1, -1, -1, 43, -1, -1,
- -1, 47, 22, -1, -1, -1, -1, -1, -1, 29,
- -1, -1, -1, 33, 34, -1, 36, -1, -1, 65,
- 66, 67, 68, 43, 70, -1, -1, 47, -1, 75,
- -1, -1, -1, -1, -1, 81, 82, 83, 84, -1,
- -1, 87, -1, -1, -1, 65, 66, 67, 68, -1,
- 70, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 10, -1, 12, 13, -1, -1, -1, -1, -1, -1,
- -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
- -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
- -1, -1, -1, 43, -1, -1, -1, 47, -1, -1,
- -1, -1, -1, -1, -1, 55, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 65, 66, 67, 68, -1,
- 70, -1, -1, -1, -1, 75, -1, -1, -1, -1,
- -1, 81, 82, 83, 84, -1, -1, 87, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 10, -1, 12, 13, -1, -1, -1, -1, -1, -1,
- -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
- -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
- -1, -1, -1, 43, -1, -1, -1, 47, -1, -1,
- -1, -1, -1, -1, -1, 55, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 65, 66, 67, 68, -1,
- 70, -1, -1, -1, -1, 75, -1, -1, -1, -1,
- -1, 81, 82, 83, 84, -1, -1, 87, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 11, 12, 13, -1, -1, -1, -1, -1, -1, -1,
- -1, 22, -1, -1, -1, -1, -1, -1, 29, -1,
- -1, -1, 33, 34, -1, 36, -1, -1, -1, 40,
- -1, 42, 43, 44, -1, -1, 47, -1, -1, -1,
- 51, -1, 53, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 65, 66, 67, 68, -1, 70,
- -1, 72, -1, 74, -1, 76, -1, -1, -1, -1,
- 81, 82, 83, -1, -1, -1, 87, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
- -1, -1, -1, 11, 12, 13, -1, -1, -1, -1,
- -1, -1, -1, -1, 22, -1, -1, -1, -1, -1,
- -1, 29, -1, -1, -1, 33, 34, -1, 36, -1,
- -1, -1, 40, -1, 42, 43, 44, -1, -1, 47,
- -1, -1, -1, 51, -1, 53, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 65, 66, 67,
- 68, -1, 70, -1, 72, -1, 74, -1, 76, -1,
- -1, -1, -1, 81, 82, 83, -1, -1, -1, 87,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 11, 12, 13, -1, -1, -1, -1, -1,
- -1, -1, -1, 22, -1, -1, -1, -1, -1, -1,
- 29, -1, -1, -1, 33, 34, -1, 36, -1, -1,
- -1, 40, -1, 42, 43, 44, -1, -1, 47, -1,
- -1, -1, 51, -1, 53, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 65, 66, 67, 68,
- -1, 70, -1, 72, -1, 74, 75, 76, -1, -1,
- -1, -1, 81, 82, 83, -1, -1, -1, 87, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 11, 12, 13, -1, -1, -1, -1, -1, -1,
- -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
- 30, -1, -1, 33, 34, -1, 36, -1, -1, -1,
- 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
- -1, 51, -1, 53, -1, -1, -1, -1, -1, -1,
- -1, 61, -1, -1, -1, 65, 66, 67, 68, -1,
- 70, -1, 72, -1, 74, -1, 76, -1, -1, -1,
- -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 8, -1, -1, 11, 12, 13, -1, -1, -1, -1,
- -1, -1, -1, -1, 22, -1, -1, -1, -1, -1,
- -1, 29, -1, -1, -1, 33, 34, -1, 36, -1,
- -1, -1, 40, -1, 42, 43, 44, -1, -1, 47,
- -1, -1, -1, 51, -1, 53, -1, -1, 56, -1,
- -1, -1, -1, -1, -1, -1, -1, 65, 66, 67,
- 68, -1, 70, -1, 72, -1, 74, -1, 76, -1,
- -1, -1, -1, 81, 82, 83, -1, -1, -1, 87,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 8, -1, -1, 11, 12, 13, -1, -1,
- -1, -1, -1, -1, -1, -1, 22, -1, -1, -1,
- -1, -1, -1, 29, -1, -1, -1, 33, 34, -1,
- 36, -1, -1, -1, 40, -1, 42, 43, 44, -1,
- -1, 47, -1, -1, -1, 51, -1, 53, -1, -1,
- 56, -1, -1, -1, -1, -1, -1, -1, -1, 65,
- 66, 67, 68, -1, 70, -1, 72, -1, 74, -1,
- 76, -1, -1, -1, -1, 81, 82, 83, -1, -1,
- -1, 87, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 8, -1, -1, 11, 12, 13,
- -1, -1, -1, -1, -1, -1, -1, -1, 22, -1,
- -1, -1, -1, -1, -1, 29, -1, -1, -1, 33,
- 34, -1, 36, -1, -1, -1, 40, -1, 42, 43,
- 44, -1, -1, 47, -1, -1, -1, 51, -1, 53,
- -1, -1, 56, -1, -1, -1, -1, -1, -1, -1,
- -1, 65, 66, 67, 68, -1, 70, -1, 72, -1,
- 74, -1, 76, -1, -1, -1, -1, 81, 82, 83,
- -1, -1, -1, 87, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 8, -1, -1, 11,
- 12, 13, -1, -1, -1, -1, -1, -1, -1, -1,
- 22, -1, -1, -1, -1, -1, -1, 29, -1, -1,
- -1, 33, 34, -1, 36, -1, -1, -1, 40, -1,
- 42, 43, 44, -1, -1, 47, -1, -1, -1, 51,
- -1, 53, -1, -1, 56, -1, -1, -1, -1, -1,
- -1, -1, -1, 65, 66, 67, 68, -1, 70, -1,
- 72, -1, 74, -1, 76, -1, -1, -1, -1, 81,
- 82, 83, -1, -1, -1, 87, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 4, 5,
- 6, -1, -1, 9, 10, 11, -1, -1, 14, -1,
- 16, -1, -1, -1, 20, 21, 22, -1, -1, -1,
- -1, -1, -1, 29, 30, 31, 32, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 43, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 59, -1, -1, -1, -1, -1, -1,
- 66, 67, 68, 69, 70, 71, -1, 73, 74, 75,
- 76, 77, 78, -1, -1, 81, 82, 83, 84, 85,
- 86, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 4, 5, 6, -1, -1, 9,
- 10, 11, -1, -1, 14, -1, 16, -1, -1, -1,
- 20, 21, 22, -1, -1, -1, -1, -1, -1, 29,
- 30, 31, 32, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 43, -1, -1, -1, 47, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 59,
- -1, -1, -1, -1, -1, 65, 66, 67, -1, 69,
- 70, 71, -1, 73, 74, 75, 76, 77, 78, -1,
- -1, 81, 82, 83, 84, 85, 86, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 4, 5, 6, -1, -1, 9, 10, 11, -1, -1,
- 14, -1, 16, -1, -1, -1, 20, 21, 22, -1,
- -1, -1, -1, -1, -1, 29, 30, 31, 32, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 43,
- -1, -1, -1, 47, -1, -1, -1, -1, -1, -1,
- -1, 55, -1, -1, -1, 59, -1, -1, -1, -1,
- -1, 65, 66, 67, -1, 69, 70, 71, -1, 73,
- 74, 75, 76, 77, 78, -1, -1, 81, 82, 83,
- 84, 85, 86, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 4, -1, -1, -1,
- -1, 9, -1, 11, 12, 13, 14, -1, -1, -1,
- -1, -1, -1, 21, 22, -1, -1, -1, -1, -1,
- -1, 29, 30, -1, -1, 33, 34, -1, 36, -1,
- -1, -1, 40, -1, 42, 43, 44, -1, -1, 47,
- -1, -1, -1, 51, -1, 53, -1, -1, -1, -1,
- -1, 59, -1, 61, -1, -1, -1, 65, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
- 78, -1, -1, 81, 82, 83, 84, 85, -1, 87,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 4, -1, -1, -1, -1, 9, -1, 11,
- 12, 13, 14, -1, -1, -1, -1, -1, -1, 21,
- 22, -1, -1, -1, -1, -1, -1, 29, 30, -1,
- -1, 33, 34, -1, 36, -1, -1, -1, 40, -1,
- 42, 43, 44, -1, -1, 47, -1, -1, -1, 51,
- -1, 53, -1, -1, -1, -1, -1, 59, -1, 61,
- -1, -1, -1, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, -1, -1, 81,
- 82, 83, 84, 85, -1, 87, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 4, 5,
- 6, -1, -1, 9, 10, 11, 12, 13, 14, -1,
- 16, -1, -1, -1, 20, 21, 22, -1, -1, -1,
- -1, -1, -1, 29, 30, 31, 32, 33, 34, -1,
- 36, -1, -1, -1, 40, -1, 42, 43, 44, -1,
- -1, 47, -1, -1, -1, 51, -1, 53, -1, -1,
- -1, -1, -1, 59, -1, 61, -1, -1, -1, 65,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
- 76, 77, 78, -1, -1, 81, 82, 83, 84, 85,
- 86, 87, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 4, 5, 6, -1, -1, 9,
- 10, 11, 12, 13, 14, -1, 16, -1, -1, -1,
- 20, 21, 22, -1, -1, -1, -1, -1, -1, 29,
- 30, 31, 32, 33, 34, -1, 36, -1, -1, -1,
- 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
- -1, 51, -1, 53, -1, 55, -1, -1, -1, 59,
- -1, 61, -1, -1, -1, 65, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, -1,
- -1, 81, 82, 83, 84, 85, 86, 87, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-
- 3, 2, 15, 25, 25, 3, 25, 3, 2, 11,
- 2, 15, 3, 13, 67, 3, 15, 104, 15, 2,
- 15, 2, 4, 3, 35, 15, 15, 3, 21, 3,
- 93, 15, 2, 2, 19, 13, 15, 96, 25, 25,
- 15, 3, 15, 15, 15, 100, 3, 3, 15, 2,
- 2, 15, 3, 21, 4, 15, 15, 15, 35, 2,
- 21, 2, 2, 2, 98, 3, 2, 2, 2, 35,
- 35, 4, 35, 2, 21, 3, 3, 3, 15, 2,
- 35, 35, 3, 3, 3, 3, 35, 35, 2, 35,
- 21, 35, -1, 35, -1, -1, 13, 2, 13, 44,
- 2, 46, 3, 3, 36, -1, -1, -1, 3, -1,
- -1, 15, -1, 35, 44, -1, 46, 13, 40, 44,
- 44, 46, 46, -1, 41, 15, 41, -1, 44, 15,
- 46, 44, 44, 46, 44, 44, 44, 44, 44, 49,
- 49, 44, 49, 49, 35, 41, 49, 37, 60, 40,
- 58, 44, 44, 46, 46, 44, 44, 44, 3, 44,
- 49, 46, 50, 50, 31, 44, 44, 68, 35, 44,
- 48, 50, 44, 68, 44, 50, 81, 49, 48, 81,
- 44, 85, 44, 44, 44, 49, 48, 44, 49, 49,
- 44, 44, 49, 44, 44, 49, 46, 44, 44, 52,
- 46, 44, 44, 46, 46, 56, 44, 54, 46, 15,
- 3, 44, 44, 99, 47, 47, 44, 44, 46, 46,
- 44, 44, 46, 68, 15, 13, 49, 44, 44, 44,
- 44, 44, 49, 49, 49, 49, 49, -1, 61, 53,
- 28, 29, 55, -1, -1, -1, 37, 38, 44, 66,
- 66, 66, 44, 49, 44, 51, -1, 49, 44, 49,
- -1, 44, -1, 49, 44, -1, 49, 57, 44, 49,
- 46, 51, 44, -1, 66, 68, 59, 49, 44, 51,
- 66, 87, 5, 49, 13, 51, 13, 16, 5, 16,
- 13, 20, 13, 20, -1, -1, 13, -1, -1, 20,
- 21, 22, 23, 24, -1, 28, 29, -1, 35, -1,
- -1, 28, 29, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 13, -1, -1, 16, -1, -1, -1, 20, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1};
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/parser/qmljsgrammar_p.h b/src/declarative/qml/parser/qmljsgrammar_p.h
deleted file mode 100644
index 21fddba..0000000
--- a/src/declarative/qml/parser/qmljsgrammar_p.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-// This file was generated by qlalr - DO NOT EDIT!
-#ifndef QMLJSGRAMMAR_P_H
-#define QMLJSGRAMMAR_P_H
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlJSGrammar
-{
-public:
- enum VariousConstants {
- EOF_SYMBOL = 0,
- REDUCE_HERE = 99,
- SHIFT_THERE = 98,
- T_AND = 1,
- T_AND_AND = 2,
- T_AND_EQ = 3,
- T_AS = 91,
- T_AUTOMATIC_SEMICOLON = 62,
- T_BREAK = 4,
- T_CASE = 5,
- T_CATCH = 6,
- T_COLON = 7,
- T_COMMA = 8,
- T_COMMENT = 88,
- T_CONST = 84,
- T_CONTINUE = 9,
- T_DEBUGGER = 85,
- T_DEFAULT = 10,
- T_DELETE = 11,
- T_DIVIDE_ = 12,
- T_DIVIDE_EQ = 13,
- T_DO = 14,
- T_DOT = 15,
- T_ELSE = 16,
- T_EQ = 17,
- T_EQ_EQ = 18,
- T_EQ_EQ_EQ = 19,
- T_FALSE = 83,
- T_FEED_JS_EXPRESSION = 95,
- T_FEED_JS_PROGRAM = 97,
- T_FEED_JS_SOURCE_ELEMENT = 96,
- T_FEED_JS_STATEMENT = 94,
- T_FEED_UI_OBJECT_MEMBER = 93,
- T_FEED_UI_PROGRAM = 92,
- T_FINALLY = 20,
- T_FOR = 21,
- T_FUNCTION = 22,
- T_GE = 23,
- T_GT = 24,
- T_GT_GT = 25,
- T_GT_GT_EQ = 26,
- T_GT_GT_GT = 27,
- T_GT_GT_GT_EQ = 28,
- T_IDENTIFIER = 29,
- T_IF = 30,
- T_IMPORT = 90,
- T_IN = 31,
- T_INSTANCEOF = 32,
- T_LBRACE = 33,
- T_LBRACKET = 34,
- T_LE = 35,
- T_LPAREN = 36,
- T_LT = 37,
- T_LT_LT = 38,
- T_LT_LT_EQ = 39,
- T_MINUS = 40,
- T_MINUS_EQ = 41,
- T_MINUS_MINUS = 42,
- T_MULTILINE_STRING_LITERAL = 87,
- T_NEW = 43,
- T_NOT = 44,
- T_NOT_EQ = 45,
- T_NOT_EQ_EQ = 46,
- T_NULL = 81,
- T_NUMERIC_LITERAL = 47,
- T_OR = 48,
- T_OR_EQ = 49,
- T_OR_OR = 50,
- T_PLUS = 51,
- T_PLUS_EQ = 52,
- T_PLUS_PLUS = 53,
- T_PROPERTY = 66,
- T_PUBLIC = 89,
- T_QUESTION = 54,
- T_RBRACE = 55,
- T_RBRACKET = 56,
- T_READONLY = 68,
- T_REMAINDER = 57,
- T_REMAINDER_EQ = 58,
- T_RESERVED_WORD = 86,
- T_RETURN = 59,
- T_RPAREN = 60,
- T_SEMICOLON = 61,
- T_SIGNAL = 67,
- T_STAR = 63,
- T_STAR_EQ = 64,
- T_STRING_LITERAL = 65,
- T_SWITCH = 69,
- T_THIS = 70,
- T_THROW = 71,
- T_TILDE = 72,
- T_TRUE = 82,
- T_TRY = 73,
- T_TYPEOF = 74,
- T_VAR = 75,
- T_VOID = 76,
- T_WHILE = 77,
- T_WITH = 78,
- T_XOR = 79,
- T_XOR_EQ = 80,
-
- ACCEPT_STATE = 635,
- RULE_COUNT = 343,
- STATE_COUNT = 636,
- TERMINAL_COUNT = 100,
- NON_TERMINAL_COUNT = 106,
-
- GOTO_INDEX_OFFSET = 636,
- GOTO_INFO_OFFSET = 2520,
- GOTO_CHECK_OFFSET = 2520
- };
-
- static const char *const spell [];
- static const short lhs [];
- static const short rhs [];
- static const short goto_default [];
- static const short action_default [];
- static const short action_index [];
- static const short action_info [];
- static const short action_check [];
-
- static inline int nt_action (int state, int nt)
- {
- const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt;
- if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt)
- return goto_default [nt];
-
- return action_info [GOTO_INFO_OFFSET + yyn];
- }
-
- static inline int t_action (int state, int token)
- {
- const int yyn = action_index [state] + token;
-
- if (yyn < 0 || action_check [yyn] != token)
- return - action_default [state];
-
- return action_info [yyn];
- }
-};
-
-
-QT_END_NAMESPACE
-#endif // QMLJSGRAMMAR_P_H
-
diff --git a/src/declarative/qml/parser/qmljslexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp
deleted file mode 100644
index 816542f..0000000
--- a/src/declarative/qml/parser/qmljslexer.cpp
+++ /dev/null
@@ -1,1161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "qmljslexer_p.h"
-
-#include "qmljsglobal_p.h"
-#include "qmljsengine_p.h"
-#include "qmljsgrammar_p.h"
-
-#include <QtCore/qcoreapplication.h>
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-QT_QML_BEGIN_NAMESPACE
-
-extern double qstrtod(const char *s00, char const **se, bool *ok);
-
-#define shiftWindowsLineBreak() \
- do { \
- if (((current == '\r') && (next1 == '\n')) \
- || ((current == '\n') && (next1 == '\r'))) { \
- shift(1); \
- } \
- } \
- while (0)
-
-namespace QmlJS {
-extern double integerFromString(const char *buf, int size, int radix);
-}
-
-using namespace QmlJS;
-
-Lexer::Lexer(Engine *eng, bool tokenizeComments)
- : driver(eng),
- yylineno(0),
- done(false),
- size8(128), size16(128),
- pos8(0), pos16(0),
- terminator(false),
- restrKeyword(false),
- delimited(false),
- stackToken(-1),
- state(Start),
- pos(0),
- code(0), length(0),
- yycolumn(0),
- startpos(0),
- startlineno(0), startcolumn(0),
- bol(true),
- current(0), next1(0), next2(0), next3(0),
- err(NoError),
- wantRx(false),
- check_reserved(true),
- parenthesesState(IgnoreParentheses),
- parenthesesCount(0),
- prohibitAutomaticSemicolon(false),
- tokenizeComments(tokenizeComments)
-{
- driver->setLexer(this);
- // allocate space for read buffers
- buffer8 = new char[size8];
- buffer16 = new QChar[size16];
- pattern = 0;
- flags = 0;
-
-}
-
-Lexer::~Lexer()
-{
- delete [] buffer8;
- delete [] buffer16;
-}
-
-void Lexer::setCode(const QString &c, int lineno)
-{
- errmsg = QString();
- yylineno = lineno;
- yycolumn = 1;
- restrKeyword = false;
- delimited = false;
- stackToken = -1;
- pos = 0;
- code = c.unicode();
- length = c.length();
- bol = true;
-
- // read first characters
- current = (length > 0) ? code[0].unicode() : 0;
- next1 = (length > 1) ? code[1].unicode() : 0;
- next2 = (length > 2) ? code[2].unicode() : 0;
- next3 = (length > 3) ? code[3].unicode() : 0;
-}
-
-void Lexer::shift(uint p)
-{
- while (p--) {
- ++pos;
- ++yycolumn;
- current = next1;
- next1 = next2;
- next2 = next3;
- next3 = (pos + 3 < length) ? code[pos+3].unicode() : 0;
- }
-}
-
-void Lexer::setDone(State s)
-{
- state = s;
- done = true;
-}
-
-int Lexer::findReservedWord(const QChar *c, int size) const
-{
- switch (size) {
- case 2: {
- if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('o'))
- return QmlJSGrammar::T_DO;
- else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('f'))
- return QmlJSGrammar::T_IF;
- else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n'))
- return QmlJSGrammar::T_IN;
- else if (c[0] == QLatin1Char('a') && c[1] == QLatin1Char('s'))
- return QmlJSGrammar::T_AS;
- } break;
-
- case 3: {
- if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('r'))
- return QmlJSGrammar::T_FOR;
- else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('e') && c[2] == QLatin1Char('w'))
- return QmlJSGrammar::T_NEW;
- else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('y'))
- return QmlJSGrammar::T_TRY;
- else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('a') && c[2] == QLatin1Char('r'))
- return QmlJSGrammar::T_VAR;
- else if (check_reserved) {
- if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n') && c[2] == QLatin1Char('t'))
- return QmlJSGrammar::T_RESERVED_WORD;
- }
- } break;
-
- case 4: {
- if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('a')
- && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('e'))
- return QmlJSGrammar::T_CASE;
- else if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('l')
- && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('e'))
- return QmlJSGrammar::T_ELSE;
- else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h')
- && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('s'))
- return QmlJSGrammar::T_THIS;
- else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('o')
- && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('d'))
- return QmlJSGrammar::T_VOID;
- else if (c[0] == QLatin1Char('w') && c[1] == QLatin1Char('i')
- && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('h'))
- return QmlJSGrammar::T_WITH;
- else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r')
- && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('e'))
- return QmlJSGrammar::T_TRUE;
- else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('u')
- && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('l'))
- return QmlJSGrammar::T_NULL;
- else if (check_reserved) {
- if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('n')
- && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('m'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('y')
- && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('l') && c[1] == QLatin1Char('o')
- && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('g'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('h')
- && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('r'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('g') && c[1] == QLatin1Char('o')
- && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('o'))
- return QmlJSGrammar::T_RESERVED_WORD;
- }
- } break;
-
- case 5: {
- if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('r')
- && c[2] == QLatin1Char('e') && c[3] == QLatin1Char('a')
- && c[4] == QLatin1Char('k'))
- return QmlJSGrammar::T_BREAK;
- else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('a')
- && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('c')
- && c[4] == QLatin1Char('h'))
- return QmlJSGrammar::T_CATCH;
- else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h')
- && c[2] == QLatin1Char('r') && c[3] == QLatin1Char('o')
- && c[4] == QLatin1Char('w'))
- return QmlJSGrammar::T_THROW;
- else if (c[0] == QLatin1Char('w') && c[1] == QLatin1Char('h')
- && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('l')
- && c[4] == QLatin1Char('e'))
- return QmlJSGrammar::T_WHILE;
- else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('o')
- && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('s')
- && c[4] == QLatin1Char('t'))
- return QmlJSGrammar::T_CONST;
- else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('a')
- && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('s')
- && c[4] == QLatin1Char('e'))
- return QmlJSGrammar::T_FALSE;
- else if (check_reserved) {
- if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('h')
- && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('r')
- && c[4] == QLatin1Char('t'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('u')
- && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('e')
- && c[4] == QLatin1Char('r'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('i')
- && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('a')
- && c[4] == QLatin1Char('l'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('l')
- && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('s')
- && c[4] == QLatin1Char('s'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('l')
- && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('a')
- && c[4] == QLatin1Char('t'))
- return QmlJSGrammar::T_RESERVED_WORD;
- }
- } break;
-
- case 6: {
- if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e')
- && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('e')
- && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('e'))
- return QmlJSGrammar::T_DELETE;
- else if (c[0] == QLatin1Char('r') && c[1] == QLatin1Char('e')
- && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('u')
- && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('n'))
- return QmlJSGrammar::T_RETURN;
- else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('w')
- && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('t')
- && c[4] == QLatin1Char('c') && c[5] == QLatin1Char('h'))
- return QmlJSGrammar::T_SWITCH;
- else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('y')
- && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('e')
- && c[4] == QLatin1Char('o') && c[5] == QLatin1Char('f'))
- return QmlJSGrammar::T_TYPEOF;
- else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m')
- && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o')
- && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t'))
- return QmlJSGrammar::T_IMPORT;
- else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('i')
- && c[2] == QLatin1Char('g') && c[3] == QLatin1Char('n')
- && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('l'))
- return QmlJSGrammar::T_SIGNAL;
- else if (check_reserved) {
- if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('x')
- && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o')
- && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('t')
- && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('t')
- && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('c'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('o')
- && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('b')
- && c[4] == QLatin1Char('l') && c[5] == QLatin1Char('e'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m')
- && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o')
- && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('u')
- && c[2] == QLatin1Char('b') && c[3] == QLatin1Char('l')
- && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('c'))
- return QmlJSGrammar::T_PUBLIC;
- else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('a')
- && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('i')
- && c[4] == QLatin1Char('v') && c[5] == QLatin1Char('e'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h')
- && c[2] == QLatin1Char('r') && c[3] == QLatin1Char('o')
- && c[4] == QLatin1Char('w') && c[5] == QLatin1Char('s'))
- return QmlJSGrammar::T_RESERVED_WORD;
- }
- } break;
-
- case 7: {
- if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e')
- && c[2] == QLatin1Char('f') && c[3] == QLatin1Char('a')
- && c[4] == QLatin1Char('u') && c[5] == QLatin1Char('l')
- && c[6] == QLatin1Char('t'))
- return QmlJSGrammar::T_DEFAULT;
- else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('i')
- && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('a')
- && c[4] == QLatin1Char('l') && c[5] == QLatin1Char('l')
- && c[6] == QLatin1Char('y'))
- return QmlJSGrammar::T_FINALLY;
- else if (check_reserved) {
- if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('o')
- && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('l')
- && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('a')
- && c[6] == QLatin1Char('n'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('x')
- && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e')
- && c[4] == QLatin1Char('n') && c[5] == QLatin1Char('d')
- && c[6] == QLatin1Char('s'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('a')
- && c[2] == QLatin1Char('c') && c[3] == QLatin1Char('k')
- && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('g')
- && c[6] == QLatin1Char('e'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r')
- && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('v')
- && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('t')
- && c[6] == QLatin1Char('e'))
- return QmlJSGrammar::T_RESERVED_WORD;
- }
- } break;
-
- case 8: {
- if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('o')
- && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('t')
- && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('n')
- && c[6] == QLatin1Char('u') && c[7] == QLatin1Char('e'))
- return QmlJSGrammar::T_CONTINUE;
- else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('u')
- && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('c')
- && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('i')
- && c[6] == QLatin1Char('o') && c[7] == QLatin1Char('n'))
- return QmlJSGrammar::T_FUNCTION;
- else if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e')
- && c[2] == QLatin1Char('b') && c[3] == QLatin1Char('u')
- && c[4] == QLatin1Char('g') && c[5] == QLatin1Char('g')
- && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('r'))
- return QmlJSGrammar::T_DEBUGGER;
- else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r')
- && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('p')
- && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('r')
- && c[6] == QLatin1Char('t') && c[7] == QLatin1Char('y'))
- return QmlJSGrammar::T_PROPERTY;
- else if (c[0] == QLatin1Char('r') && c[1] == QLatin1Char('e')
- && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('d')
- && c[4] == QLatin1Char('o') && c[5] == QLatin1Char('n')
- && c[6] == QLatin1Char('l') && c[7] == QLatin1Char('y'))
- return QmlJSGrammar::T_READONLY;
- else if (check_reserved) {
- if (c[0] == QLatin1Char('a') && c[1] == QLatin1Char('b')
- && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('t')
- && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('a')
- && c[6] == QLatin1Char('c') && c[7] == QLatin1Char('t'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('o')
- && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('a')
- && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('i')
- && c[6] == QLatin1Char('l') && c[7] == QLatin1Char('e'))
- return QmlJSGrammar::T_RESERVED_WORD;
- }
- } break;
-
- case 9: {
- if (check_reserved) {
- if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n')
- && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e')
- && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('f')
- && c[6] == QLatin1Char('a') && c[7] == QLatin1Char('c')
- && c[8] == QLatin1Char('e'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r')
- && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('n')
- && c[4] == QLatin1Char('s') && c[5] == QLatin1Char('i')
- && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('n')
- && c[8] == QLatin1Char('t'))
- return QmlJSGrammar::T_RESERVED_WORD;
- else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r')
- && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('t')
- && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('c')
- && c[6] == QLatin1Char('t') && c[7] == QLatin1Char('e')
- && c[8] == QLatin1Char('d'))
- return QmlJSGrammar::T_RESERVED_WORD;
- }
- } break;
-
- case 10: {
- if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n')
- && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('t')
- && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('n')
- && c[6] == QLatin1Char('c') && c[7] == QLatin1Char('e')
- && c[8] == QLatin1Char('o') && c[9] == QLatin1Char('f'))
- return QmlJSGrammar::T_INSTANCEOF;
- else if (check_reserved) {
- if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m')
- && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('l')
- && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('m')
- && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('n')
- && c[8] == QLatin1Char('t') && c[9] == QLatin1Char('s'))
- return QmlJSGrammar::T_RESERVED_WORD;
- }
- } break;
-
- case 12: {
- if (check_reserved) {
- if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('y')
- && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('c')
- && c[4] == QLatin1Char('h') && c[5] == QLatin1Char('r')
- && c[6] == QLatin1Char('o') && c[7] == QLatin1Char('n')
- && c[8] == QLatin1Char('i') && c[9] == QLatin1Char('z')
- && c[10] == QLatin1Char('e') && c[11] == QLatin1Char('d'))
- return QmlJSGrammar::T_RESERVED_WORD;
- }
- } break;
-
- } // switch
-
- return -1;
-}
-
-int Lexer::lex()
-{
- int token = 0;
- state = Start;
- ushort stringType = 0; // either single or double quotes
- bool multiLineString = false;
- pos8 = pos16 = 0;
- done = false;
- terminator = false;
-
- // did we push a token on the stack previously ?
- // (after an automatic semicolon insertion)
- if (stackToken >= 0) {
- setDone(Other);
- token = stackToken;
- stackToken = -1;
- }
-
- while (!done) {
- switch (state) {
- case Start:
- if (isWhiteSpace()) {
- // do nothing
- } else if (current == '/' && next1 == '/') {
- recordStartPos();
- shift(1);
- state = InSingleLineComment;
- } else if (current == '/' && next1 == '*') {
- recordStartPos();
- shift(1);
- state = InMultiLineComment;
- } else if (current == 0) {
- syncProhibitAutomaticSemicolon();
- if (!terminator && !delimited && !prohibitAutomaticSemicolon) {
- // automatic semicolon insertion if program incomplete
- token = QmlJSGrammar::T_SEMICOLON;
- stackToken = 0;
- setDone(Other);
- } else {
- setDone(Eof);
- }
- } else if (isLineTerminator()) {
- shiftWindowsLineBreak();
- yylineno++;
- yycolumn = 0;
- bol = true;
- terminator = true;
- syncProhibitAutomaticSemicolon();
- if (restrKeyword) {
- token = QmlJSGrammar::T_SEMICOLON;
- setDone(Other);
- }
- } else if (current == '"' || current == '\'') {
- recordStartPos();
- state = InString;
- multiLineString = false;
- stringType = current;
- } else if (isIdentLetter(current)) {
- recordStartPos();
- record16(current);
- state = InIdentifier;
- } else if (current == '0') {
- recordStartPos();
- record8(current);
- state = InNum0;
- } else if (isDecimalDigit(current)) {
- recordStartPos();
- record8(current);
- state = InNum;
- } else if (current == '.' && isDecimalDigit(next1)) {
- recordStartPos();
- record8(current);
- state = InDecimal;
- } else {
- recordStartPos();
- token = matchPunctuator(current, next1, next2, next3);
- if (token != -1) {
- if (terminator && !delimited && !prohibitAutomaticSemicolon
- && (token == QmlJSGrammar::T_PLUS_PLUS
- || token == QmlJSGrammar::T_MINUS_MINUS)) {
- // automatic semicolon insertion
- stackToken = token;
- token = QmlJSGrammar::T_SEMICOLON;
- }
- setDone(Other);
- }
- else {
- setDone(Bad);
- err = IllegalCharacter;
- errmsg = QCoreApplication::translate("QmlParser", "Illegal character");
- }
- }
- break;
- case InString:
- if (current == stringType) {
- shift(1);
- setDone(String);
- } else if (isLineTerminator()) {
- multiLineString = true;
- record16(current);
- } else if (current == 0 || isLineTerminator()) {
- setDone(Bad);
- err = UnclosedStringLiteral;
- errmsg = QCoreApplication::translate("QmlParser", "Unclosed string at end of line");
- } else if (current == '\\') {
- state = InEscapeSequence;
- } else {
- record16(current);
- }
- break;
- // Escape Sequences inside of strings
- case InEscapeSequence:
- if (isOctalDigit(current)) {
- if (current >= '0' && current <= '3' &&
- isOctalDigit(next1) && isOctalDigit(next2)) {
- record16(convertOctal(current, next1, next2));
- shift(2);
- state = InString;
- } else if (isOctalDigit(current) &&
- isOctalDigit(next1)) {
- record16(convertOctal('0', current, next1));
- shift(1);
- state = InString;
- } else if (isOctalDigit(current)) {
- record16(convertOctal('0', '0', current));
- state = InString;
- } else {
- setDone(Bad);
- err = IllegalEscapeSequence;
- errmsg = QCoreApplication::translate("QmlParser", "Illegal escape squence");
- }
- } else if (current == 'x')
- state = InHexEscape;
- else if (current == 'u')
- state = InUnicodeEscape;
- else {
- if (isLineTerminator()) {
- shiftWindowsLineBreak();
- yylineno++;
- yycolumn = 0;
- bol = true;
- } else {
- record16(singleEscape(current));
- }
- state = InString;
- }
- break;
- case InHexEscape:
- if (isHexDigit(current) && isHexDigit(next1)) {
- state = InString;
- record16(QLatin1Char(convertHex(current, next1)));
- shift(1);
- } else if (current == stringType) {
- record16(QLatin1Char('x'));
- shift(1);
- setDone(String);
- } else {
- record16(QLatin1Char('x'));
- record16(current);
- state = InString;
- }
- break;
- case InUnicodeEscape:
- if (isHexDigit(current) && isHexDigit(next1) &&
- isHexDigit(next2) && isHexDigit(next3)) {
- record16(convertUnicode(current, next1, next2, next3));
- shift(3);
- state = InString;
- } else if (current == stringType) {
- record16(QLatin1Char('u'));
- shift(1);
- setDone(String);
- } else {
- setDone(Bad);
- err = IllegalUnicodeEscapeSequence;
- errmsg = QCoreApplication::translate("QmlParser", "Illegal unicode escape sequence");
- }
- break;
- case InSingleLineComment:
- if (isLineTerminator()) {
- shiftWindowsLineBreak();
- yylineno++;
- yycolumn = 0;
- terminator = true;
- bol = true;
- if (restrKeyword) {
- token = QmlJSGrammar::T_SEMICOLON;
- setDone(Other);
- } else
- state = Start;
- driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
- } else if (current == 0) {
- driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
- setDone(Eof);
- }
-
- break;
- case InMultiLineComment:
- if (current == 0) {
- setDone(Bad);
- err = UnclosedComment;
- errmsg = QCoreApplication::translate("QmlParser", "Unclosed comment at end of file");
- 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);
- }
-
- break;
- case InIdentifier:
- if (isIdentLetter(current) || isDecimalDigit(current)) {
- record16(current);
- break;
- }
- setDone(Identifier);
- break;
- case InNum0:
- if (current == 'x' || current == 'X') {
- record8(current);
- state = InHex;
- } else if (current == '.') {
- record8(current);
- state = InDecimal;
- } else if (current == 'e' || current == 'E') {
- record8(current);
- state = InExponentIndicator;
- } else if (isOctalDigit(current)) {
- record8(current);
- state = InOctal;
- } else if (isDecimalDigit(current)) {
- record8(current);
- state = InDecimal;
- } else {
- setDone(Number);
- }
- break;
- case InHex:
- if (isHexDigit(current))
- record8(current);
- else
- setDone(Hex);
- break;
- case InOctal:
- if (isOctalDigit(current)) {
- record8(current);
- } else if (isDecimalDigit(current)) {
- record8(current);
- state = InDecimal;
- } else {
- setDone(Octal);
- }
- break;
- case InNum:
- if (isDecimalDigit(current)) {
- record8(current);
- } else if (current == '.') {
- record8(current);
- state = InDecimal;
- } else if (current == 'e' || current == 'E') {
- record8(current);
- state = InExponentIndicator;
- } else {
- setDone(Number);
- }
- break;
- case InDecimal:
- if (isDecimalDigit(current)) {
- record8(current);
- } else if (current == 'e' || current == 'E') {
- record8(current);
- state = InExponentIndicator;
- } else {
- setDone(Number);
- }
- break;
- case InExponentIndicator:
- if (current == '+' || current == '-') {
- record8(current);
- } else if (isDecimalDigit(current)) {
- record8(current);
- state = InExponent;
- } else {
- setDone(Bad);
- err = IllegalExponentIndicator;
- errmsg = QCoreApplication::translate("QmlParser", "Illegal syntax for exponential number");
- }
- break;
- case InExponent:
- if (isDecimalDigit(current)) {
- record8(current);
- } else {
- setDone(Number);
- }
- break;
- default:
- Q_ASSERT_X(0, "Lexer::lex", "Unhandled state in switch statement");
- }
-
- // move on to the next character
- if (!done)
- shift(1);
- if (state != Start && state != InSingleLineComment)
- bol = false;
- }
-
- // no identifiers allowed directly after numeric literal, e.g. "3in" is bad
- if ((state == Number || state == Octal || state == Hex)
- && isIdentLetter(current)) {
- state = Bad;
- err = IllegalIdentifier;
- errmsg = QCoreApplication::translate("QmlParser", "Identifier cannot start with numeric literal");
- }
-
- // terminate string
- buffer8[pos8] = '\0';
-
- double dval = 0;
- if (state == Number) {
- dval = qstrtod(buffer8, 0, 0);
- } else if (state == Hex) { // scan hex numbers
- dval = integerFromString(buffer8, pos8, 16);
- state = Number;
- } else if (state == Octal) { // scan octal number
- dval = integerFromString(buffer8, pos8, 8);
- state = Number;
- }
-
- restrKeyword = false;
- delimited = false;
-
- switch (parenthesesState) {
- case IgnoreParentheses:
- break;
- case CountParentheses:
- if (token == QmlJSGrammar::T_RPAREN) {
- --parenthesesCount;
- if (parenthesesCount == 0)
- parenthesesState = BalancedParentheses;
- } else if (token == QmlJSGrammar::T_LPAREN) {
- ++parenthesesCount;
- }
- break;
- case BalancedParentheses:
- parenthesesState = IgnoreParentheses;
- break;
- }
-
- switch (state) {
- case Eof:
- return 0;
- case Other:
- if (token == QmlJSGrammar::T_RBRACE || token == QmlJSGrammar::T_SEMICOLON)
- delimited = true;
- return token;
- case Identifier:
- if ((token = findReservedWord(buffer16, pos16)) < 0) {
- /* TODO: close leak on parse error. same holds true for String */
- if (driver)
- qsyylval.ustr = driver->intern(buffer16, pos16);
- else
- qsyylval.ustr = 0;
- return QmlJSGrammar::T_IDENTIFIER;
- }
- if (token == QmlJSGrammar::T_CONTINUE || token == QmlJSGrammar::T_BREAK
- || token == QmlJSGrammar::T_RETURN || token == QmlJSGrammar::T_THROW) {
- restrKeyword = true;
- } else if (token == QmlJSGrammar::T_IF || token == QmlJSGrammar::T_FOR
- || token == QmlJSGrammar::T_WHILE || token == QmlJSGrammar::T_WITH) {
- parenthesesState = CountParentheses;
- parenthesesCount = 0;
- } else if (token == QmlJSGrammar::T_DO) {
- parenthesesState = BalancedParentheses;
- }
- return token;
- case String:
- if (driver)
- qsyylval.ustr = driver->intern(buffer16, pos16);
- else
- qsyylval.ustr = 0;
- return multiLineString?QmlJSGrammar::T_MULTILINE_STRING_LITERAL:QmlJSGrammar::T_STRING_LITERAL;
- case Number:
- qsyylval.dval = dval;
- return QmlJSGrammar::T_NUMERIC_LITERAL;
- case Bad:
- return -1;
- default:
- Q_ASSERT(!"unhandled numeration value in switch");
- return -1;
- }
-}
-
-bool Lexer::isWhiteSpace() const
-{
- return (current == ' ' || current == '\t' ||
- current == 0x0b || current == 0x0c);
-}
-
-bool Lexer::isLineTerminator() const
-{
- return (current == '\n' || current == '\r');
-}
-
-bool Lexer::isIdentLetter(ushort c)
-{
- // ASCII-biased, since all reserved words are ASCII, aand hence the
- // bulk of content to be parsed.
- if ((c >= 'a' && c <= 'z')
- || (c >= 'A' && c <= 'Z')
- || c == '$'
- || c == '_')
- return true;
- if (c < 128)
- return false;
- return QChar(c).isLetterOrNumber();
-}
-
-bool Lexer::isDecimalDigit(ushort c)
-{
- return (c >= '0' && c <= '9');
-}
-
-bool Lexer::isHexDigit(ushort c) const
-{
- return ((c >= '0' && c <= '9')
- || (c >= 'a' && c <= 'f')
- || (c >= 'A' && c <= 'F'));
-}
-
-bool Lexer::isOctalDigit(ushort c) const
-{
- return (c >= '0' && c <= '7');
-}
-
-int Lexer::matchPunctuator(ushort c1, ushort c2,
- ushort c3, ushort c4)
-{
- if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') {
- shift(4);
- return QmlJSGrammar::T_GT_GT_GT_EQ;
- } else if (c1 == '=' && c2 == '=' && c3 == '=') {
- shift(3);
- return QmlJSGrammar::T_EQ_EQ_EQ;
- } else if (c1 == '!' && c2 == '=' && c3 == '=') {
- shift(3);
- return QmlJSGrammar::T_NOT_EQ_EQ;
- } else if (c1 == '>' && c2 == '>' && c3 == '>') {
- shift(3);
- return QmlJSGrammar::T_GT_GT_GT;
- } else if (c1 == '<' && c2 == '<' && c3 == '=') {
- shift(3);
- return QmlJSGrammar::T_LT_LT_EQ;
- } else if (c1 == '>' && c2 == '>' && c3 == '=') {
- shift(3);
- return QmlJSGrammar::T_GT_GT_EQ;
- } else if (c1 == '<' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_LE;
- } else if (c1 == '>' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_GE;
- } else if (c1 == '!' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_NOT_EQ;
- } else if (c1 == '+' && c2 == '+') {
- shift(2);
- return QmlJSGrammar::T_PLUS_PLUS;
- } else if (c1 == '-' && c2 == '-') {
- shift(2);
- return QmlJSGrammar::T_MINUS_MINUS;
- } else if (c1 == '=' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_EQ_EQ;
- } else if (c1 == '+' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_PLUS_EQ;
- } else if (c1 == '-' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_MINUS_EQ;
- } else if (c1 == '*' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_STAR_EQ;
- } else if (c1 == '/' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_DIVIDE_EQ;
- } else if (c1 == '&' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_AND_EQ;
- } else if (c1 == '^' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_XOR_EQ;
- } else if (c1 == '%' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_REMAINDER_EQ;
- } else if (c1 == '|' && c2 == '=') {
- shift(2);
- return QmlJSGrammar::T_OR_EQ;
- } else if (c1 == '<' && c2 == '<') {
- shift(2);
- return QmlJSGrammar::T_LT_LT;
- } else if (c1 == '>' && c2 == '>') {
- shift(2);
- return QmlJSGrammar::T_GT_GT;
- } else if (c1 == '&' && c2 == '&') {
- shift(2);
- return QmlJSGrammar::T_AND_AND;
- } else if (c1 == '|' && c2 == '|') {
- shift(2);
- return QmlJSGrammar::T_OR_OR;
- }
-
- switch(c1) {
- case '=': shift(1); return QmlJSGrammar::T_EQ;
- case '>': shift(1); return QmlJSGrammar::T_GT;
- case '<': shift(1); return QmlJSGrammar::T_LT;
- case ',': shift(1); return QmlJSGrammar::T_COMMA;
- case '!': shift(1); return QmlJSGrammar::T_NOT;
- case '~': shift(1); return QmlJSGrammar::T_TILDE;
- case '?': shift(1); return QmlJSGrammar::T_QUESTION;
- case ':': shift(1); return QmlJSGrammar::T_COLON;
- case '.': shift(1); return QmlJSGrammar::T_DOT;
- case '+': shift(1); return QmlJSGrammar::T_PLUS;
- case '-': shift(1); return QmlJSGrammar::T_MINUS;
- case '*': shift(1); return QmlJSGrammar::T_STAR;
- case '/': shift(1); return QmlJSGrammar::T_DIVIDE_;
- case '&': shift(1); return QmlJSGrammar::T_AND;
- case '|': shift(1); return QmlJSGrammar::T_OR;
- case '^': shift(1); return QmlJSGrammar::T_XOR;
- case '%': shift(1); return QmlJSGrammar::T_REMAINDER;
- case '(': shift(1); return QmlJSGrammar::T_LPAREN;
- case ')': shift(1); return QmlJSGrammar::T_RPAREN;
- case '{': shift(1); return QmlJSGrammar::T_LBRACE;
- case '}': shift(1); return QmlJSGrammar::T_RBRACE;
- case '[': shift(1); return QmlJSGrammar::T_LBRACKET;
- case ']': shift(1); return QmlJSGrammar::T_RBRACKET;
- case ';': shift(1); return QmlJSGrammar::T_SEMICOLON;
-
- default: return -1;
- }
-}
-
-ushort Lexer::singleEscape(ushort c) const
-{
- switch(c) {
- case 'b':
- return 0x08;
- case 't':
- return 0x09;
- case 'n':
- return 0x0A;
- case 'v':
- return 0x0B;
- case 'f':
- return 0x0C;
- case 'r':
- return 0x0D;
- case '"':
- return 0x22;
- case '\'':
- return 0x27;
- case '\\':
- return 0x5C;
- default:
- return c;
- }
-}
-
-ushort Lexer::convertOctal(ushort c1, ushort c2,
- ushort c3) const
-{
- return ((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0');
-}
-
-unsigned char Lexer::convertHex(ushort c)
-{
- if (c >= '0' && c <= '9')
- return (c - '0');
- else if (c >= 'a' && c <= 'f')
- return (c - 'a' + 10);
- else
- return (c - 'A' + 10);
-}
-
-unsigned char Lexer::convertHex(ushort c1, ushort c2)
-{
- return ((convertHex(c1) << 4) + convertHex(c2));
-}
-
-QChar Lexer::convertUnicode(ushort c1, ushort c2,
- ushort c3, ushort c4)
-{
- return QChar((convertHex(c3) << 4) + convertHex(c4),
- (convertHex(c1) << 4) + convertHex(c2));
-}
-
-void Lexer::record8(ushort c)
-{
- Q_ASSERT(c <= 0xff);
-
- // enlarge buffer if full
- if (pos8 >= size8 - 1) {
- char *tmp = new char[2 * size8];
- memcpy(tmp, buffer8, size8 * sizeof(char));
- delete [] buffer8;
- buffer8 = tmp;
- size8 *= 2;
- }
-
- buffer8[pos8++] = (char) c;
-}
-
-void Lexer::record16(QChar c)
-{
- // enlarge buffer if full
- if (pos16 >= size16 - 1) {
- QChar *tmp = new QChar[2 * size16];
- memcpy(tmp, buffer16, size16 * sizeof(QChar));
- delete [] buffer16;
- buffer16 = tmp;
- size16 *= 2;
- }
-
- buffer16[pos16++] = c;
-}
-
-void Lexer::recordStartPos()
-{
- startpos = pos;
- startlineno = yylineno;
- startcolumn = yycolumn;
-}
-
-bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
-{
- pos16 = 0;
- bool lastWasEscape = false;
-
- if (prefix == EqualPrefix)
- record16(QLatin1Char('='));
-
- while (1) {
- if (isLineTerminator() || current == 0) {
- errmsg = QCoreApplication::translate("QmlParser", "Unterminated regular expression literal");
- return false;
- }
- else if (current != '/' || lastWasEscape == true)
- {
- record16(current);
- lastWasEscape = !lastWasEscape && (current == '\\');
- }
- else {
- if (driver)
- pattern = driver->intern(buffer16, pos16);
- else
- pattern = 0;
- pos16 = 0;
- shift(1);
- break;
- }
- shift(1);
- }
-
- flags = 0;
- while (isIdentLetter(current)) {
- int flag = Ecma::RegExp::flagFromChar(current);
- if (flag == 0) {
- errmsg = QCoreApplication::translate("QmlParser", "Invalid regular expression flag '%0'")
- .arg(QChar(current));
- return false;
- }
- flags |= flag;
- record16(current);
- shift(1);
- }
-
- return true;
-}
-
-void Lexer::syncProhibitAutomaticSemicolon()
-{
- if (parenthesesState == BalancedParentheses) {
- // we have seen something like "if (foo)", which means we should
- // never insert an automatic semicolon at this point, since it would
- // then be expanded into an empty statement (ECMA-262 7.9.1)
- prohibitAutomaticSemicolon = true;
- parenthesesState = IgnoreParentheses;
- } else {
- prohibitAutomaticSemicolon = false;
- }
-}
-
-QT_QML_END_NAMESPACE
-
-
diff --git a/src/declarative/qml/parser/qmljslexer_p.h b/src/declarative/qml/parser/qmljslexer_p.h
deleted file mode 100644
index 8f95a90..0000000
--- a/src/declarative/qml/parser/qmljslexer_p.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLJSLEXER_P_H
-#define QMLJSLEXER_P_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 "qmljsglobal_p.h"
-
-#include <QtCore/QString>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS {
-
-class Engine;
-class NameId;
-
-class QML_PARSER_EXPORT Lexer
-{
-public:
- Lexer(Engine *eng, bool tokenizeComments = false);
- ~Lexer();
-
- void setCode(const QString &c, int lineno);
- int lex();
-
- int currentLineNo() const { return yylineno; }
- int currentColumnNo() const { return yycolumn; }
-
- int tokenOffset() const { return startpos; }
- int tokenLength() const { return pos - startpos; }
-
- int startLineNo() const { return startlineno; }
- int startColumnNo() const { return startcolumn; }
-
- int endLineNo() const { return currentLineNo(); }
- int endColumnNo() const
- { int col = currentColumnNo(); return (col > 0) ? col - 1 : col; }
-
- bool prevTerminator() const { return terminator; }
-
- enum State { Start,
- Identifier,
- InIdentifier,
- InSingleLineComment,
- InMultiLineComment,
- InNum,
- InNum0,
- InHex,
- InOctal,
- InDecimal,
- InExponentIndicator,
- InExponent,
- Hex,
- Octal,
- Number,
- String,
- Eof,
- InString,
- InEscapeSequence,
- InHexEscape,
- InUnicodeEscape,
- Other,
- Bad };
-
- enum Error {
- NoError,
- IllegalCharacter,
- UnclosedStringLiteral,
- IllegalEscapeSequence,
- IllegalUnicodeEscapeSequence,
- UnclosedComment,
- IllegalExponentIndicator,
- IllegalIdentifier
- };
-
- enum ParenthesesState {
- IgnoreParentheses,
- CountParentheses,
- BalancedParentheses
- };
-
- enum RegExpBodyPrefix {
- NoPrefix,
- EqualPrefix
- };
-
- bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix);
-
- NameId *pattern;
- int flags;
-
- State lexerState() const
- { return state; }
-
- QString errorMessage() const
- { return errmsg; }
- void setErrorMessage(const QString &err)
- { errmsg = err; }
- void setErrorMessage(const char *err)
- { setErrorMessage(QString::fromLatin1(err)); }
-
- Error error() const
- { return err; }
- void clearError()
- { err = NoError; }
-
-private:
- Engine *driver;
- int yylineno;
- bool done;
- char *buffer8;
- QChar *buffer16;
- uint size8, size16;
- uint pos8, pos16;
- bool terminator;
- bool restrKeyword;
- // encountered delimiter like "'" and "}" on last run
- bool delimited;
- int stackToken;
-
- State state;
- void setDone(State s);
- uint pos;
- void shift(uint p);
- int lookupKeyword(const char *);
-
- bool isWhiteSpace() const;
- bool isLineTerminator() const;
- bool isHexDigit(ushort c) const;
- bool isOctalDigit(ushort c) const;
-
- int matchPunctuator(ushort c1, ushort c2,
- ushort c3, ushort c4);
- ushort singleEscape(ushort c) const;
- ushort convertOctal(ushort c1, ushort c2,
- ushort c3) const;
-public:
- static unsigned char convertHex(ushort c1);
- static unsigned char convertHex(ushort c1, ushort c2);
- static QChar convertUnicode(ushort c1, ushort c2,
- ushort c3, ushort c4);
- static bool isIdentLetter(ushort c);
- static bool isDecimalDigit(ushort c);
-
- inline int ival() const { return qsyylval.ival; }
- inline double dval() const { return qsyylval.dval; }
- inline NameId *ustr() const { return qsyylval.ustr; }
-
- const QChar *characterBuffer() const { return buffer16; }
- int characterCount() const { return pos16; }
-
-private:
- void record8(ushort c);
- void record16(QChar c);
- void recordStartPos();
-
- int findReservedWord(const QChar *buffer, int size) const;
-
- void syncProhibitAutomaticSemicolon();
-
- const QChar *code;
- uint length;
- int yycolumn;
- int startpos;
- int startlineno;
- int startcolumn;
- int bol; // begin of line
-
- union {
- int ival;
- double dval;
- NameId *ustr;
- } qsyylval;
-
- // current and following unicode characters
- ushort current, next1, next2, next3;
-
- struct keyword {
- const char *name;
- int token;
- };
-
- QString errmsg;
- Error err;
-
- bool wantRx;
- bool check_reserved;
-
- ParenthesesState parenthesesState;
- int parenthesesCount;
- bool prohibitAutomaticSemicolon;
- bool tokenizeComments;
-};
-
-} // namespace QmlJS
-
-QT_QML_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/parser/qmljsmemorypool_p.h b/src/declarative/qml/parser/qmljsmemorypool_p.h
deleted file mode 100644
index 5dffdc8..0000000
--- a/src/declarative/qml/parser/qmljsmemorypool_p.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLJSMEMORYPOOL_P_H
-#define QMLJSMEMORYPOOL_P_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 "qmljsglobal_p.h"
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qshareddata.h>
-
-#include <string.h>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS {
-
-class QML_PARSER_EXPORT MemoryPool : public QSharedData
-{
-public:
- enum { maxBlockCount = -1 };
- enum { defaultBlockSize = 1 << 12 };
-
- MemoryPool() {
- m_blockIndex = maxBlockCount;
- m_currentIndex = 0;
- m_storage = 0;
- m_currentBlock = 0;
- m_currentBlockSize = 0;
- }
-
- virtual ~MemoryPool() {
- for (int index = 0; index < m_blockIndex + 1; ++index)
- qFree(m_storage[index]);
-
- qFree(m_storage);
- }
-
- char *allocate(int bytes) {
- bytes += (8 - bytes) & 7; // ensure multiple of 8 bytes (maintain alignment)
- if (m_currentBlock == 0 || m_currentBlockSize < m_currentIndex + bytes) {
- ++m_blockIndex;
- m_currentBlockSize = defaultBlockSize << m_blockIndex;
-
- m_storage = reinterpret_cast<char**>(qRealloc(m_storage, sizeof(char*) * (1 + m_blockIndex)));
- m_currentBlock = m_storage[m_blockIndex] = reinterpret_cast<char*>(qMalloc(m_currentBlockSize));
- ::memset(m_currentBlock, 0, m_currentBlockSize);
-
- m_currentIndex = (8 - quintptr(m_currentBlock)) & 7; // ensure first chunk is 64-bit aligned
- Q_ASSERT(m_currentIndex + bytes <= m_currentBlockSize);
- }
-
- char *p = reinterpret_cast<char *>
- (m_currentBlock + m_currentIndex);
-
- m_currentIndex += bytes;
-
- return p;
- }
-
- int bytesAllocated() const {
- int bytes = 0;
- for (int index = 0; index < m_blockIndex; ++index)
- bytes += (defaultBlockSize << index);
- bytes += m_currentIndex;
- return bytes;
- }
-
-private:
- int m_blockIndex;
- int m_currentIndex;
- char *m_currentBlock;
- int m_currentBlockSize;
- char **m_storage;
-
-private:
- Q_DISABLE_COPY(MemoryPool)
-};
-
-} // namespace QmlJS
-
-QT_QML_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/parser/qmljsnodepool_p.h b/src/declarative/qml/parser/qmljsnodepool_p.h
deleted file mode 100644
index 2055a7e..0000000
--- a/src/declarative/qml/parser/qmljsnodepool_p.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLJSNODEPOOL_P_H
-#define QMLJSNODEPOOL_P_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 "qmljsglobal_p.h"
-#include "qmljsmemorypool_p.h"
-
-#include <QtCore/QHash>
-#include <QtCore/QString>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS {
-
-namespace AST {
-class Node;
-} // namespace AST
-
-class Code;
-class CompilationUnit;
-class Engine;
-
-template <typename NodeType>
-inline NodeType *makeAstNode(MemoryPool *storage)
-{
- NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType();
- return node;
-}
-
-template <typename NodeType, typename Arg1>
-inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1)
-{
- NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1);
- return node;
-}
-
-template <typename NodeType, typename Arg1, typename Arg2>
-inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1, Arg2 arg2)
-{
- NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2);
- return node;
-}
-
-template <typename NodeType, typename Arg1, typename Arg2, typename Arg3>
-inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1, Arg2 arg2, Arg3 arg3)
-{
- NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2, arg3);
- return node;
-}
-
-template <typename NodeType, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
-inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
-{
- NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2, arg3, arg4);
- return node;
-}
-
-class QML_PARSER_EXPORT NodePool : public MemoryPool
-{
-public:
- NodePool(const QString &fileName, Engine *engine);
- virtual ~NodePool();
-
- Code *createCompiledCode(AST::Node *node, CompilationUnit &compilation);
-
- inline QString fileName() const { return m_fileName; }
- inline Engine *engine() const { return m_engine; }
-#ifndef J_SCRIPT_NO_EVENT_NOTIFY
- inline qint64 id() const { return m_id; }
-#endif
-
-private:
- QHash<AST::Node*, Code*> m_codeCache;
- QString m_fileName;
- Engine *m_engine;
-#ifndef J_SCRIPT_NO_EVENT_NOTIFY
- qint64 m_id;
-#endif
-
-private:
- Q_DISABLE_COPY(NodePool)
-};
-
-} // namespace QmlJS
-
-QT_QML_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/parser/qmljsparser.cpp b/src/declarative/qml/parser/qmljsparser.cpp
deleted file mode 100644
index 856d06d..0000000
--- a/src/declarative/qml/parser/qmljsparser.cpp
+++ /dev/null
@@ -1,1843 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QtDebug>
-#include <QtGui/QApplication>
-
-#include <string.h>
-
-#include "qmljsengine_p.h"
-#include "qmljslexer_p.h"
-#include "qmljsast_p.h"
-#include "qmljsnodepool_p.h"
-
-
-
-#include "qmljsparser_p.h"
-#include <QVarLengthArray>
-
-//
-// This file is automatically generated from qmljs.g.
-// Changes will be lost.
-//
-
-using namespace QmlJS;
-
-QT_QML_BEGIN_NAMESPACE
-
-void Parser::reallocateStack()
-{
- if (! stack_size)
- stack_size = 128;
- else
- stack_size <<= 1;
-
- sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
- state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
- location_stack = reinterpret_cast<AST::SourceLocation*> (qRealloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
-}
-
-inline static bool automatic(Engine *driver, int token)
-{
- return token == QmlJSGrammar::T_RBRACE
- || token == 0
- || driver->lexer()->prevTerminator();
-}
-
-
-Parser::Parser(Engine *engine):
- driver(engine),
- tos(0),
- stack_size(0),
- sym_stack(0),
- state_stack(0),
- location_stack(0),
- first_token(0),
- last_token(0)
-{
-}
-
-Parser::~Parser()
-{
- if (stack_size) {
- qFree(sym_stack);
- qFree(state_stack);
- qFree(location_stack);
- }
-}
-
-static inline AST::SourceLocation location(Lexer *lexer)
-{
- AST::SourceLocation loc;
- loc.offset = lexer->tokenOffset();
- loc.length = lexer->tokenLength();
- loc.startLine = lexer->startLineNo();
- loc.startColumn = lexer->startColumnNo();
- return loc;
-}
-
-AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
-{
- QVarLengthArray<NameId *, 4> nameIds;
- QVarLengthArray<AST::SourceLocation, 4> locations;
-
- AST::ExpressionNode *it = expr;
- while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
- nameIds.append(m->name);
- locations.append(m->identifierToken);
- it = m->base;
- }
-
- if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
- AST::UiQualifiedId *q = makeAstNode<AST::UiQualifiedId>(driver->nodePool(), idExpr->name);
- q->identifierToken = idExpr->identifierToken;
-
- AST::UiQualifiedId *currentId = q;
- for (int i = nameIds.size() - 1; i != -1; --i) {
- currentId = makeAstNode<AST::UiQualifiedId>(driver->nodePool(), currentId, nameIds[i]);
- currentId->identifierToken = locations[i];
- }
-
- return currentId->finish();
- }
-
- return 0;
-}
-
-bool Parser::parse(int startToken)
-{
- Lexer *lexer = driver->lexer();
- bool hadErrors = false;
- int yytoken = -1;
- int action = 0;
-
- token_buffer[0].token = startToken;
- first_token = &token_buffer[0];
- last_token = &token_buffer[1];
-
- tos = -1;
- program = 0;
-
- do {
- if (++tos == stack_size)
- reallocateStack();
-
- state_stack[tos] = action;
-
- _Lcheck_token:
- if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
- yyprevlloc = yylloc;
-
- if (first_token == last_token) {
- yytoken = lexer->lex();
- yylval = lexer->dval();
- yylloc = location(lexer);
- } else {
- yytoken = first_token->token;
- yylval = first_token->dval;
- yylloc = first_token->loc;
- ++first_token;
- }
- }
-
- action = t_action(action, yytoken);
- if (action > 0) {
- if (action != ACCEPT_STATE) {
- yytoken = -1;
- sym(1).dval = yylval;
- loc(1) = yylloc;
- } else {
- --tos;
- return ! hadErrors;
- }
- } else if (action < 0) {
- const int r = -action - 1;
- tos -= rhs[r];
-
- switch (r) {
-
-case 0: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 1: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 2: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 3: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 4: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 5: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 6: {
- sym(1).UiProgram = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList,
- sym(2).UiObjectMemberList->finish());
-} break;
-
-case 8: {
- sym(1).Node = sym(1).UiImportList->finish();
-} break;
-
-case 9: {
- sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(), sym(1).UiImport);
-} break;
-
-case 10: {
- sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(),
- sym(1).UiImportList, sym(2).UiImport);
-} break;
-
-case 13: {
- sym(1).UiImport->semicolonToken = loc(2);
-} break;
-
-case 15: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->semicolonToken = loc(3);
-} break;
-
-case 17: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->asToken = loc(3);
- sym(1).UiImport->importIdToken = loc(4);
- sym(1).UiImport->importId = sym(4).sval;
- sym(1).UiImport->semicolonToken = loc(5);
-} break;
-
-case 19: {
- sym(1).UiImport->asToken = loc(2);
- sym(1).UiImport->importIdToken = loc(3);
- sym(1).UiImport->importId = sym(3).sval;
- sym(1).UiImport->semicolonToken = loc(4);
-} break;
-
-case 20: {
- AST::UiImport *node = 0;
-
- if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
- node = makeAstNode<AST::UiImport>(driver->nodePool(), importIdLiteral->value);
- node->fileNameToken = loc(2);
- } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
- QString text;
- for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) {
- text += q->name->asString();
- if (q->next) text += QLatin1String(".");
- }
- node = makeAstNode<AST::UiImport>(driver->nodePool(), qualifiedId);
- node->fileNameToken = loc(2);
- }
-
- sym(1).Node = node;
-
- if (! node) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id or a string literal")));
-
- return false; // ### remove me
- }
-} break;
-
-case 21: {
- sym(1).Node = 0;
-} break;
-
-case 22: {
- sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
-} break;
-
-case 23: {
- sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
-} break;
-
-case 24: {
- AST::UiObjectMemberList *node = makeAstNode<AST:: UiObjectMemberList> (driver->nodePool(),
- sym(1).UiObjectMemberList, sym(2).UiObjectMember);
- sym(1).Node = node;
-} break;
-
-case 25: {
- sym(1).Node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(), sym(1).UiObjectMember);
-} break;
-
-case 26: {
- AST::UiArrayMemberList *node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(),
- sym(1).UiArrayMemberList, sym(3).UiObjectMember);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 27: {
- AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), (AST::UiObjectMemberList*)0);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 28: {
- AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), sym(2).UiObjectMemberList->finish());
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 29: {
- AST::UiObjectDefinition *node = makeAstNode<AST::UiObjectDefinition> (driver->nodePool(), sym(1).UiQualifiedId,
- sym(2).UiObjectInitializer);
- sym(1).Node = node;
-} break;
-
-case 31: {
- AST::UiArrayBinding *node = makeAstNode<AST::UiArrayBinding> (driver->nodePool(),
- sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
- node->colonToken = loc(2);
- node->lbracketToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 32: {
- AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
- sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-case 33:case 34:case 35:case 36:
-{
- AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
- sym(1).UiQualifiedId, sym(3).Statement);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 37:
-
-case 38: {
- sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
- break;
-}
-
-case 40: {
- sym(1).Node = 0;
-} break;
-
-case 41: {
- sym(1).Node = sym(1).UiParameterList->finish ();
-} break;
-
-case 42: {
- AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).sval, sym(2).sval);
- node->identifierToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 43: {
- AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).UiParameterList, sym(3).sval, sym(4).sval);
- node->commaToken = loc(2);
- node->identifierToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 45: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->parameters = sym(4).UiParameterList;
- node->semicolonToken = loc(6);
- sym(1).Node = node;
-} break;
-
-case 47: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 49: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(4).sval, sym(6).sval);
- node->typeModifier = sym(2).sval;
- node->propertyToken = loc(1);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 51: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval);
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->semicolonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 53: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval);
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->semicolonToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 55: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval,
- sym(5).Expression);
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->colonToken = loc(4);
- node->semicolonToken = loc(6);
- sym(1).Node = node;
-} break;
-
-case 57: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
- sym(6).Expression);
- node->isReadonlyMember = true;
- node->readonlyToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 59: {
- AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
- sym(6).Expression);
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 60: {
- sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
-} break;
-
-case 61: {
- sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
-} break;
-
-case 63: {
- QString s = QLatin1String(QmlJSGrammar::spell[T_PROPERTY]);
- sym(1).sval = driver->intern(s.constData(), s.length());
- break;
-}
-
-case 64: {
- QString s = QLatin1String(QmlJSGrammar::spell[T_SIGNAL]);
- sym(1).sval = driver->intern(s.constData(), s.length());
- break;
-}
-
-case 65: {
- QString s = QLatin1String(QmlJSGrammar::spell[T_READONLY]);
- sym(1).sval = driver->intern(s.constData(), s.length());
- break;
-}
-
-case 66: {
- AST::ThisExpression *node = makeAstNode<AST::ThisExpression> (driver->nodePool());
- node->thisToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 67: {
- AST::IdentifierExpression *node = makeAstNode<AST::IdentifierExpression> (driver->nodePool(), sym(1).sval);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 68: {
- AST::NullExpression *node = makeAstNode<AST::NullExpression> (driver->nodePool());
- node->nullToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 69: {
- AST::TrueLiteral *node = makeAstNode<AST::TrueLiteral> (driver->nodePool());
- node->trueToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 70: {
- AST::FalseLiteral *node = makeAstNode<AST::FalseLiteral> (driver->nodePool());
- node->falseToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 71: {
- AST::NumericLiteral *node = makeAstNode<AST::NumericLiteral> (driver->nodePool(), sym(1).dval);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-case 72:
-case 73: {
- AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 74: {
- bool rx = lexer->scanRegExp(Lexer::NoPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false; // ### remove me
- }
- AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 75: {
- bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false;
- }
- AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 76: {
- AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), (AST::Elision *) 0);
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 77: {
- AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).Elision->finish());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 78: {
- AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish ());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 79: {
- AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (),
- (AST::Elision *) 0);
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 80: {
- AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (),
- sym(4).Elision->finish());
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 81: {
- AST::ObjectLiteral *node = 0;
- if (sym(2).Node)
- node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
- sym(2).PropertyNameAndValueList->finish ());
- else
- node = makeAstNode<AST::ObjectLiteral> (driver->nodePool());
- node->lbraceToken = loc(1);
- node->lbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 82: {
- AST::ObjectLiteral *node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
- sym(2).PropertyNameAndValueList->finish ());
- node->lbraceToken = loc(1);
- node->lbraceToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 83: {
- AST::NestedExpression *node = makeAstNode<AST::NestedExpression>(driver->nodePool(), sym(2).Expression);
- node->lparenToken = loc(1);
- node->rparenToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 84: {
- if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
- QLatin1String("Ignored annotation")));
-
- sym(1).Expression = mem->base;
- }
-
- if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
- sym(1).UiQualifiedId = qualifiedId;
- } else {
- sym(1).UiQualifiedId = 0;
-
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id")));
-
- return false; // ### recover
- }
-} break;
-
-case 85: {
- sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), (AST::Elision *) 0, sym(1).Expression);
-} break;
-
-case 86: {
- sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).Elision->finish(), sym(2).Expression);
-} break;
-
-case 87: {
- AST::ElementList *node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).ElementList,
- (AST::Elision *) 0, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 88: {
- AST::ElementList *node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).ElementList, sym(3).Elision->finish(),
- sym(4).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 89: {
- AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool());
- node->commaToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 90: {
- AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool(), sym(1).Elision);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 91: {
- AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
- sym(1).PropertyName, sym(3).Expression);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 92: {
- AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
- sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
- node->commaToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 93: {
- AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-case 94:
-case 95: {
- AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 96: {
- AST::StringLiteralPropertyName *node = makeAstNode<AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 97: {
- AST::NumericLiteralPropertyName *node = makeAstNode<AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 98: {
- AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 99:
-
-case 100:
-
-case 101:
-
-case 102:
-
-case 103:
-
-case 104:
-
-case 105:
-
-case 106:
-
-case 107:
-
-case 108:
-
-case 109:
-
-case 110:
-
-case 111:
-
-case 112:
-
-case 113:
-
-case 114:
-
-case 115:
-
-case 116:
-
-case 117:
-
-case 118:
-
-case 119:
-
-case 120:
-
-case 121:
-
-case 122:
-
-case 123:
-
-case 124:
-
-case 125:
-
-case 126:
-
-case 127:
-
-case 128:
-
-case 129:
-{
- sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
-} break;
-
-case 134: {
- AST::ArrayMemberExpression *node = makeAstNode<AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 135: {
- AST::FieldMemberExpression *node = makeAstNode<AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 136: {
- AST::NewMemberExpression *node = makeAstNode<AST::NewMemberExpression> (driver->nodePool(), sym(2).Expression, sym(4).ArgumentList);
- node->newToken = loc(1);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 138: {
- AST::NewExpression *node = makeAstNode<AST::NewExpression> (driver->nodePool(), sym(2).Expression);
- node->newToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 139: {
- AST::CallExpression *node = makeAstNode<AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 140: {
- AST::CallExpression *node = makeAstNode<AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 141: {
- AST::ArrayMemberExpression *node = makeAstNode<AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 142: {
- AST::FieldMemberExpression *node = makeAstNode<AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 143: {
- sym(1).Node = 0;
-} break;
-
-case 144: {
- sym(1).Node = sym(1).ArgumentList->finish();
-} break;
-
-case 145: {
- sym(1).Node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).Expression);
-} break;
-
-case 146: {
- AST::ArgumentList *node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).ArgumentList, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 150: {
- AST::PostIncrementExpression *node = makeAstNode<AST::PostIncrementExpression> (driver->nodePool(), sym(1).Expression);
- node->incrementToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 151: {
- AST::PostDecrementExpression *node = makeAstNode<AST::PostDecrementExpression> (driver->nodePool(), sym(1).Expression);
- node->decrementToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 153: {
- AST::DeleteExpression *node = makeAstNode<AST::DeleteExpression> (driver->nodePool(), sym(2).Expression);
- node->deleteToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 154: {
- AST::VoidExpression *node = makeAstNode<AST::VoidExpression> (driver->nodePool(), sym(2).Expression);
- node->voidToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 155: {
- AST::TypeOfExpression *node = makeAstNode<AST::TypeOfExpression> (driver->nodePool(), sym(2).Expression);
- node->typeofToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 156: {
- AST::PreIncrementExpression *node = makeAstNode<AST::PreIncrementExpression> (driver->nodePool(), sym(2).Expression);
- node->incrementToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 157: {
- AST::PreDecrementExpression *node = makeAstNode<AST::PreDecrementExpression> (driver->nodePool(), sym(2).Expression);
- node->decrementToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 158: {
- AST::UnaryPlusExpression *node = makeAstNode<AST::UnaryPlusExpression> (driver->nodePool(), sym(2).Expression);
- node->plusToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 159: {
- AST::UnaryMinusExpression *node = makeAstNode<AST::UnaryMinusExpression> (driver->nodePool(), sym(2).Expression);
- node->minusToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 160: {
- AST::TildeExpression *node = makeAstNode<AST::TildeExpression> (driver->nodePool(), sym(2).Expression);
- node->tildeToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 161: {
- AST::NotExpression *node = makeAstNode<AST::NotExpression> (driver->nodePool(), sym(2).Expression);
- node->notToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 163: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Mul, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 164: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Div, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 165: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Mod, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 167: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Add, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 168: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Sub, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 170: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::LShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 171: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::RShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 172: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::URShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 174: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 175: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 176: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 177: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 178: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 179: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::In, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 181: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 182: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 183: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 184: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 185: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 187: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 188: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 189: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 190: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 192: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 193: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 194: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 195: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 197: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 199: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 201: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 203: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 205: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 207: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 209: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 211: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 213: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 215: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 217: {
- AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 219: {
- AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 221: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 223: {
- AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 224: {
- sym(1).ival = QSOperator::Assign;
-} break;
-
-case 225: {
- sym(1).ival = QSOperator::InplaceMul;
-} break;
-
-case 226: {
- sym(1).ival = QSOperator::InplaceDiv;
-} break;
-
-case 227: {
- sym(1).ival = QSOperator::InplaceMod;
-} break;
-
-case 228: {
- sym(1).ival = QSOperator::InplaceAdd;
-} break;
-
-case 229: {
- sym(1).ival = QSOperator::InplaceSub;
-} break;
-
-case 230: {
- sym(1).ival = QSOperator::InplaceLeftShift;
-} break;
-
-case 231: {
- sym(1).ival = QSOperator::InplaceRightShift;
-} break;
-
-case 232: {
- sym(1).ival = QSOperator::InplaceURightShift;
-} break;
-
-case 233: {
- sym(1).ival = QSOperator::InplaceAnd;
-} break;
-
-case 234: {
- sym(1).ival = QSOperator::InplaceXor;
-} break;
-
-case 235: {
- sym(1).ival = QSOperator::InplaceOr;
-} break;
-
-case 237: {
- AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 238: {
- sym(1).Node = 0;
-} break;
-
-case 241: {
- AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 242: {
- sym(1).Node = 0;
-} break;
-
-case 259: {
- AST::Block *node = makeAstNode<AST::Block> (driver->nodePool(), sym(2).StatementList);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 260: {
- sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).Statement);
-} break;
-
-case 261: {
- sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).StatementList, sym(2).Statement);
-} break;
-
-case 262: {
- sym(1).Node = 0;
-} break;
-
-case 263: {
- sym(1).Node = sym(1).StatementList->finish ();
-} break;
-
-case 265: {
- AST::VariableStatement *node = makeAstNode<AST::VariableStatement> (driver->nodePool(),
- sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
- node->declarationKindToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 266: {
- sym(1).ival = T_CONST;
-} break;
-
-case 267: {
- sym(1).ival = T_VAR;
-} break;
-
-case 268: {
- sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
-} break;
-
-case 269: {
- AST::VariableDeclarationList *node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(),
- sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 270: {
- sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
-} break;
-
-case 271: {
- sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
-} break;
-
-case 272: {
- AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 273: {
- AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 274: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
-
-case 275: {
- sym(1).Node = 0;
-} break;
-
-case 277: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
-
-case 278: {
- sym(1).Node = 0;
-} break;
-
-case 280: {
- AST::EmptyStatement *node = makeAstNode<AST::EmptyStatement> (driver->nodePool());
- node->semicolonToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 282: {
- AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 283: {
- AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- node->elseToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 284: {
- AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 286: {
- AST::DoWhileStatement *node = makeAstNode<AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression);
- node->doToken = loc(1);
- node->whileToken = loc(3);
- node->lparenToken = loc(4);
- node->rparenToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 287: {
- AST::WhileStatement *node = makeAstNode<AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
- node->whileToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 288: {
- AST::ForStatement *node = makeAstNode<AST::ForStatement> (driver->nodePool(), sym(3).Expression,
- sym(5).Expression, sym(7).Expression, sym(9).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->firstSemicolonToken = loc(4);
- node->secondSemicolonToken = loc(6);
- node->rparenToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 289: {
- AST::LocalForStatement *node = makeAstNode<AST::LocalForStatement> (driver->nodePool(),
- sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
- sym(8).Expression, sym(10).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->firstSemicolonToken = loc(5);
- node->secondSemicolonToken = loc(7);
- node->rparenToken = loc(9);
- sym(1).Node = node;
-} break;
-
-case 290: {
- AST:: ForEachStatement *node = makeAstNode<AST::ForEachStatement> (driver->nodePool(), sym(3).Expression,
- sym(5).Expression, sym(7).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->inToken = loc(4);
- node->rparenToken = loc(6);
- sym(1).Node = node;
-} break;
-
-case 291: {
- AST::LocalForEachStatement *node = makeAstNode<AST::LocalForEachStatement> (driver->nodePool(),
- sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->inToken = loc(5);
- node->rparenToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 293: {
- AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool());
- node->continueToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 295: {
- AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool(), sym(2).sval);
- node->continueToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 297: {
- AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool());
- node->breakToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 299: {
- AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool(), sym(2).sval);
- node->breakToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 301: {
- AST::ReturnStatement *node = makeAstNode<AST::ReturnStatement> (driver->nodePool(), sym(2).Expression);
- node->returnToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 302: {
- AST::WithStatement *node = makeAstNode<AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
- node->withToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 303: {
- AST::SwitchStatement *node = makeAstNode<AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock);
- node->switchToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 304: {
- AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 305: {
- AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 306: {
- sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClause);
-} break;
-
-case 307: {
- sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClauses, sym(2).CaseClause);
-} break;
-
-case 308: {
- sym(1).Node = 0;
-} break;
-
-case 309: {
- sym(1).Node = sym(1).CaseClauses->finish ();
-} break;
-
-case 310: {
- AST::CaseClause *node = makeAstNode<AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList);
- node->caseToken = loc(1);
- node->colonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 311: {
- AST::DefaultClause *node = makeAstNode<AST::DefaultClause> (driver->nodePool(), sym(3).StatementList);
- node->defaultToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-case 312:
-case 313: {
- AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()), sym(3).Statement);
- node->identifierToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 314: {
- AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement);
- node->identifierToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 316: {
- AST::ThrowStatement *node = makeAstNode<AST::ThrowStatement> (driver->nodePool(), sym(2).Expression);
- node->throwToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 317: {
- AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 318: {
- AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 319: {
- AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 320: {
- AST::Catch *node = makeAstNode<AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Block);
- node->catchToken = loc(1);
- node->lparenToken = loc(2);
- node->identifierToken = loc(3);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 321: {
- AST::Finally *node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Block);
- node->finallyToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 323: {
- AST::DebuggerStatement *node = makeAstNode<AST::DebuggerStatement> (driver->nodePool());
- node->debuggerToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 324: {
- AST::FunctionDeclaration *node = makeAstNode<AST::FunctionDeclaration> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 325: {
- AST::FunctionExpression *node = makeAstNode<AST::FunctionExpression> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- if (sym(2).sval)
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 326: {
- AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).sval);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 327: {
- AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).FormalParameterList, sym(3).sval);
- node->commaToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 328: {
- sym(1).Node = 0;
-} break;
-
-case 329: {
- sym(1).Node = sym(1).FormalParameterList->finish ();
-} break;
-
-case 330: {
- sym(1).Node = 0;
-} break;
-
-case 332: {
- sym(1).Node = makeAstNode<AST::FunctionBody> (driver->nodePool(), sym(1).SourceElements->finish ());
-} break;
-
-case 333: {
- sym(1).Node = makeAstNode<AST::Program> (driver->nodePool(), sym(1).SourceElements->finish ());
-} break;
-
-case 334: {
- sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElement);
-} break;
-
-case 335: {
- sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElements, sym(2).SourceElement);
-} break;
-
-case 336: {
- sym(1).Node = makeAstNode<AST::StatementSourceElement> (driver->nodePool(), sym(1).Statement);
-} break;
-
-case 337: {
- sym(1).Node = makeAstNode<AST::FunctionSourceElement> (driver->nodePool(), sym(1).FunctionDeclaration);
-} break;
-
-case 338: {
- sym(1).sval = 0;
-} break;
-
-case 340: {
- sym(1).Node = 0;
-} break;
-
- } // switch
- action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
- } // if
- } while (action != 0);
-
- if (first_token == last_token) {
- const int errorState = state_stack[tos];
-
- // automatic insertion of `;'
- if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && automatic(driver, yytoken)) {
- SavedToken &tk = token_buffer[0];
- tk.token = yytoken;
- tk.dval = yylval;
- tk.loc = yylloc;
-
- yylloc = yyprevlloc;
- yylloc.offset += yylloc.length;
- yylloc.startColumn += yylloc.length;
- yylloc.length = 0;
-
- //const QString msg = qApp->translate("QmlParser", "Missing `;'");
- //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
-
- first_token = &token_buffer[0];
- last_token = &token_buffer[1];
-
- yytoken = T_SEMICOLON;
- yylval = 0;
-
- action = errorState;
-
- goto _Lcheck_token;
- }
-
- hadErrors = true;
-
- token_buffer[0].token = yytoken;
- token_buffer[0].dval = yylval;
- token_buffer[0].loc = yylloc;
-
- token_buffer[1].token = yytoken = lexer->lex();
- token_buffer[1].dval = yylval = lexer->dval();
- token_buffer[1].loc = yylloc = location(lexer);
-
- if (t_action(errorState, yytoken)) {
- QString msg;
- int token = token_buffer[0].token;
- if (token < 0 || token >= TERMINAL_COUNT)
- msg = qApp->translate("QmlParser", "Syntax error");
- else
- msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- action = errorState;
- goto _Lcheck_token;
- }
-
- static int tokens[] = {
- T_PLUS,
- T_EQ,
-
- T_COMMA,
- T_COLON,
- T_SEMICOLON,
-
- T_RPAREN, T_RBRACKET, T_RBRACE,
-
- T_NUMERIC_LITERAL,
- T_IDENTIFIER,
-
- T_LPAREN, T_LBRACKET, T_LBRACE,
-
- EOF_SYMBOL
- };
-
- for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
- int a = t_action(errorState, *tk);
- if (a > 0 && t_action(a, yytoken)) {
- const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- yytoken = *tk;
- yylval = 0;
- yylloc = token_buffer[0].loc;
- yylloc.length = 0;
-
- first_token = &token_buffer[0];
- last_token = &token_buffer[2];
-
- action = errorState;
- goto _Lcheck_token;
- }
- }
-
- for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
- if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
- tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
- tk == T_FEED_JS_SOURCE_ELEMENT)
- continue;
-
- int a = t_action(errorState, tk);
- if (a > 0 && t_action(a, yytoken)) {
- const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- yytoken = tk;
- yylval = 0;
- yylloc = token_buffer[0].loc;
- yylloc.length = 0;
-
- action = errorState;
- goto _Lcheck_token;
- }
- }
-
- const QString msg = qApp->translate("QmlParser", "Syntax error");
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
- }
-
- return false;
-}
-
-QT_QML_END_NAMESPACE
-
-
diff --git a/src/declarative/qml/parser/qmljsparser_p.h b/src/declarative/qml/parser/qmljsparser_p.h
deleted file mode 100644
index 42fb422..0000000
--- a/src/declarative/qml/parser/qmljsparser_p.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-//
-// 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.
-//
-
-//
-// This file is automatically generated from qmljs.g.
-// Changes will be lost.
-//
-
-#ifndef QMLJSPARSER_P_H
-#define QMLJSPARSER_P_H
-
-#include "qmljsglobal_p.h"
-#include "qmljsgrammar_p.h"
-#include "qmljsast_p.h"
-#include "qmljsengine_p.h"
-
-#include <QtCore/QList>
-#include <QtCore/QString>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QmlJS {
-
-class Engine;
-class NameId;
-
-class QML_PARSER_EXPORT Parser: protected QmlJSGrammar
-{
-public:
- union Value {
- int ival;
- double dval;
- NameId *sval;
- AST::ArgumentList *ArgumentList;
- AST::CaseBlock *CaseBlock;
- AST::CaseClause *CaseClause;
- AST::CaseClauses *CaseClauses;
- AST::Catch *Catch;
- AST::DefaultClause *DefaultClause;
- AST::ElementList *ElementList;
- AST::Elision *Elision;
- AST::ExpressionNode *Expression;
- AST::Finally *Finally;
- AST::FormalParameterList *FormalParameterList;
- AST::FunctionBody *FunctionBody;
- AST::FunctionDeclaration *FunctionDeclaration;
- AST::Node *Node;
- AST::PropertyName *PropertyName;
- AST::PropertyNameAndValueList *PropertyNameAndValueList;
- AST::SourceElement *SourceElement;
- AST::SourceElements *SourceElements;
- AST::Statement *Statement;
- AST::StatementList *StatementList;
- AST::Block *Block;
- AST::VariableDeclaration *VariableDeclaration;
- AST::VariableDeclarationList *VariableDeclarationList;
-
- AST::UiProgram *UiProgram;
- AST::UiImportList *UiImportList;
- AST::UiImport *UiImport;
- AST::UiParameterList *UiParameterList;
- AST::UiPublicMember *UiPublicMember;
- AST::UiObjectDefinition *UiObjectDefinition;
- AST::UiObjectInitializer *UiObjectInitializer;
- AST::UiObjectBinding *UiObjectBinding;
- AST::UiScriptBinding *UiScriptBinding;
- AST::UiArrayBinding *UiArrayBinding;
- AST::UiObjectMember *UiObjectMember;
- AST::UiObjectMemberList *UiObjectMemberList;
- AST::UiArrayMemberList *UiArrayMemberList;
- AST::UiQualifiedId *UiQualifiedId;
- AST::UiSignature *UiSignature;
- AST::UiFormalList *UiFormalList;
- AST::UiFormal *UiFormal;
- };
-
-public:
- Parser(Engine *engine);
- ~Parser();
-
- // parse a UI program
- bool parse() { return parse(T_FEED_UI_PROGRAM); }
- bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
- bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
- bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
- bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
- bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
-
- AST::UiProgram *ast() const
- { return AST::cast<AST::UiProgram *>(program); }
-
- AST::Statement *statement() const
- {
- if (! program)
- return 0;
-
- return program->statementCast();
- }
-
- AST::ExpressionNode *expression() const
- {
- if (! program)
- return 0;
-
- return program->expressionCast();
- }
-
- AST::UiObjectMember *uiObjectMember() const
- {
- if (! program)
- return 0;
-
- return program->uiObjectMemberCast();
- }
-
- AST::Node *rootNode() const
- { return program; }
-
- QList<DiagnosticMessage> diagnosticMessages() const
- { return diagnostic_messages; }
-
- inline DiagnosticMessage diagnosticMessage() const
- {
- foreach (const DiagnosticMessage &d, diagnostic_messages) {
- if (! d.kind == DiagnosticMessage::Warning)
- return d;
- }
-
- return DiagnosticMessage();
- }
-
- inline QString errorMessage() const
- { return diagnosticMessage().message; }
-
- inline int errorLineNumber() const
- { return diagnosticMessage().loc.startLine; }
-
- inline int errorColumnNumber() const
- { return diagnosticMessage().loc.startColumn; }
-
-protected:
- bool parse(int startToken);
-
- void reallocateStack();
-
- inline Value &sym(int index)
- { return sym_stack [tos + index - 1]; }
-
- inline AST::SourceLocation &loc(int index)
- { return location_stack [tos + index - 1]; }
-
- AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
-
-protected:
- Engine *driver;
- int tos;
- int stack_size;
- Value *sym_stack;
- int *state_stack;
- AST::SourceLocation *location_stack;
-
- AST::Node *program;
-
- // error recovery
- enum { TOKEN_BUFFER_SIZE = 3 };
-
- struct SavedToken {
- int token;
- double dval;
- AST::SourceLocation loc;
- };
-
- double yylval;
- AST::SourceLocation yylloc;
- AST::SourceLocation yyprevlloc;
-
- SavedToken token_buffer[TOKEN_BUFFER_SIZE];
- SavedToken *first_token;
- SavedToken *last_token;
-
- QList<DiagnosticMessage> diagnostic_messages;
-};
-
-} // end of namespace QmlJS
-
-
-
-#define J_SCRIPT_REGEXPLITERAL_RULE1 74
-
-#define J_SCRIPT_REGEXPLITERAL_RULE2 75
-
-QT_QML_END_NAMESPACE
-
-
-
-#endif // QMLJSPARSER_P_H
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
new file mode 100644
index 0000000..ee5a27a
--- /dev/null
+++ b/src/declarative/qml/qdeclarative.h
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QML_H
+#define QML_H
+
+#include "qdeclarativemetatype.h"
+#include "qdeclarativemetaproperty.h"
+#include "qdeclarativeparserstatus.h"
+#include "qdeclarativepropertyvaluesource.h"
+#include "qdeclarativelist.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qmetaobject.h>
+
+QT_BEGIN_HEADER
+
+#define QML_DECLARE_TYPE(TYPE) \
+ Q_DECLARE_METATYPE(TYPE *) \
+ Q_DECLARE_METATYPE(QDeclarativeListProperty<TYPE>)
+
+#define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \
+ Q_DECLARE_METATYPE(QDeclarativeListProperty<TYPE>)
+
+#define QML_DECLARE_INTERFACE(INTERFACE) \
+ QML_DECLARE_TYPE(INTERFACE)
+
+#define QML_DECLARE_INTERFACE_HASMETATYPE(INTERFACE) \
+ QML_DECLARE_TYPE_HASMETATYPE(INTERFACE)
+
+enum { /* TYPEINFO flags */
+ QML_HAS_ATTACHED_PROPERTIES = 0x01,
+};
+
+#define QML_DECLARE_TYPEINFO(TYPE, FLAGS) \
+QT_BEGIN_NAMESPACE \
+template <> \
+class QDeclarativeTypeInfo<TYPE > \
+{ \
+public: \
+ enum { \
+ hasAttachedProperties = (((FLAGS) & QML_HAS_ATTACHED_PROPERTIES) == QML_HAS_ATTACHED_PROPERTIES) \
+ }; \
+}; \
+QT_END_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+#define QML_REGISTER_INTERFACE(INTERFACE) \
+ qmlRegisterInterface<INTERFACE>(#INTERFACE)
+
+#define QML_REGISTER_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \
+ qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE)
+
+#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \
+ qmlRegisterType<CLASS>(#URI, VMAJ, VMIN, #TYPE, #CLASS)
+
+#define QML_REGISTER_NOCREATE_TYPE(CLASS) \
+ qmlRegisterType<CLASS>(#CLASS)
+
+class QDeclarativeContext;
+class QDeclarativeEngine;
+Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *);
+Q_DECLARATIVE_EXPORT QDeclarativeContext *qmlContext(const QObject *);
+Q_DECLARATIVE_EXPORT QDeclarativeEngine *qmlEngine(const QObject *);
+Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true);
+
+template<typename T>
+QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)
+{
+ // ### is this threadsafe?
+ static int idx = -1;
+
+ if (idx == -1)
+ idx = QDeclarativeMetaType::attachedPropertiesFuncId(&T::staticMetaObject);
+
+ if (idx == -1 || !obj)
+ return 0;
+
+ return qmlAttachedPropertiesObjectById(idx, obj, create);
+}
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QObject)
+Q_DECLARE_METATYPE(QVariant)
+
+QT_END_HEADER
+
+#endif // QML_H
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
new file mode 100644
index 0000000..5ac5701
--- /dev/null
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -0,0 +1,308 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativebinding_p.h"
+#include "qdeclarativebinding_p_p.h"
+
+#include "qdeclarative.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarativeinfo.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativedeclarativedata_p.h"
+#include "qdeclarativestringconverters_p.h"
+
+#include <qfxperf_p_p.h>
+
+#include <QVariant>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeBindingData::QDeclarativeBindingData()
+: updating(false), enabled(false)
+{
+}
+
+QDeclarativeBindingData::~QDeclarativeBindingData()
+{
+ removeError();
+}
+
+void QDeclarativeBindingData::refresh()
+{
+ if (enabled && !updating && q) {
+ QDeclarativeBinding *b = static_cast<QDeclarativeBinding *>(QDeclarativeExpressionPrivate::get(q));
+ b->update();
+ }
+}
+
+QDeclarativeBindingPrivate::QDeclarativeBindingPrivate()
+: QDeclarativeExpressionPrivate(new QDeclarativeBindingData)
+{
+}
+
+QDeclarativeBinding::QDeclarativeBinding(void *data, QDeclarativeRefCount *rc, QObject *obj, QDeclarativeContext *ctxt, const QString &url, int lineNumber, QObject *parent)
+: QDeclarativeExpression(ctxt, data, rc, obj, url, lineNumber, *new QDeclarativeBindingPrivate)
+{
+ setParent(parent);
+ setNotifyOnValueChanged(true);
+}
+
+QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContext *ctxt, QObject *parent)
+: QDeclarativeExpression(ctxt, str, obj, *new QDeclarativeBindingPrivate)
+{
+ setParent(parent);
+ setNotifyOnValueChanged(true);
+}
+
+QDeclarativeBinding::~QDeclarativeBinding()
+{
+}
+
+void QDeclarativeBinding::setTarget(const QDeclarativeMetaProperty &prop)
+{
+ Q_D(QDeclarativeBinding);
+ d->bindingData()->property = prop;
+
+ update();
+}
+
+QDeclarativeMetaProperty QDeclarativeBinding::property() const
+{
+ Q_D(const QDeclarativeBinding);
+ return d->bindingData()->property;
+}
+
+void QDeclarativeBinding::update(QDeclarativeMetaProperty::WriteFlags flags)
+{
+ Q_D(QDeclarativeBinding);
+
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::BindableValueUpdate> bu;
+#endif
+ QDeclarativeBindingData *data = d->bindingData();
+
+ if (!data->enabled)
+ return;
+
+ data->addref();
+
+ if (!data->updating) {
+ data->updating = true;
+
+ if (data->property.propertyCategory() == QDeclarativeMetaProperty::Bindable) {
+
+ int idx = data->property.coreIndex();
+ Q_ASSERT(idx != -1);
+
+
+ QDeclarativeBinding *t = this;
+ int status = -1;
+ void *a[] = { &t, 0, &status, &flags };
+ QMetaObject::metacall(data->property.object(),
+ QMetaObject::WriteProperty,
+ idx, a);
+
+ } else {
+ bool isUndefined = false;
+ QVariant value = this->value(&isUndefined);
+
+ if (isUndefined && !data->error.isValid() && data->property.isResettable()) {
+
+ data->property.reset();
+
+ } else if (isUndefined && !data->error.isValid()) {
+
+ QUrl url = QUrl(data->url);
+ int line = data->line;
+ if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
+
+ data->error.setUrl(url);
+ data->error.setLine(line);
+ data->error.setColumn(-1);
+ data->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + QLatin1String(QMetaType::typeName(data->property.propertyType())));
+
+ } else if (!isUndefined && data->property.object() &&
+ !data->property.write(value, flags)) {
+
+ QUrl url = QUrl(data->url);
+ int line = data->line;
+ if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
+
+ const char *valueType = 0;
+ if (value.userType() == QVariant::Invalid) valueType = "null";
+ else valueType = QMetaType::typeName(value.userType());
+
+ data->error.setUrl(url);
+ data->error.setLine(line);
+ data->error.setColumn(-1);
+ data->error.setDescription(QLatin1String("Unable to assign ") +
+ QLatin1String(valueType) +
+ QLatin1String(" to ") +
+ QLatin1String(QMetaType::typeName(data->property.propertyType())));
+ }
+
+ if (data->error.isValid()) {
+ QDeclarativeEnginePrivate *p = (data->context() && data->context()->engine())?
+ QDeclarativeEnginePrivate::get(data->context()->engine()):0;
+ if (!data->addError(p))
+ qWarning().nospace() << qPrintable(this->error().toString());
+ } else {
+ data->removeError();
+ }
+ }
+
+ data->updating = false;
+ } else {
+ qmlInfo(data->property.object()) << tr("Binding loop detected for property \"%1\"").arg(data->property.name());
+ }
+
+ data->release();
+}
+
+void QDeclarativeBindingPrivate::emitValueChanged()
+{
+ Q_Q(QDeclarativeBinding);
+ q->update();
+}
+
+void QDeclarativeBinding::setEnabled(bool e, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ Q_D(QDeclarativeBinding);
+ d->bindingData()->enabled = e;
+ setNotifyOnValueChanged(e);
+
+ QDeclarativeAbstractBinding::setEnabled(e, flags);
+
+ if (e) {
+ addToObject(d->bindingData()->property.object());
+ update(flags);
+ } else {
+ removeFromObject();
+ }
+}
+
+int QDeclarativeBinding::propertyIndex()
+{
+ Q_D(QDeclarativeBinding);
+ return d->bindingData()->property.coreIndex();
+}
+
+bool QDeclarativeBinding::enabled() const
+{
+ Q_D(const QDeclarativeBinding);
+
+ return d->bindingData()->enabled;
+}
+
+QString QDeclarativeBinding::expression() const
+{
+ return QDeclarativeExpression::expression();
+}
+
+QDeclarativeAbstractBinding::QDeclarativeAbstractBinding()
+: m_object(0), m_mePtr(0), m_prevBinding(0), m_nextBinding(0)
+{
+}
+
+QDeclarativeAbstractBinding::~QDeclarativeAbstractBinding()
+{
+ removeFromObject();
+ if (m_mePtr)
+ *m_mePtr = 0;
+}
+
+void QDeclarativeAbstractBinding::destroy()
+{
+ delete this;
+}
+
+void QDeclarativeAbstractBinding::addToObject(QObject *object)
+{
+ Q_ASSERT(object);
+
+ removeFromObject();
+
+ Q_ASSERT(!m_prevBinding);
+
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object, true);
+ m_nextBinding = data->bindings;
+ if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding;
+ m_prevBinding = &data->bindings;
+ data->bindings = this;
+ m_object = object;
+
+ data->setBindingBit(m_object, propertyIndex());
+}
+
+void QDeclarativeAbstractBinding::removeFromObject()
+{
+ if (m_prevBinding) {
+ Q_ASSERT(m_object);
+
+ *m_prevBinding = m_nextBinding;
+ if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding;
+ m_prevBinding = 0;
+ m_nextBinding = 0;
+
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(m_object, false);
+ if (data) data->clearBindingBit(propertyIndex());
+ m_object = 0;
+ }
+}
+
+void QDeclarativeAbstractBinding::clear()
+{
+ if (m_mePtr)
+ *m_mePtr = 0;
+}
+
+QString QDeclarativeAbstractBinding::expression() const
+{
+ return QLatin1String("<Unknown>");
+}
+
+void QDeclarativeAbstractBinding::setEnabled(bool e, QDeclarativeMetaProperty::WriteFlags)
+{
+ if (e) m_mePtr = 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h
new file mode 100644
index 0000000..432bf22
--- /dev/null
+++ b/src/declarative/qml/qdeclarativebinding_p.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEBINDING_P_H
+#define QDECLARATIVEBINDING_P_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 "qdeclarative.h"
+#include "qdeclarativepropertyvaluesource.h"
+#include "qdeclarativeexpression.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QMetaProperty>
+
+QT_BEGIN_NAMESPACE
+
+class Q_AUTOTEST_EXPORT QDeclarativeAbstractBinding
+{
+public:
+ QDeclarativeAbstractBinding();
+ virtual ~QDeclarativeAbstractBinding();
+
+ virtual void destroy();
+
+ virtual QString expression() const;
+
+ void setEnabled(bool e) { setEnabled(e, QDeclarativeMetaProperty::DontRemoveBinding); }
+ virtual void setEnabled(bool, QDeclarativeMetaProperty::WriteFlags) = 0;
+ virtual int propertyIndex() = 0;
+
+ void update() { update(QDeclarativeMetaProperty::DontRemoveBinding); }
+ virtual void update(QDeclarativeMetaProperty::WriteFlags) = 0;
+
+ void addToObject(QObject *);
+ void removeFromObject();
+
+protected:
+ void clear();
+
+private:
+ friend class QDeclarativeDeclarativeData;
+ friend class QDeclarativeMetaProperty;
+ friend class QDeclarativeMetaPropertyPrivate;
+ friend class QDeclarativeVME;
+
+ QObject *m_object;
+ QDeclarativeAbstractBinding **m_mePtr;
+ QDeclarativeAbstractBinding **m_prevBinding;
+ QDeclarativeAbstractBinding *m_nextBinding;
+};
+
+class QDeclarativeContext;
+class QDeclarativeBindingPrivate;
+class Q_AUTOTEST_EXPORT QDeclarativeBinding : public QDeclarativeExpression, public QDeclarativeAbstractBinding
+{
+Q_OBJECT
+public:
+ QDeclarativeBinding(const QString &, QObject *, QDeclarativeContext *, QObject *parent=0);
+ QDeclarativeBinding(void *, QDeclarativeRefCount *, QObject *, QDeclarativeContext *, const QString &, int,
+ QObject *parent);
+ ~QDeclarativeBinding();
+
+ void setTarget(const QDeclarativeMetaProperty &);
+ QDeclarativeMetaProperty property() const;
+
+ bool enabled() const;
+
+ // Inherited from QDeclarativeAbstractBinding
+ virtual void setEnabled(bool, QDeclarativeMetaProperty::WriteFlags flags);
+ virtual int propertyIndex();
+ virtual void update(QDeclarativeMetaProperty::WriteFlags flags);
+ virtual QString expression() const;
+
+public Q_SLOTS:
+ void update() { update(QDeclarativeMetaProperty::DontRemoveBinding); }
+
+protected:
+ void emitValueChanged();
+
+private:
+ Q_DECLARE_PRIVATE(QDeclarativeBinding)
+};
+Q_DECLARE_METATYPE(QDeclarativeBinding*);
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEBINDING_P_H
diff --git a/src/declarative/qml/qdeclarativebinding_p_p.h b/src/declarative/qml/qdeclarativebinding_p_p.h
new file mode 100644
index 0000000..ac88400
--- /dev/null
+++ b/src/declarative/qml/qdeclarativebinding_p_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEBINDING_P_P_H
+#define QDECLARATIVEBINDING_P_P_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 "qdeclarativebinding_p.h"
+
+#include "qdeclarativemetaproperty.h"
+#include "qdeclarativeexpression_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeBindingData : public QDeclarativeExpressionData
+{
+public:
+ QDeclarativeBindingData();
+ virtual ~QDeclarativeBindingData();
+
+ bool updating:1;
+ bool enabled:1;
+
+ QDeclarativeMetaProperty property;
+
+ virtual void refresh();
+};
+
+class QDeclarativeBindingPrivate : public QDeclarativeExpressionPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeBinding)
+public:
+ QDeclarativeBindingPrivate();
+
+ QDeclarativeBindingData *bindingData() { return static_cast<QDeclarativeBindingData *>(data); }
+ const QDeclarativeBindingData *bindingData() const { return static_cast<const QDeclarativeBindingData *>(data); }
+
+ virtual void emitValueChanged();
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEBINDING_P_P_H
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
new file mode 100644
index 0000000..c47df32
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeboundsignal.cpp
@@ -0,0 +1,263 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeboundsignal_p.h"
+
+#include "qmetaobjectbuilder_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativeexpression_p.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativemetatype.h"
+#include "qdeclarative.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarativeglobal_p.h"
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeBoundSignalParameters : public QObject
+{
+Q_OBJECT
+public:
+ QDeclarativeBoundSignalParameters(const QMetaMethod &, QObject * = 0);
+ ~QDeclarativeBoundSignalParameters();
+
+ void setValues(void **);
+ void clearValues();
+
+private:
+ friend class MetaObject;
+ int metaCall(QMetaObject::Call, int _id, void **);
+ struct MetaObject : public QAbstractDynamicMetaObject {
+ MetaObject(QDeclarativeBoundSignalParameters *b)
+ : parent(b) {}
+
+ int metaCall(QMetaObject::Call c, int id, void **a) {
+ return parent->metaCall(c, id, a);
+ }
+ QDeclarativeBoundSignalParameters *parent;
+ };
+
+ int *types;
+ void **values;
+ QMetaObject *myMetaObject;
+};
+
+static int evaluateIdx = -1;
+
+QDeclarativeAbstractBoundSignal::QDeclarativeAbstractBoundSignal(QObject *parent)
+: QObject(parent)
+{
+}
+
+QDeclarativeAbstractBoundSignal::~QDeclarativeAbstractBoundSignal()
+{
+}
+
+QDeclarativeBoundSignal::QDeclarativeBoundSignal(QObject *scope, const QMetaMethod &signal,
+ QObject *parent)
+: m_expression(0), m_signal(signal), m_paramsValid(false), m_params(0)
+{
+ // A cached evaluation of the QDeclarativeExpression::value() slot index.
+ //
+ // This is thread safe. Although it may be updated by two threads, they
+ // will both set it to the same value - so the worst thing that can happen
+ // is that they both do the work to figure it out. Boo hoo.
+ if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
+
+ QDeclarativeGraphics_setParent_noEvent(this, parent);
+ QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
+}
+
+QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, const QString &val,
+ QObject *scope, const QMetaMethod &signal,
+ QObject *parent)
+: m_expression(0), m_signal(signal), m_paramsValid(false), m_params(0)
+{
+ // A cached evaluation of the QDeclarativeExpression::value() slot index.
+ //
+ // This is thread safe. Although it may be updated by two threads, they
+ // will both set it to the same value - so the worst thing that can happen
+ // is that they both do the work to figure it out. Boo hoo.
+ if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
+
+ QDeclarativeGraphics_setParent_noEvent(this, parent);
+ QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
+
+ m_expression = new QDeclarativeExpression(ctxt, val, scope);
+}
+
+QDeclarativeBoundSignal::~QDeclarativeBoundSignal()
+{
+ delete m_expression;
+ m_expression = 0;
+}
+
+int QDeclarativeBoundSignal::index() const
+{
+ return m_signal.methodIndex();
+}
+
+/*!
+ Returns the signal expression.
+*/
+QDeclarativeExpression *QDeclarativeBoundSignal::expression() const
+{
+ return m_expression;
+}
+
+/*!
+ Sets the signal expression to \a e. Returns the current signal expression,
+ or null if there is no signal expression.
+
+ The QDeclarativeBoundSignal instance takes ownership of \a e. The caller is
+ assumes ownership of the returned QDeclarativeExpression.
+*/
+QDeclarativeExpression *QDeclarativeBoundSignal::setExpression(QDeclarativeExpression *e)
+{
+ QDeclarativeExpression *rv = m_expression;
+ m_expression = e;
+ if (m_expression) m_expression->setNotifyOnValueChanged(false);
+ return rv;
+}
+
+QDeclarativeBoundSignal *QDeclarativeBoundSignal::cast(QObject *o)
+{
+ QDeclarativeAbstractBoundSignal *s = qobject_cast<QDeclarativeAbstractBoundSignal*>(o);
+ return static_cast<QDeclarativeBoundSignal *>(s);
+}
+
+int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
+{
+ if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) {
+ if (!m_paramsValid) {
+ if (!m_signal.parameterTypes().isEmpty())
+ m_params = new QDeclarativeBoundSignalParameters(m_signal, this);
+ m_paramsValid = true;
+ }
+
+ if (m_params) m_params->setValues(a);
+ if (m_expression) {
+ QDeclarativeExpressionPrivate::get(m_expression)->value(m_params);
+ if (m_expression && m_expression->hasError())
+ qWarning().nospace() << qPrintable(m_expression->error().toString());
+ }
+ if (m_params) m_params->clearValues();
+ return -1;
+ } else {
+ return QObject::qt_metacall(c, id, a);
+ }
+}
+
+QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMetaMethod &method,
+ QObject *parent)
+: QObject(parent), types(0), values(0)
+{
+ MetaObject *mo = new MetaObject(this);
+
+ // ### Optimize!
+ // ### Ensure only supported types are allowed, otherwise it might crash
+ QMetaObjectBuilder mob;
+ mob.setSuperClass(&QDeclarativeBoundSignalParameters::staticMetaObject);
+ mob.setClassName("QDeclarativeBoundSignalParameters");
+
+ QList<QByteArray> paramTypes = method.parameterTypes();
+ QList<QByteArray> paramNames = method.parameterNames();
+ types = new int[paramTypes.count()];
+ for (int ii = 0; ii < paramTypes.count(); ++ii) {
+ const QByteArray &type = paramTypes.at(ii);
+ const QByteArray &name = paramNames.at(ii);
+
+ if (name.isEmpty() || type.isEmpty()) {
+ types[ii] = 0;
+ continue;
+ }
+
+ QVariant::Type t = (QVariant::Type)QMetaType::type(type.constData());
+ if (QDeclarativeMetaType::isQObject(t)) {
+ types[ii] = QMetaType::QObjectStar;
+ QMetaPropertyBuilder prop = mob.addProperty(name, "QObject*");
+ prop.setWritable(false);
+ } else {
+ types[ii] = t;
+ QMetaPropertyBuilder prop = mob.addProperty(name, type);
+ prop.setWritable(false);
+ }
+ }
+ myMetaObject = mob.toMetaObject();
+ *static_cast<QMetaObject *>(mo) = *myMetaObject;
+
+ d_ptr->metaObject = mo;
+}
+
+QDeclarativeBoundSignalParameters::~QDeclarativeBoundSignalParameters()
+{
+ delete [] types;
+ qFree(myMetaObject);
+}
+
+void QDeclarativeBoundSignalParameters::setValues(void **v)
+{
+ values = v;
+}
+
+void QDeclarativeBoundSignalParameters::clearValues()
+{
+ values = 0;
+}
+
+int QDeclarativeBoundSignalParameters::metaCall(QMetaObject::Call c, int id, void **a)
+{
+ if (!values)
+ return -1;
+
+ if (c == QMetaObject::ReadProperty && id >= 1) {
+ QDeclarativeMetaType::copy(types[id - 1], a[0], values[id]);
+ return -1;
+ } else {
+ return qt_metacall(c, id, a);
+ }
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativeboundsignal.moc>
diff --git a/src/declarative/qml/qdeclarativeboundsignal_p.h b/src/declarative/qml/qdeclarativeboundsignal_p.h
new file mode 100644
index 0000000..bba4eec
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeboundsignal_p.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEBOUNDSIGNAL_P_H
+#define QDECLARATIVEBOUNDSIGNAL_P_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 "qdeclarativeexpression.h"
+
+#include <QtCore/qmetaobject.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeAbstractBoundSignal : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeAbstractBoundSignal(QObject *parent = 0);
+ virtual ~QDeclarativeAbstractBoundSignal() = 0;
+};
+
+class QDeclarativeBoundSignalParameters;
+class QDeclarativeBoundSignal : public QDeclarativeAbstractBoundSignal
+{
+public:
+ QDeclarativeBoundSignal(QObject *scope, const QMetaMethod &signal, QObject *parent);
+ QDeclarativeBoundSignal(QDeclarativeContext *ctxt, const QString &val, QObject *scope,
+ const QMetaMethod &signal, QObject *parent);
+ virtual ~QDeclarativeBoundSignal();
+
+ int index() const;
+
+ QDeclarativeExpression *expression() const;
+ QDeclarativeExpression *setExpression(QDeclarativeExpression *);
+
+ static QDeclarativeBoundSignal *cast(QObject *);
+
+protected:
+ virtual int qt_metacall(QMetaObject::Call c, int id, void **a);
+
+private:
+ QDeclarativeExpression *m_expression;
+ QMetaMethod m_signal;
+ bool m_paramsValid;
+ QDeclarativeBoundSignalParameters *m_params;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEBOUNDSIGNAL_P_H
diff --git a/src/declarative/qml/qdeclarativeclassfactory.cpp b/src/declarative/qml/qdeclarativeclassfactory.cpp
new file mode 100644
index 0000000..ae4975c
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeclassfactory.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeclassfactory_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeClassFactory::~QDeclarativeClassFactory()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeclassfactory_p.h b/src/declarative/qml/qdeclarativeclassfactory_p.h
new file mode 100644
index 0000000..9f4a3de
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeclassfactory_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECLASSFACTORY_P_H
+#define QDECLARATIVECLASSFACTORY_P_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>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QByteArray;
+class QUrl;
+class QDeclarativeComponent;
+
+class QDeclarativeClassFactory
+{
+public:
+ virtual ~QDeclarativeClassFactory();
+ virtual QDeclarativeComponent *create(const QByteArray &, const QUrl& baseUrl, QDeclarativeEngine*) = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVECLASSFACTORY_P_H
diff --git a/src/declarative/qml/qdeclarativecleanup.cpp b/src/declarative/qml/qdeclarativecleanup.cpp
new file mode 100644
index 0000000..0fa49d1
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecleanup.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecleanup_p.h"
+
+#include "qdeclarativeengine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+\internal
+\class QDeclarativeCleanup
+\brief The QDeclarativeCleanup provides a callback when a QDeclarativeEngine is deleted.
+
+Any object that needs cleanup to occur before the QDeclarativeEngine's QScriptEngine is
+destroyed should inherit from QDeclarativeCleanup. The clear() virtual method will be
+called by QDeclarativeEngine just before it deletes the QScriptEngine.
+*/
+
+/*!
+\internal
+
+Create a QDeclarativeCleanup for \a engine
+*/
+QDeclarativeCleanup::QDeclarativeCleanup(QDeclarativeEngine *engine)
+: prev(0), next(0)
+{
+ if (!engine)
+ return;
+
+ QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
+
+ if (p->cleanup) next = p->cleanup;
+ p->cleanup = this;
+ prev = &p->cleanup;
+ if (next) next->prev = &next;
+}
+
+/*!
+\internal
+*/
+QDeclarativeCleanup::~QDeclarativeCleanup()
+{
+ if (prev) *prev = next;
+ if (next) next->prev = prev;
+ prev = 0;
+ next = 0;
+}
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecleanup_p.h b/src/declarative/qml/qdeclarativecleanup_p.h
new file mode 100644
index 0000000..e9b6b45
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecleanup_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECLEANUP_P_H
+#define QDECLARATIVECLEANUP_P_H
+
+#include <QtCore/qglobal.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.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QDeclarativeCleanup
+{
+public:
+ QDeclarativeCleanup(QDeclarativeEngine *);
+ virtual ~QDeclarativeCleanup();
+
+protected:
+ virtual void clear() = 0;
+
+private:
+ friend class QDeclarativeEnginePrivate;
+ QDeclarativeCleanup **prev;
+ QDeclarativeCleanup *next;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVECLEANUP_P_H
+
diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp
new file mode 100644
index 0000000..face22c
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp
@@ -0,0 +1,2738 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// #define COMPILEDBINDINGS_DEBUG
+
+#include "qdeclarativecompiledbindings_p.h"
+
+#include <QtDeclarative/qdeclarativeinfo.h>
+#include <private/qdeclarativecontext_p.h>
+#include <private/qdeclarativejsast_p.h>
+#include <private/qdeclarativejsengine_p.h>
+#include <private/qdeclarativeexpression_p.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qnumeric.h>
+#include <private/qdeclarativeanchors_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QDeclarativeJS;
+
+namespace {
+// Supported types: int, qreal, QString (needs constr/destr), QObject*, bool
+struct Register {
+ void setUndefined() { type = 0; }
+ void setUnknownButDefined() { type = -1; }
+ void setNaN() { setqreal(qSNaN()); }
+ bool isUndefined() const { return type == 0; }
+
+ void setQObject(QObject *o) { *((QObject **)data) = o; type = QMetaType::QObjectStar; }
+ QObject *getQObject() const { return *((QObject **)data); }
+
+ void setqreal(qreal v) { *((qreal *)data) = v; type = QMetaType::QReal; }
+ qreal getqreal() const { return *((qreal *)data); }
+
+ void setint(int v) { *((int *)data) = v; type = QMetaType::Int; }
+ int getint() const { return *((int *)data); }
+
+ void setbool(bool v) { *((bool *)data) = v; type = QMetaType::Bool; }
+ bool getbool() const { return *((bool *)data); }
+
+ QVariant *getvariantptr() { return (QVariant *)typeDataPtr(); }
+ QString *getstringptr() { return (QString *)typeDataPtr(); }
+ QUrl *geturlptr() { return (QUrl *)typeDataPtr(); }
+ const QVariant *getvariantptr() const { return (QVariant *)typeDataPtr(); }
+ const QString *getstringptr() const { return (QString *)typeDataPtr(); }
+ const QUrl *geturlptr() const { return (QUrl *)typeDataPtr(); }
+
+ void *typeDataPtr() { return (void *)&data; }
+ void *typeMemory() { return (void *)data; }
+ const void *typeDataPtr() const { return (void *)&data; }
+ const void *typeMemory() const { return (void *)data; }
+
+ int gettype() const { return type; }
+ void settype(int t) { type = t; }
+
+ int type; // Optional type
+ void *data[2]; // Object stored here
+};
+}
+
+class QDeclarativeCompiledBindingsPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeCompiledBindings)
+
+public:
+ QDeclarativeCompiledBindingsPrivate();
+ virtual ~QDeclarativeCompiledBindingsPrivate();
+
+ struct Binding : public QDeclarativeAbstractBinding, public QDeclarativeDelayedError {
+ Binding() : enabled(false), updating(0), property(0),
+ scope(0), target(0), parent(0) {}
+
+ // Inherited from QDeclarativeAbstractBinding
+ virtual void setEnabled(bool, QDeclarativeMetaProperty::WriteFlags flags);
+ virtual int propertyIndex();
+ virtual void update(QDeclarativeMetaProperty::WriteFlags flags);
+ virtual void destroy();
+
+ int index:30;
+ bool enabled:1;
+ bool updating:1;
+ int property;
+ QObject *scope;
+ QObject *target;
+
+ QDeclarativeCompiledBindingsPrivate *parent;
+ };
+
+ struct Subscription {
+ struct Signal {
+ QDeclarativeGuard<QObject> source;
+ int notifyIndex;
+ };
+
+ enum { InvalidType, SignalType, IdType } type;
+ inline Subscription();
+ inline ~Subscription();
+ bool isSignal() const { return type == SignalType; }
+ bool isId() const { return type == IdType; }
+ inline Signal *signal();
+ inline QDeclarativeContextPrivate::IdNotifier *id();
+ union {
+ char signalData[sizeof(Signal)];
+ char idData[sizeof(QDeclarativeContextPrivate::IdNotifier)];
+ };
+ };
+ Subscription *subscriptions;
+ QScriptDeclarativeClass::PersistentIdentifier *identifiers;
+
+ void run(Binding *);
+
+ const char *programData;
+ Binding *m_bindings;
+ quint32 *m_signalTable;
+
+ static int methodCount;
+
+ void init();
+ void run(int instr, QDeclarativeContextPrivate *context,
+ QDeclarativeDelayedError *error, QObject *scope, QObject *output);
+
+
+ inline void unsubscribe(int subIndex);
+ inline void subscribeId(QDeclarativeContextPrivate *p, int idIndex, int subIndex);
+ inline void subscribe(QObject *o, int notifyIndex, int subIndex);
+
+ QDeclarativePropertyCache::Data *findproperty(QObject *obj,
+ const QScriptDeclarativeClass::Identifier &name,
+ QDeclarativeEnginePrivate *enginePriv,
+ QDeclarativePropertyCache::Data &local);
+ bool findproperty(QObject *obj,
+ Register *output,
+ QDeclarativeEnginePrivate *enginePriv,
+ int subIdx,
+ const QScriptDeclarativeClass::Identifier &name,
+ bool isTerminal);
+ void findgeneric(Register *output, // value output
+ int subIdx, // Subscription index in config
+ QDeclarativeContextPrivate *context, // Context to search in
+ const QScriptDeclarativeClass::Identifier &name,
+ bool isTerminal);
+};
+
+QDeclarativeCompiledBindingsPrivate::QDeclarativeCompiledBindingsPrivate()
+: subscriptions(0), identifiers(0)
+{
+}
+
+QDeclarativeCompiledBindingsPrivate::~QDeclarativeCompiledBindingsPrivate()
+{
+ delete [] subscriptions; subscriptions = 0;
+ delete [] identifiers; identifiers = 0;
+}
+
+QDeclarativeCompiledBindingsPrivate::Subscription::Subscription()
+: type(InvalidType)
+{
+}
+
+QDeclarativeCompiledBindingsPrivate::Subscription::~Subscription()
+{
+ if (type == SignalType) ((Signal *)signalData)->~Signal();
+ else if (type == IdType) ((QDeclarativeContextPrivate::IdNotifier *)idData)->~IdNotifier();
+}
+
+
+int QDeclarativeCompiledBindingsPrivate::methodCount = -1;
+
+QDeclarativeCompiledBindings::QDeclarativeCompiledBindings(const char *program, QDeclarativeContext *context)
+: QObject(*(new QDeclarativeCompiledBindingsPrivate))
+{
+ Q_D(QDeclarativeCompiledBindings);
+
+ if (d->methodCount == -1)
+ d->methodCount = QDeclarativeCompiledBindings::staticMetaObject.methodCount();
+
+ d->programData = program;
+
+ d->init();
+
+ QDeclarativeAbstractExpression::setContext(context);
+}
+
+QDeclarativeCompiledBindings::~QDeclarativeCompiledBindings()
+{
+ Q_D(QDeclarativeCompiledBindings);
+
+ delete [] d->m_bindings;
+}
+
+QDeclarativeAbstractBinding *QDeclarativeCompiledBindings::configBinding(int index, QObject *target,
+ QObject *scope, int property)
+{
+ Q_D(QDeclarativeCompiledBindings);
+
+ QDeclarativeCompiledBindingsPrivate::Binding *rv = d->m_bindings + index;
+
+ rv->index = index;
+ rv->property = property;
+ rv->target = target;
+ rv->scope = scope;
+ rv->parent = d;
+
+ addref(); // This is decremented in Binding::destroy()
+
+ return rv;
+}
+
+void QDeclarativeCompiledBindingsPrivate::Binding::setEnabled(bool e, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ if (e) {
+ addToObject(target);
+ update(flags);
+ } else {
+ removeFromObject();
+ }
+
+ QDeclarativeAbstractBinding::setEnabled(e, flags);
+
+ if (enabled != e) {
+ enabled = e;
+
+ if (e) update(flags);
+ }
+}
+
+int QDeclarativeCompiledBindingsPrivate::Binding::propertyIndex()
+{
+ return property & 0xFFFF;
+}
+
+void QDeclarativeCompiledBindingsPrivate::Binding::update(QDeclarativeMetaProperty::WriteFlags)
+{
+ parent->run(this);
+}
+
+void QDeclarativeCompiledBindingsPrivate::Binding::destroy()
+{
+ enabled = false;
+ removeFromObject();
+ parent->q_func()->release();
+ clear();
+}
+
+int QDeclarativeCompiledBindings::qt_metacall(QMetaObject::Call c, int id, void **)
+{
+ Q_D(QDeclarativeCompiledBindings);
+
+ if (c == QMetaObject::InvokeMetaMethod && id >= d->methodCount) {
+ id -= d->methodCount;
+
+ quint32 *reeval = d->m_signalTable + d->m_signalTable[id];
+ quint32 count = *reeval;
+ ++reeval;
+ for (quint32 ii = 0; ii < count; ++ii) {
+ d->run(d->m_bindings + reeval[ii]);
+ }
+ }
+ return -1;
+}
+
+void QDeclarativeCompiledBindingsPrivate::run(Binding *binding)
+{
+ Q_Q(QDeclarativeCompiledBindings);
+
+ if (!binding->enabled)
+ return;
+ if (binding->updating)
+ qWarning("ERROR: Circular binding");
+
+ QDeclarativeContext *context = q->QDeclarativeAbstractExpression::context();
+ if (!context) {
+ qWarning("QDeclarativeCompiledBindings: Attempted to evaluate an expression in an invalid context");
+ return;
+ }
+ QDeclarativeContextPrivate *cp = QDeclarativeContextPrivate::get(context);
+
+ if (binding->property & 0xFFFF0000) {
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(cp->engine);
+
+ QDeclarativeValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
+ Q_ASSERT(vt);
+ vt->read(binding->target, binding->property & 0xFFFF);
+
+ QObject *target = vt;
+ run(binding->index, cp, binding, binding->scope, target);
+
+ vt->write(binding->target, binding->property & 0xFFFF,
+ QDeclarativeMetaProperty::DontRemoveBinding);
+ } else {
+ run(binding->index, cp, binding, binding->scope, binding->target);
+ }
+}
+
+QDeclarativeCompiledBindingsPrivate::Subscription::Signal *QDeclarativeCompiledBindingsPrivate::Subscription::signal()
+{
+ if (type == IdType) ((QDeclarativeContextPrivate::IdNotifier *)idData)->~IdNotifier();
+ if (type != SignalType) new (signalData) Signal;
+ type = SignalType;
+ return (Signal *)signalData;
+}
+
+QDeclarativeContextPrivate::IdNotifier *QDeclarativeCompiledBindingsPrivate::Subscription::id()
+{
+ if (type == SignalType) ((Signal *)signalData)->~Signal();
+ if (type != IdType) new (idData) QDeclarativeContextPrivate::IdNotifier;
+ type = IdType;
+ return (QDeclarativeContextPrivate::IdNotifier *)idData;
+}
+
+namespace {
+// This structure is exactly 8-bytes in size
+struct Instr {
+ enum {
+ Noop,
+
+ Subscribe, // subscribe
+ SubscribeId, // subscribe
+
+ LoadId, // load
+ LoadScope, // load
+ LoadRoot, // load
+ LoadAttached, // attached
+
+ ConvertIntToReal, // unaryop
+ ConvertRealToInt, // unaryop
+
+ Real, // real_value
+ Int, // int_value
+ Bool, // bool_value
+ String, // string_value
+
+ AddReal, // binaryop
+ AddInt, // binaryop
+ AddString, // binaryop
+
+ MinusReal, // binaryop
+ MinusInt, // binaryop
+
+ CompareReal, // binaryop
+ CompareString, // binaryop
+
+ NotCompareReal, // binaryop
+ NotCompareString, // binaryop
+
+ GreaterThanReal, // binaryop
+ MaxReal, // binaryop
+ MinReal, // binaryop
+
+ NewString, // construct
+ NewUrl, // construct
+
+ CleanupUrl, // cleanup
+ CleanupString, // cleanup
+
+ Copy, // copy
+ Fetch, // fetch
+ Store, // store
+
+ Skip, // skip
+
+ Done,
+
+ // Speculative property resolution
+ InitString, // initstring
+ FindGeneric, // find
+ FindGenericTerminal, // find
+ FindProperty, // find
+ FindPropertyTerminal, // find
+ CleanupGeneric, // cleanup
+ ConvertGenericToReal, // unaryop
+ ConvertGenericToBool, // unaryop
+ ConvertGenericToString, // unaryop
+ ConvertGenericToUrl, // unaryop
+ };
+
+ union {
+ struct {
+ quint8 type;
+ quint8 packing[7];
+ } common;
+ struct {
+ quint8 type;
+ quint8 packing[3];
+ quint16 subscriptions;
+ quint16 identifiers;
+ } init;
+ struct {
+ quint8 type;
+ qint8 reg;
+ quint16 offset;
+ quint32 index;
+ } subscribe;
+ struct {
+ quint8 type;
+ qint8 reg;
+ quint8 packing[2];
+ quint32 index;
+ } load;
+ struct {
+ quint8 type;
+ qint8 output;
+ qint8 reg;
+ quint8 exceptionId;
+ quint32 index;
+ } attached;
+ struct {
+ quint8 type;
+ qint8 output;
+ qint8 reg;
+ quint8 exceptionId;
+ quint32 index;
+ } store;
+ struct {
+ quint8 type;
+ qint8 output;
+ qint8 objectReg;
+ quint8 exceptionId;
+ quint32 index;
+ } fetch;
+ struct {
+ quint8 type;
+ qint8 reg;
+ qint8 src;
+ quint8 packing[5];
+ } copy;
+ struct {
+ quint8 type;
+ qint8 reg;
+ quint8 packing[6];
+ } construct;
+ struct {
+ quint8 type;
+ qint8 reg;
+ quint8 packing[2];
+ float value;
+ } real_value;
+ struct {
+ quint8 type;
+ qint8 reg;
+ quint8 packing[2];
+ int value;
+ } int_value;
+ struct {
+ quint8 type;
+ qint8 reg;
+ bool value;
+ quint8 packing[5];
+ } bool_value;
+ struct {
+ quint8 type;
+ qint8 reg;
+ quint16 length;
+ quint32 offset;
+ } string_value;
+ struct {
+ quint8 type;
+ qint8 output;
+ qint8 src1;
+ qint8 src2;
+ quint8 packing[4];
+ } binaryop;
+ struct {
+ quint8 type;
+ qint8 output;
+ qint8 src;
+ quint8 packing[5];
+ } unaryop;
+ struct {
+ quint8 type;
+ qint8 reg;
+ quint8 packing[2];
+ quint32 count;
+ } skip;
+ struct {
+ quint8 type;
+ qint8 reg;
+ qint8 src;
+ quint8 exceptionId;
+ quint16 name;
+ quint16 subscribeIndex;
+ } find;
+ struct {
+ quint8 type;
+ qint8 reg;
+ quint8 packing[6];
+ } cleanup;
+ struct {
+ quint8 type;
+ quint8 packing[1];
+ quint16 offset;
+ quint32 dataIdx;
+ } initstring;
+ };
+};
+
+struct Program {
+ quint32 bindings;
+ quint32 dataLength;
+ quint32 signalTableOffset;
+ quint32 exceptionDataOffset;
+ quint16 subscriptions;
+ quint16 identifiers;
+ quint16 instructionCount;
+ quint16 dummy;
+
+ const char *data() const { return ((const char *)this) + sizeof(Program); }
+ const Instr *instructions() const { return (const Instr *)(data() + dataLength); }
+};
+}
+
+struct QDeclarativeBindingCompilerPrivate
+{
+ struct Result {
+ Result() : unknownType(false), metaObject(0), type(-1), reg(-1) {}
+ bool operator==(const Result &o) const {
+ return unknownType == o.unknownType &&
+ metaObject == o.metaObject &&
+ type == o.type &&
+ reg == o.reg;
+ }
+ bool operator!=(const Result &o) const {
+ return !(*this == o);
+ }
+ bool unknownType;
+ const QMetaObject *metaObject;
+ int type;
+ int reg;
+
+ QSet<QString> subscriptionSet;
+ };
+
+ QDeclarativeBindingCompilerPrivate() : registers(0) {}
+
+ void resetInstanceState();
+ int commitCompile();
+
+ QDeclarativeParser::Object *context;
+ QDeclarativeParser::Object *component;
+ QDeclarativeParser::Property *destination;
+ QHash<QString, QDeclarativeParser::Object *> ids;
+ QDeclarativeEnginePrivate::Imports imports;
+ QDeclarativeEnginePrivate *engine;
+
+ QString contextName() const { return QLatin1String("$$$SCOPE_") + QString::number((intptr_t)context, 16); }
+
+ bool compile(QDeclarativeJS::AST::Node *);
+
+ bool parseExpression(QDeclarativeJS::AST::Node *, Result &);
+
+ bool tryName(QDeclarativeJS::AST::Node *);
+ bool parseName(QDeclarativeJS::AST::Node *, Result &);
+
+ bool tryArith(QDeclarativeJS::AST::Node *);
+ bool parseArith(QDeclarativeJS::AST::Node *, Result &);
+ bool numberArith(Result &, const Result &, const Result &, QSOperator::Op op);
+ bool stringArith(Result &, const Result &, const Result &, QSOperator::Op op);
+
+ bool tryLogic(QDeclarativeJS::AST::Node *);
+ bool parseLogic(QDeclarativeJS::AST::Node *, Result &);
+
+ bool tryConditional(QDeclarativeJS::AST::Node *);
+ bool parseConditional(QDeclarativeJS::AST::Node *, Result &);
+
+ bool tryConstant(QDeclarativeJS::AST::Node *);
+ bool parseConstant(QDeclarativeJS::AST::Node *, Result &);
+
+ bool tryMethod(QDeclarativeJS::AST::Node *);
+ bool parseMethod(QDeclarativeJS::AST::Node *, Result &);
+
+ bool buildName(QStringList &, QDeclarativeJS::AST::Node *, QList<QDeclarativeJS::AST::ExpressionNode *> *nodes = 0);
+ bool fetch(Result &type, const QMetaObject *, int reg, int idx, const QStringList &, QDeclarativeJS::AST::ExpressionNode *);
+
+ quint32 registers;
+ QHash<int, QPair<int, int> > registerCleanups;
+ int acquireReg(int cleanup = Instr::Noop, int cleanupType = 0);
+ void registerCleanup(int reg, int cleanup, int cleanupType = 0);
+ void releaseReg(int);
+
+ int registerLiteralString(const QString &);
+ int registerString(const QString &);
+ QHash<QString, QPair<int, int> > registeredStrings;
+ QByteArray data;
+
+ bool subscription(const QStringList &, Result *);
+ int subscriptionIndex(const QStringList &);
+ bool subscriptionNeutral(const QSet<QString> &base, const QSet<QString> &lhs, const QSet<QString> &rhs);
+
+ quint8 exceptionId(QDeclarativeJS::AST::ExpressionNode *);
+ QVector<quint64> exceptions;
+
+ QSet<int> usedSubscriptionIds;
+ QSet<QString> subscriptionSet;
+ QHash<QString, int> subscriptionIds;
+ QVector<Instr> bytecode;
+
+ // Committed binding data
+ struct {
+ QList<int> offsets;
+ QList<QSet<int> > dependencies;
+
+ QVector<Instr> bytecode;
+ QByteArray data;
+ QHash<QString, int> subscriptionIds;
+ QVector<quint64> exceptions;
+
+ QHash<QString, QPair<int, int> > registeredStrings;
+
+ int count() const { return offsets.count(); }
+ } committed;
+
+ QByteArray buildSignalTable() const;
+ QByteArray buildExceptionData() const;
+};
+
+void QDeclarativeCompiledBindingsPrivate::unsubscribe(int subIndex)
+{
+ Q_Q(QDeclarativeCompiledBindings);
+
+ QDeclarativeCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
+ if (sub->isSignal()) {
+ QDeclarativeCompiledBindingsPrivate::Subscription::Signal *s = sub->signal();
+ if (s->source)
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
+ QMetaObject::disconnectOne(s->source, s->notifyIndex,
+ q, methodCount + subIndex);
+#else
+ // QTBUG-6781
+ QMetaObject::disconnect(s->source, s->notifyIndex,
+ q, methodCount + subIndex);
+#endif
+ } else if (sub->isId()) {
+ sub->id()->clear();
+ }
+}
+
+void QDeclarativeCompiledBindingsPrivate::subscribeId(QDeclarativeContextPrivate *p, int idIndex, int subIndex)
+{
+ Q_Q(QDeclarativeCompiledBindings);
+
+ unsubscribe(subIndex);
+
+ if (p->idValues[idIndex]) {
+ QDeclarativeCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
+ QDeclarativeContextPrivate::IdNotifier *i = sub->id();
+
+ i->next = p->idValues[idIndex].bindings;
+ i->prev = &p->idValues[idIndex].bindings;
+ p->idValues[idIndex].bindings = i;
+ if (i->next) i->next->prev = &i->next;
+
+ i->target = q;
+ i->methodIndex = methodCount + subIndex;
+ }
+}
+
+void QDeclarativeCompiledBindingsPrivate::subscribe(QObject *o, int notifyIndex, int subIndex)
+{
+ Q_Q(QDeclarativeCompiledBindings);
+
+ QDeclarativeCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
+
+ if (sub->isId())
+ unsubscribe(subIndex);
+
+ QDeclarativeCompiledBindingsPrivate::Subscription::Signal *s = sub->signal();
+ if (o != s->source || notifyIndex != s->notifyIndex) {
+ if (s->source)
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
+ QMetaObject::disconnectOne(s->source, s->notifyIndex,
+ q, methodCount + subIndex);
+#else
+ // QTBUG-6781
+ QMetaObject::disconnect(s->source, s->notifyIndex,
+ q, methodCount + subIndex);
+#endif
+ s->source = o;
+ s->notifyIndex = notifyIndex;
+ if (s->source && s->notifyIndex != -1)
+ QMetaObject::connect(s->source, s->notifyIndex, q,
+ methodCount + subIndex, Qt::DirectConnection);
+ }
+}
+
+// Conversion functions - these MUST match the QtScript expression path
+inline static qreal toReal(Register *reg, int type, bool *ok = 0)
+{
+ if (ok) *ok = true;
+
+ if (type == QMetaType::QReal) {
+ return reg->getqreal();
+ } else if (type == qMetaTypeId<QVariant>()) {
+ return reg->getvariantptr()->toReal();
+ } else {
+ if (ok) *ok = false;
+ return 0;
+ }
+}
+
+inline static QString toString(Register *reg, int type, bool *ok = 0)
+{
+ if (ok) *ok = true;
+
+ if (type == QMetaType::QReal) {
+ return QString::number(reg->getqreal());
+ } else if (type == QMetaType::Int) {
+ return QString::number(reg->getint());
+ } else if (type == qMetaTypeId<QVariant>()) {
+ return reg->getvariantptr()->toString();
+ } else if (type == QMetaType::QString) {
+ return *reg->getstringptr();
+ } else {
+ if (ok) *ok = false;
+ return QString();
+ }
+}
+
+inline static bool toBool(Register *reg, int type, bool *ok = 0)
+{
+ if (ok) *ok = true;
+
+ if (type == QMetaType::Bool) {
+ return reg->getbool();
+ } else if (type == qMetaTypeId<QVariant>()) {
+ return reg->getvariantptr()->toBool();
+ } else {
+ if (ok) *ok = false;
+ return false;
+ }
+}
+
+inline static QUrl toUrl(Register *reg, int type, QDeclarativeContextPrivate *context, bool *ok = 0)
+{
+ if (ok) *ok = true;
+
+ QUrl base;
+ if (type == qMetaTypeId<QVariant>()) {
+ QVariant *var = reg->getvariantptr();
+ int vt = var->type();
+ if (vt == QVariant::Url) {
+ base = var->toUrl();
+ } else if (vt == QVariant::ByteArray) {
+ base = QUrl(QString::fromUtf8(var->toByteArray()));
+ } else if (vt == QVariant::String) {
+ base = QUrl(var->toString());
+ } else {
+ if (ok) *ok = false;
+ return QUrl();
+ }
+ } else if (type == QMetaType::QString) {
+ base = QUrl(*reg->getstringptr());
+ } else {
+ if (ok) *ok = false;
+ return QUrl();
+ }
+
+ if (!base.isEmpty() && base.isRelative())
+ return context->url.resolved(base);
+ else
+ return base;
+}
+
+static QObject *variantToQObject(const QVariant &value, bool *ok)
+{
+ if (ok) *ok = true;
+
+ if (value.userType() == QMetaType::QObjectStar) {
+ return qvariant_cast<QObject*>(value);
+ } else {
+ if (ok) *ok = false;
+ return 0;
+ }
+}
+
+bool QDeclarativeCompiledBindingsPrivate::findproperty(QObject *obj, Register *output,
+ QDeclarativeEnginePrivate *enginePriv,
+ int subIdx, const QScriptDeclarativeClass::Identifier &name,
+ bool isTerminal)
+{
+ if (!obj) {
+ output->setUndefined();
+ return false;
+ }
+
+ QDeclarativePropertyCache::Data local;
+ QDeclarativePropertyCache::Data *property =
+ QDeclarativePropertyCache::property(QDeclarativeEnginePrivate::get(enginePriv), obj, name, local);
+
+ if (property) {
+ if (subIdx != -1)
+ subscribe(obj, property->notifyIndex, subIdx);
+
+ if (property->flags & QDeclarativePropertyCache::Data::IsQObjectDerived) {
+ void *args[] = { output->typeDataPtr(), 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
+ output->settype(QMetaType::QObjectStar);
+ } else if (property->propType == qMetaTypeId<QVariant>()) {
+ QVariant v;
+ void *args[] = { &v, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
+
+ if (isTerminal) {
+ new (output->typeDataPtr()) QVariant(v);
+ output->settype(qMetaTypeId<QVariant>());
+ } else {
+ bool ok;
+ output->setQObject(variantToQObject(v, &ok));
+ if (!ok)
+ output->setUndefined();
+ else
+ output->settype(QMetaType::QObjectStar);
+ }
+
+ } else {
+ if (!isTerminal) {
+ output->setUndefined();
+ } else if (property->propType == QMetaType::QReal) {
+ void *args[] = { output->typeDataPtr(), 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
+ output->settype(QMetaType::QReal);
+ } else if (property->propType == QMetaType::Int) {
+ void *args[] = { output->typeDataPtr(), 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
+ output->settype(QMetaType::Int);
+ } else if (property->propType == QMetaType::Bool) {
+ void *args[] = { output->typeDataPtr(), 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
+ output->settype(QMetaType::Bool);
+ } else if (property->propType == QMetaType::QString) {
+ new (output->typeDataPtr()) QString();
+ void *args[] = { output->typeDataPtr(), 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
+ output->settype(QMetaType::QString);
+ } else {
+ new (output->typeDataPtr())
+ QVariant(obj->metaObject()->property(property->coreIndex).read(obj));
+ output->settype(qMetaTypeId<QVariant>());
+ }
+ }
+
+ return true;
+ } else {
+ output->setUndefined();
+ return false;
+ }
+}
+
+void QDeclarativeCompiledBindingsPrivate::findgeneric(Register *output,
+ int subIdx,
+ QDeclarativeContextPrivate *context,
+ const QScriptDeclarativeClass::Identifier &name,
+ bool isTerminal)
+{
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(context->engine);
+
+ while (context) {
+
+ int contextPropertyIndex = context->propertyNames?context->propertyNames->value(name):-1;
+
+
+ if (contextPropertyIndex != -1) {
+
+ if (subIdx != -1)
+ subscribe(QDeclarativeContextPrivate::get(context), contextPropertyIndex + context->notifyIndex, subIdx);
+
+ if (contextPropertyIndex < context->idValueCount) {
+ output->setQObject(context->idValues[contextPropertyIndex]);
+ output->settype(QMetaType::QObjectStar);
+ } else {
+ const QVariant &value = context->propertyValues.at(contextPropertyIndex);
+ if (isTerminal) {
+ new (output->typeDataPtr()) QVariant(value);
+ output->settype(qMetaTypeId<QVariant>());
+ } else {
+ bool ok;
+ output->setQObject(variantToQObject(value, &ok));
+ if (!ok) { output->setUndefined(); }
+ else { output->settype(QMetaType::QObjectStar); }
+ return;
+ }
+ }
+
+ return;
+ }
+
+ for (int ii = 0; ii < context->scripts.count(); ++ii) {
+ QScriptValue function = QScriptDeclarativeClass::function(context->scripts.at(ii), name);
+ if (function.isValid()) {
+ qFatal("Binding optimizer resolved name to QScript method");
+ }
+ }
+
+ if (QObject *root = context->defaultObjects.isEmpty()?0:context->defaultObjects.first()) {
+
+ if (findproperty(root, output, enginePriv, subIdx, name, isTerminal))
+ return;
+
+ }
+
+ if (context->parent) {
+ context = QDeclarativeContextPrivate::get(context->parent);
+ } else {
+ context = 0;
+ }
+ }
+
+ output->setUndefined();
+}
+
+void QDeclarativeCompiledBindingsPrivate::init()
+{
+ Program *program = (Program *)programData;
+ if (program->subscriptions)
+ subscriptions = new QDeclarativeCompiledBindingsPrivate::Subscription[program->subscriptions];
+ if (program->identifiers)
+ identifiers = new QScriptDeclarativeClass::PersistentIdentifier[program->identifiers];
+
+ m_signalTable = (quint32 *)(program->data() + program->signalTableOffset);
+ m_bindings = new QDeclarativeCompiledBindingsPrivate::Binding[program->bindings];
+}
+
+static void throwException(int id, QDeclarativeDelayedError *error,
+ Program *program, QDeclarativeContextPrivate *context,
+ const QString &description = QString())
+{
+ error->error.setUrl(context->url);
+ if (description.isEmpty())
+ error->error.setDescription(QLatin1String("TypeError: Result of expression is not an object"));
+ else
+ error->error.setDescription(description);
+ if (id != 0xFF) {
+ quint64 e = *((quint64 *)(program->data() + program->exceptionDataOffset) + id);
+ error->error.setLine((e >> 32) & 0xFFFFFFFF);
+ error->error.setColumn(e & 0xFFFFFFFF);
+ } else {
+ error->error.setLine(-1);
+ error->error.setColumn(-1);
+ }
+ if (!context->engine || !error->addError(QDeclarativeEnginePrivate::get(context->engine)))
+ qWarning() << error->error;
+}
+
+static void dumpInstruction(const Instr *instr)
+{
+ switch (instr->common.type) {
+ case Instr::Noop:
+ qWarning().nospace() << "Noop";
+ break;
+ case Instr::Subscribe:
+ qWarning().nospace() << "Subscribe" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index;
+ break;
+ case Instr::SubscribeId:
+ qWarning().nospace() << "SubscribeId" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index;
+ break;
+ case Instr::LoadId:
+ qWarning().nospace() << "LoadId" << "\t\t\t" << instr->load.index << "\t" << instr->load.reg;
+ break;
+ case Instr::LoadScope:
+ qWarning().nospace() << "LoadScope" << "\t\t" << instr->load.index << "\t" << instr->load.reg;
+ break;
+ case Instr::LoadRoot:
+ qWarning().nospace() << "LoadRoot" << "\t\t" << instr->load.index << "\t" << instr->load.reg;
+ break;
+ case Instr::LoadAttached:
+ qWarning().nospace() << "LoadAttached" << "\t\t" << instr->attached.output << "\t" << instr->attached.reg << "\t" << instr->attached.index;
+ break;
+ case Instr::ConvertIntToReal:
+ qWarning().nospace() << "ConvertIntToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ case Instr::ConvertRealToInt:
+ qWarning().nospace() << "ConvertRealToInt" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ case Instr::Real:
+ qWarning().nospace() << "Real" << "\t\t\t" << instr->real_value.reg << "\t" << instr->real_value.value;
+ break;
+ case Instr::Int:
+ qWarning().nospace() << "Int" << "\t\t\t" << instr->int_value.reg << "\t" << instr->int_value.value;
+ break;
+ case Instr::Bool:
+ qWarning().nospace() << "Bool" << "\t\t\t" << instr->bool_value.reg << "\t" << instr->bool_value.value;
+ break;
+ case Instr::String:
+ qWarning().nospace() << "String" << "\t\t\t" << instr->string_value.reg << "\t" << instr->string_value.offset << "\t" << instr->string_value.length;
+ break;
+ case Instr::AddReal:
+ qWarning().nospace() << "AddReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::AddInt:
+ qWarning().nospace() << "AddInt" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::AddString:
+ qWarning().nospace() << "AddString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::MinusReal:
+ qWarning().nospace() << "MinusReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::MinusInt:
+ qWarning().nospace() << "MinusInt" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::CompareReal:
+ qWarning().nospace() << "CompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::CompareString:
+ qWarning().nospace() << "CompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::NotCompareReal:
+ qWarning().nospace() << "NotCompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::NotCompareString:
+ qWarning().nospace() << "NotCompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::GreaterThanReal:
+ qWarning().nospace() << "GreaterThanReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::MaxReal:
+ qWarning().nospace() << "MaxReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::MinReal:
+ qWarning().nospace() << "MinReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::NewString:
+ qWarning().nospace() << "NewString" << "\t\t" << instr->construct.reg;
+ break;
+ case Instr::NewUrl:
+ qWarning().nospace() << "NewUrl" << "\t\t\t" << instr->construct.reg;
+ break;
+ case Instr::CleanupString:
+ qWarning().nospace() << "CleanupString" << "\t\t" << instr->cleanup.reg;
+ break;
+ case Instr::CleanupUrl:
+ qWarning().nospace() << "CleanupUrl" << "\t\t" << instr->cleanup.reg;
+ break;
+ case Instr::Fetch:
+ qWarning().nospace() << "Fetch" << "\t\t\t" << instr->fetch.output << "\t" << instr->fetch.index << "\t" << instr->fetch.objectReg;
+ break;
+ case Instr::Store:
+ qWarning().nospace() << "Store" << "\t\t\t" << instr->store.output << "\t" << instr->store.index << "\t" << instr->store.reg;
+ break;
+ case Instr::Copy:
+ qWarning().nospace() << "Copy" << "\t\t\t" << instr->copy.reg << "\t" << instr->copy.src;
+ break;
+ case Instr::Skip:
+ qWarning().nospace() << "Skip" << "\t\t\t" << instr->skip.reg << "\t" << instr->skip.count;
+ break;
+ case Instr::Done:
+ qWarning().nospace() << "Done";
+ break;
+ case Instr::InitString:
+ qWarning().nospace() << "InitString" << "\t\t" << instr->initstring.offset << "\t" << instr->initstring.dataIdx;
+ break;
+ case Instr::FindGeneric:
+ qWarning().nospace() << "FindGeneric" << "\t\t" << instr->find.reg << "\t" << instr->find.name;
+ break;
+ case Instr::FindGenericTerminal:
+ qWarning().nospace() << "FindGenericTerminal" << "\t" << instr->find.reg << "\t" << instr->find.name;
+ break;
+ case Instr::FindProperty:
+ qWarning().nospace() << "FindProperty" << "\t\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name;
+ break;
+ case Instr::FindPropertyTerminal:
+ qWarning().nospace() << "FindPropertyTerminal" << "\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name;
+ break;
+ case Instr::CleanupGeneric:
+ qWarning().nospace() << "CleanupGeneric" << "\t\t" << instr->cleanup.reg;
+ break;
+ case Instr::ConvertGenericToReal:
+ qWarning().nospace() << "ConvertGenericToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ case Instr::ConvertGenericToBool:
+ qWarning().nospace() << "ConvertGenericToBool" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ case Instr::ConvertGenericToString:
+ qWarning().nospace() << "ConvertGenericToString" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ case Instr::ConvertGenericToUrl:
+ qWarning().nospace() << "ConvertGenericToUrl" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ default:
+ qWarning().nospace() << "Unknown";
+ break;
+ }
+}
+
+void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
+ QDeclarativeContextPrivate *context, QDeclarativeDelayedError *error,
+ QObject *scope, QObject *output)
+{
+ error->removeError();
+
+ Register registers[32];
+ int storeFlags = 0;
+
+ QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(context->engine);
+ Program *program = (Program *)programData;
+ const Instr *instr = program->instructions();
+ instr += instrIndex;
+ const char *data = program->data();
+
+#ifdef COMPILEDBINDINGS_DEBUG
+ qWarning().nospace() << "Begin binding run";
+#endif
+
+ while (instr) {
+#ifdef COMPILEDBINDINGS_DEBUG
+ dumpInstruction(instr);
+#endif
+
+ switch (instr->common.type) {
+ case Instr::Noop:
+ break;
+
+ case Instr::SubscribeId:
+ subscribeId(context, instr->subscribe.index, instr->subscribe.offset);
+ break;
+
+ case Instr::Subscribe:
+ {
+ QObject *o = 0;
+ const Register &object = registers[instr->subscribe.reg];
+ if (!object.isUndefined()) o = object.getQObject();
+ subscribe(o, instr->subscribe.index, instr->subscribe.offset);
+ }
+ break;
+
+ case Instr::LoadId:
+ registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
+ break;
+
+ case Instr::LoadScope:
+ registers[instr->load.reg].setQObject(scope);
+ break;
+
+ case Instr::LoadRoot:
+ registers[instr->load.reg].setQObject(context->defaultObjects.at(0));
+ break;
+
+ case Instr::LoadAttached:
+ {
+ const Register &input = registers[instr->attached.reg];
+ Register &output = registers[instr->attached.output];
+ if (input.isUndefined()) {
+ throwException(instr->attached.exceptionId, error, program, context);
+ return;
+ }
+
+ QObject *object = registers[instr->attached.reg].getQObject();
+ if (!object) {
+ output.setUndefined();
+ } else {
+ QObject *attached =
+ qmlAttachedPropertiesObjectById(instr->attached.index,
+ registers[instr->attached.reg].getQObject(),
+ true);
+ Q_ASSERT(attached);
+ output.setQObject(attached);
+ }
+ }
+ break;
+
+ case Instr::ConvertIntToReal:
+ {
+ const Register &input = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (input.isUndefined()) output.setUndefined();
+ else output.setqreal(qreal(input.getint()));
+ }
+ break;
+
+ case Instr::ConvertRealToInt:
+ {
+ const Register &input = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (input.isUndefined()) output.setUndefined();
+ else output.setint(int(input.getqreal()));
+ }
+ break;
+
+ case Instr::Real:
+ registers[instr->real_value.reg].setqreal(instr->real_value.value);
+ break;
+
+ case Instr::Int:
+ registers[instr->int_value.reg].setint(instr->int_value.value);
+ break;
+
+ case Instr::Bool:
+ registers[instr->bool_value.reg].setbool(instr->bool_value.value);
+ break;
+
+ case Instr::String:
+ {
+ Register &output = registers[instr->string_value.reg];
+ new (output.getstringptr())
+ QString((QChar *)(data + instr->string_value.offset), instr->string_value.length);
+ output.settype(QMetaType::QString);
+ }
+ break;
+
+ case Instr::AddReal:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
+ else output.setqreal(lhs.getqreal() + rhs.getqreal());
+ }
+ break;
+
+ case Instr::AddInt:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
+ else output.setint(lhs.getint() + rhs.getint());
+ }
+ break;
+
+ case Instr::AddString:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() && rhs.isUndefined()) { output.setNaN(); }
+ else {
+ if (lhs.isUndefined())
+ new (output.getstringptr())
+ QString(QLatin1String("undefined") + *registers[instr->binaryop.src2].getstringptr());
+ else if (rhs.isUndefined())
+ new (output.getstringptr())
+ QString(*registers[instr->binaryop.src1].getstringptr() + QLatin1String("undefined"));
+ else
+ new (output.getstringptr())
+ QString(*registers[instr->binaryop.src1].getstringptr() +
+ *registers[instr->binaryop.src2].getstringptr());
+ output.settype(QMetaType::QString);
+ }
+ }
+ break;
+
+ case Instr::MinusReal:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
+ else output.setqreal(lhs.getqreal() - rhs.getqreal());
+ }
+ break;
+
+ case Instr::MinusInt:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
+ else output.setint(lhs.getint() - rhs.getint());
+ }
+ break;
+
+ case Instr::CompareReal:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
+ else output.setbool(lhs.getqreal() == rhs.getqreal());
+ }
+ break;
+
+ case Instr::CompareString:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
+ else output.setbool(*lhs.getstringptr() == *rhs.getstringptr());
+ }
+ break;
+
+ case Instr::NotCompareReal:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
+ else output.setbool(lhs.getqreal() != rhs.getqreal());
+ }
+ break;
+
+ case Instr::NotCompareString:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
+ else output.setbool(*lhs.getstringptr() != *rhs.getstringptr());
+ }
+ break;
+
+ case Instr::GreaterThanReal:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(false);
+ else output.setbool(lhs.getqreal() > rhs.getqreal());
+ }
+ break;
+
+ case Instr::MaxReal:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
+ else output.setqreal(qMax(lhs.getqreal(), rhs.getqreal()));
+ }
+ break;
+
+ case Instr::MinReal:
+ {
+ const Register &lhs = registers[instr->binaryop.src1];
+ const Register &rhs = registers[instr->binaryop.src2];
+ Register &output = registers[instr->binaryop.output];
+ if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
+ else output.setqreal(qMin(lhs.getqreal(), rhs.getqreal()));
+ }
+ break;
+
+ case Instr::NewString:
+ {
+ Register &output = registers[instr->construct.reg];
+ new (output.getstringptr()) QString;
+ output.settype(QMetaType::QString);
+ }
+ break;
+
+ case Instr::NewUrl:
+ {
+ Register &output = registers[instr->construct.reg];
+ new (output.geturlptr()) QUrl;
+ output.settype(QMetaType::QUrl);
+ }
+ break;
+
+ case Instr::CleanupString:
+ registers[instr->cleanup.reg].getstringptr()->~QString();
+ break;
+
+ case Instr::CleanupUrl:
+ registers[instr->cleanup.reg].geturlptr()->~QUrl();
+ break;
+
+ case Instr::Fetch:
+ {
+ const Register &input = registers[instr->fetch.objectReg];
+ Register &output = registers[instr->fetch.output];
+
+ if (input.isUndefined()) {
+ throwException(instr->fetch.exceptionId, error, program, context);
+ return;
+ }
+
+ QObject *object = input.getQObject();
+ if (!object) {
+ output.setUndefined();
+ } else {
+ void *argv[] = { output.typeDataPtr(), 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv);
+ }
+ }
+ break;
+
+ case Instr::Store:
+ {
+ Register &data = registers[instr->store.reg];
+ if (data.isUndefined()) {
+ throwException(instr->store.exceptionId, error, program, context,
+ QLatin1String("Unable to assign undefined value"));
+ return;
+ }
+
+ int status = -1;
+ void *argv[] = { data.typeDataPtr(), 0, &status, &storeFlags };
+ QMetaObject::metacall(output, QMetaObject::WriteProperty,
+ instr->store.index, argv);
+ }
+ break;
+
+ case Instr::Copy:
+ registers[instr->copy.reg] = registers[instr->copy.src];
+ break;
+
+ case Instr::Skip:
+ if (instr->skip.reg == -1 || !registers[instr->skip.reg].getbool())
+ instr += instr->skip.count;
+ break;
+
+ case Instr::Done:
+ return;
+
+ case Instr::InitString:
+ if (!identifiers[instr->initstring.offset].identifier) {
+ quint32 len = *(quint32 *)(data + instr->initstring.dataIdx);
+ QChar *strdata = (QChar *)(data + instr->initstring.dataIdx + sizeof(quint32));
+
+ QString str = QString::fromRawData(strdata, len);
+
+ identifiers[instr->initstring.offset] = engine->objectClass->createPersistentIdentifier(str);
+ }
+ break;
+
+ case Instr::FindGenericTerminal:
+ case Instr::FindGeneric:
+ // We start the search in the parent context, as we know that the
+ // name is not present in the current context or it would have been
+ // found during the static compile
+ findgeneric(registers + instr->find.reg, instr->find.subscribeIndex,
+ QDeclarativeContextPrivate::get(context->parent),
+ identifiers[instr->find.name].identifier,
+ instr->common.type == Instr::FindGenericTerminal);
+ break;
+
+ case Instr::FindPropertyTerminal:
+ case Instr::FindProperty:
+ {
+ const Register &object = registers[instr->find.src];
+ if (object.isUndefined()) {
+ throwException(instr->find.exceptionId, error, program, context);
+ return;
+ }
+
+ findproperty(object.getQObject(), registers + instr->find.reg,
+ QDeclarativeEnginePrivate::get(context->engine),
+ instr->find.subscribeIndex, identifiers[instr->find.name].identifier,
+ instr->common.type == Instr::FindPropertyTerminal);
+ }
+ break;
+
+ case Instr::CleanupGeneric:
+ {
+ int type = registers[instr->cleanup.reg].gettype();
+ if (type == qMetaTypeId<QVariant>()) {
+ registers[instr->cleanup.reg].getvariantptr()->~QVariant();
+ } else if (type == QMetaType::QString) {
+ registers[instr->cleanup.reg].getstringptr()->~QString();
+ } else if (type == QMetaType::QUrl) {
+ registers[instr->cleanup.reg].geturlptr()->~QUrl();
+ }
+ }
+ break;
+
+ case Instr::ConvertGenericToReal:
+ {
+ Register &output = registers[instr->unaryop.output];
+ Register &input = registers[instr->unaryop.src];
+ bool ok = true;
+ output.setqreal(toReal(&input, input.gettype(), &ok));
+ if (!ok) output.setUndefined();
+ }
+ break;
+
+ case Instr::ConvertGenericToBool:
+ {
+ Register &output = registers[instr->unaryop.output];
+ Register &input = registers[instr->unaryop.src];
+ bool ok = true;
+ output.setbool(toBool(&input, input.gettype(), &ok));
+ if (!ok) output.setUndefined();
+ }
+ break;
+
+ case Instr::ConvertGenericToString:
+ {
+ Register &output = registers[instr->unaryop.output];
+ Register &input = registers[instr->unaryop.src];
+ bool ok = true;
+ QString str = toString(&input, input.gettype(), &ok);
+ if (ok) { new (output.getstringptr()) QString(str); output.settype(QMetaType::QString); }
+ else { output.setUndefined(); }
+ }
+ break;
+
+ case Instr::ConvertGenericToUrl:
+ {
+ Register &output = registers[instr->unaryop.output];
+ Register &input = registers[instr->unaryop.src];
+ bool ok = true;
+ QUrl url = toUrl(&input, input.gettype(), context, &ok);
+ if (ok) { new (output.geturlptr()) QUrl(url); output.settype(QMetaType::QUrl); }
+ else { output.setUndefined(); }
+ }
+ break;
+
+ default:
+ qFatal("EEK");
+ break;
+ }
+
+ instr++;
+ }
+}
+
+void QDeclarativeBindingCompiler::dump(const QByteArray &programData)
+{
+ const Program *program = (const Program *)programData.constData();
+
+ qWarning() << "Program.bindings:" << program->bindings;
+ qWarning() << "Program.dataLength:" << program->dataLength;
+ qWarning() << "Program.subscriptions:" << program->subscriptions;
+ qWarning() << "Program.indentifiers:" << program->identifiers;
+
+ int count = program->instructionCount;
+ const Instr *instr = program->instructions();
+
+ while (count--) {
+
+ dumpInstruction(instr);
+ ++instr;
+ }
+}
+
+/*!
+Clear the state associated with attempting to compile a specific binding.
+This does not clear the global "commited binding" states.
+*/
+void QDeclarativeBindingCompilerPrivate::resetInstanceState()
+{
+ registers = 0;
+ registerCleanups.clear();
+ data = committed.data;
+ exceptions = committed.exceptions;
+ usedSubscriptionIds.clear();
+ subscriptionSet.clear();
+ subscriptionIds = committed.subscriptionIds;
+ registeredStrings = committed.registeredStrings;
+ bytecode.clear();
+}
+
+/*!
+Mark the last compile as successful, and add it to the "committed data"
+section.
+
+Returns the index for the committed binding.
+*/
+int QDeclarativeBindingCompilerPrivate::commitCompile()
+{
+ int rv = committed.count();
+ committed.offsets << committed.bytecode.count();
+ committed.dependencies << usedSubscriptionIds;
+ committed.bytecode << bytecode;
+ committed.data = data;
+ committed.exceptions = exceptions;
+ committed.subscriptionIds = subscriptionIds;
+ committed.registeredStrings = registeredStrings;
+ return rv;
+}
+
+bool QDeclarativeBindingCompilerPrivate::compile(QDeclarativeJS::AST::Node *node)
+{
+ resetInstanceState();
+
+ if (destination->type == -1)
+ return false;
+
+ Result type;
+
+ if (!parseExpression(node, type))
+ return false;
+
+ if (subscriptionSet.count() > 0xFFFF ||
+ registeredStrings.count() > 0xFFFF)
+ return false;
+
+ if (type.unknownType) {
+ if (destination->type != QMetaType::QReal &&
+ destination->type != QVariant::String &&
+ destination->type != QMetaType::Bool &&
+ destination->type != QVariant::Url)
+ return false;
+
+ int convertReg = acquireReg();
+
+ if (destination->type == QMetaType::QReal) {
+ Instr convert;
+ convert.common.type = Instr::ConvertGenericToReal;
+ convert.unaryop.output = convertReg;
+ convert.unaryop.src = type.reg;
+ bytecode << convert;
+ } else if (destination->type == QVariant::String) {
+ Instr convert;
+ convert.common.type = Instr::ConvertGenericToString;
+ convert.unaryop.output = convertReg;
+ convert.unaryop.src = type.reg;
+ bytecode << convert;
+ } else if (destination->type == QMetaType::Bool) {
+ Instr convert;
+ convert.common.type = Instr::ConvertGenericToBool;
+ convert.unaryop.output = convertReg;
+ convert.unaryop.src = type.reg;
+ bytecode << convert;
+ } else if (destination->type == QVariant::Url) {
+ Instr convert;
+ convert.common.type = Instr::ConvertGenericToUrl;
+ convert.unaryop.output = convertReg;
+ convert.unaryop.src = type.reg;
+ bytecode << convert;
+ }
+
+ Instr cleanup;
+ cleanup.common.type = Instr::CleanupGeneric;
+ cleanup.cleanup.reg = type.reg;
+ bytecode << cleanup;
+
+ Instr instr;
+ instr.common.type = Instr::Store;
+ instr.store.output = 0;
+ instr.store.index = destination->index;
+ instr.store.reg = convertReg;
+ instr.store.exceptionId = exceptionId(node->expressionCast());
+ bytecode << instr;
+
+ if (destination->type == QVariant::String) {
+ Instr cleanup;
+ cleanup.common.type = Instr::CleanupString;
+ cleanup.cleanup.reg = convertReg;
+ bytecode << cleanup;
+ } else if (destination->type == QVariant::Url) {
+ Instr cleanup;
+ cleanup.common.type = Instr::CleanupUrl;
+ cleanup.cleanup.reg = convertReg;
+ bytecode << cleanup;
+ }
+
+ releaseReg(convertReg);
+
+ Instr done;
+ done.common.type = Instr::Done;
+ bytecode << done;
+
+ return true;
+ } else {
+ // Can we store the final value?
+ if (type.type == QVariant::Int &&
+ destination->type == QMetaType::QReal) {
+ Instr instr;
+ instr.common.type = Instr::ConvertIntToReal;
+ instr.unaryop.output = type.reg;
+ instr.unaryop.src = type.reg;
+ bytecode << instr;
+ type.type = QMetaType::QReal;
+ } else if (type.type == QMetaType::QReal &&
+ destination->type == QVariant::Int) {
+ Instr instr;
+ instr.common.type = Instr::ConvertRealToInt;
+ instr.unaryop.output = type.reg;
+ instr.unaryop.src = type.reg;
+ bytecode << instr;
+ type.type = QVariant::Int;
+ } else if (type.type == destination->type) {
+ } else {
+ const QMetaObject *from = type.metaObject;
+ const QMetaObject *to = engine->rawMetaObjectForType(destination->type);
+
+ if (QDeclarativeMetaPropertyPrivate::canConvert(from, to))
+ type.type = destination->type;
+ }
+
+ if (type.type == destination->type) {
+ Instr instr;
+ instr.common.type = Instr::Store;
+ instr.store.output = 0;
+ instr.store.index = destination->index;
+ instr.store.reg = type.reg;
+ instr.store.exceptionId = exceptionId(node->expressionCast());
+ bytecode << instr;
+
+ releaseReg(type.reg);
+
+ Instr done;
+ done.common.type = Instr::Done;
+ bytecode << done;
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
+
+bool QDeclarativeBindingCompilerPrivate::parseExpression(QDeclarativeJS::AST::Node *node, Result &type)
+{
+ while (node->kind == AST::Node::Kind_NestedExpression)
+ node = static_cast<AST::NestedExpression *>(node)->expression;
+
+ if (tryArith(node)) {
+ if (!parseArith(node, type)) return false;
+ } else if (tryLogic(node)) {
+ if (!parseLogic(node, type)) return false;
+ } else if (tryConditional(node)) {
+ if (!parseConditional(node, type)) return false;
+ } else if (tryName(node)) {
+ if (!parseName(node, type)) return false;
+ } else if (tryConstant(node)) {
+ if (!parseConstant(node, type)) return false;
+ } else if (tryMethod(node)) {
+ if (!parseMethod(node, type)) return false;
+ } else {
+ return false;
+ }
+ return true;
+}
+
+bool QDeclarativeBindingCompilerPrivate::tryName(QDeclarativeJS::AST::Node *node)
+{
+ return node->kind == AST::Node::Kind_IdentifierExpression ||
+ node->kind == AST::Node::Kind_FieldMemberExpression;
+}
+
+bool QDeclarativeBindingCompilerPrivate::parseName(AST::Node *node, Result &type)
+{
+ QStringList nameParts;
+ QList<AST::ExpressionNode *> nameNodes;
+ if (!buildName(nameParts, node, &nameNodes))
+ return false;
+
+ int reg = acquireReg();
+ if (reg == -1)
+ return false;
+ type.reg = reg;
+
+ QDeclarativeParser::Object *absType = 0;
+
+ QStringList subscribeName;
+
+ bool wasAttachedObject = false;
+
+ for (int ii = 0; ii < nameParts.count(); ++ii) {
+ const QString &name = nameParts.at(ii);
+
+ // We don't handle signal properties or attached properties
+ if (name.length() > 2 && name.startsWith(QLatin1String("on")) &&
+ name.at(2).isUpper())
+ return false;
+
+ QDeclarativeType *attachType = 0;
+ if (name.at(0).isUpper()) {
+ // Could be an attached property
+ if (ii == nameParts.count() - 1)
+ return false;
+ if (nameParts.at(ii + 1).at(0).isUpper())
+ return false;
+
+ QDeclarativeEnginePrivate::ImportedNamespace *ns = 0;
+ if (!engine->resolveType(imports, name.toUtf8(), &attachType, 0, 0, 0, &ns))
+ return false;
+ if (ns || !attachType || !attachType->attachedPropertiesType())
+ return false;
+
+ wasAttachedObject = true;
+ }
+
+ if (ii == 0) {
+
+ if (attachType) {
+ Instr instr;
+ instr.common.type = Instr::LoadScope;
+ instr.load.index = 0;
+ instr.load.reg = reg;
+ bytecode << instr;
+
+ Instr attach;
+ attach.common.type = Instr::LoadAttached;
+ attach.attached.output = reg;
+ attach.attached.reg = reg;
+ attach.attached.index = attachType->index();
+ attach.attached.exceptionId = exceptionId(nameNodes.at(ii));
+ bytecode << attach;
+
+ subscribeName << contextName();
+ subscribeName << QLatin1String("$$$ATTACH_") + name;
+
+ absType = 0;
+ type.metaObject = attachType->attachedPropertiesType();
+
+ continue;
+ } else if (ids.contains(name)) {
+ QDeclarativeParser::Object *idObject = ids.value(name);
+ absType = idObject;
+ type.metaObject = absType->metaObject();
+
+ // We check if the id object is the root or
+ // scope object to avoid a subscription
+ if (idObject == component) {
+ Instr instr;
+ instr.common.type = Instr::LoadRoot;
+ instr.load.index = 0;
+ instr.load.reg = reg;
+ bytecode << instr;
+ } else if (idObject == context) {
+ Instr instr;
+ instr.common.type = Instr::LoadScope;
+ instr.load.index = 0;
+ instr.load.reg = reg;
+ bytecode << instr;
+ } else {
+ Instr instr;
+ instr.common.type = Instr::LoadId;
+ instr.load.index = idObject->idIndex;
+ instr.load.reg = reg;
+ bytecode << instr;
+
+ subscribeName << QLatin1String("$$$ID_") + name;
+
+ if (subscription(subscribeName, &type)) {
+ Instr sub;
+ sub.common.type = Instr::SubscribeId;
+ sub.subscribe.offset = subscriptionIndex(subscribeName);
+ sub.subscribe.reg = reg;
+ sub.subscribe.index = instr.load.index;
+ bytecode << sub;
+ }
+ }
+
+ } else {
+
+ QByteArray utf8Name = name.toUtf8();
+ const char *cname = utf8Name.constData();
+
+ int d0Idx = (context == component)?-1:context->metaObject()->indexOfProperty(cname);
+ int d1Idx = -1;
+ if (d0Idx == -1)
+ d1Idx = component->metaObject()->indexOfProperty(cname);
+
+ if (d0Idx != -1) {
+ Instr instr;
+ instr.common.type = Instr::LoadScope;
+ instr.load.index = 0;
+ instr.load.reg = reg;
+ bytecode << instr;
+
+ subscribeName << contextName();
+ subscribeName << name;
+
+ if (!fetch(type, context->metaObject(), reg, d0Idx, subscribeName, nameNodes.at(ii)))
+ return false;
+ } else if(d1Idx != -1) {
+ Instr instr;
+ instr.common.type = Instr::LoadRoot;
+ instr.load.index = 0;
+ instr.load.reg = reg;
+ bytecode << instr;
+
+ subscribeName << QLatin1String("$$$ROOT");
+ subscribeName << name;
+
+ if (!fetch(type, component->metaObject(), reg, d1Idx, subscribeName, nameNodes.at(ii)))
+ return false;
+ } else {
+ Instr find;
+ if (nameParts.count() == 1)
+ find.common.type = Instr::FindGenericTerminal;
+ else
+ find.common.type = Instr::FindGeneric;
+
+ find.find.reg = reg;
+ find.find.src = -1;
+ find.find.name = registerString(name);
+ find.find.exceptionId = exceptionId(nameNodes.at(ii));
+
+ subscribeName << QString(QLatin1String("$$$Generic_") + name);
+ if (subscription(subscribeName, &type))
+ find.find.subscribeIndex = subscriptionIndex(subscribeName);
+ else
+ find.find.subscribeIndex = -1;
+
+ bytecode << find;
+ type.unknownType = true;
+ }
+
+ if (!type.unknownType && type.type == -1)
+ return false; // Couldn't fetch that type
+ }
+
+ } else {
+
+ if (attachType) {
+ Instr attach;
+ attach.common.type = Instr::LoadAttached;
+ attach.attached.output = reg;
+ attach.attached.reg = reg;
+ attach.attached.index = attachType->index();
+ bytecode << attach;
+
+ absType = 0;
+ type.metaObject = attachType->attachedPropertiesType();
+
+ subscribeName << QLatin1String("$$$ATTACH_") + name;
+ continue;
+ }
+
+ const QMetaObject *mo = 0;
+ if (absType)
+ mo = absType->metaObject();
+ else if (type.metaObject)
+ mo = type.metaObject;
+
+ QByteArray utf8Name = name.toUtf8();
+ const char *cname = utf8Name.constData();
+ int idx = mo?mo->indexOfProperty(cname):-1;
+ if (absType && idx == -1)
+ return false;
+
+ subscribeName << name;
+
+ if (absType || (wasAttachedObject && idx != -1) || (mo && mo->property(idx).isFinal())) {
+ absType = 0;
+ if (!fetch(type, mo, reg, idx, subscribeName, nameNodes.at(ii)))
+ return false;
+ } else {
+
+ Instr prop;
+ if (ii == nameParts.count() -1 )
+ prop.common.type = Instr::FindPropertyTerminal;
+ else
+ prop.common.type = Instr::FindProperty;
+
+ prop.find.reg = reg;
+ prop.find.src = reg;
+ prop.find.name = registerString(name);
+ prop.find.exceptionId = exceptionId(nameNodes.at(ii));
+
+ if (subscription(subscribeName, &type))
+ prop.find.subscribeIndex = subscriptionIndex(subscribeName);
+ else
+ prop.find.subscribeIndex = -1;
+
+ type.unknownType = true;
+ type.metaObject = 0;
+ type.type = -1;
+ type.reg = reg;
+ bytecode << prop;
+ }
+ }
+
+ wasAttachedObject = false;
+ }
+
+ return true;
+}
+
+bool QDeclarativeBindingCompilerPrivate::tryArith(QDeclarativeJS::AST::Node *node)
+{
+ if (node->kind != AST::Node::Kind_BinaryExpression)
+ return false;
+
+ AST::BinaryExpression *expression = static_cast<AST::BinaryExpression *>(node);
+ if (expression->op == QSOperator::Add ||
+ expression->op == QSOperator::Sub)
+ return true;
+ else
+ return false;
+}
+
+bool QDeclarativeBindingCompilerPrivate::parseArith(QDeclarativeJS::AST::Node *node, Result &type)
+{
+ AST::BinaryExpression *expression = static_cast<AST::BinaryExpression *>(node);
+
+ type.reg = acquireReg();
+
+ Result lhs;
+ Result rhs;
+
+ if (!parseExpression(expression->left, lhs)) return false;
+ if (!parseExpression(expression->right, rhs)) return false;
+
+ if ((lhs.type == QVariant::Int || lhs.type == QMetaType::QReal) &&
+ (rhs.type == QVariant::Int || rhs.type == QMetaType::QReal))
+ return numberArith(type, lhs, rhs, (QSOperator::Op)expression->op);
+ else if(expression->op == QSOperator::Sub)
+ return numberArith(type, lhs, rhs, (QSOperator::Op)expression->op);
+ else if ((lhs.type == QMetaType::QString || lhs.unknownType) &&
+ (rhs.type == QMetaType::QString || rhs.unknownType) &&
+ (lhs.type == QMetaType::QString || rhs.type == QMetaType::QString))
+ return stringArith(type, lhs, rhs, (QSOperator::Op)expression->op);
+ else
+ return false;
+}
+
+bool QDeclarativeBindingCompilerPrivate::numberArith(Result &type, const Result &lhs, const Result &rhs, QSOperator::Op op)
+{
+ bool nativeReal = rhs.type == QMetaType::QReal ||
+ lhs.type == QMetaType::QReal ||
+ lhs.unknownType ||
+ rhs.unknownType;
+
+ if (nativeReal && lhs.type == QMetaType::Int) {
+ Instr convert;
+ convert.common.type = Instr::ConvertIntToReal;
+ convert.unaryop.output = lhs.reg;
+ convert.unaryop.src = lhs.reg;
+ bytecode << convert;
+ }
+
+ if (nativeReal && rhs.type == QMetaType::Int) {
+ Instr convert;
+ convert.common.type = Instr::ConvertIntToReal;
+ convert.unaryop.output = rhs.reg;
+ convert.unaryop.src = rhs.reg;
+ bytecode << convert;
+ }
+
+ int lhsTmp = -1;
+ int rhsTmp = -1;
+ if (lhs.unknownType) {
+ lhsTmp = acquireReg();
+
+ Instr conv;
+ conv.common.type = Instr::ConvertGenericToReal;
+ conv.unaryop.output = lhsTmp;
+ conv.unaryop.src = lhs.reg;
+ bytecode << conv;
+ }
+
+ if (rhs.unknownType) {
+ rhsTmp = acquireReg();
+
+ Instr conv;
+ conv.common.type = Instr::ConvertGenericToReal;
+ conv.unaryop.output = rhsTmp;
+ conv.unaryop.src = rhs.reg;
+ bytecode << conv;
+ }
+
+ Instr arith;
+ if (op == QSOperator::Add) {
+ arith.common.type = nativeReal?Instr::AddReal:Instr::AddInt;
+ } else if (op == QSOperator::Sub) {
+ arith.common.type = nativeReal?Instr::MinusReal:Instr::MinusInt;
+ } else {
+ qFatal("Unsupported arithmetic operator");
+ }
+
+ arith.binaryop.output = type.reg;
+ arith.binaryop.src1 = (lhsTmp == -1)?lhs.reg:lhsTmp;
+ arith.binaryop.src2 = (rhsTmp == -1)?rhs.reg:rhsTmp;
+ bytecode << arith;
+
+ type.metaObject = 0;
+ type.type = nativeReal?QMetaType::QReal:QMetaType::Int;
+ type.subscriptionSet.unite(lhs.subscriptionSet);
+ type.subscriptionSet.unite(rhs.subscriptionSet);
+
+ if (lhsTmp != -1) releaseReg(lhsTmp);
+ if (rhsTmp != -1) releaseReg(rhsTmp);
+ releaseReg(lhs.reg);
+ releaseReg(rhs.reg);
+
+ return true;
+}
+
+bool QDeclarativeBindingCompilerPrivate::stringArith(Result &type, const Result &lhs, const Result &rhs, QSOperator::Op op)
+{
+ if (op != QSOperator::Add)
+ return false;
+
+ int lhsTmp = -1;
+ int rhsTmp = -1;
+
+ if (lhs.unknownType) {
+ lhsTmp = acquireReg(Instr::CleanupString);
+
+ Instr convert;
+ convert.common.type = Instr::ConvertGenericToString;
+ convert.unaryop.output = lhsTmp;
+ convert.unaryop.src = lhs.reg;
+ bytecode << convert;
+ }
+
+ if (rhs.unknownType) {
+ rhsTmp = acquireReg(Instr::CleanupString);
+
+ Instr convert;
+ convert.common.type = Instr::ConvertGenericToString;
+ convert.unaryop.output = rhsTmp;
+ convert.unaryop.src = rhs.reg;
+ bytecode << convert;
+ }
+
+ type.reg = acquireReg(Instr::CleanupString);
+ type.type = QMetaType::QString;
+
+ Instr add;
+ add.common.type = Instr::AddString;
+ add.binaryop.output = type.reg;
+ add.binaryop.src1 = (lhsTmp == -1)?lhs.reg:lhsTmp;
+ add.binaryop.src2 = (rhsTmp == -1)?rhs.reg:rhsTmp;
+ bytecode << add;
+
+ if (lhsTmp != -1) releaseReg(lhsTmp);
+ if (rhsTmp != -1) releaseReg(rhsTmp);
+
+ return true;
+}
+
+bool QDeclarativeBindingCompilerPrivate::tryLogic(QDeclarativeJS::AST::Node *node)
+{
+ if (node->kind != AST::Node::Kind_BinaryExpression)
+ return false;
+
+ AST::BinaryExpression *expression = static_cast<AST::BinaryExpression *>(node);
+ if (expression->op == QSOperator::Gt ||
+ expression->op == QSOperator::Equal ||
+ expression->op == QSOperator::NotEqual)
+ return true;
+ else
+ return false;
+}
+
+bool QDeclarativeBindingCompilerPrivate::parseLogic(QDeclarativeJS::AST::Node *node, Result &type)
+{
+ AST::BinaryExpression *expression = static_cast<AST::BinaryExpression *>(node);
+
+ Result lhs;
+ Result rhs;
+
+ if (!parseExpression(expression->left, lhs)) return false;
+ if (!parseExpression(expression->right, rhs)) return false;
+
+ type.reg = acquireReg();
+ type.metaObject = 0;
+ type.type = QVariant::Bool;
+
+ if (lhs.type == QMetaType::QReal && rhs.type == QMetaType::QReal) {
+
+ Instr op;
+ if (expression->op == QSOperator::Gt)
+ op.common.type = Instr::GreaterThanReal;
+ else if (expression->op == QSOperator::Equal)
+ op.common.type = Instr::CompareReal;
+ else if (expression->op == QSOperator::NotEqual)
+ op.common.type = Instr::NotCompareReal;
+ else
+ return false;
+ op.binaryop.output = type.reg;
+ op.binaryop.src1 = lhs.reg;
+ op.binaryop.src2 = rhs.reg;
+ bytecode << op;
+
+
+ } else if (lhs.type == QMetaType::QString && rhs.type == QMetaType::QString) {
+
+ Instr op;
+ if (expression->op == QSOperator::Equal)
+ op.common.type = Instr::CompareString;
+ else if (expression->op == QSOperator::NotEqual)
+ op.common.type = Instr::NotCompareString;
+ else
+ return false;
+ op.binaryop.output = type.reg;
+ op.binaryop.src1 = lhs.reg;
+ op.binaryop.src2 = rhs.reg;
+ bytecode << op;
+
+ } else {
+ return false;
+ }
+
+ releaseReg(lhs.reg);
+ releaseReg(rhs.reg);
+
+ return true;
+}
+
+bool QDeclarativeBindingCompilerPrivate::tryConditional(QDeclarativeJS::AST::Node *node)
+{
+ return (node->kind == AST::Node::Kind_ConditionalExpression);
+}
+
+bool QDeclarativeBindingCompilerPrivate::parseConditional(QDeclarativeJS::AST::Node *node, Result &type)
+{
+ AST::ConditionalExpression *expression = static_cast<AST::ConditionalExpression *>(node);
+
+ AST::Node *test = expression->expression;
+ if (test->kind == AST::Node::Kind_NestedExpression)
+ test = static_cast<AST::NestedExpression*>(test)->expression;
+
+ Result etype;
+ if (!parseExpression(test, etype)) return false;
+
+ if (etype.type != QVariant::Bool)
+ return false;
+
+ Instr skip;
+ skip.common.type = Instr::Skip;
+ skip.skip.reg = etype.reg;
+ skip.skip.count = 0;
+ int skipIdx = bytecode.count();
+ bytecode << skip;
+
+ // Release to allow reuse of reg
+ releaseReg(etype.reg);
+
+ QSet<QString> preSubSet = subscriptionSet;
+
+ // int preConditionalSubscriptions = subscriptionSet.count();
+
+ Result ok;
+ if (!parseExpression(expression->ok, ok)) return false;
+ if (ok.unknownType) return false;
+
+ int skipIdx2 = bytecode.count();
+ skip.skip.reg = -1;
+ bytecode << skip;
+
+ // Release to allow reuse of reg
+ releaseReg(ok.reg);
+ bytecode[skipIdx].skip.count = bytecode.count() - skipIdx - 1;
+
+ subscriptionSet = preSubSet;
+
+ Result ko;
+ if (!parseExpression(expression->ko, ko)) return false;
+ if (ko.unknownType) return false;
+
+ // Release to allow reuse of reg
+ releaseReg(ko.reg);
+ bytecode[skipIdx2].skip.count = bytecode.count() - skipIdx2 - 1;
+
+ if (ok != ko)
+ return false; // Must be same type and in same register
+
+ subscriptionSet = preSubSet;
+
+ if (!subscriptionNeutral(subscriptionSet, ok.subscriptionSet, ko.subscriptionSet))
+ return false; // Conditionals cannot introduce new subscriptions
+
+ type = ok;
+
+ return true;
+}
+
+bool QDeclarativeBindingCompilerPrivate::tryConstant(QDeclarativeJS::AST::Node *node)
+{
+ return node->kind == AST::Node::Kind_TrueLiteral ||
+ node->kind == AST::Node::Kind_FalseLiteral ||
+ node->kind == AST::Node::Kind_NumericLiteral ||
+ node->kind == AST::Node::Kind_StringLiteral;
+}
+
+bool QDeclarativeBindingCompilerPrivate::parseConstant(QDeclarativeJS::AST::Node *node, Result &type)
+{
+ type.metaObject = 0;
+ type.type = -1;
+ type.reg = acquireReg();
+
+ if (node->kind == AST::Node::Kind_TrueLiteral) {
+ type.type = QVariant::Bool;
+ Instr instr;
+ instr.common.type = Instr::Bool;
+ instr.bool_value.reg = type.reg;
+ instr.bool_value.value = true;
+ bytecode << instr;
+ return true;
+ } else if (node->kind == AST::Node::Kind_FalseLiteral) {
+ type.type = QVariant::Bool;
+ Instr instr;
+ instr.common.type = Instr::Bool;
+ instr.bool_value.reg = type.reg;
+ instr.bool_value.value = false;
+ bytecode << instr;
+ return true;
+ } else if (node->kind == AST::Node::Kind_NumericLiteral) {
+ qreal value = qreal(static_cast<AST::NumericLiteral *>(node)->value);
+
+ if (qreal(float(value)) != value)
+ return false;
+
+ type.type = QMetaType::QReal;
+ Instr instr;
+ instr.common.type = Instr::Real;
+ instr.real_value.reg = type.reg;
+ instr.real_value.value = float(value);
+ bytecode << instr;
+ return true;
+ } else if (node->kind == AST::Node::Kind_StringLiteral) {
+ QString str = static_cast<AST::StringLiteral *>(node)->value->asString();
+ type.type = QMetaType::QString;
+ type.reg = registerLiteralString(str);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool QDeclarativeBindingCompilerPrivate::tryMethod(QDeclarativeJS::AST::Node *node)
+{
+ return node->kind == AST::Node::Kind_CallExpression;
+}
+
+bool QDeclarativeBindingCompilerPrivate::parseMethod(QDeclarativeJS::AST::Node *node, Result &result)
+{
+ AST::CallExpression *expr = static_cast<AST::CallExpression *>(node);
+
+ QStringList name;
+ if (!buildName(name, expr->base))
+ return false;
+
+ if (name.count() != 2 || name.at(0) != QLatin1String("Math"))
+ return false;
+
+ QString method = name.at(1);
+
+ AST::ArgumentList *args = expr->arguments;
+ if (!args) return false;
+ AST::ExpressionNode *arg0 = args->expression;
+ args = args->next;
+ if (!args) return false;
+ AST::ExpressionNode *arg1 = args->expression;
+ if (args->next != 0) return false;
+ if (!arg0 || !arg1) return false;
+
+ Result r0;
+ if (!parseExpression(arg0, r0)) return false;
+ Result r1;
+ if (!parseExpression(arg1, r1)) return false;
+
+ if (r0.type != QMetaType::QReal || r1.type != QMetaType::QReal)
+ return false;
+
+ Instr op;
+ if (method == QLatin1String("max")) {
+ op.common.type = Instr::MaxReal;
+ } else if (method == QLatin1String("min")) {
+ op.common.type = Instr::MinReal;
+ } else {
+ return false;
+ }
+ // We release early to reuse registers
+ releaseReg(r0.reg);
+ releaseReg(r1.reg);
+
+ op.binaryop.output = acquireReg();
+ op.binaryop.src1 = r0.reg;
+ op.binaryop.src2 = r1.reg;
+ bytecode << op;
+
+ result.type = QMetaType::QReal;
+ result.reg = op.binaryop.output;
+
+ return true;
+}
+
+bool QDeclarativeBindingCompilerPrivate::buildName(QStringList &name,
+ QDeclarativeJS::AST::Node *node,
+ QList<QDeclarativeJS::AST::ExpressionNode *> *nodes)
+{
+ if (node->kind == AST::Node::Kind_IdentifierExpression) {
+ name << static_cast<AST::IdentifierExpression*>(node)->name->asString();
+ if (nodes) *nodes << static_cast<AST::IdentifierExpression*>(node);
+ } else if (node->kind == AST::Node::Kind_FieldMemberExpression) {
+ AST::FieldMemberExpression *expr =
+ static_cast<AST::FieldMemberExpression *>(node);
+
+ if (!buildName(name, expr->base, nodes))
+ return false;
+
+ name << expr->name->asString();
+ if (nodes) *nodes << expr;
+ } else {
+ return false;
+ }
+
+ return true;
+}
+
+
+bool QDeclarativeBindingCompilerPrivate::fetch(Result &rv, const QMetaObject *mo, int reg,
+ int idx, const QStringList &subName, QDeclarativeJS::AST::ExpressionNode *node)
+{
+ QMetaProperty prop = mo->property(idx);
+ rv.metaObject = 0;
+ rv.type = 0;
+
+ if (subscription(subName, &rv) && prop.hasNotifySignal() && prop.notifySignalIndex() != -1) {
+ Instr sub;
+ sub.common.type = Instr::Subscribe;
+ sub.subscribe.offset = subscriptionIndex(subName);
+ sub.subscribe.reg = reg;
+ sub.subscribe.index = prop.notifySignalIndex();
+ bytecode << sub;
+ }
+
+ Instr fetch;
+ fetch.common.type = Instr::Fetch;
+ fetch.fetch.objectReg = reg;
+ fetch.fetch.index = idx;
+ fetch.fetch.output = reg;
+ fetch.fetch.exceptionId = exceptionId(node);
+
+ rv.type = prop.userType();
+ rv.metaObject = engine->metaObjectForType(rv.type);
+ rv.reg = reg;
+
+ if (rv.type == QMetaType::QString) {
+ int tmp = acquireReg();
+ Instr copy;
+ copy.common.type = Instr::Copy;
+ copy.copy.reg = tmp;
+ copy.copy.src = reg;
+ bytecode << copy;
+ releaseReg(tmp);
+ fetch.fetch.objectReg = tmp;
+
+ Instr setup;
+ setup.common.type = Instr::NewString;
+ setup.construct.reg = reg;
+ bytecode << setup;
+ registerCleanup(reg, Instr::CleanupString);
+ }
+
+ bytecode << fetch;
+
+ if (!rv.metaObject &&
+ rv.type != QMetaType::QReal &&
+ rv.type != QMetaType::Int &&
+ rv.type != QMetaType::Bool &&
+ rv.type != qMetaTypeId<QDeclarativeAnchorLine>() &&
+ rv.type != QMetaType::QString) {
+ rv.metaObject = 0;
+ rv.type = 0;
+ return false; // Unsupported type (string not supported yet);
+ }
+
+ return true;
+}
+
+void QDeclarativeBindingCompilerPrivate::registerCleanup(int reg, int cleanup, int cleanupType)
+{
+ registerCleanups.insert(reg, qMakePair(cleanup, cleanupType));
+}
+
+int QDeclarativeBindingCompilerPrivate::acquireReg(int cleanup, int cleanupType)
+{
+ for (int ii = 0; ii < 32; ++ii) {
+ if (!(registers & (1 << ii))) {
+ registers |= (1 << ii);
+
+ if (cleanup != Instr::Noop)
+ registerCleanup(ii, cleanup, cleanupType);
+
+ return ii;
+ }
+ }
+ return -1;
+}
+
+void QDeclarativeBindingCompilerPrivate::releaseReg(int reg)
+{
+ Q_ASSERT(reg >= 0 && reg <= 31);
+
+ if (registerCleanups.contains(reg)) {
+ QPair<int, int> c = registerCleanups[reg];
+ registerCleanups.remove(reg);
+ Instr cleanup;
+ cleanup.common.type = (quint8)c.first;
+ cleanup.cleanup.reg = reg;
+ bytecode << cleanup;
+ }
+
+ quint32 mask = 1 << reg;
+ registers &= ~mask;
+}
+
+// Returns a reg
+int QDeclarativeBindingCompilerPrivate::registerLiteralString(const QString &str)
+{
+ QByteArray strdata((const char *)str.constData(), str.length() * sizeof(QChar));
+ int offset = data.count();
+ data += strdata;
+
+ int reg = acquireReg(Instr::CleanupString);
+
+ Instr string;
+ string.common.type = Instr::String;
+ string.string_value.reg = reg;
+ string.string_value.offset = offset;
+ string.string_value.length = str.length();
+ bytecode << string;
+
+ return reg;
+}
+
+// Returns an identifier offset
+int QDeclarativeBindingCompilerPrivate::registerString(const QString &string)
+{
+ Q_ASSERT(!string.isEmpty());
+
+ QHash<QString, QPair<int, int> >::ConstIterator iter = registeredStrings.find(string);
+
+ if (iter == registeredStrings.end()) {
+ quint32 len = string.length();
+ QByteArray lendata((const char *)&len, sizeof(quint32));
+ QByteArray strdata((const char *)string.constData(), string.length() * sizeof(QChar));
+ strdata.prepend(lendata);
+ int rv = data.count();
+ data += strdata;
+
+ iter = registeredStrings.insert(string, qMakePair(registeredStrings.count(), rv));
+ }
+
+ Instr reg;
+ reg.common.type = Instr::InitString;
+ reg.initstring.offset = iter->first;
+ reg.initstring.dataIdx = iter->second;
+ bytecode << reg;
+ return reg.initstring.offset;
+}
+
+bool QDeclarativeBindingCompilerPrivate::subscription(const QStringList &sub, Result *result)
+{
+ QString str = sub.join(QLatin1String("."));
+ result->subscriptionSet.insert(str);
+
+ if (subscriptionSet.contains(str)) {
+ return false;
+ } else {
+ subscriptionSet.insert(str);
+ return true;
+ }
+}
+
+int QDeclarativeBindingCompilerPrivate::subscriptionIndex(const QStringList &sub)
+{
+ QString str = sub.join(QLatin1String("."));
+ QHash<QString, int>::ConstIterator iter = subscriptionIds.find(str);
+ if (iter == subscriptionIds.end())
+ iter = subscriptionIds.insert(str, subscriptionIds.count());
+ usedSubscriptionIds.insert(*iter);
+ return *iter;
+}
+
+/*
+ Returns true if lhs contains no subscriptions that aren't also in base or rhs AND
+ rhs contains no subscriptions that aren't also in base or lhs.
+*/
+bool QDeclarativeBindingCompilerPrivate::subscriptionNeutral(const QSet<QString> &base,
+ const QSet<QString> &lhs,
+ const QSet<QString> &rhs)
+{
+ QSet<QString> difflhs = lhs;
+ difflhs.subtract(rhs);
+ QSet<QString> diffrhs = rhs;
+ diffrhs.subtract(lhs);
+
+ difflhs.unite(diffrhs);
+ difflhs.subtract(base);
+
+ return difflhs.isEmpty();
+}
+
+quint8 QDeclarativeBindingCompilerPrivate::exceptionId(QDeclarativeJS::AST::ExpressionNode *n)
+{
+ quint8 rv = 0xFF;
+ if (n && exceptions.count() < 0xFF) {
+ rv = (quint8)exceptions.count();
+ QDeclarativeJS::AST::SourceLocation l = n->firstSourceLocation();
+ quint64 e = l.startLine;
+ e <<= 32;
+ e |= l.startColumn;
+ exceptions.append(e);
+ }
+ return rv;
+}
+
+QDeclarativeBindingCompiler::QDeclarativeBindingCompiler()
+: d(new QDeclarativeBindingCompilerPrivate)
+{
+}
+
+QDeclarativeBindingCompiler::~QDeclarativeBindingCompiler()
+{
+ delete d; d = 0;
+}
+
+/*
+Returns true if any bindings were compiled.
+*/
+bool QDeclarativeBindingCompiler::isValid() const
+{
+ return !d->committed.bytecode.isEmpty();
+}
+
+/*
+-1 on failure, otherwise the binding index to use.
+*/
+int QDeclarativeBindingCompiler::compile(const Expression &expression, QDeclarativeEnginePrivate *engine)
+{
+ if (!expression.expression.asAST()) return false;
+
+ d->context = expression.context;
+ d->component = expression.component;
+ d->destination = expression.property;
+ d->ids = expression.ids;
+ d->imports = expression.imports;
+ d->engine = engine;
+
+ if (d->compile(expression.expression.asAST())) {
+ return d->commitCompile();
+ } else {
+ return -1;
+ }
+}
+
+
+QByteArray QDeclarativeBindingCompilerPrivate::buildSignalTable() const
+{
+ QHash<int, QList<int> > table;
+
+ for (int ii = 0; ii < committed.count(); ++ii) {
+ const QSet<int> &deps = committed.dependencies.at(ii);
+ for (QSet<int>::ConstIterator iter = deps.begin(); iter != deps.end(); ++iter)
+ table[*iter].append(ii);
+ }
+
+ QVector<quint32> header;
+ QVector<quint32> data;
+ for (int ii = 0; ii < committed.subscriptionIds.count(); ++ii) {
+ header.append(committed.subscriptionIds.count() + data.count());
+ const QList<int> &bindings = table[ii];
+ data.append(bindings.count());
+ for (int jj = 0; jj < bindings.count(); ++jj)
+ data.append(bindings.at(jj));
+ }
+ header << data;
+
+ return QByteArray((const char *)header.constData(), header.count() * sizeof(quint32));
+}
+
+QByteArray QDeclarativeBindingCompilerPrivate::buildExceptionData() const
+{
+ QByteArray rv;
+ rv.resize(committed.exceptions.count() * sizeof(quint64));
+ ::memcpy(rv.data(), committed.exceptions.constData(), rv.size());
+ return rv;
+}
+
+/*
+Returns the compiled program.
+*/
+QByteArray QDeclarativeBindingCompiler::program() const
+{
+ QByteArray programData;
+
+ if (isValid()) {
+ Program prog;
+ prog.bindings = d->committed.count();
+
+ QVector<Instr> bytecode;
+ Instr skip;
+ skip.common.type = Instr::Skip;
+ skip.skip.reg = -1;
+ for (int ii = 0; ii < d->committed.count(); ++ii) {
+ skip.skip.count = d->committed.count() - ii - 1;
+ skip.skip.count+= d->committed.offsets.at(ii);
+ bytecode << skip;
+ }
+ bytecode << d->committed.bytecode;
+
+ QByteArray data = d->committed.data;
+ while (data.count() % 4) data.append('\0');
+ prog.signalTableOffset = data.count();
+ data += d->buildSignalTable();
+ while (data.count() % 4) data.append('\0');
+ prog.exceptionDataOffset = data.count();
+ data += d->buildExceptionData();
+
+ prog.dataLength = 4 * ((data.size() + 3) / 4);
+ prog.subscriptions = d->committed.subscriptionIds.count();
+ prog.identifiers = d->committed.registeredStrings.count();
+ prog.instructionCount = bytecode.count();
+ int size = sizeof(Program) + bytecode.count() * sizeof(Instr);
+ size += prog.dataLength;
+
+ programData.resize(size);
+ memcpy(programData.data(), &prog, sizeof(Program));
+ if (prog.dataLength)
+ memcpy((char *)((Program *)programData.data())->data(), data.constData(),
+ data.size());
+ memcpy((char *)((Program *)programData.data())->instructions(), bytecode.constData(),
+ bytecode.count() * sizeof(Instr));
+ }
+
+ return programData;
+}
+
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompiledbindings_p.h b/src/declarative/qml/qdeclarativecompiledbindings_p.h
new file mode 100644
index 0000000..2e24371
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecompiledbindings_p.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEBINDINGOPTIMIZATIONS_P_H
+#define QDECLARATIVEBINDINGOPTIMIZATIONS_P_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 "qdeclarativeexpression_p.h"
+#include "qdeclarativebinding_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeBindingCompilerPrivate;
+class QDeclarativeBindingCompiler
+{
+public:
+ QDeclarativeBindingCompiler();
+ ~QDeclarativeBindingCompiler();
+
+ // Returns true if bindings were compiled
+ bool isValid() const;
+
+ struct Expression
+ {
+ QDeclarativeParser::Object *component;
+ QDeclarativeParser::Object *context;
+ QDeclarativeParser::Property *property;
+ QDeclarativeParser::Variant expression;
+ QHash<QString, QDeclarativeParser::Object *> ids;
+ QDeclarativeEnginePrivate::Imports imports;
+ };
+
+ // -1 on failure, otherwise the binding index to use
+ int compile(const Expression &, QDeclarativeEnginePrivate *);
+
+ // Returns the compiled program
+ QByteArray program() const;
+
+ static void dump(const QByteArray &);
+private:
+ QDeclarativeBindingCompilerPrivate *d;
+};
+
+class QDeclarativeCompiledBindingsPrivate;
+class QDeclarativeCompiledBindings : public QObject, public QDeclarativeAbstractExpression, public QDeclarativeRefCount
+{
+public:
+ QDeclarativeCompiledBindings(const char *program, QDeclarativeContext *context);
+ virtual ~QDeclarativeCompiledBindings();
+
+ QDeclarativeAbstractBinding *configBinding(int index, QObject *target, QObject *scope, int property);
+
+protected:
+ int qt_metacall(QMetaObject::Call, int, void **);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeCompiledBindings);
+ Q_DECLARE_PRIVATE(QDeclarativeCompiledBindings);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEBINDINGOPTIMIZATIONS_P_H
+
diff --git a/src/declarative/qml/qdeclarativecompileddata.cpp b/src/declarative/qml/qdeclarativecompileddata.cpp
new file mode 100644
index 0000000..bdf16a3
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecompileddata.cpp
@@ -0,0 +1,239 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecompiler_p.h"
+#include "qdeclarativeengine.h"
+#include "qdeclarativecomponent.h"
+#include "qdeclarativecomponent_p.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarativecontext_p.h"
+
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+int QDeclarativeCompiledData::pack(const char *data, size_t size)
+{
+ const char *p = packData.constData();
+ unsigned int ps = packData.size();
+
+ for (unsigned int ii = 0; (ii + size) <= ps; ii += sizeof(int)) {
+ if (0 == ::memcmp(p + ii, data, size))
+ return ii;
+ }
+
+ int rv = packData.size();
+ packData.append(data, size);
+ return rv;
+}
+
+int QDeclarativeCompiledData::indexForString(const QString &data)
+{
+ int idx = primitives.indexOf(data);
+ if (idx == -1) {
+ idx = primitives.count();
+ primitives << data;
+ }
+ return idx;
+}
+
+int QDeclarativeCompiledData::indexForByteArray(const QByteArray &data)
+{
+ int idx = datas.indexOf(data);
+ if (idx == -1) {
+ idx = datas.count();
+ datas << data;
+ }
+ return idx;
+}
+
+int QDeclarativeCompiledData::indexForUrl(const QUrl &data)
+{
+ int idx = urls.indexOf(data);
+ if (idx == -1) {
+ idx = urls.count();
+ urls << data;
+ }
+ return idx;
+}
+
+int QDeclarativeCompiledData::indexForFloat(float *data, int count)
+{
+ Q_ASSERT(count > 0);
+
+ for (int ii = 0; ii <= floatData.count() - count; ++ii) {
+ bool found = true;
+ for (int jj = 0; jj < count; ++jj) {
+ if (floatData.at(ii + jj) != data[jj]) {
+ found = false;
+ break;
+ }
+ }
+
+ if (found)
+ return ii;
+ }
+
+ int idx = floatData.count();
+ for (int ii = 0; ii < count; ++ii)
+ floatData << data[ii];
+
+ return idx;
+}
+
+int QDeclarativeCompiledData::indexForInt(int *data, int count)
+{
+ Q_ASSERT(count > 0);
+
+ for (int ii = 0; ii <= intData.count() - count; ++ii) {
+ bool found = true;
+ for (int jj = 0; jj < count; ++jj) {
+ if (intData.at(ii + jj) != data[jj]) {
+ found = false;
+ break;
+ }
+ }
+
+ if (found)
+ return ii;
+ }
+
+ int idx = intData.count();
+ for (int ii = 0; ii < count; ++ii)
+ intData << data[ii];
+
+ return idx;
+}
+
+int QDeclarativeCompiledData::indexForLocation(const QDeclarativeParser::Location &l)
+{
+ // ### FIXME
+ int rv = locations.count();
+ locations << l;
+ return rv;
+}
+
+int QDeclarativeCompiledData::indexForLocation(const QDeclarativeParser::LocationSpan &l)
+{
+ // ### FIXME
+ int rv = locations.count();
+ locations << l.start << l.end;
+ return rv;
+}
+
+QDeclarativeCompiledData::QDeclarativeCompiledData(QDeclarativeEngine *engine)
+: QDeclarativeCleanup(engine), importCache(0), root(0), rootPropertyCache(0)
+{
+}
+
+QDeclarativeCompiledData::~QDeclarativeCompiledData()
+{
+ for (int ii = 0; ii < types.count(); ++ii) {
+ if (types.at(ii).ref)
+ types.at(ii).ref->release();
+ }
+
+ for (int ii = 0; ii < propertyCaches.count(); ++ii)
+ propertyCaches.at(ii)->release();
+
+ for (int ii = 0; ii < contextCaches.count(); ++ii)
+ contextCaches.at(ii)->release();
+
+ if (importCache)
+ importCache->release();
+
+ if (rootPropertyCache)
+ rootPropertyCache->release();
+
+ qDeleteAll(cachedPrograms);
+ qDeleteAll(cachedClosures);
+}
+
+void QDeclarativeCompiledData::clear()
+{
+ qDeleteAll(cachedPrograms);
+ qDeleteAll(cachedClosures);
+ for (int ii = 0; ii < cachedClosures.count(); ++ii)
+ cachedClosures[ii] = 0;
+ for (int ii = 0; ii < cachedPrograms.count(); ++ii)
+ cachedPrograms[ii] = 0;
+}
+
+
+QObject *QDeclarativeCompiledData::TypeReference::createInstance(QDeclarativeContext *ctxt, const QBitField &bindings) const
+{
+ if (type) {
+ QObject *rv = type->create();
+ if (rv)
+ QDeclarativeEngine::setContextForObject(rv, ctxt);
+ return rv;
+ } else {
+ Q_ASSERT(component);
+ return QDeclarativeComponentPrivate::get(component)->create(ctxt, bindings);
+ }
+}
+
+const QMetaObject *QDeclarativeCompiledData::TypeReference::metaObject() const
+{
+ if (type) {
+ return type->metaObject();
+ } else {
+ Q_ASSERT(component);
+ return static_cast<QDeclarativeComponentPrivate *>(QObjectPrivate::get(component))->cc->root;
+ }
+}
+
+void QDeclarativeCompiledData::dumpInstructions()
+{
+ if (!name.isEmpty())
+ qWarning() << name;
+ qWarning().nospace() << "Index\tLine\tOperation\t\tData1\tData2\tData3\tComments";
+ qWarning().nospace() << "-------------------------------------------------------------------------------";
+ for (int ii = 0; ii < bytecode.count(); ++ii) {
+ dump(&bytecode[ii], ii);
+ }
+ qWarning().nospace() << "-------------------------------------------------------------------------------";
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
new file mode 100644
index 0000000..0593a5d
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -0,0 +1,2779 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecompiler_p.h"
+
+#include "qdeclarativecompositetypedata_p.h"
+#include "qdeclarativeparser_p.h"
+#include "qdeclarativescriptparser_p.h"
+#include "qdeclarativepropertyvaluesource.h"
+#include "qdeclarativecomponent.h"
+#include "qmetaobjectbuilder_p.h"
+#include "qdeclarativestringconverters_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativeengine.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarativemetatype.h"
+#include "qdeclarativecustomparser_p_p.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativecomponent_p.h"
+#include "parser/qdeclarativejsast_p.h"
+#include "qdeclarativevmemetaobject_p.h"
+#include "qdeclarativeexpression_p.h"
+#include "qdeclarativemetaproperty_p.h"
+#include "qdeclarativerewrite_p.h"
+#include "qdeclarativescriptstring.h"
+#include "qdeclarativeglobal_p.h"
+#include "qdeclarativescriptparser_p.h"
+#include "qdeclarativebinding_p.h"
+#include "qdeclarativecompiledbindings_p.h"
+
+#include <qfxperf_p_p.h>
+
+#include <QCoreApplication>
+#include <QColor>
+#include <QDebug>
+#include <QPointF>
+#include <QSizeF>
+#include <QRectF>
+#include <QAtomicInt>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP);
+DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATISTICS_DUMP);
+DEFINE_BOOL_CONFIG_OPTION(qmlExperimental, QML_EXPERIMENTAL);
+
+using namespace QDeclarativeParser;
+
+/*!
+ Instantiate a new QDeclarativeCompiler.
+*/
+QDeclarativeCompiler::QDeclarativeCompiler()
+: output(0), engine(0), unitRoot(0), unit(0)
+{
+}
+
+/*!
+ Returns true if the last call to compile() caused errors.
+
+ \sa errors()
+*/
+bool QDeclarativeCompiler::isError() const
+{
+ return !exceptions.isEmpty();
+}
+
+/*!
+ Return the list of errors from the last call to compile(), or an empty list
+ if there were no errors.
+*/
+QList<QDeclarativeError> QDeclarativeCompiler::errors() const
+{
+ return exceptions;
+}
+
+/*!
+ Returns true if \a val is a legal object id, false otherwise.
+
+ Legal ids must start with a lower-case letter or underscore, and contain only
+ letters, numbers and underscores.
+*/
+bool QDeclarativeCompiler::isValidId(const QString &val)
+{
+ if (val.isEmpty())
+ return false;
+
+ if (val.at(0).isLetter() && !val.at(0).isLower()) {
+ qWarning().nospace() << "id " << val << " is invalid: ids cannot start with uppercase letters";
+ return false;
+ }
+
+ QChar u(QLatin1Char('_'));
+ for (int ii = 0; ii < val.count(); ++ii)
+ if (val.at(ii) != u &&
+ ((ii == 0 && !val.at(ii).isLetter()) ||
+ (ii != 0 && !val.at(ii).isLetterOrNumber())) )
+ return false;
+
+ return true;
+}
+
+/*!
+ Returns true if \a name refers to an attached property, false otherwise.
+
+ Attached property names are those that start with a capital letter.
+*/
+bool QDeclarativeCompiler::isAttachedPropertyName(const QByteArray &name)
+{
+ return !name.isEmpty() && name.at(0) >= 'A' && name.at(0) <= 'Z';
+}
+
+/*!
+ Returns true if \a name refers to a signal property, false otherwise.
+
+ Signal property names are those that start with "on", followed by a capital
+ letter.
+*/
+bool QDeclarativeCompiler::isSignalPropertyName(const QByteArray &name)
+{
+ return name.length() >= 3 && name.startsWith("on") &&
+ 'A' <= name.at(2) && 'Z' >= name.at(2);
+}
+
+/*!
+ \macro COMPILE_EXCEPTION
+ \internal
+ Inserts an error into the QDeclarativeCompiler error list, and returns false
+ (failure).
+
+ \a token is used to source the error line and column, and \a desc is the
+ error itself. \a desc can be an expression that can be piped into QDebug.
+
+ For example:
+
+ \code
+ COMPILE_EXCEPTION(property, QCoreApplication::translate("QDeclarativeCompiler","Error for property \"%1\"").arg(QString::fromUtf8(property->name)));
+ \endcode
+*/
+#define COMPILE_EXCEPTION(token, desc) \
+ { \
+ QString exceptionDescription; \
+ QDeclarativeError error; \
+ error.setUrl(output->url); \
+ error.setLine((token)->location.start.line); \
+ error.setColumn((token)->location.start.column); \
+ error.setDescription(desc.trimmed()); \
+ exceptions << error; \
+ return false; \
+ }
+
+/*!
+ \macro COMPILE_CHECK
+ \internal
+ Returns false if \a is false, otherwise does nothing.
+*/
+#define COMPILE_CHECK(a) \
+ { \
+ if (!a) return false; \
+ }
+
+/*!
+ Returns true if literal \a v can be assigned to property \a prop, otherwise
+ false.
+
+ This test corresponds to action taken by genLiteralAssignment(). Any change
+ made here, must have a corresponding action in genLiteralAssigment().
+*/
+bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
+ QDeclarativeParser::Value *v)
+{
+ QString string = v->value.asScript();
+
+ if (!prop.isWritable())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name())));
+
+ if (prop.isEnumType()) {
+ int value;
+ if (prop.isFlagType()) {
+ value = prop.enumerator().keysToValue(string.toUtf8().constData());
+ } else
+ value = prop.enumerator().keyToValue(string.toUtf8().constData());
+ if (value == -1)
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: unknown enumeration"));
+ return true;
+ }
+ int type = prop.userType();
+ switch(type) {
+ case -1:
+ break;
+ case QVariant::String:
+ if (!v->value.isString()) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: string expected"));
+ break;
+ case QVariant::Url:
+ if (!v->value.isString()) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: url expected"));
+ break;
+ case QVariant::UInt:
+ {
+ bool ok;
+ string.toUInt(&ok);
+ if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: unsigned int expected"));
+ }
+ break;
+ case QVariant::Int:
+ {
+ bool ok;
+ string.toInt(&ok);
+ if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: int expected"));
+ }
+ break;
+ case QMetaType::Float:
+ {
+ bool ok;
+ string.toFloat(&ok);
+ if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: float expected"));
+ }
+ break;
+ case QVariant::Double:
+ {
+ bool ok;
+ string.toDouble(&ok);
+ if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: double expected"));
+ }
+ break;
+ case QVariant::Color:
+ {
+ bool ok;
+ QDeclarativeStringConverters::colorFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: color expected"));
+ }
+ break;
+ case QVariant::Date:
+ {
+ bool ok;
+ QDeclarativeStringConverters::dateFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: date expected"));
+ }
+ break;
+ case QVariant::Time:
+ {
+ bool ok;
+ QDeclarativeStringConverters::timeFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: time expected"));
+ }
+ break;
+ case QVariant::DateTime:
+ {
+ bool ok;
+ QDeclarativeStringConverters::dateTimeFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: datetime expected"));
+ }
+ break;
+ case QVariant::Point:
+ case QVariant::PointF:
+ {
+ bool ok;
+ QPointF point = QDeclarativeStringConverters::pointFFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: point expected"));
+ }
+ break;
+ case QVariant::Size:
+ case QVariant::SizeF:
+ {
+ bool ok;
+ QSizeF size = QDeclarativeStringConverters::sizeFFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: size expected"));
+ }
+ break;
+ case QVariant::Rect:
+ case QVariant::RectF:
+ {
+ bool ok;
+ QRectF rect = QDeclarativeStringConverters::rectFFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: rect expected"));
+ }
+ break;
+ case QVariant::Bool:
+ {
+ if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: boolean expected"));
+ }
+ break;
+ case QVariant::Vector3D:
+ {
+ bool ok;
+ QDeclarativeStringConverters::vector3DFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: 3D vector expected"));
+ }
+ break;
+ default:
+ {
+ int t = prop.userType();
+ QDeclarativeMetaType::StringConverter converter =
+ QDeclarativeMetaType::customStringConverter(t);
+ if (!converter)
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QVariant::typeToName(prop.type()))));
+ }
+ break;
+ }
+ return true;
+}
+
+/*!
+ Generate a store instruction for assigning literal \a v to property \a prop.
+
+ Any literal assignment that is approved in testLiteralAssignment() must have
+ a corresponding action in this method.
+*/
+void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
+ QDeclarativeParser::Value *v)
+{
+ QString string = v->value.asScript();
+
+ QDeclarativeInstruction instr;
+ instr.line = v->location.start.line;
+ if (prop.isEnumType()) {
+ int value;
+ if (prop.isFlagType()) {
+ value = prop.enumerator().keysToValue(string.toUtf8().constData());
+ } else
+ value = prop.enumerator().keyToValue(string.toUtf8().constData());
+
+ instr.type = QDeclarativeInstruction::StoreInteger;
+ instr.storeInteger.propertyIndex = prop.propertyIndex();
+ instr.storeInteger.value = value;
+ output->bytecode << instr;
+ return;
+ }
+
+ int type = prop.userType();
+ switch(type) {
+ case -1:
+ {
+ instr.type = QDeclarativeInstruction::StoreVariant;
+ instr.storeString.propertyIndex = prop.propertyIndex();
+ instr.storeString.value = output->indexForString(string);
+ }
+ break;
+ case QVariant::String:
+ {
+ instr.type = QDeclarativeInstruction::StoreString;
+ instr.storeString.propertyIndex = prop.propertyIndex();
+ instr.storeString.value = output->indexForString(string);
+ }
+ break;
+ case QVariant::Url:
+ {
+ instr.type = QDeclarativeInstruction::StoreUrl;
+ QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(QUrl(string));
+ instr.storeUrl.propertyIndex = prop.propertyIndex();
+ instr.storeUrl.value = output->indexForUrl(u);
+ }
+ break;
+ case QVariant::UInt:
+ {
+ instr.type = QDeclarativeInstruction::StoreInteger;
+ instr.storeInteger.propertyIndex = prop.propertyIndex();
+ instr.storeInteger.value = string.toUInt();
+ }
+ break;
+ case QVariant::Int:
+ {
+ instr.type = QDeclarativeInstruction::StoreInteger;
+ instr.storeInteger.propertyIndex = prop.propertyIndex();
+ instr.storeInteger.value = string.toInt();
+ }
+ break;
+ case QMetaType::Float:
+ {
+ instr.type = QDeclarativeInstruction::StoreFloat;
+ instr.storeFloat.propertyIndex = prop.propertyIndex();
+ instr.storeFloat.value = string.toFloat();
+ }
+ break;
+ case QVariant::Double:
+ {
+ instr.type = QDeclarativeInstruction::StoreDouble;
+ instr.storeDouble.propertyIndex = prop.propertyIndex();
+ instr.storeDouble.value = string.toDouble();
+ }
+ break;
+ case QVariant::Color:
+ {
+ QColor c = QDeclarativeStringConverters::colorFromString(string);
+ instr.type = QDeclarativeInstruction::StoreColor;
+ instr.storeColor.propertyIndex = prop.propertyIndex();
+ instr.storeColor.value = c.rgba();
+ }
+ break;
+ case QVariant::Date:
+ {
+ QDate d = QDeclarativeStringConverters::dateFromString(string);
+ instr.type = QDeclarativeInstruction::StoreDate;
+ instr.storeDate.propertyIndex = prop.propertyIndex();
+ instr.storeDate.value = d.toJulianDay();
+ }
+ break;
+ case QVariant::Time:
+ {
+ QTime time = QDeclarativeStringConverters::timeFromString(string);
+ int data[] = { time.hour(), time.minute(),
+ time.second(), time.msec() };
+ int index = output->indexForInt(data, 4);
+ instr.type = QDeclarativeInstruction::StoreTime;
+ instr.storeTime.propertyIndex = prop.propertyIndex();
+ instr.storeTime.valueIndex = index;
+ }
+ break;
+ case QVariant::DateTime:
+ {
+ QDateTime dateTime = QDeclarativeStringConverters::dateTimeFromString(string);
+ int data[] = { dateTime.date().toJulianDay(),
+ dateTime.time().hour(),
+ dateTime.time().minute(),
+ dateTime.time().second(),
+ dateTime.time().msec() };
+ int index = output->indexForInt(data, 5);
+ instr.type = QDeclarativeInstruction::StoreDateTime;
+ instr.storeDateTime.propertyIndex = prop.propertyIndex();
+ instr.storeDateTime.valueIndex = index;
+ }
+ break;
+ case QVariant::Point:
+ case QVariant::PointF:
+ {
+ bool ok;
+ QPointF point =
+ QDeclarativeStringConverters::pointFFromString(string, &ok);
+ float data[] = { point.x(), point.y() };
+ int index = output->indexForFloat(data, 2);
+ if (type == QVariant::PointF)
+ instr.type = QDeclarativeInstruction::StorePointF;
+ else
+ instr.type = QDeclarativeInstruction::StorePoint;
+ instr.storeRealPair.propertyIndex = prop.propertyIndex();
+ instr.storeRealPair.valueIndex = index;
+ }
+ break;
+ case QVariant::Size:
+ case QVariant::SizeF:
+ {
+ bool ok;
+ QSizeF size = QDeclarativeStringConverters::sizeFFromString(string, &ok);
+ float data[] = { size.width(), size.height() };
+ int index = output->indexForFloat(data, 2);
+ if (type == QVariant::SizeF)
+ instr.type = QDeclarativeInstruction::StoreSizeF;
+ else
+ instr.type = QDeclarativeInstruction::StoreSize;
+ instr.storeRealPair.propertyIndex = prop.propertyIndex();
+ instr.storeRealPair.valueIndex = index;
+ }
+ break;
+ case QVariant::Rect:
+ case QVariant::RectF:
+ {
+ bool ok;
+ QRectF rect = QDeclarativeStringConverters::rectFFromString(string, &ok);
+ float data[] = { rect.x(), rect.y(),
+ rect.width(), rect.height() };
+ int index = output->indexForFloat(data, 4);
+ if (type == QVariant::RectF)
+ instr.type = QDeclarativeInstruction::StoreRectF;
+ else
+ instr.type = QDeclarativeInstruction::StoreRect;
+ instr.storeRect.propertyIndex = prop.propertyIndex();
+ instr.storeRect.valueIndex = index;
+ }
+ break;
+ case QVariant::Bool:
+ {
+ bool b = v->value.asBoolean();
+ instr.type = QDeclarativeInstruction::StoreBool;
+ instr.storeBool.propertyIndex = prop.propertyIndex();
+ instr.storeBool.value = b;
+ }
+ break;
+ case QVariant::Vector3D:
+ {
+ bool ok;
+ QVector3D vector =
+ QDeclarativeStringConverters::vector3DFromString(string, &ok);
+ float data[] = { vector.x(), vector.y(), vector.z() };
+ int index = output->indexForFloat(data, 3);
+ instr.type = QDeclarativeInstruction::StoreVector3D;
+ instr.storeRealPair.propertyIndex = prop.propertyIndex();
+ instr.storeRealPair.valueIndex = index;
+ }
+ break;
+ default:
+ {
+ int t = prop.userType();
+ int index = output->customTypeData.count();
+ instr.type = QDeclarativeInstruction::AssignCustomType;
+ instr.assignCustomType.propertyIndex = prop.propertyIndex();
+ instr.assignCustomType.valueIndex = index;
+
+ QDeclarativeCompiledData::CustomTypeData data;
+ data.index = output->indexForString(string);
+ data.type = t;
+ output->customTypeData << data;
+ }
+ break;
+ }
+ output->bytecode << instr;
+}
+
+/*!
+ Resets data by clearing the lists that the QDeclarativeCompiler modifies.
+*/
+void QDeclarativeCompiler::reset(QDeclarativeCompiledData *data)
+{
+ data->types.clear();
+ data->primitives.clear();
+ data->floatData.clear();
+ data->intData.clear();
+ data->customTypeData.clear();
+ data->datas.clear();
+ data->bytecode.clear();
+}
+
+/*!
+ Compile \a unit, and store the output in \a out. \a engine is the QDeclarativeEngine
+ with which the QDeclarativeCompiledData will be associated.
+
+ Returns true on success, false on failure. On failure, the compile errors
+ are available from errors().
+
+ If the environment variant QML_COMPILER_DUMP is set
+ (eg. QML_COMPILER_DUMP=1) the compiled instructions will be dumped to stderr
+ on a successful compiler.
+*/
+bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
+ QDeclarativeCompositeTypeData *unit,
+ QDeclarativeCompiledData *out)
+{
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::Compilation> pc;
+#endif
+ exceptions.clear();
+
+ Q_ASSERT(out);
+ reset(out);
+
+ output = out;
+
+ // Compile types
+ for (int ii = 0; ii < unit->types.count(); ++ii) {
+ QDeclarativeCompositeTypeData::TypeReference &tref = unit->types[ii];
+ QDeclarativeCompiledData::TypeReference ref;
+ QDeclarativeScriptParser::TypeReference *parserRef = unit->data.referencedTypes().at(ii);
+ if (tref.type)
+ ref.type = tref.type;
+ else if (tref.unit) {
+ ref.component = tref.unit->toComponent(engine);
+
+ if (ref.component->isError()) {
+ QDeclarativeError error;
+ error.setUrl(output->url);
+ error.setDescription(QLatin1String("Unable to create type ") +
+ parserRef->name);
+ if (!parserRef->refObjects.isEmpty()) {
+ QDeclarativeParser::Object *parserObject = parserRef->refObjects.first();
+ error.setLine(parserObject->location.start.line);
+ error.setColumn(parserObject->location.start.column);
+ }
+
+ exceptions << error;
+ exceptions << ref.component->errors();
+ reset(out);
+ return false;
+ }
+ ref.ref = tref.unit;
+ ref.ref->addref();
+ }
+ ref.className = parserRef->name.toUtf8();
+ out->types << ref;
+ }
+
+ Object *root = unit->data.tree();
+ Q_ASSERT(root);
+
+ this->engine = engine;
+ this->unit = unit;
+ this->unitRoot = root;
+ compileTree(root);
+
+ if (!isError()) {
+ if (compilerDump())
+ out->dumpInstructions();
+ if (compilerStatDump())
+ dumpStats();
+ } else {
+ reset(out);
+ }
+
+ compileState = ComponentCompileState();
+ savedCompileStates.clear();
+ output = 0;
+ this->engine = 0;
+ this->unit = 0;
+ this->unitRoot = 0;
+
+ return !isError();
+}
+
+void QDeclarativeCompiler::compileTree(Object *tree)
+{
+ compileState.root = tree;
+
+ if (!buildObject(tree, BindingContext()) || !completeComponentBuild())
+ return;
+
+ QDeclarativeInstruction init;
+ init.type = QDeclarativeInstruction::Init;
+ init.line = 0;
+ init.init.bindingsSize = compileState.bindings.count();
+ init.init.parserStatusSize = compileState.parserStatusCount;
+ init.init.contextCache = genContextCache();
+ if (compileState.compiledBindingData.isEmpty())
+ init.init.compiledBinding = -1;
+ else
+ init.init.compiledBinding = output->indexForByteArray(compileState.compiledBindingData);
+ output->bytecode << init;
+
+ genObject(tree);
+
+ QDeclarativeInstruction def;
+ init.line = 0;
+ def.type = QDeclarativeInstruction::SetDefault;
+ output->bytecode << def;
+
+ output->imports = unit->imports;
+ output->importCache = output->imports.cache(engine);
+
+ Q_ASSERT(tree->metatype);
+
+ if (tree->metadata.isEmpty()) {
+ output->root = tree->metatype;
+ } else {
+ static_cast<QMetaObject &>(output->rootData) = *tree->metaObject();
+ output->root = &output->rootData;
+ }
+ if (!tree->metadata.isEmpty())
+ QDeclarativeEnginePrivate::get(engine)->registerCompositeType(output);
+}
+
+static bool ValuePtrLessThan(const Value *t1, const Value *t2)
+{
+ return t1->location.start.line < t2->location.start.line ||
+ (t1->location.start.line == t2->location.start.line &&
+ t1->location.start.column < t2->location.start.column);
+}
+
+bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
+{
+ componentStat.objects++;
+
+ Q_ASSERT (obj->type != -1);
+ const QDeclarativeCompiledData::TypeReference &tr =
+ output->types.at(obj->type);
+ obj->metatype = tr.metaObject();
+
+ if (tr.component)
+ obj->url = tr.component->url();
+ if (tr.type)
+ obj->typeName = tr.type->qmlTypeName();
+ obj->className = tr.className;
+
+ // This object is a "Component" element
+ if (tr.type && obj->metatype == &QDeclarativeComponent::staticMetaObject) {
+ COMPILE_CHECK(buildComponent(obj, ctxt));
+ return true;
+ }
+
+ // Build any script blocks for this type
+ for (int ii = 0; ii < obj->scriptBlockObjects.count(); ++ii)
+ COMPILE_CHECK(buildScript(obj, obj->scriptBlockObjects.at(ii)));
+
+ // Object instantiations reset the binding context
+ BindingContext objCtxt(obj);
+
+ // Create the synthesized meta object, ignoring aliases
+ COMPILE_CHECK(mergeDynamicMetaProperties(obj));
+ COMPILE_CHECK(buildDynamicMeta(obj, IgnoreAliases));
+
+ // Find the native type and check for the QDeclarativeParserStatus interface
+ QDeclarativeType *type = toQmlType(obj);
+ Q_ASSERT(type);
+ obj->parserStatusCast = type->parserStatusCast();
+ if (obj->parserStatusCast != -1)
+ compileState.parserStatusCount++;
+
+ // Check if this is a custom parser type. Custom parser types allow
+ // assignments to non-existent properties. These assignments are then
+ // compiled by the type.
+ bool isCustomParser = output->types.at(obj->type).type &&
+ output->types.at(obj->type).type->customParser() != 0;
+ QList<QDeclarativeCustomParserProperty> customProps;
+
+ // Fetch the list of deferred properties
+ QStringList deferredList = deferredProperties(obj);
+
+ // Must do id property first. This is to ensure that the id given to any
+ // id reference created matches the order in which the objects are
+ // instantiated
+ foreach(Property *prop, obj->properties) {
+ if (prop->name == "id") {
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ break;
+ }
+ }
+
+ // Merge
+ Property *defaultProperty = 0;
+ Property *skipProperty = 0;
+ if (obj->defaultProperty) {
+ const QMetaObject *metaObject = obj->metaObject();
+ Q_ASSERT(metaObject);
+ QMetaProperty p = QDeclarativeMetaType::defaultProperty(metaObject);
+ if (p.name()) {
+ Property *explicitProperty = obj->getProperty(p.name(), false);
+ if (explicitProperty && !explicitProperty->value) {
+ skipProperty = explicitProperty;
+
+ defaultProperty = new Property;
+ defaultProperty->parent = obj;
+ defaultProperty->isDefault = true;
+ defaultProperty->location = obj->defaultProperty->location;
+ defaultProperty->listValueRange = obj->defaultProperty->listValueRange;
+ defaultProperty->listCommaPositions = obj->defaultProperty->listCommaPositions;
+
+ defaultProperty->values = obj->defaultProperty->values;
+ defaultProperty->values += explicitProperty->values;
+ foreach(Value *value, defaultProperty->values)
+ value->addref();
+ qSort(defaultProperty->values.begin(), defaultProperty->values.end(), ValuePtrLessThan);
+
+ } else {
+ defaultProperty = obj->defaultProperty;
+ defaultProperty->addref();
+ }
+ } else {
+ defaultProperty = obj->defaultProperty;
+ defaultProperty->addref();
+ }
+ }
+
+ // Build all explicit properties specified
+ foreach(Property *prop, obj->properties) {
+
+ if (prop == skipProperty)
+ continue;
+ if (prop->name == "id")
+ continue;
+
+ bool canDefer = false;
+ if (isCustomParser) {
+ if (doesPropertyExist(prop, obj)) {
+ int ids = compileState.ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState.ids.count();
+ } else {
+ customProps << QDeclarativeCustomParserNodePrivate::fromProperty(prop);
+ }
+ } else {
+ if (isSignalPropertyName(prop->name)) {
+ COMPILE_CHECK(buildSignal(prop,obj,objCtxt));
+ } else {
+ int ids = compileState.ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState.ids.count();
+ }
+ }
+
+ if (canDefer && !deferredList.isEmpty() &&
+ deferredList.contains(QString::fromUtf8(prop->name)))
+ prop->isDeferred = true;
+
+ }
+
+ // Build the default property
+ if (defaultProperty) {
+ Property *prop = defaultProperty;
+
+ bool canDefer = false;
+ if (isCustomParser) {
+ if (doesPropertyExist(prop, obj)) {
+ int ids = compileState.ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState.ids.count();
+ } else {
+ customProps << QDeclarativeCustomParserNodePrivate::fromProperty(prop);
+ }
+ } else {
+ int ids = compileState.ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState.ids.count();
+ }
+
+ if (canDefer && !deferredList.isEmpty() &&
+ deferredList.contains(QString::fromUtf8(prop->name)))
+ prop->isDeferred = true;
+ }
+
+ if (defaultProperty)
+ defaultProperty->release();
+
+ // Compile custom parser parts
+ if (isCustomParser && !customProps.isEmpty()) {
+ QDeclarativeCustomParser *cp = output->types.at(obj->type).type->customParser();
+ cp->clearErrors();
+ obj->custom = cp->compile(customProps);
+ foreach (QDeclarativeError err, cp->errors()) {
+ err.setUrl(output->url);
+ exceptions << err;
+ }
+ }
+
+ return true;
+}
+
+void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
+{
+ const QDeclarativeCompiledData::TypeReference &tr =
+ output->types.at(obj->type);
+ if (tr.type && obj->metatype == &QDeclarativeComponent::staticMetaObject) {
+ genComponent(obj);
+ return;
+ }
+
+ // Create the object
+ QDeclarativeInstruction create;
+ create.type = QDeclarativeInstruction::CreateObject;
+ create.line = obj->location.start.line;
+ create.create.column = obj->location.start.column;
+ create.create.data = -1;
+ if (!obj->custom.isEmpty())
+ create.create.data = output->indexForByteArray(obj->custom);
+ create.create.type = obj->type;
+ if (!output->types.at(create.create.type).type &&
+ !obj->bindingBitmask.isEmpty()) {
+ Q_ASSERT(obj->bindingBitmask.size() % 4 == 0);
+ create.create.bindingBits =
+ output->indexForByteArray(obj->bindingBitmask);
+ } else {
+ create.create.bindingBits = -1;
+ }
+ output->bytecode << create;
+
+ // Setup the synthesized meta object if necessary
+ if (!obj->metadata.isEmpty()) {
+ QDeclarativeInstruction meta;
+ meta.type = QDeclarativeInstruction::StoreMetaObject;
+ meta.line = 0;
+ meta.storeMeta.data = output->indexForByteArray(obj->metadata);
+ meta.storeMeta.aliasData = output->indexForByteArray(obj->synthdata);
+ meta.storeMeta.propertyCache = output->propertyCaches.count();
+ // ### Surely the creation of this property cache could be more efficient
+ QDeclarativePropertyCache *propertyCache = 0;
+ if (tr.component && QDeclarativeComponentPrivate::get(tr.component)->cc->rootPropertyCache) {
+ propertyCache = QDeclarativeComponentPrivate::get(tr.component)->cc->rootPropertyCache->copy();
+ } else {
+ propertyCache = QDeclarativePropertyCache::create(engine, obj->metaObject()->superClass());
+ }
+ propertyCache->append(engine, obj->metaObject(), QDeclarativePropertyCache::Data::NoFlags,
+ QDeclarativePropertyCache::Data::IsVMEFunction);
+ if (obj == unitRoot) {
+ propertyCache->addref();
+ output->rootPropertyCache = propertyCache;
+ }
+ output->propertyCaches << propertyCache;
+ output->bytecode << meta;
+ }
+
+ // Set the object id
+ if (!obj->id.isEmpty()) {
+ QDeclarativeInstruction id;
+ id.type = QDeclarativeInstruction::SetId;
+ id.line = 0;
+ id.setId.value = output->indexForString(obj->id);
+ id.setId.index = obj->idIndex;
+ output->bytecode << id;
+ }
+
+ // Set any script blocks
+ for (int ii = 0; ii < obj->scripts.count(); ++ii) {
+ QDeclarativeInstruction script;
+ script.type = QDeclarativeInstruction::StoreScript;
+ script.line = 0; // ###
+ int idx = output->scripts.count();
+ output->scripts << obj->scripts.at(ii);
+ script.storeScript.value = idx;
+ output->bytecode << script;
+ }
+
+ // Begin the class
+ if (obj->parserStatusCast != -1) {
+ QDeclarativeInstruction begin;
+ begin.type = QDeclarativeInstruction::BeginObject;
+ begin.begin.castValue = obj->parserStatusCast;
+ begin.line = obj->location.start.line;
+ output->bytecode << begin;
+ }
+
+ genObjectBody(obj);
+}
+
+void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
+{
+ typedef QPair<Property *, int> PropPair;
+ foreach(const PropPair &prop, obj->scriptStringProperties) {
+ QDeclarativeInstruction ss;
+ ss.type = QDeclarativeInstruction::StoreScriptString;
+ ss.storeScriptString.propertyIndex = prop.first->index;
+ ss.storeScriptString.value =
+ output->indexForString(prop.first->values.at(0)->value.asScript());
+ ss.storeScriptString.scope = prop.second;
+ output->bytecode << ss;
+ }
+
+ bool seenDefer = false;
+ foreach(Property *prop, obj->valueProperties) {
+ if (prop->isDeferred) {
+ seenDefer = true;
+ continue;
+ }
+ genValueProperty(prop, obj);
+ }
+ if (seenDefer) {
+ QDeclarativeInstruction defer;
+ defer.type = QDeclarativeInstruction::Defer;
+ defer.line = 0;
+ defer.defer.deferCount = 0;
+ int deferIdx = output->bytecode.count();
+ output->bytecode << defer;
+
+ QDeclarativeInstruction init;
+ init.type = QDeclarativeInstruction::Init;
+ init.init.bindingsSize = compileState.bindings.count(); // XXX - bigger than necessary
+ init.init.parserStatusSize = compileState.parserStatusCount; // XXX - bigger than necessary
+ init.init.contextCache = -1;
+ init.init.compiledBinding = -1;
+ output->bytecode << init;
+
+ foreach(Property *prop, obj->valueProperties) {
+ if (!prop->isDeferred)
+ continue;
+ genValueProperty(prop, obj);
+ }
+
+ output->bytecode[deferIdx].defer.deferCount =
+ output->bytecode.count() - deferIdx - 1;
+ }
+
+ foreach(Property *prop, obj->signalProperties) {
+
+ QDeclarativeParser::Value *v = prop->values.at(0);
+
+ if (v->type == Value::SignalObject) {
+
+ genObject(v->object);
+
+ QDeclarativeInstruction assign;
+ assign.type = QDeclarativeInstruction::AssignSignalObject;
+ assign.line = v->location.start.line;
+ assign.assignSignalObject.signal =
+ output->indexForByteArray(prop->name);
+ output->bytecode << assign;
+
+ } else if (v->type == Value::SignalExpression) {
+
+ QDeclarativeInstruction store;
+ store.type = QDeclarativeInstruction::StoreSignal;
+ store.line = v->location.start.line;
+ store.storeSignal.signalIndex = prop->index;
+ store.storeSignal.value =
+ output->indexForString(v->value.asScript().trimmed());
+ output->bytecode << store;
+
+ }
+
+ }
+
+ foreach(Property *prop, obj->attachedProperties) {
+ QDeclarativeInstruction fetch;
+ fetch.type = QDeclarativeInstruction::FetchAttached;
+ fetch.line = prop->location.start.line;
+ fetch.fetchAttached.id = prop->index;
+ output->bytecode << fetch;
+
+ genObjectBody(prop->value);
+
+ QDeclarativeInstruction pop;
+ pop.type = QDeclarativeInstruction::PopFetchedObject;
+ pop.line = prop->location.start.line;
+ output->bytecode << pop;
+ }
+
+ foreach(Property *prop, obj->groupedProperties) {
+ QDeclarativeInstruction fetch;
+ fetch.type = QDeclarativeInstruction::FetchObject;
+ fetch.fetch.property = prop->index;
+ fetch.line = prop->location.start.line;
+ output->bytecode << fetch;
+
+ genObjectBody(prop->value);
+
+ QDeclarativeInstruction pop;
+ pop.type = QDeclarativeInstruction::PopFetchedObject;
+ pop.line = prop->location.start.line;
+ output->bytecode << pop;
+ }
+
+ foreach(Property *prop, obj->valueTypeProperties) {
+ QDeclarativeInstruction fetch;
+ fetch.type = QDeclarativeInstruction::FetchValueType;
+ fetch.fetchValue.property = prop->index;
+ fetch.fetchValue.type = prop->type;
+ fetch.line = prop->location.start.line;
+
+ output->bytecode << fetch;
+
+ foreach(Property *vprop, prop->value->valueProperties) {
+ genPropertyAssignment(vprop, prop->value, prop);
+ }
+
+ QDeclarativeInstruction pop;
+ pop.type = QDeclarativeInstruction::PopValueType;
+ pop.fetchValue.property = prop->index;
+ pop.fetchValue.type = prop->type;
+ pop.line = prop->location.start.line;
+ output->bytecode << pop;
+ }
+}
+
+void QDeclarativeCompiler::genComponent(QDeclarativeParser::Object *obj)
+{
+ QDeclarativeParser::Object *root = obj->defaultProperty->values.at(0)->object;
+ Q_ASSERT(root);
+
+ QDeclarativeInstruction create;
+ create.type = QDeclarativeInstruction::CreateComponent;
+ create.line = root->location.start.line;
+ create.createComponent.column = root->location.start.column;
+ create.createComponent.endLine = root->location.end.line;
+ output->bytecode << create;
+ int count = output->bytecode.count();
+
+ ComponentCompileState oldCompileState = compileState;
+ compileState = componentState(root);
+
+ QDeclarativeInstruction init;
+ init.type = QDeclarativeInstruction::Init;
+ init.init.bindingsSize = compileState.bindings.count();
+ init.init.parserStatusSize = compileState.parserStatusCount;
+ init.init.contextCache = genContextCache();
+ if (compileState.compiledBindingData.isEmpty())
+ init.init.compiledBinding = -1;
+ else
+ init.init.compiledBinding = output->indexForByteArray(compileState.compiledBindingData);
+ init.line = obj->location.start.line;
+ output->bytecode << init;
+
+ genObject(root);
+
+ QDeclarativeInstruction def;
+ init.line = 0;
+ def.type = QDeclarativeInstruction::SetDefault;
+ output->bytecode << def;
+
+ output->bytecode[count - 1].createComponent.count =
+ output->bytecode.count() - count;
+
+ compileState = oldCompileState;
+
+ if (!obj->id.isEmpty()) {
+ QDeclarativeInstruction id;
+ id.type = QDeclarativeInstruction::SetId;
+ id.line = 0;
+ id.setId.value = output->indexForString(obj->id);
+ id.setId.index = obj->idIndex;
+ output->bytecode << id;
+ }
+}
+
+bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ // The special "Component" element can only have the id property and a
+ // default property, that actually defines the component's tree
+
+ // Find, check and set the "id" property (if any)
+ Property *idProp = 0;
+ if (obj->properties.count() > 1 ||
+ (obj->properties.count() == 1 && obj->properties.begin().key() != "id"))
+ COMPILE_EXCEPTION(*obj->properties.begin(), QCoreApplication::translate("QDeclarativeCompiler","Component elements may not contain properties other than id"));
+
+ if (!obj->scriptBlockObjects.isEmpty())
+ COMPILE_EXCEPTION(obj->scriptBlockObjects.first(), QCoreApplication::translate("QDeclarativeCompiler","Component elements may not contain script blocks"));
+
+ if (obj->properties.count())
+ idProp = *obj->properties.begin();
+
+ if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive())))
+ COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification"));
+
+ if (idProp) {
+ QString idVal = idProp->values.first()->primitive();
+
+ if (compileState.ids.contains(idVal))
+ COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","id is not unique"));
+
+ obj->id = idVal;
+ addId(idVal, obj);
+ }
+
+ // Check the Component tree is well formed
+ if (obj->defaultProperty &&
+ (obj->defaultProperty->value || obj->defaultProperty->values.count() > 1 ||
+ (obj->defaultProperty->values.count() == 1 && !obj->defaultProperty->values.first()->object)))
+ COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Invalid component body specification"));
+
+ Object *root = 0;
+ if (obj->defaultProperty && obj->defaultProperty->values.count())
+ root = obj->defaultProperty->values.first()->object;
+
+ if (!root)
+ COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Cannot create empty component specification"));
+
+ // Build the component tree
+ COMPILE_CHECK(buildComponentFromRoot(root, ctxt));
+
+ return true;
+}
+
+bool QDeclarativeCompiler::buildScript(QDeclarativeParser::Object *obj, QDeclarativeParser::Object *script)
+{
+ Object::ScriptBlock scriptBlock;
+
+ if (script->properties.count() == 1 &&
+ script->properties.begin().key() == QByteArray("source")) {
+
+ Property *source = *script->properties.begin();
+ if (script->defaultProperty)
+ COMPILE_EXCEPTION(source, QCoreApplication::translate("QDeclarativeCompiler","Invalid Script block. Specify either the source property or inline script"));
+
+ if (source->value || source->values.count() != 1 ||
+ source->values.at(0)->object || !source->values.at(0)->value.isStringList())
+ COMPILE_EXCEPTION(source, QCoreApplication::translate("QDeclarativeCompiler","Invalid Script source value"));
+
+ QStringList sources = source->values.at(0)->value.asStringList();
+
+ for (int jj = 0; jj < sources.count(); ++jj) {
+ QString sourceUrl = output->url.resolved(QUrl(sources.at(jj))).toString();
+ QString scriptCode;
+ int lineNumber = 1;
+
+ for (int ii = 0; ii < unit->resources.count(); ++ii) {
+ if (unit->resources.at(ii)->url == sourceUrl) {
+ scriptCode = QString::fromUtf8(unit->resources.at(ii)->data);
+ break;
+ }
+ }
+
+ if (!scriptCode.isEmpty()) {
+ scriptBlock.codes.append(scriptCode);
+ scriptBlock.files.append(sourceUrl);
+ scriptBlock.lineNumbers.append(lineNumber);
+ }
+ }
+
+ } else if (!script->properties.isEmpty()) {
+ COMPILE_EXCEPTION(*script->properties.begin(), QCoreApplication::translate("QDeclarativeCompiler","Properties cannot be set on Script block"));
+ } else if (script->defaultProperty) {
+
+ QString scriptCode;
+ int lineNumber = 1;
+ QString sourceUrl = output->url.toString();
+
+ QDeclarativeParser::Location currentLocation;
+
+ for (int ii = 0; ii < script->defaultProperty->values.count(); ++ii) {
+ Value *v = script->defaultProperty->values.at(ii);
+ if (lineNumber == 1)
+ lineNumber = v->location.start.line;
+ if (v->object || !v->value.isString())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid Script block"));
+
+ if (ii == 0) {
+ currentLocation = v->location.start;
+ scriptCode.append(QString(currentLocation.column, QLatin1Char(' ')));
+ }
+
+ while (currentLocation.line < v->location.start.line) {
+ scriptCode.append(QLatin1Char('\n'));
+ currentLocation.line++;
+ currentLocation.column = 0;
+ }
+
+ scriptCode.append(QString(v->location.start.column - currentLocation.column, QLatin1Char(' ')));
+
+ scriptCode += v->value.asString();
+ currentLocation = v->location.end;
+ currentLocation.column++;
+ }
+
+ if (!scriptCode.isEmpty()) {
+ scriptBlock.codes.append(scriptCode);
+ scriptBlock.files.append(sourceUrl);
+ scriptBlock.lineNumbers.append(lineNumber);
+ }
+ }
+
+ if (!scriptBlock.codes.isEmpty())
+ obj->scripts << scriptBlock;
+
+ return true;
+}
+
+bool QDeclarativeCompiler::buildComponentFromRoot(QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ ComponentCompileState oldComponentCompileState = compileState;
+ ComponentStat oldComponentStat = componentStat;
+
+ compileState = ComponentCompileState();
+ compileState.root = obj;
+
+ componentStat = ComponentStat();
+ componentStat.lineNumber = obj->location.start.line;
+
+ if (obj)
+ COMPILE_CHECK(buildObject(obj, ctxt));
+
+ COMPILE_CHECK(completeComponentBuild());
+
+ compileState = oldComponentCompileState;
+ componentStat = oldComponentStat;
+
+ return true;
+}
+
+
+// Build a sub-object. A sub-object is one that was not created directly by
+// QML - such as a grouped property object, or an attached object. Sub-object's
+// can't have an id, involve a custom parser, have attached properties etc.
+bool QDeclarativeCompiler::buildSubObject(Object *obj, const BindingContext &ctxt)
+{
+ Q_ASSERT(obj->metatype);
+ Q_ASSERT(!obj->defaultProperty);
+ Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding
+ // sub-context
+
+ foreach(Property *prop, obj->properties) {
+ if (isSignalPropertyName(prop->name)) {
+ COMPILE_CHECK(buildSignal(prop, obj, ctxt));
+ } else {
+ COMPILE_CHECK(buildProperty(prop, obj, ctxt));
+ }
+ }
+
+ return true;
+}
+
+int QDeclarativeCompiler::componentTypeRef()
+{
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/Component",4,6);
+ for (int ii = output->types.count() - 1; ii >= 0; --ii) {
+ if (output->types.at(ii).type == t)
+ return ii;
+ }
+ QDeclarativeCompiledData::TypeReference ref;
+ ref.className = "Component";
+ ref.type = t;
+ output->types << ref;
+ return output->types.count() - 1;
+}
+
+int QDeclarativeCompiler::findSignalByName(const QMetaObject *mo, const QByteArray &name)
+{
+ int methods = mo->methodCount();
+ for (int ii = methods - 1; ii >= 0; --ii) {
+ QMetaMethod method = mo->method(ii);
+ QByteArray methodName = method.signature();
+ int idx = methodName.indexOf('(');
+ methodName = methodName.left(idx);
+
+ if (methodName == name)
+ return ii;
+ }
+ return -1;
+}
+
+bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(obj->metaObject());
+ Q_ASSERT(!prop->isEmpty());
+
+ QByteArray name = prop->name;
+ Q_ASSERT(name.startsWith("on"));
+ name = name.mid(2);
+ if(name[0] >= 'A' && name[0] <= 'Z')
+ name[0] = name[0] - 'A' + 'a';
+
+ int sigIdx = findSignalByName(obj->metaObject(), name);
+
+ if (sigIdx == -1) {
+
+ // If the "on<Signal>" name doesn't resolve into a signal, try it as a
+ // property.
+ COMPILE_CHECK(buildProperty(prop, obj, ctxt));
+
+ } else {
+
+ if (prop->value || prop->values.count() > 1)
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Incorrectly specified signal"));
+
+ prop->index = sigIdx;
+ obj->addSignalProperty(prop);
+
+ if (prop->values.at(0)->object) {
+ COMPILE_CHECK(buildObject(prop->values.at(0)->object, ctxt));
+ prop->values.at(0)->type = Value::SignalObject;
+ } else {
+ prop->values.at(0)->type = Value::SignalExpression;
+
+ QString script = prop->values.at(0)->value.asScript().trimmed();
+ if (script.isEmpty())
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Empty signal assignment"));
+ }
+ }
+
+ return true;
+}
+
+
+/*!
+ Returns true if (value) property \a prop exists on obj, false otherwise.
+*/
+bool QDeclarativeCompiler::doesPropertyExist(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj)
+{
+ if(isAttachedPropertyName(prop->name) || prop->name == "id")
+ return true;
+
+ const QMetaObject *mo = obj->metaObject();
+ if (mo) {
+ if (prop->isDefault) {
+ QMetaProperty p = QDeclarativeMetaType::defaultProperty(mo);
+ return p.name() != 0;
+ } else {
+ int idx = mo->indexOfProperty(prop->name.constData());
+ return idx != -1;
+ }
+ }
+
+ return false;
+}
+
+bool QDeclarativeCompiler::buildProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ if (prop->isEmpty())
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Empty property assignment"));
+
+ const QMetaObject *metaObject = obj->metaObject();
+ Q_ASSERT(metaObject);
+
+ if (isAttachedPropertyName(prop->name)) {
+ // Setup attached property data
+
+ if (ctxt.isSubContext()) {
+ // Attached properties cannot be used on sub-objects. Sub-objects
+ // always exist in a binding sub-context, which is what we test
+ // for here.
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Attached properties cannot be used here"));
+ }
+
+ QDeclarativeType *type = 0;
+ QDeclarativeEnginePrivate::ImportedNamespace *typeNamespace = 0;
+ QDeclarativeEnginePrivate::get(engine)->resolveType(unit->imports, prop->name,
+ &type, 0, 0, 0, &typeNamespace);
+
+ if (typeNamespace) {
+ // ### We might need to indicate that this property is a namespace
+ // for the DOM API
+ COMPILE_CHECK(buildPropertyInNamespace(typeNamespace, prop, obj,
+ ctxt));
+ return true;
+ } else if (!type || !type->attachedPropertiesType()) {
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Non-existent attached object"));
+ }
+
+ if (!prop->value)
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Invalid attached object assignment"));
+
+ Q_ASSERT(type->attachedPropertiesFunction());
+ prop->index = type->index();
+ prop->value->metatype = type->attachedPropertiesType();
+ } else {
+ // Setup regular property data
+ QMetaProperty p;
+
+ if (prop->isDefault) {
+ p = QDeclarativeMetaType::defaultProperty(metaObject);
+
+ if (p.name()) {
+ prop->index = p.propertyIndex();
+ prop->name = p.name();
+ }
+
+ } else {
+ prop->index = metaObject->indexOfProperty(prop->name.constData());
+
+ if (prop->index != -1) {
+ p = metaObject->property(prop->index);
+ Q_ASSERT(p.name());
+ }
+ }
+
+ // We can't error here as the "id" property does not require a
+ // successful index resolution
+ if (p.name()) {
+ prop->type = p.userType();
+ }
+ }
+
+ if (prop->index != -1)
+ prop->parent->setBindingBit(prop->index);
+
+ if (!prop->isDefault && prop->name == "id" && !ctxt.isSubContext()) {
+
+ // The magic "id" behavior doesn't apply when "id" is resolved as a
+ // default property or to sub-objects (which are always in binding
+ // sub-contexts)
+ COMPILE_CHECK(buildIdProperty(prop, obj));
+ if (prop->type == QVariant::String &&
+ prop->values.at(0)->value.isString())
+ COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
+
+ } else if (isAttachedPropertyName(prop->name)) {
+
+ COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt));
+
+ } else if (prop->index == -1) {
+
+ if (prop->isDefault) {
+ COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QDeclarativeCompiler","Cannot assign to non-existent default property"));
+ } else {
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(prop->name)));
+ }
+
+ } else if (prop->value) {
+
+ COMPILE_CHECK(buildGroupedProperty(prop, obj, ctxt));
+
+ } else if (QDeclarativeEnginePrivate::get(engine)->isList(prop->type)) {
+
+ COMPILE_CHECK(buildListProperty(prop, obj, ctxt));
+
+ } else if (prop->type == qMetaTypeId<QDeclarativeScriptString>()) {
+
+ COMPILE_CHECK(buildScriptStringProperty(prop, obj, ctxt));
+
+ } else {
+
+ COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
+
+ }
+
+ return true;
+}
+
+bool
+QDeclarativeCompiler::buildPropertyInNamespace(QDeclarativeEnginePrivate::ImportedNamespace *ns,
+ QDeclarativeParser::Property *nsProp,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ if (!nsProp->value)
+ COMPILE_EXCEPTION(nsProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid use of namespace"));
+
+ foreach (Property *prop, nsProp->value->properties) {
+
+ if (!isAttachedPropertyName(prop->name))
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Not an attached property name"));
+
+ // Setup attached property data
+
+ QDeclarativeType *type = 0;
+ QDeclarativeEnginePrivate::get(engine)->resolveTypeInNamespace(ns, prop->name,
+ &type, 0, 0, 0);
+
+ if (!type || !type->attachedPropertiesType())
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Non-existent attached object"));
+
+ if (!prop->value)
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Invalid attached object assignment"));
+
+ Q_ASSERT(type->attachedPropertiesFunction());
+ prop->index = type->index();
+ prop->value->metatype = type->attachedPropertiesType();
+
+ COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt));
+ }
+
+ return true;
+}
+
+void QDeclarativeCompiler::genValueProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj)
+{
+ if (QDeclarativeEnginePrivate::get(engine)->isList(prop->type)) {
+ genListProperty(prop, obj);
+ } else {
+ genPropertyAssignment(prop, obj);
+ }
+}
+
+void QDeclarativeCompiler::genListProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj)
+{
+ int listType = QDeclarativeEnginePrivate::get(engine)->listType(prop->type);
+
+ QDeclarativeInstruction fetch;
+ fetch.type = QDeclarativeInstruction::FetchQList;
+ fetch.line = prop->location.start.line;
+ fetch.fetchQmlList.property = prop->index;
+ bool listTypeIsInterface = QDeclarativeMetaType::isInterface(listType);
+ fetch.fetchQmlList.type = listType;
+ output->bytecode << fetch;
+
+ for (int ii = 0; ii < prop->values.count(); ++ii) {
+ Value *v = prop->values.at(ii);
+
+ if (v->type == Value::CreatedObject) {
+
+ genObject(v->object);
+ if (listTypeIsInterface) {
+ QDeclarativeInstruction assign;
+ assign.type = QDeclarativeInstruction::AssignObjectList;
+ assign.line = prop->location.start.line;
+ output->bytecode << assign;
+ } else {
+ QDeclarativeInstruction store;
+ store.type = QDeclarativeInstruction::StoreObjectQList;
+ store.line = prop->location.start.line;
+ output->bytecode << store;
+ }
+
+ } else if (v->type == Value::PropertyBinding) {
+
+ genBindingAssignment(v, prop, obj);
+
+ }
+
+ }
+
+ QDeclarativeInstruction pop;
+ pop.type = QDeclarativeInstruction::PopQList;
+ pop.line = prop->location.start.line;
+ output->bytecode << pop;
+}
+
+void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Property *valueTypeProperty)
+{
+ for (int ii = 0; ii < prop->values.count(); ++ii) {
+ QDeclarativeParser::Value *v = prop->values.at(ii);
+
+ if (v->type == Value::CreatedObject) {
+
+ genObject(v->object);
+
+ if (QDeclarativeMetaType::isInterface(prop->type)) {
+
+ QDeclarativeInstruction store;
+ store.type = QDeclarativeInstruction::StoreInterface;
+ store.line = v->object->location.start.line;
+ store.storeObject.propertyIndex = prop->index;
+ output->bytecode << store;
+
+ } else if (prop->type == -1) {
+
+ QDeclarativeInstruction store;
+ store.type = QDeclarativeInstruction::StoreVariantObject;
+ store.line = v->object->location.start.line;
+ store.storeObject.propertyIndex = prop->index;
+ output->bytecode << store;
+
+ } else {
+
+ QDeclarativeInstruction store;
+ store.type = QDeclarativeInstruction::StoreObject;
+ store.line = v->object->location.start.line;
+ store.storeObject.propertyIndex = prop->index;
+ output->bytecode << store;
+
+ }
+ } else if (v->type == Value::ValueSource) {
+ genObject(v->object);
+
+ QDeclarativeInstruction store;
+ store.type = QDeclarativeInstruction::StoreValueSource;
+ store.line = v->object->location.start.line;
+ if (valueTypeProperty) {
+ store.assignValueSource.property = genValueTypeData(prop, valueTypeProperty);
+ store.assignValueSource.owner = 1;
+ } else {
+ store.assignValueSource.property = genPropertyData(prop);
+ store.assignValueSource.owner = 0;
+ }
+ QDeclarativeType *valueType = toQmlType(v->object);
+ store.assignValueSource.castValue = valueType->propertyValueSourceCast();
+ output->bytecode << store;
+
+ } else if (v->type == Value::ValueInterceptor) {
+ genObject(v->object);
+
+ QDeclarativeInstruction store;
+ store.type = QDeclarativeInstruction::StoreValueInterceptor;
+ store.line = v->object->location.start.line;
+ if (valueTypeProperty) {
+ store.assignValueInterceptor.property = genValueTypeData(prop, valueTypeProperty);
+ store.assignValueInterceptor.owner = 1;
+ } else {
+ store.assignValueInterceptor.property = genPropertyData(prop);
+ store.assignValueInterceptor.owner = 0;
+ }
+ QDeclarativeType *valueType = toQmlType(v->object);
+ store.assignValueInterceptor.castValue = valueType->propertyValueInterceptorCast();
+ output->bytecode << store;
+
+ } else if (v->type == Value::PropertyBinding) {
+
+ genBindingAssignment(v, prop, obj, valueTypeProperty);
+
+ } else if (v->type == Value::Literal) {
+
+ QMetaProperty mp = obj->metaObject()->property(prop->index);
+ genLiteralAssignment(mp, v);
+
+ }
+
+ }
+}
+
+bool QDeclarativeCompiler::buildIdProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj)
+{
+ if (prop->value ||
+ prop->values.count() > 1 ||
+ prop->values.at(0)->object)
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Invalid use of id property"));
+
+ QDeclarativeParser::Value *idValue = prop->values.at(0);
+ QString val = idValue->primitive();
+
+ if (!isValidId(val))
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" is not a valid object id").arg(val));
+
+ // We disallow id's that conflict with import prefixes and types
+ QDeclarativeEnginePrivate::ImportedNamespace *ns = 0;
+ QDeclarativeType *type = 0;
+ QDeclarativeEnginePrivate::get(engine)->resolveType(unit->imports, val.toUtf8(),
+ &type, 0, 0, 0, &ns);
+ if (type)
+ COMPILE_EXCEPTION(idValue, QCoreApplication::translate("QDeclarativeCompiler","id conflicts with type name"));
+ if (ns)
+ COMPILE_EXCEPTION(idValue, QCoreApplication::translate("QDeclarativeCompiler","id conflicts with namespace prefix"));
+
+ if (compileState.ids.contains(val))
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","id is not unique"));
+
+ prop->values.at(0)->type = Value::Id;
+
+ obj->id = val;
+ addId(val, obj);
+
+ return true;
+}
+
+void QDeclarativeCompiler::addId(const QString &id, QDeclarativeParser::Object *obj)
+{
+ Q_ASSERT(!compileState.ids.contains(id));
+ Q_ASSERT(obj->id == id);
+ obj->idIndex = compileState.ids.count();
+ compileState.ids.insert(id, obj);
+ compileState.idIndexes.insert(obj->idIndex, obj);
+}
+
+void QDeclarativeCompiler::addBindingReference(const BindingReference &ref)
+{
+ Q_ASSERT(ref.value && !compileState.bindings.contains(ref.value));
+ compileState.bindings.insert(ref.value, ref);
+}
+
+void QDeclarativeCompiler::saveComponentState()
+{
+ Q_ASSERT(compileState.root);
+ Q_ASSERT(!savedCompileStates.contains(compileState.root));
+
+ savedCompileStates.insert(compileState.root, compileState);
+ savedComponentStats.append(componentStat);
+}
+
+QDeclarativeCompiler::ComponentCompileState
+QDeclarativeCompiler::componentState(QDeclarativeParser::Object *obj)
+{
+ Q_ASSERT(savedCompileStates.contains(obj));
+ return savedCompileStates.value(obj);
+}
+
+// Build attached property object. In this example,
+// Text {
+// GridView.row: 10
+// }
+// GridView is an attached property object.
+bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->value);
+ Q_ASSERT(prop->index != -1); // This is set in buildProperty()
+
+ obj->addAttachedProperty(prop);
+
+ COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
+
+ return true;
+}
+
+
+// Build "grouped" properties. In this example:
+// Text {
+// font.pointSize: 12
+// font.family: "Helvetica"
+// }
+// font is a nested property. pointSize and family are not.
+bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->type != 0);
+ Q_ASSERT(prop->index != -1);
+
+ if (prop->values.count())
+ COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QDeclarativeCompiler", "Invalid value in grouped property"));
+
+ if (prop->type < (int)QVariant::UserType) {
+ QDeclarativeEnginePrivate *ep =
+ static_cast<QDeclarativeEnginePrivate *>(QObjectPrivate::get(engine));
+ if (prop->type >= 0 /* QVariant == -1 */ && ep->valueTypes[prop->type]) {
+ COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type],
+ prop->value, obj, ctxt.incr()));
+ obj->addValueTypeProperty(prop);
+ } else {
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Invalid grouped property access"));
+ }
+
+ } else {
+ // Load the nested property's meta type
+ prop->value->metatype =
+ QDeclarativeEnginePrivate::get(engine)->metaObjectForType(prop->type);
+ if (!prop->value->metatype)
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Invalid grouped property access"));
+
+ obj->addGroupedProperty(prop);
+
+ COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
+ }
+
+ return true;
+}
+
+bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Object *baseObj,
+ const BindingContext &ctxt)
+{
+ if (obj->defaultProperty)
+ COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Invalid property use"));
+ obj->metatype = type->metaObject();
+
+ foreach (Property *prop, obj->properties) {
+ int idx = type->metaObject()->indexOfProperty(prop->name.constData());
+ if (idx == -1)
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(prop->name)));
+ QMetaProperty p = type->metaObject()->property(idx);
+ prop->index = idx;
+ prop->type = p.userType();
+
+ if (prop->value)
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Property assignment expected"));
+
+ if (prop->values.count() != 1)
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Single property assignment expected"));
+
+ Value *value = prop->values.at(0);
+
+ if (value->object) {
+ bool isPropertyValue = output->types.at(value->object->type).type->propertyValueSourceCast() != -1;
+ bool isPropertyInterceptor = output->types.at(value->object->type).type->propertyValueInterceptorCast() != -1;
+ if (!isPropertyValue && !isPropertyInterceptor) {
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Unexpected object assignment"));
+ } else {
+ COMPILE_CHECK(buildObject(value->object, ctxt));
+
+ if (isPropertyInterceptor && baseObj->synthdata.isEmpty())
+ buildDynamicMeta(baseObj, ForceCreation);
+ value->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
+ }
+ } else if (value->value.isScript()) {
+ // ### Check for writability
+ BindingReference reference;
+ reference.expression = value->value;
+ reference.property = prop;
+ reference.value = value;
+ reference.bindingContext = ctxt;
+ reference.bindingContext.owner++;
+ addBindingReference(reference);
+ value->type = Value::PropertyBinding;
+ } else {
+ COMPILE_CHECK(testLiteralAssignment(p, value));
+ value->type = Value::Literal;
+ }
+ obj->addValueProperty(prop);
+ }
+
+ return true;
+}
+
+// Build assignments to QML lists. QML lists are properties of type
+// QList<T *> * and QDeclarativeList<T *> *.
+//
+// QList<T *> * types can accept a list of objects, or a single binding
+// QDeclarativeList<T *> * types can accept a list of objects
+bool QDeclarativeCompiler::buildListProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(QDeclarativeEnginePrivate::get(engine)->isList(prop->type));
+
+ int t = prop->type;
+
+ obj->addValueProperty(prop);
+
+ int listType = QDeclarativeEnginePrivate::get(engine)->listType(t);
+ bool listTypeIsInterface = QDeclarativeMetaType::isInterface(listType);
+
+ bool assignedBinding = false;
+ for (int ii = 0; ii < prop->values.count(); ++ii) {
+ Value *v = prop->values.at(ii);
+ if (v->object) {
+ v->type = Value::CreatedObject;
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ // We check object coercian here. We check interface assignment
+ // at runtime.
+ if (!listTypeIsInterface) {
+ if (!canCoerce(listType, v->object)) {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Cannot assign object to list"));
+ }
+ }
+
+ } else if (v->value.isScript()) {
+ if (assignedBinding)
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Can only assign one binding to lists"));
+
+ assignedBinding = true;
+ COMPILE_CHECK(buildBinding(v, prop, ctxt));
+ v->type = Value::PropertyBinding;
+ } else {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Cannot assign primitives to lists"));
+ }
+ }
+
+ return true;
+}
+
+// Compiles an assignment to a QDeclarativeScriptString property
+bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ if (prop->values.count() > 1)
+ COMPILE_EXCEPTION(prop->values.at(1), QCoreApplication::translate("QDeclarativeCompiler", "Cannot assign multiple values to a script property"));
+
+ if (prop->values.at(0)->object || !prop->values.at(0)->value.isScript())
+ COMPILE_EXCEPTION(prop->values.at(0), QCoreApplication::translate("QDeclarativeCompiler", "Invalid property assignment: script expected"));
+
+ obj->addScriptStringProperty(prop, ctxt.stack);
+
+ return true;
+}
+
+// Compile regular property assignments of the form "property: <value>"
+//
+// ### The following problems exist
+//
+// There is no distinction between how "lists" of values are specified. This
+// Item {
+// children: Item {}
+// children: Item {}
+// }
+// is identical to
+// Item {
+// children: [ Item {}, Item {} ]
+// }
+//
+// We allow assignming multiple values to single value properties
+bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ obj->addValueProperty(prop);
+
+ for (int ii = 0; ii < prop->values.count(); ++ii) {
+ Value *v = prop->values.at(ii);
+ if (v->object) {
+
+ COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
+
+ } else {
+
+ COMPILE_CHECK(buildPropertyLiteralAssignment(prop, obj, v, ctxt));
+
+ }
+ }
+
+ return true;
+}
+
+// Compile assigning a single object instance to a regular property
+bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Value *v,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->index != -1);
+ Q_ASSERT(v->object->type != -1);
+
+ if (!obj->metaObject()->property(prop->index).isWritable())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name)));
+
+ if (QDeclarativeMetaType::isInterface(prop->type)) {
+
+ // Assigning an object to an interface ptr property
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ v->type = Value::CreatedObject;
+
+ } else if (prop->type == -1) {
+
+ // Assigning an object to a QVariant
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ v->type = Value::CreatedObject;
+ } else {
+ // Normally buildObject() will set this up, but we need the static
+ // meta object earlier to test for assignability. It doesn't matter
+ // that there may still be outstanding synthesized meta object changes
+ // on this type, as they are not relevant for assignability testing
+ v->object->metatype = output->types.at(v->object->type).metaObject();
+ Q_ASSERT(v->object->metaObject());
+
+ // Will be true if the assigned type inherits QDeclarativePropertyValueSource
+ bool isPropertyValue = false;
+ // Will be true if the assigned type inherits QDeclarativePropertyValueInterceptor
+ bool isPropertyInterceptor = false;
+ if (QDeclarativeType *valueType = toQmlType(v->object)) {
+ isPropertyValue = valueType->propertyValueSourceCast() != -1;
+ isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1;
+ }
+
+ // We want to raw metaObject here as the raw metaobject is the
+ // actual property type before we applied any extensions that might
+ // effect the properties on the type, but don't effect assignability
+ const QMetaObject *propertyMetaObject =
+ QDeclarativeEnginePrivate::get(engine)->rawMetaObjectForType(prop->type);
+
+ // Will be true if the assgned type inherits propertyMetaObject
+ bool isAssignable = false;
+ // Determine isAssignable value
+ if (propertyMetaObject) {
+ const QMetaObject *c = v->object->metatype;
+ while(c) {
+ isAssignable |= (QDeclarativeMetaPropertyPrivate::equal(c, propertyMetaObject));
+ c = c->superClass();
+ }
+ }
+
+ if (isAssignable) {
+ // Simple assignment
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ v->type = Value::CreatedObject;
+ } else if (propertyMetaObject == &QDeclarativeComponent::staticMetaObject) {
+ // Automatic "Component" insertion
+ QDeclarativeParser::Object *root = v->object;
+ QDeclarativeParser::Object *component = new QDeclarativeParser::Object;
+ component->type = componentTypeRef();
+ component->typeName = "Qt/Component";
+ component->metatype = &QDeclarativeComponent::staticMetaObject;
+ component->location = root->location;
+ QDeclarativeParser::Value *componentValue = new QDeclarativeParser::Value;
+ componentValue->object = root;
+ component->getDefaultProperty()->addValue(componentValue);
+ v->object = component;
+ COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
+ } else if (isPropertyValue || isPropertyInterceptor) {
+ // Assign as a property value source
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ if (isPropertyInterceptor && prop->parent->synthdata.isEmpty())
+ buildDynamicMeta(prop->parent, ForceCreation);
+ v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
+ } else {
+ COMPILE_EXCEPTION(v->object, QCoreApplication::translate("QDeclarativeCompiler","Cannot assign object to property"));
+ }
+ }
+
+ return true;
+}
+
+// Compile assigning a literal or binding to a regular property
+bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Value *v,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->index != -1);
+
+ if (v->value.isScript()) {
+
+ //optimization for <Type>.<EnumValue> enum assignments
+ bool isEnumAssignment = false;
+ COMPILE_CHECK(testQualifiedEnumAssignment(obj->metaObject()->property(prop->index), obj, v, &isEnumAssignment));
+ if (isEnumAssignment) {
+ v->type = Value::Literal;
+ return true;
+ }
+
+ COMPILE_CHECK(buildBinding(v, prop, ctxt));
+
+ v->type = Value::PropertyBinding;
+
+ } else {
+
+ COMPILE_CHECK(testLiteralAssignment(obj->metaObject()->property(prop->index), v));
+
+ v->type = Value::Literal;
+ }
+
+ return true;
+}
+
+bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Value *v,
+ bool *isAssignment)
+{
+ *isAssignment = false;
+ if (!prop.isEnumType())
+ return true;
+
+ if (!prop.isWritable())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name())));
+
+ QString string = v->value.asString();
+ if (!string.at(0).isUpper())
+ return true;
+
+ QStringList parts = string.split(QLatin1Char('.'));
+ if (parts.count() != 2)
+ return true;
+
+ QString typeName = parts.at(0);
+ QDeclarativeType *type = 0;
+ QDeclarativeEnginePrivate::get(engine)->resolveType(unit->imports, typeName.toUtf8(),
+ &type, 0, 0, 0, 0);
+
+ if (!type || obj->typeName != type->qmlTypeName())
+ return true;
+
+ QString enumValue = parts.at(1);
+ int value;
+ if (prop.isFlagType()) {
+ value = prop.enumerator().keysToValue(enumValue.toUtf8().constData());
+ } else
+ value = prop.enumerator().keyToValue(enumValue.toUtf8().constData());
+ if (value == -1)
+ return true;
+
+ v->type = Value::Literal;
+ v->value = QDeclarativeParser::Variant(enumValue);
+ *isAssignment = true;
+
+ return true;
+}
+
+// Ensures that the dynamic meta specification on obj is valid
+bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
+{
+ QSet<QByteArray> propNames;
+ QSet<QByteArray> methodNames;
+ bool seenDefaultProperty = false;
+
+ // Check properties
+ for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
+ const QDeclarativeParser::Object::DynamicProperty &prop =
+ obj->dynamicProperties.at(ii);
+
+ if (prop.isDefaultProperty) {
+ if (seenDefaultProperty)
+ COMPILE_EXCEPTION(&prop, QCoreApplication::translate("QDeclarativeCompiler","Duplicate default property"));
+ seenDefaultProperty = true;
+ }
+
+ if (propNames.contains(prop.name))
+ COMPILE_EXCEPTION(&prop, QCoreApplication::translate("QDeclarativeCompiler","Duplicate property name"));
+
+ propNames.insert(prop.name);
+ }
+
+ for (int ii = 0; ii < obj->dynamicSignals.count(); ++ii) {
+ QByteArray name = obj->dynamicSignals.at(ii).name;
+ if (methodNames.contains(name))
+ COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Duplicate signal name"));
+ methodNames.insert(name);
+ }
+ for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
+ QByteArray name = obj->dynamicSlots.at(ii).name;
+ if (methodNames.contains(name))
+ COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Duplicate method name"));
+ methodNames.insert(name);
+ }
+
+ return true;
+}
+
+bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeParser::Object *obj)
+{
+ for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
+ const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
+
+ if (!p.defaultValue || p.type == Object::DynamicProperty::Alias)
+ continue;
+
+ Property *property = 0;
+ if (p.isDefaultProperty)
+ property = obj->getDefaultProperty();
+ else
+ property = obj->getProperty(p.name);
+
+ if (property->value)
+ COMPILE_EXCEPTION(property, QCoreApplication::translate("QDeclarativeCompiler","Invalid property nesting"));
+
+ for (int ii = 0; ii < p.defaultValue->values.count(); ++ii) {
+ Value *v = p.defaultValue->values.at(ii);
+ v->addref();
+ property->values.append(v);
+ }
+ }
+ return true;
+}
+
+Q_GLOBAL_STATIC(QAtomicInt, classIndexCounter)
+
+bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, DynamicMetaMode mode)
+{
+ Q_ASSERT(obj);
+ Q_ASSERT(obj->metatype);
+
+ if (mode != ForceCreation &&
+ obj->dynamicProperties.isEmpty() &&
+ obj->dynamicSignals.isEmpty() &&
+ obj->dynamicSlots.isEmpty())
+ return true;
+
+ COMPILE_CHECK(checkDynamicMeta(obj));
+
+ QByteArray dynamicData(sizeof(QDeclarativeVMEMetaData), (char)0);
+
+ QByteArray newClassName = obj->metatype->className();
+ newClassName.append("_QML_");
+ int idx = classIndexCounter()->fetchAndAddRelaxed(1);
+ newClassName.append(QByteArray::number(idx));
+ if (compileState.root == obj) {
+ QString path = output->url.path();
+ int lastSlash = path.lastIndexOf(QLatin1Char('/'));
+ if (lastSlash > -1) {
+ QString nameBase = path.mid(lastSlash + 1, path.length()-lastSlash-5);
+ if (!nameBase.isEmpty() && nameBase.at(0).isUpper())
+ newClassName = nameBase.toUtf8() + "_QMLTYPE_" + QByteArray::number(idx);
+ }
+ }
+
+ QMetaObjectBuilder builder;
+ builder.setClassName(newClassName);
+ builder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
+
+ bool hasAlias = false;
+ for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
+ const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
+
+ int propIdx =
+ obj->metaObject()->indexOfProperty(p.name.constData());
+ if (-1 != propIdx) {
+ QMetaProperty prop = obj->metaObject()->property(propIdx);
+ if (prop.isFinal())
+ COMPILE_EXCEPTION(&p, QCoreApplication::translate("QDeclarativeCompiler","Cannot override FINAL property"));
+ }
+
+ if (p.isDefaultProperty &&
+ (p.type != Object::DynamicProperty::Alias ||
+ mode == ResolveAliases))
+ builder.addClassInfo("DefaultProperty", p.name);
+
+ QByteArray type;
+ int propertyType = 0;
+ bool readonly = false;
+ switch(p.type) {
+ case Object::DynamicProperty::Alias:
+ hasAlias = true;
+ continue;
+ break;
+ case Object::DynamicProperty::CustomList:
+ case Object::DynamicProperty::Custom:
+ {
+ QByteArray customTypeName;
+ QDeclarativeType *qmltype = 0;
+ QUrl url;
+ QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(engine);
+ if (!priv->resolveType(unit->imports, p.customType, &qmltype,
+ &url, 0, 0, 0))
+ COMPILE_EXCEPTION(&p, QCoreApplication::translate("QDeclarativeCompiler","Invalid property type"));
+
+ if (!qmltype) {
+ QDeclarativeCompositeTypeData *tdata = priv->typeManager.get(url);
+ Q_ASSERT(tdata);
+ Q_ASSERT(tdata->status == QDeclarativeCompositeTypeData::Complete);
+
+ QDeclarativeCompiledData *data = tdata->toCompiledComponent(engine);
+ customTypeName = data->root->className();
+ } else {
+ customTypeName = qmltype->typeName();
+ }
+
+ if (p.type == Object::DynamicProperty::Custom) {
+ type = customTypeName + '*';
+ propertyType = QMetaType::QObjectStar;
+ } else {
+ readonly = true;
+ type = "QDeclarativeListProperty<";
+ type.append(customTypeName);
+ type.append(">");
+ propertyType = qMetaTypeId<QDeclarativeListProperty<QObject> >();
+ }
+ }
+ break;
+ case Object::DynamicProperty::Variant:
+ propertyType = -1;
+ type = "QVariant";
+ break;
+ case Object::DynamicProperty::Int:
+ propertyType = QVariant::Int;
+ type = "int";
+ break;
+ case Object::DynamicProperty::Bool:
+ propertyType = QVariant::Bool;
+ type = "bool";
+ break;
+ case Object::DynamicProperty::Real:
+ propertyType = QVariant::Double;
+ type = "double";
+ break;
+ case Object::DynamicProperty::String:
+ propertyType = QVariant::String;
+ type = "QString";
+ break;
+ case Object::DynamicProperty::Url:
+ propertyType = QVariant::Url;
+ type = "QUrl";
+ break;
+ case Object::DynamicProperty::Color:
+ propertyType = QVariant::Color;
+ type = "QColor";
+ break;
+ case Object::DynamicProperty::Date:
+ propertyType = QVariant::Date;
+ type = "QDate";
+ break;
+ }
+
+ ((QDeclarativeVMEMetaData *)dynamicData.data())->propertyCount++;
+ QDeclarativeVMEMetaData::PropertyData propertyData = { propertyType };
+ dynamicData.append((char *)&propertyData, sizeof(propertyData));
+
+ builder.addSignal(p.name + "Changed()");
+ QMetaPropertyBuilder propBuilder =
+ builder.addProperty(p.name, type, builder.methodCount() - 1);
+ propBuilder.setScriptable(true);
+ propBuilder.setWritable(!readonly);
+ }
+
+ if (mode == ResolveAliases) {
+ for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
+ const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
+
+ if (p.type == Object::DynamicProperty::Alias) {
+ ((QDeclarativeVMEMetaData *)dynamicData.data())->aliasCount++;
+ compileAlias(builder, dynamicData, obj, p);
+ }
+ }
+ }
+
+ for (int ii = 0; ii < obj->dynamicSignals.count(); ++ii) {
+ const Object::DynamicSignal &s = obj->dynamicSignals.at(ii);
+ QByteArray sig(s.name + '(');
+ for (int jj = 0; jj < s.parameterTypes.count(); ++jj) {
+ if (jj) sig.append(',');
+ sig.append(s.parameterTypes.at(jj));
+ }
+ sig.append(')');
+ QMetaMethodBuilder b = builder.addSignal(sig);
+ b.setParameterNames(s.parameterNames);
+ ((QDeclarativeVMEMetaData *)dynamicData.data())->signalCount++;
+ }
+
+ QStringList funcScripts;
+
+ for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
+ Object::DynamicSlot &s = obj->dynamicSlots[ii];
+ QByteArray sig(s.name + '(');
+ QString funcScript(QLatin1String("(function("));
+
+ for (int jj = 0; jj < s.parameterNames.count(); ++jj) {
+ if (jj) {
+ sig.append(',');
+ funcScript.append(QLatin1Char(','));
+ }
+ funcScript.append(QLatin1String(s.parameterNames.at(jj)));
+ sig.append("QVariant");
+ }
+ sig.append(')');
+ funcScript.append(QLatin1Char(')'));
+ funcScript.append(s.body);
+ funcScript.append(QLatin1Char(')'));
+ funcScripts << funcScript;
+
+ QMetaMethodBuilder b = builder.addSlot(sig);
+ b.setReturnType("QVariant");
+ b.setParameterNames(s.parameterNames);
+
+ ((QDeclarativeVMEMetaData *)dynamicData.data())->methodCount++;
+ QDeclarativeVMEMetaData::MethodData methodData =
+ { s.parameterNames.count(), 0, funcScript.length(), 0 };
+
+ dynamicData.append((char *)&methodData, sizeof(methodData));
+ }
+
+ for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
+ const QString &funcScript = funcScripts.at(ii);
+ QDeclarativeVMEMetaData::MethodData *data =
+ ((QDeclarativeVMEMetaData *)dynamicData.data())->methodData() + ii;
+
+ data->bodyOffset = dynamicData.size();
+
+ dynamicData.append((const char *)funcScript.constData(),
+ (funcScript.length() * sizeof(QChar)));
+ }
+
+ obj->metadata = builder.toRelocatableData();
+ builder.fromRelocatableData(&obj->extObject, obj->metatype, obj->metadata);
+
+ if (mode == IgnoreAliases && hasAlias)
+ compileState.aliasingObjects << obj;
+
+ obj->synthdata = dynamicData;
+
+ return true;
+}
+
+#include <qdeclarativejsparser_p.h>
+
+static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node)
+{
+ if (node->kind == QDeclarativeJS::AST::Node::Kind_IdentifierExpression) {
+ QString name =
+ static_cast<QDeclarativeJS::AST::IdentifierExpression *>(node)->name->asString();
+ return QStringList() << name;
+ } else if (node->kind == QDeclarativeJS::AST::Node::Kind_FieldMemberExpression) {
+ QDeclarativeJS::AST::FieldMemberExpression *expr = static_cast<QDeclarativeJS::AST::FieldMemberExpression *>(node);
+
+ QStringList rv = astNodeToStringList(expr->base);
+ if (rv.isEmpty())
+ return rv;
+ rv.append(expr->name->asString());
+ return rv;
+ }
+ return QStringList();
+}
+
+bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
+ QByteArray &data,
+ Object *obj,
+ const Object::DynamicProperty &prop)
+{
+ if (!prop.defaultValue)
+ COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","No property alias location"));
+
+ if (prop.defaultValue->values.count() != 1 ||
+ prop.defaultValue->values.at(0)->object ||
+ !prop.defaultValue->values.at(0)->value.isScript())
+ COMPILE_EXCEPTION(prop.defaultValue, QCoreApplication::translate("QDeclarativeCompiler","Invalid alias location"));
+
+ QDeclarativeJS::AST::Node *node = prop.defaultValue->values.at(0)->value.asAST();
+ if (!node)
+ COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","No property alias location")); // ### Can this happen?
+
+ QStringList alias = astNodeToStringList(node);
+
+ if (alias.count() != 1 && alias.count() != 2)
+ COMPILE_EXCEPTION(prop.defaultValue, QCoreApplication::translate("QDeclarativeCompiler","Invalid alias reference. An alias reference must be specified as <id> or <id>.<property>"));
+
+ if (!compileState.ids.contains(alias.at(0)))
+ COMPILE_EXCEPTION(prop.defaultValue, QCoreApplication::translate("QDeclarativeCompiler","Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0)));
+
+ Object *idObject = compileState.ids[alias.at(0)];
+
+ QByteArray typeName;
+
+ int propIdx = -1;
+ int flags = 0;
+ bool writable = false;
+ if (alias.count() == 2) {
+ propIdx = idObject->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData());
+
+ if (-1 == propIdx)
+ COMPILE_EXCEPTION(prop.defaultValue, QCoreApplication::translate("QDeclarativeCompiler","Invalid alias location"));
+
+ QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx);
+ writable = aliasProperty.isWritable();
+
+ if (aliasProperty.isEnumType())
+ typeName = "int"; // Avoid introducing a dependency on the aliased metaobject
+ else
+ typeName = aliasProperty.typeName();
+ } else {
+ typeName = idObject->metaObject()->className();
+
+ //use the base type since it has been registered with metatype system
+ int index = typeName.indexOf("_QML_");
+ if (index != -1) {
+ typeName = typeName.left(index);
+ } else {
+ index = typeName.indexOf("_QMLTYPE_");
+ const QMetaObject *mo = idObject->metaObject();
+ while (index != -1 && mo) {
+ typeName = mo->superClass()->className();
+ index = typeName.indexOf("_QMLTYPE_");
+ mo = mo->superClass();
+ }
+ }
+
+ typeName += '*';
+ }
+
+ if (typeName.endsWith('*'))
+ flags |= QML_ALIAS_FLAG_PTR;
+
+ data.append((const char *)&idObject->idIndex, sizeof(idObject->idIndex));
+ data.append((const char *)&propIdx, sizeof(propIdx));
+ data.append((const char *)&flags, sizeof(flags));
+
+ builder.addSignal(prop.name + "Changed()");
+ QMetaPropertyBuilder propBuilder =
+ builder.addProperty(prop.name, typeName.constData(), builder.methodCount() - 1);
+ propBuilder.setScriptable(true);
+ propBuilder.setWritable(writable);
+ return true;
+}
+
+bool QDeclarativeCompiler::buildBinding(QDeclarativeParser::Value *value,
+ QDeclarativeParser::Property *prop,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->index != -1);
+ Q_ASSERT(prop->parent);
+ Q_ASSERT(prop->parent->metaObject());
+
+ QMetaProperty mp = prop->parent->metaObject()->property(prop->index);
+ if (!mp.isWritable() && !QDeclarativeMetaType::isList(prop->type))
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name)));
+
+ BindingReference reference;
+ reference.expression = value->value;
+ reference.property = prop;
+ reference.value = value;
+ reference.bindingContext = ctxt;
+ addBindingReference(reference);
+
+ return true;
+}
+
+void QDeclarativeCompiler::genBindingAssignment(QDeclarativeParser::Value *binding,
+ QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Property *valueTypeProperty)
+{
+ Q_UNUSED(obj);
+ Q_ASSERT(compileState.bindings.contains(binding));
+
+ const BindingReference &ref = compileState.bindings.value(binding);
+ if (ref.dataType == BindingReference::Experimental) {
+ QDeclarativeInstruction store;
+ store.type = QDeclarativeInstruction::StoreCompiledBinding;
+ store.assignBinding.value = ref.compiledIndex;
+ store.assignBinding.context = ref.bindingContext.stack;
+ store.assignBinding.owner = ref.bindingContext.owner;
+ if (valueTypeProperty)
+ store.assignBinding.property = (valueTypeProperty->index & 0xFFFF) |
+ ((valueTypeProperty->type & 0xFF)) << 16 |
+ ((prop->index & 0xFF) << 24);
+ else
+ store.assignBinding.property = prop->index;
+ store.line = binding->location.start.line;
+ output->bytecode << store;
+ return;
+ }
+
+ QDeclarativeInstruction store;
+ store.type = QDeclarativeInstruction::StoreBinding;
+ store.assignBinding.value = output->indexForByteArray(ref.compiledData);
+ store.assignBinding.context = ref.bindingContext.stack;
+ store.assignBinding.owner = ref.bindingContext.owner;
+ store.line = binding->location.start.line;
+
+ Q_ASSERT(ref.bindingContext.owner == 0 ||
+ (ref.bindingContext.owner != 0 && valueTypeProperty));
+ if (ref.bindingContext.owner) {
+ store.assignBinding.property = genValueTypeData(prop, valueTypeProperty);
+ } else {
+ store.assignBinding.property = genPropertyData(prop);
+ }
+
+ output->bytecode << store;
+}
+
+int QDeclarativeCompiler::genContextCache()
+{
+ if (compileState.ids.count() == 0)
+ return -1;
+
+ QDeclarativeIntegerCache *cache = new QDeclarativeIntegerCache(engine);
+
+ for (QHash<QString, QDeclarativeParser::Object *>::ConstIterator iter = compileState.ids.begin();
+ iter != compileState.ids.end();
+ ++iter)
+ cache->add(iter.key(), (*iter)->idIndex);
+
+ output->contextCaches.append(cache);
+ return output->contextCaches.count() - 1;
+}
+
+int QDeclarativeCompiler::genValueTypeData(QDeclarativeParser::Property *valueTypeProp,
+ QDeclarativeParser::Property *prop)
+{
+ QByteArray data =
+ QDeclarativeMetaPropertyPrivate::saveValueType(prop->parent->metaObject(), prop->index,
+ QDeclarativeEnginePrivate::get(engine)->valueTypes[prop->type]->metaObject(),
+ valueTypeProp->index);
+// valueTypeProp->index, valueTypeProp->type);
+
+ return output->indexForByteArray(data);
+}
+
+int QDeclarativeCompiler::genPropertyData(QDeclarativeParser::Property *prop)
+{
+ return output->indexForByteArray(QDeclarativeMetaPropertyPrivate::saveProperty(prop->parent->metaObject(), prop->index));
+}
+
+bool QDeclarativeCompiler::completeComponentBuild()
+{
+ componentStat.ids = compileState.ids.count();
+
+ for (int ii = 0; ii < compileState.aliasingObjects.count(); ++ii) {
+ Object *aliasObject = compileState.aliasingObjects.at(ii);
+ COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases));
+ }
+
+ QDeclarativeBindingCompiler::Expression expr;
+ expr.component = compileState.root;
+ expr.ids = compileState.ids;
+
+ QDeclarativeBindingCompiler bindingCompiler;
+
+ for (QHash<QDeclarativeParser::Value*,BindingReference>::Iterator iter = compileState.bindings.begin(); iter != compileState.bindings.end(); ++iter) {
+ BindingReference &binding = *iter;
+
+ expr.context = binding.bindingContext.object;
+ expr.property = binding.property;
+ expr.expression = binding.expression;
+ expr.imports = unit->imports;
+
+ if (qmlExperimental()) {
+ int index = bindingCompiler.compile(expr, QDeclarativeEnginePrivate::get(engine));
+ if (index != -1) {
+ qWarning() << "Accepted for optimization:" << qPrintable(expr.expression.asScript());
+ binding.dataType = BindingReference::Experimental;
+ binding.compiledIndex = index;
+ componentStat.optimizedBindings++;
+ continue;
+ } else {
+ qWarning() << "Rejected for optimization:" << qPrintable(expr.expression.asScript());
+ }
+ }
+
+ binding.dataType = BindingReference::QtScript;
+
+ // Pre-rewrite the expression
+ QString expression = binding.expression.asScript();
+
+ // ### Optimize
+ QDeclarativeRewrite::SharedBindingTester sharableTest;
+ bool isSharable = sharableTest.isSharable(expression);
+
+ QDeclarativeRewrite::RewriteBinding rewriteBinding;
+ expression = rewriteBinding(expression);
+
+ quint32 length = expression.length();
+ quint32 pc;
+
+ if (isSharable) {
+ pc = output->cachedClosures.count();
+ pc |= 0x80000000;
+ output->cachedClosures.append(0);
+ } else {
+ pc = output->cachedPrograms.length();
+ output->cachedPrograms.append(0);
+ }
+
+ binding.compiledData =
+ QByteArray((const char *)&pc, sizeof(quint32)) +
+ QByteArray((const char *)&length, sizeof(quint32)) +
+ QByteArray((const char *)expression.constData(),
+ expression.length() * sizeof(QChar));
+
+ componentStat.scriptBindings++;
+ }
+
+ if (bindingCompiler.isValid()) {
+ compileState.compiledBindingData = bindingCompiler.program();
+ QDeclarativeBindingCompiler::dump(compileState.compiledBindingData);
+ }
+
+ saveComponentState();
+
+ return true;
+}
+
+void QDeclarativeCompiler::dumpStats()
+{
+ qWarning().nospace() << "QML Document: " << output->url.toString();
+ for (int ii = 0; ii < savedComponentStats.count(); ++ii) {
+ const ComponentStat &stat = savedComponentStats.at(ii);
+ qWarning().nospace() << " Component Line " << stat.lineNumber;
+ qWarning().nospace() << " Total Objects: " << stat.objects;
+ qWarning().nospace() << " IDs Used: " << stat.ids;
+ qWarning().nospace() << " Optimized Bindings: " << stat.optimizedBindings;
+ qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings;
+ }
+}
+
+/*!
+ Returns true if from can be assigned to a (QObject) property of type
+ to.
+*/
+bool QDeclarativeCompiler::canCoerce(int to, QDeclarativeParser::Object *from)
+{
+ const QMetaObject *toMo =
+ QDeclarativeEnginePrivate::get(engine)->rawMetaObjectForType(to);
+ const QMetaObject *fromMo = from->metaObject();
+
+ while (fromMo) {
+ if (QDeclarativeMetaPropertyPrivate::equal(fromMo, toMo))
+ return true;
+ fromMo = fromMo->superClass();
+ }
+ return false;
+}
+
+/*!
+ Returns true if from can be assigned to a (QObject) property of type
+ to.
+*/
+bool QDeclarativeCompiler::canCoerce(int to, int from)
+{
+ const QMetaObject *toMo =
+ QDeclarativeEnginePrivate::get(engine)->rawMetaObjectForType(to);
+ const QMetaObject *fromMo =
+ QDeclarativeEnginePrivate::get(engine)->rawMetaObjectForType(from);
+
+ while (fromMo) {
+ if (QDeclarativeMetaPropertyPrivate::equal(fromMo, toMo))
+ return true;
+ fromMo = fromMo->superClass();
+ }
+ return false;
+}
+
+QDeclarativeType *QDeclarativeCompiler::toQmlType(QDeclarativeParser::Object *from)
+{
+ // ### Optimize
+ const QMetaObject *mo = from->metatype;
+ QDeclarativeType *type = 0;
+ while (!type && mo) {
+ type = QDeclarativeMetaType::qmlType(mo);
+ mo = mo->superClass();
+ }
+ return type;
+}
+
+QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeParser::Object *obj)
+{
+ const QMetaObject *mo = obj->metatype;
+
+ int idx = mo->indexOfClassInfo("DeferredPropertyNames");
+ if (idx == -1)
+ return QStringList();
+
+ QMetaClassInfo classInfo = mo->classInfo(idx);
+ QStringList rv = QString::fromUtf8(classInfo.value()).split(QLatin1Char(','));
+ return rv;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
new file mode 100644
index 0000000..627490d
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -0,0 +1,337 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECOMPILER_P_H
+#define QDECLARATIVECOMPILER_P_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 "qdeclarative.h"
+#include "qdeclarativeerror.h"
+#include "qdeclarativeinstruction_p.h"
+#include "qdeclarativecompositetypemanager_p.h"
+#include "qdeclarativeparser_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qbitfield_p.h"
+#include "qdeclarativepropertycache_p.h"
+#include "qdeclarativeintegercache_p.h"
+#include "qdeclarativetypenamecache_p.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qset.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QDeclarativeComponent;
+class QDeclarativeContext;
+
+class QScriptProgram;
+class Q_AUTOTEST_EXPORT QDeclarativeCompiledData : public QDeclarativeRefCount, public QDeclarativeCleanup
+{
+public:
+ QDeclarativeCompiledData(QDeclarativeEngine *engine);
+ virtual ~QDeclarativeCompiledData();
+
+ QString name;
+ QUrl url;
+ QDeclarativeEnginePrivate::Imports imports;
+ QDeclarativeTypeNameCache *importCache;
+
+ struct TypeReference
+ {
+ TypeReference()
+ : type(0), component(0), ref(0) {}
+
+ QByteArray className;
+ QDeclarativeType *type;
+ QDeclarativeComponent *component;
+
+ QDeclarativeRefCount *ref;
+ QObject *createInstance(QDeclarativeContext *, const QBitField &) const;
+ const QMetaObject *metaObject() const;
+ };
+ QList<TypeReference> types;
+ struct CustomTypeData
+ {
+ int index;
+ int type;
+ };
+
+ const QMetaObject *root;
+ QAbstractDynamicMetaObject rootData;
+ QDeclarativePropertyCache *rootPropertyCache;
+ QList<QString> primitives;
+ QList<float> floatData;
+ QList<int> intData;
+ QList<CustomTypeData> customTypeData;
+ QList<QByteArray> datas;
+ QList<QDeclarativeParser::Location> locations;
+ QList<QDeclarativeInstruction> bytecode;
+ QList<QScriptProgram *> cachedPrograms;
+ QList<QScriptValue *> cachedClosures;
+ QList<QDeclarativePropertyCache *> propertyCaches;
+ QList<QDeclarativeIntegerCache *> contextCaches;
+ QList<QDeclarativeParser::Object::ScriptBlock> scripts;
+ QList<QUrl> urls;
+
+ void dumpInstructions();
+
+protected:
+ virtual void clear(); // From QDeclarativeCleanup
+
+private:
+ void dump(QDeclarativeInstruction *, int idx = -1);
+ QDeclarativeCompiledData(const QDeclarativeCompiledData &other);
+ QDeclarativeCompiledData &operator=(const QDeclarativeCompiledData &other);
+ QByteArray packData;
+ friend class QDeclarativeCompiler;
+ int pack(const char *, size_t);
+
+ int indexForString(const QString &);
+ int indexForByteArray(const QByteArray &);
+ int indexForFloat(float *, int);
+ int indexForInt(int *, int);
+ int indexForLocation(const QDeclarativeParser::Location &);
+ int indexForLocation(const QDeclarativeParser::LocationSpan &);
+ int indexForUrl(const QUrl &);
+};
+
+class QMetaObjectBuilder;
+class Q_DECLARATIVE_EXPORT QDeclarativeCompiler
+{
+public:
+ QDeclarativeCompiler();
+
+ bool compile(QDeclarativeEngine *, QDeclarativeCompositeTypeData *, QDeclarativeCompiledData *);
+
+ bool isError() const;
+ QList<QDeclarativeError> errors() const;
+
+ static bool isValidId(const QString &);
+ static bool isAttachedPropertyName(const QByteArray &);
+ static bool isSignalPropertyName(const QByteArray &);
+
+private:
+ static void reset(QDeclarativeCompiledData *);
+
+ struct BindingContext {
+ BindingContext()
+ : stack(0), owner(0), object(0) {}
+ BindingContext(QDeclarativeParser::Object *o)
+ : stack(0), owner(0), object(o) {}
+ BindingContext incr() const {
+ BindingContext rv(object);
+ rv.stack = stack + 1;
+ return rv;
+ }
+ bool isSubContext() const { return stack != 0; }
+ int stack;
+ int owner;
+ QDeclarativeParser::Object *object;
+ };
+
+ void compileTree(QDeclarativeParser::Object *tree);
+
+
+ bool buildObject(QDeclarativeParser::Object *obj, const BindingContext &);
+ bool buildScript(QDeclarativeParser::Object *obj, QDeclarativeParser::Object *script);
+ bool buildComponent(QDeclarativeParser::Object *obj, const BindingContext &);
+ bool buildSubObject(QDeclarativeParser::Object *obj, const BindingContext &);
+ bool buildSignal(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj,
+ const BindingContext &);
+ bool buildProperty(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj,
+ const BindingContext &);
+ bool buildPropertyInNamespace(QDeclarativeEnginePrivate::ImportedNamespace *ns,
+ QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &);
+ bool buildIdProperty(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj);
+ bool buildAttachedProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt);
+ bool buildGroupedProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt);
+ bool buildValueTypeProperty(QObject *type,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Object *baseObj,
+ const BindingContext &ctxt);
+ bool buildListProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt);
+ bool buildScriptStringProperty(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt);
+ bool buildPropertyAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt);
+ bool buildPropertyObjectAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Value *value,
+ const BindingContext &ctxt);
+ bool buildPropertyLiteralAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Value *value,
+ const BindingContext &ctxt);
+ bool doesPropertyExist(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj);
+ bool testLiteralAssignment(const QMetaProperty &prop,
+ QDeclarativeParser::Value *value);
+ bool testQualifiedEnumAssignment(const QMetaProperty &prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Value *value,
+ bool *isAssignment);
+ enum DynamicMetaMode { IgnoreAliases, ResolveAliases, ForceCreation };
+ bool mergeDynamicMetaProperties(QDeclarativeParser::Object *obj);
+ bool buildDynamicMeta(QDeclarativeParser::Object *obj, DynamicMetaMode mode);
+ bool checkDynamicMeta(QDeclarativeParser::Object *obj);
+ bool buildBinding(QDeclarativeParser::Value *, QDeclarativeParser::Property *prop,
+ const BindingContext &ctxt);
+ bool buildComponentFromRoot(QDeclarativeParser::Object *obj, const BindingContext &);
+ bool compileAlias(QMetaObjectBuilder &,
+ QByteArray &data,
+ QDeclarativeParser::Object *obj,
+ const QDeclarativeParser::Object::DynamicProperty &);
+ bool completeComponentBuild();
+
+
+ void genObject(QDeclarativeParser::Object *obj);
+ void genObjectBody(QDeclarativeParser::Object *obj);
+ void genComponent(QDeclarativeParser::Object *obj);
+ void genValueProperty(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj);
+ void genListProperty(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj);
+ void genPropertyAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Property *valueTypeProperty = 0);
+ void genLiteralAssignment(const QMetaProperty &prop,
+ QDeclarativeParser::Value *value);
+ void genBindingAssignment(QDeclarativeParser::Value *binding,
+ QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Property *valueTypeProperty = 0);
+ int genContextCache();
+
+ int genValueTypeData(QDeclarativeParser::Property *prop, QDeclarativeParser::Property *valueTypeProp);
+ int genPropertyData(QDeclarativeParser::Property *prop);
+
+ int componentTypeRef();
+
+ static int findSignalByName(const QMetaObject *, const QByteArray &name);
+ static QDeclarativeType *toQmlType(QDeclarativeParser::Object *from);
+ bool canCoerce(int to, QDeclarativeParser::Object *from);
+ bool canCoerce(int to, int from);
+
+ QStringList deferredProperties(QDeclarativeParser::Object *);
+
+ void addId(const QString &, QDeclarativeParser::Object *);
+
+ void dumpStats();
+
+ struct BindingReference {
+ QDeclarativeParser::Variant expression;
+ QDeclarativeParser::Property *property;
+ QDeclarativeParser::Value *value;
+
+ enum DataType { QtScript, Experimental };
+ DataType dataType;
+
+ int compiledIndex;
+
+ QByteArray compiledData;
+ BindingContext bindingContext;
+ };
+ void addBindingReference(const BindingReference &);
+
+ struct ComponentCompileState
+ {
+ ComponentCompileState()
+ : parserStatusCount(0), pushedProperties(0), root(0) {}
+ QHash<QString, QDeclarativeParser::Object *> ids;
+ QHash<int, QDeclarativeParser::Object *> idIndexes;
+ int parserStatusCount;
+ int pushedProperties;
+
+ QByteArray compiledBindingData;
+
+ QHash<QDeclarativeParser::Value *, BindingReference> bindings;
+ QList<QDeclarativeParser::Object *> aliasingObjects;
+ QDeclarativeParser::Object *root;
+ };
+ ComponentCompileState compileState;
+
+ struct ComponentStat
+ {
+ ComponentStat()
+ : ids(0), scriptBindings(0), optimizedBindings(0), objects(0) {}
+
+ int lineNumber;
+
+ int ids;
+ int scriptBindings;
+ int optimizedBindings;
+ int objects;
+ };
+ ComponentStat componentStat;
+
+ void saveComponentState();
+
+ ComponentCompileState componentState(QDeclarativeParser::Object *);
+ QHash<QDeclarativeParser::Object *, ComponentCompileState> savedCompileStates;
+ QList<ComponentStat> savedComponentStats;
+
+ QList<QDeclarativeError> exceptions;
+ QDeclarativeCompiledData *output;
+ QDeclarativeEngine *engine;
+ QDeclarativeParser::Object *unitRoot;
+ QDeclarativeCompositeTypeData *unit;
+};
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVECOMPILER_P_H
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
new file mode 100644
index 0000000..beaba4a
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -0,0 +1,798 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecomponent.h"
+#include "qdeclarativecomponent_p.h"
+
+#include "qdeclarativecompiler_p.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativecompositetypedata_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativevme_p.h"
+#include "qdeclarative.h"
+#include "qdeclarativeengine.h"
+#include "qdeclarativebinding_p.h"
+#include "qdeclarativebinding_p_p.h"
+#include "qdeclarativeglobal_p.h"
+#include "qdeclarativescriptparser_p.h"
+
+#include <qfxperf_p_p.h>
+
+#include <QStack>
+#include <QStringList>
+#include <QFileInfo>
+#include <QtCore/qdebug.h>
+#include <QApplication>
+
+QT_BEGIN_NAMESPACE
+
+class QByteArray;
+int statusId = qRegisterMetaType<QDeclarativeComponent::Status>("QDeclarativeComponent::Status");
+
+/*!
+ \class QDeclarativeComponent
+ \since 4.7
+ \brief The QDeclarativeComponent class encapsulates a QML component description.
+ \mainclass
+*/
+
+/*!
+ \qmlclass Component QDeclarativeComponent
+ \since 4.7
+ \brief The Component element encapsulates a QML component description.
+
+ Components are reusable, encapsulated Qml element with a well-defined interface.
+ They are often defined in \l {qdeclarativedocuments.html}{Component Files}.
+
+ The \e Component element allows defining components within a QML file.
+ This can be useful for reusing a small component within a single QML
+ file, or for defining a component that logically belongs with the
+ file containing it.
+
+ \qml
+Item {
+ Component {
+ id: redSquare
+ Rectangle {
+ color: "red"
+ width: 10
+ height: 10
+ }
+ }
+ Loader { sourceComponent: redSquare }
+ Loader { sourceComponent: redSquare; x: 20 }
+}
+ \endqml
+
+ \section1 Attached Properties
+
+ \e onCompleted
+
+ Emitted after component "startup" has completed. This can be used to
+ execute script code at startup, once the full QML environment has been
+ established.
+
+ The \c {Component::onCompleted} attached property can be applied to
+ any element. The order of running the \c onCompleted scripts is
+ undefined.
+
+ \qml
+ Rectangle {
+ Component.onCompleted: console.log("Completed Running!")
+ Rectangle {
+ Component.onCompleted: console.log("Nested Completed Running!")
+ }
+ }
+ \endqml
+*/
+
+/*!
+ \enum QDeclarativeComponent::Status
+
+ Specifies the loading status of the QDeclarativeComponent.
+
+ \value Null This QDeclarativeComponent has no data. Call loadUrl() or setData() to add QML content.
+ \value Ready This QDeclarativeComponent is ready and create() may be called.
+ \value Loading This QDeclarativeComponent is loading network data.
+ \value Error An error has occured. Calling errorDescription() to retrieve a description.
+*/
+
+void QDeclarativeComponentPrivate::typeDataReady()
+{
+ Q_Q(QDeclarativeComponent);
+
+ Q_ASSERT(typeData);
+
+ fromTypeData(typeData);
+ typeData = 0;
+
+ emit q->statusChanged(q->status());
+}
+
+void QDeclarativeComponentPrivate::updateProgress(qreal p)
+{
+ Q_Q(QDeclarativeComponent);
+
+ progress = p;
+ emit q->progressChanged(p);
+}
+
+void QDeclarativeComponentPrivate::fromTypeData(QDeclarativeCompositeTypeData *data)
+{
+ url = data->imports.baseUrl();
+ QDeclarativeCompiledData *c = data->toCompiledComponent(engine);
+
+ if (!c) {
+ Q_ASSERT(data->status == QDeclarativeCompositeTypeData::Error);
+
+ state.errors = data->errors;
+
+ } else {
+
+ cc = c;
+
+ }
+
+ data->release();
+}
+
+void QDeclarativeComponentPrivate::clear()
+{
+ if (typeData) {
+ typeData->remWaiter(this);
+ typeData->release();
+ typeData = 0;
+ }
+
+ if (cc) {
+ cc->release();
+ cc = 0;
+ }
+}
+
+/*!
+ \internal
+*/
+QDeclarativeComponent::QDeclarativeComponent(QObject *parent)
+ : QObject(*(new QDeclarativeComponentPrivate), parent)
+{
+}
+
+/*!
+ Destruct the QDeclarativeComponent.
+*/
+QDeclarativeComponent::~QDeclarativeComponent()
+{
+ Q_D(QDeclarativeComponent);
+
+ if (d->state.completePending) {
+ qWarning("QDeclarativeComponent: Component destroyed while completion pending");
+ d->completeCreate();
+ }
+
+ if (d->typeData) {
+ d->typeData->remWaiter(d);
+ d->typeData->release();
+ }
+ if (d->cc)
+ d->cc->release();
+}
+
+/*!
+ \property QDeclarativeComponent::status
+ The component's current \l{QDeclarativeComponent::Status} {status}.
+ */
+QDeclarativeComponent::Status QDeclarativeComponent::status() const
+{
+ Q_D(const QDeclarativeComponent);
+
+ if (d->typeData)
+ return Loading;
+ else if (!d->state.errors.isEmpty())
+ return Error;
+ else if (d->engine && d->cc)
+ return Ready;
+ else
+ return Null;
+}
+
+/*!
+ \property QDeclarativeComponent::isNull
+
+ Is true if the component is in the Null state, false otherwise.
+
+ Equivalent to status() == QDeclarativeComponent::Null.
+*/
+bool QDeclarativeComponent::isNull() const
+{
+ return status() == Null;
+}
+
+/*!
+ \property QDeclarativeComponent::isReady
+
+ Is true if the component is in the Ready state, false otherwise.
+
+ Equivalent to status() == QDeclarativeComponent::Ready.
+*/
+bool QDeclarativeComponent::isReady() const
+{
+ return status() == Ready;
+}
+
+/*!
+ \property QDeclarativeComponent::isError
+
+ Is true if the component is in the Error state, false otherwise.
+
+ Equivalent to status() == QDeclarativeComponent::Error.
+*/
+bool QDeclarativeComponent::isError() const
+{
+ return status() == Error;
+}
+
+/*!
+ \property QDeclarativeComponent::isLoading
+
+ Is true if the component is in the Loading state, false otherwise.
+
+ Equivalent to status() == QDeclarativeComponent::Loading.
+*/
+bool QDeclarativeComponent::isLoading() const
+{
+ return status() == Loading;
+}
+
+/*!
+ \property QDeclarativeComponent::progress
+ The progress of loading the component, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+*/
+qreal QDeclarativeComponent::progress() const
+{
+ Q_D(const QDeclarativeComponent);
+ return d->progress;
+}
+
+/*!
+ \fn void QDeclarativeComponent::progressChanged(qreal progress)
+
+ Emitted whenever the component's loading progress changes. \a progress will be the
+ current progress between 0.0 (nothing loaded) and 1.0 (finished).
+*/
+
+/*!
+ \fn void QDeclarativeComponent::statusChanged(QDeclarativeComponent::Status status)
+
+ Emitted whenever the component's status changes. \a status will be the
+ new status.
+*/
+
+/*!
+ Create a QDeclarativeComponent with no data and give it the specified
+ \a engine and \a parent. Set the data with setData().
+*/
+QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QObject *parent)
+ : QObject(*(new QDeclarativeComponentPrivate), parent)
+{
+ Q_D(QDeclarativeComponent);
+ d->engine = engine;
+}
+
+/*!
+ Create a QDeclarativeComponent from the given \a url and give it the
+ specified \a parent and \a engine.
+
+ \sa loadUrl()
+*/
+QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const QUrl &url, QObject *parent)
+: QObject(*(new QDeclarativeComponentPrivate), parent)
+{
+ Q_D(QDeclarativeComponent);
+ d->engine = engine;
+ loadUrl(url);
+}
+
+/*!
+ Create a QDeclarativeComponent from the given \a fileName and give it the specified
+ \a parent and \a engine.
+
+ \sa loadUrl()
+*/
+QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const QString &fileName,
+ QObject *parent)
+: QObject(*(new QDeclarativeComponentPrivate), parent)
+{
+ Q_D(QDeclarativeComponent);
+ d->engine = engine;
+ loadUrl(QUrl::fromLocalFile(fileName));
+}
+
+/*!
+ \internal
+*/
+QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QDeclarativeCompiledData *cc, int start, int count, QObject *parent)
+ : QObject(*(new QDeclarativeComponentPrivate), parent)
+{
+ Q_D(QDeclarativeComponent);
+ d->engine = engine;
+ d->cc = cc;
+ cc->addref();
+ d->start = start;
+ d->count = count;
+ d->url = cc->url;
+ d->progress = 1.0;
+}
+
+/*!
+ Sets the QDeclarativeComponent 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 QDeclarativeComponent::setData(const QByteArray &data, const QUrl &url)
+{
+ Q_D(QDeclarativeComponent);
+
+ d->clear();
+
+ d->url = url;
+
+ QDeclarativeCompositeTypeData *typeData =
+ QDeclarativeEnginePrivate::get(d->engine)->typeManager.getImmediate(data, url);
+
+ if (typeData->status == QDeclarativeCompositeTypeData::Waiting
+ || typeData->status == QDeclarativeCompositeTypeData::WaitingResources)
+ {
+ d->typeData = typeData;
+ d->typeData->addWaiter(d);
+
+ } else {
+
+ d->fromTypeData(typeData);
+
+ }
+
+ d->progress = 1.0;
+ emit statusChanged(status());
+ emit progressChanged(d->progress);
+}
+
+/*!
+Returns the QDeclarativeContext the component was created in. This is only
+valid for components created directly from QML.
+*/
+QDeclarativeContext *QDeclarativeComponent::creationContext() const
+{
+ Q_D(const QDeclarativeComponent);
+ if(d->creationContext)
+ return d->creationContext;
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(this);
+ if (ddata)
+ return ddata->context;
+ else
+ return 0;
+}
+
+/*!
+ \internal
+ Sets the QDeclarativeContext the component was created in. This is only
+ desirable for components created in QML script.
+*/
+void QDeclarativeComponent::setCreationContext(QDeclarativeContext* c)
+{
+ Q_D(QDeclarativeComponent);
+ d->creationContext = c;
+}
+
+/*!
+ Load the QDeclarativeComponent from the provided \a url.
+*/
+void QDeclarativeComponent::loadUrl(const QUrl &url)
+{
+ Q_D(QDeclarativeComponent);
+
+ d->clear();
+
+ if (url.isRelative() && !url.isEmpty())
+ d->url = d->engine->baseUrl().resolved(url);
+ else
+ d->url = url;
+
+ QDeclarativeCompositeTypeData *data =
+ QDeclarativeEnginePrivate::get(d->engine)->typeManager.get(d->url);
+
+ if (data->status == QDeclarativeCompositeTypeData::Waiting
+ || data->status == QDeclarativeCompositeTypeData::WaitingResources)
+ {
+ d->typeData = data;
+ d->typeData->addWaiter(d);
+ d->progress = data->progress;
+ } else {
+ d->fromTypeData(data);
+ d->progress = 1.0;
+ }
+
+ emit statusChanged(status());
+ emit progressChanged(d->progress);
+}
+
+/*!
+ Return the list of errors that occured during the last compile or create
+ operation. An empty list is returned if isError() is not set.
+*/
+QList<QDeclarativeError> QDeclarativeComponent::errors() const
+{
+ Q_D(const QDeclarativeComponent);
+ if (isError())
+ return d->state.errors;
+ else
+ return QList<QDeclarativeError>();
+}
+
+/*!
+ \internal
+ errorsString is only meant as a way to get the errors in script
+*/
+QString QDeclarativeComponent::errorsString() const
+{
+ Q_D(const QDeclarativeComponent);
+ QString ret;
+ if(!isError())
+ return ret;
+ foreach(const QDeclarativeError &e, d->state.errors) {
+ ret += e.url().toString() + QLatin1Char(':') +
+ QString::number(e.line()) + QLatin1Char(' ') +
+ e.description() + QLatin1Char('\n');
+ }
+ return ret;
+}
+
+/*!
+ \property QDeclarativeComponent::url
+ The component URL. This is the URL passed to either the constructor,
+ or the loadUrl() or setData() methods.
+*/
+QUrl QDeclarativeComponent::url() const
+{
+ Q_D(const QDeclarativeComponent);
+ return d->url;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+}
+
+
+/*!
+ \internal
+ A version of create which returns a scriptObject, for use in script
+*/
+QScriptValue QDeclarativeComponent::createObject()
+{
+ Q_D(QDeclarativeComponent);
+ QDeclarativeContext* ctxt = creationContext();
+ if(!ctxt){
+ qWarning() << QLatin1String("createObject can only be used in QML");
+ return QScriptValue();
+ }
+ QObject* ret = create(ctxt);
+ return QDeclarativeEnginePrivate::qmlScriptObject(ret, d->engine);
+}
+
+/*!
+ Create an object instance from this component. Returns 0 if creation
+ failed. \a context specifies the context within which to create the object
+ instance.
+
+ If \a context is 0 (the default), it will create the instance in the
+ engine' s \l {QDeclarativeEngine::rootContext()}{root context}.
+*/
+QObject *QDeclarativeComponent::create(QDeclarativeContext *context)
+{
+ Q_D(QDeclarativeComponent);
+
+ return d->create(context, QBitField());
+}
+
+QObject *QDeclarativeComponentPrivate::create(QDeclarativeContext *context,
+ const QBitField &bindings)
+{
+ if (!context)
+ context = engine->rootContext();
+
+ if (context->engine() != engine) {
+ qWarning("QDeclarativeComponent::create(): Must create component in context from the same QDeclarativeEngine");
+ return 0;
+ }
+
+ QObject *rv = beginCreate(context, bindings);
+ completeCreate();
+ return rv;
+}
+
+/*!
+ This method provides more advanced control over component instance creation.
+ In general, programmers should use QDeclarativeComponent::create() to create a
+ component.
+
+ Create an object instance from this component. Returns 0 if creation
+ failed. \a context specifies the context within which to create the object
+ instance.
+
+ When QDeclarativeComponent constructs an instance, it occurs in three steps:
+ \list 1
+ \i The object hierarchy is created, and constant values are assigned.
+ \i Property bindings are evaluated for the the first time.
+ \i If applicable, QDeclarativeParserStatus::componentComplete() is called on objects.
+ \endlist
+ QDeclarativeComponent::beginCreate() differs from QDeclarativeComponent::create() in that it
+ only performs step 1. QDeclarativeComponent::completeCreate() must be called to
+ complete steps 2 and 3.
+
+ This breaking point is sometimes useful when using attached properties to
+ communicate information to an instantiated component, as it allows their
+ initial values to be configured before property bindings take effect.
+*/
+QObject *QDeclarativeComponent::beginCreate(QDeclarativeContext *context)
+{
+ Q_D(QDeclarativeComponent);
+ return d->beginCreate(context, QBitField());
+}
+
+QObject *
+QDeclarativeComponentPrivate::beginCreate(QDeclarativeContext *context, const QBitField &bindings)
+{
+ Q_Q(QDeclarativeComponent);
+ if (!context) {
+ qWarning("QDeclarativeComponent::beginCreate(): Cannot create a component in a null context");
+ return 0;
+ }
+
+ if (context->engine() != engine) {
+ qWarning("QDeclarativeComponent::beginCreate(): Must create component in context from the same QDeclarativeEngine");
+ return 0;
+ }
+
+ if (state.completePending) {
+ qWarning("QDeclarativeComponent: Cannot create new component instance before completing the previous");
+ return 0;
+ }
+
+ if (!q->isReady()) {
+ qWarning("QDeclarativeComponent: Component is not ready");
+ return 0;
+ }
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+
+ QDeclarativeContextPrivate *contextPriv =
+ static_cast<QDeclarativeContextPrivate *>(QObjectPrivate::get(context));
+ QDeclarativeContext *ctxt = new QDeclarativeContext(context, 0, true);
+ static_cast<QDeclarativeContextPrivate*>(ctxt->d_func())->url = cc->url;
+ static_cast<QDeclarativeContextPrivate*>(ctxt->d_func())->imports = cc->importCache;
+ cc->importCache->addref();
+
+ QObject *rv = begin(ctxt, ep, cc, start, count, &state, bindings);
+
+ if (rv) {
+ QDeclarativeGraphics_setParent_noEvent(ctxt, rv);
+ } else {
+ delete ctxt;
+ }
+
+ if (rv && !contextPriv->isInternal && ep->isDebugging)
+ contextPriv->instances.append(rv);
+ return rv;
+}
+
+QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContext *ctxt, QDeclarativeEnginePrivate *enginePriv,
+ QDeclarativeCompiledData *component, int start, int count,
+ ConstructionState *state, const QBitField &bindings)
+{
+ bool isRoot = !enginePriv->inBeginCreate;
+ enginePriv->inBeginCreate = true;
+
+ QDeclarativeVME vme;
+ QObject *rv = vme.run(ctxt, component, start, count, bindings);
+
+ if (vme.isError())
+ state->errors = vme.errors();
+
+ if (isRoot) {
+ enginePriv->inBeginCreate = false;
+
+ state->bindValues = enginePriv->bindValues;
+ state->parserStatus = enginePriv->parserStatus;
+ state->componentAttacheds = enginePriv->componentAttacheds;
+ if (state->componentAttacheds)
+ state->componentAttacheds->prev = &state->componentAttacheds;
+
+ enginePriv->componentAttacheds = 0;
+ enginePriv->bindValues.clear();
+ enginePriv->parserStatus.clear();
+ state->completePending = true;
+ enginePriv->inProgressCreations++;
+ }
+
+ return rv;
+}
+
+void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeContext *, QDeclarativeEnginePrivate *enginePriv,
+ QObject *object, ConstructionState *state)
+{
+ bool isRoot = !enginePriv->inBeginCreate;
+ enginePriv->inBeginCreate = true;
+
+ QDeclarativeVME vme;
+ vme.runDeferred(object);
+
+ if (vme.isError())
+ state->errors = vme.errors();
+
+ if (isRoot) {
+ enginePriv->inBeginCreate = false;
+
+ state->bindValues = enginePriv->bindValues;
+ state->parserStatus = enginePriv->parserStatus;
+ state->componentAttacheds = enginePriv->componentAttacheds;
+ if (state->componentAttacheds)
+ state->componentAttacheds->prev = &state->componentAttacheds;
+
+ enginePriv->componentAttacheds = 0;
+ enginePriv->bindValues.clear();
+ enginePriv->parserStatus.clear();
+ state->completePending = true;
+ enginePriv->inProgressCreations++;
+ }
+}
+
+void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state)
+{
+ if (state->completePending) {
+
+ for (int ii = 0; ii < state->bindValues.count(); ++ii) {
+ QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding> bv =
+ state->bindValues.at(ii);
+ for (int jj = 0; jj < bv.count; ++jj) {
+ if(bv.at(jj))
+ bv.at(jj)->setEnabled(true, QDeclarativeMetaProperty::BypassInterceptor |
+ QDeclarativeMetaProperty::DontRemoveBinding);
+ }
+ QDeclarativeEnginePrivate::clear(bv);
+ }
+
+ for (int ii = 0; ii < state->parserStatus.count(); ++ii) {
+ QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus> ps =
+ state->parserStatus.at(ii);
+
+ for (int jj = ps.count - 1; jj >= 0; --jj) {
+ QDeclarativeParserStatus *status = ps.at(jj);
+ if (status && status->d) {
+ status->d = 0;
+ status->componentComplete();
+ }
+ }
+ QDeclarativeEnginePrivate::clear(ps);
+ }
+
+ while (state->componentAttacheds) {
+ QDeclarativeComponentAttached *a = state->componentAttacheds;
+ if (a->next) a->next->prev = &state->componentAttacheds;
+ state->componentAttacheds = a->next;
+ a->prev = 0; a->next = 0;
+ emit a->completed();
+ }
+
+ state->bindValues.clear();
+ state->parserStatus.clear();
+ state->completePending = false;
+
+ enginePriv->inProgressCreations--;
+ if (0 == enginePriv->inProgressCreations) {
+ while (enginePriv->erroredBindings) {
+ qWarning().nospace() << qPrintable(enginePriv->erroredBindings->error.toString());
+ enginePriv->erroredBindings->removeError();
+ }
+ }
+ }
+}
+
+/*!
+ This method provides more advanced control over component instance creation.
+ In general, programmers should use QDeclarativeComponent::create() to create a
+ component.
+
+ Complete a component creation begin with QDeclarativeComponent::beginCreate().
+*/
+void QDeclarativeComponent::completeCreate()
+{
+ Q_D(QDeclarativeComponent);
+ d->completeCreate();
+}
+
+void QDeclarativeComponentPrivate::completeCreate()
+{
+ if (state.completePending) {
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ complete(ep, &state);
+ }
+}
+
+QDeclarativeComponentAttached::QDeclarativeComponentAttached(QObject *parent)
+: QObject(parent), prev(0), next(0)
+{
+}
+
+QDeclarativeComponentAttached::~QDeclarativeComponentAttached()
+{
+ if (prev) *prev = next;
+ if (next) next->prev = prev;
+ prev = 0;
+ next = 0;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeComponentAttached *QDeclarativeComponent::qmlAttachedProperties(QObject *obj)
+{
+ QDeclarativeComponentAttached *a = new QDeclarativeComponentAttached(obj);
+
+ QDeclarativeEngine *engine = qmlEngine(obj);
+ if (!engine || !QDeclarativeEnginePrivate::get(engine)->inBeginCreate)
+ return a;
+
+ QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
+
+ a->next = p->componentAttacheds;
+ a->prev = &p->componentAttacheds;
+ if (a->next) a->next->prev = &a->next;
+ p->componentAttacheds = a;
+
+ return a;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecomponent.h b/src/declarative/qml/qdeclarativecomponent.h
new file mode 100644
index 0000000..aec0480
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecomponent.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECOMPONENT_H
+#define QDECLARATIVECOMPONENT_H
+
+#include "qdeclarative.h"
+#include "qdeclarativeerror.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qstring.h>
+#include <QtScript/qscriptvalue.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeCompiledData;
+class QByteArray;
+class QDeclarativeComponentPrivate;
+class QDeclarativeEngine;
+class QDeclarativeComponentAttached;
+class Q_DECLARATIVE_EXPORT QDeclarativeComponent : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeComponent)
+ Q_PROPERTY(bool isNull READ isNull NOTIFY statusChanged)
+ Q_PROPERTY(bool isReady READ isReady NOTIFY statusChanged)
+ Q_PROPERTY(bool isError READ isError NOTIFY statusChanged)
+ Q_PROPERTY(bool isLoading READ isLoading NOTIFY statusChanged)
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(QUrl url READ url CONSTANT)
+
+public:
+ QDeclarativeComponent(QObject *parent = 0);
+ QDeclarativeComponent(QDeclarativeEngine *, QObject *parent=0);
+ QDeclarativeComponent(QDeclarativeEngine *, const QString &fileName, QObject *parent = 0);
+ QDeclarativeComponent(QDeclarativeEngine *, const QUrl &url, QObject *parent = 0);
+ virtual ~QDeclarativeComponent();
+
+ Q_ENUMS(Status)
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+
+ bool isNull() const;
+ bool isReady() const;
+ bool isError() const;
+ bool isLoading() const;
+
+ QList<QDeclarativeError> errors() const;
+ Q_INVOKABLE QString errorsString() const;
+
+ qreal progress() const;
+
+ QUrl url() const;
+
+ virtual QObject *create(QDeclarativeContext *context = 0);
+ virtual QObject *beginCreate(QDeclarativeContext *);
+ virtual void completeCreate();
+
+ Q_INVOKABLE QScriptValue createObject();
+
+ void loadUrl(const QUrl &url);
+ void setData(const QByteArray &, const QUrl &baseUrl);
+
+ void setCreationContext(QDeclarativeContext*);
+ QDeclarativeContext *creationContext() const;
+
+ static QDeclarativeComponentAttached *qmlAttachedProperties(QObject *);
+
+Q_SIGNALS:
+ void statusChanged(QDeclarativeComponent::Status);
+ void progressChanged(qreal);
+
+protected:
+ QDeclarativeComponent(QDeclarativeComponentPrivate &dd, QObject* parent);
+
+private:
+ QDeclarativeComponent(QDeclarativeEngine *, QDeclarativeCompiledData *, int, int, QObject *parent);
+
+ friend class QDeclarativeVME;
+ friend class QDeclarativeCompositeTypeData;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeclarativeComponent::Status)
+QML_DECLARE_TYPE(QDeclarativeComponent)
+QML_DECLARE_TYPEINFO(QDeclarativeComponent, QML_HAS_ATTACHED_PROPERTIES)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVECOMPONENT_H
diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h
new file mode 100644
index 0000000..3155813
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecomponent_p.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECOMPONENT_P_H
+#define QDECLARATIVECOMPONENT_P_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 "qdeclarativecomponent.h"
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativecompositetypemanager_p.h"
+#include "qbitfield_p.h"
+#include "qdeclarativeerror.h"
+#include "qdeclarative.h"
+
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QList>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeComponent;
+class QDeclarativeEngine;
+class QDeclarativeCompiledData;
+
+class QDeclarativeComponentAttached;
+class QDeclarativeComponentPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeComponent)
+
+public:
+ QDeclarativeComponentPrivate() : typeData(0), progress(0.), start(-1), count(-1), cc(0), engine(0), creationContext(0) {}
+
+ QObject *create(QDeclarativeContext *context, const QBitField &);
+ QObject *beginCreate(QDeclarativeContext *, const QBitField &);
+ void completeCreate();
+
+ QDeclarativeCompositeTypeData *typeData;
+ void typeDataReady();
+ void updateProgress(qreal);
+
+ void fromTypeData(QDeclarativeCompositeTypeData *data);
+
+ QUrl url;
+ qreal progress;
+
+ int start;
+ int count;
+ QDeclarativeCompiledData *cc;
+
+ struct ConstructionState {
+ ConstructionState() : componentAttacheds(0), completePending(false) {}
+ QList<QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding> > bindValues;
+ QList<QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus> > parserStatus;
+ QDeclarativeComponentAttached *componentAttacheds;
+ QList<QDeclarativeError> errors;
+ bool completePending;
+ };
+ ConstructionState state;
+
+ static QObject *begin(QDeclarativeContext *ctxt, QDeclarativeEnginePrivate *enginePriv,
+ QDeclarativeCompiledData *component, int start, int count,
+ ConstructionState *state, const QBitField &bindings = QBitField());
+ static void beginDeferred(QDeclarativeContext *ctxt, QDeclarativeEnginePrivate *enginePriv,
+ QObject *object, ConstructionState *state);
+ static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state);
+
+ QDeclarativeEngine *engine;
+ QDeclarativeContext *creationContext;
+
+ void clear();
+
+ static QDeclarativeComponentPrivate *get(QDeclarativeComponent *c) {
+ return static_cast<QDeclarativeComponentPrivate *>(QObjectPrivate::get(c));
+ }
+};
+
+class QDeclarativeComponentAttached : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeComponentAttached(QObject *parent = 0);
+ ~QDeclarativeComponentAttached();
+
+ QDeclarativeComponentAttached **prev;
+ QDeclarativeComponentAttached *next;
+
+Q_SIGNALS:
+ void completed();
+
+private:
+ friend class QDeclarativeComponentPrivate;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVECOMPONENT_P_H
diff --git a/src/declarative/qml/qdeclarativecompositetypedata_p.h b/src/declarative/qml/qdeclarativecompositetypedata_p.h
new file mode 100644
index 0000000..fb26af9
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecompositetypedata_p.h
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECOMPOSITETYPEDATA_P_H
+#define QDECLARATIVECOMPOSITETYPEDATA_P_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 "qdeclarativeengine_p.h"
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCompositeTypeResource;
+class QDeclarativeCompositeTypeData : public QDeclarativeRefCount
+{
+public:
+ QDeclarativeCompositeTypeData();
+ virtual ~QDeclarativeCompositeTypeData();
+
+ enum Status {
+ Invalid,
+ Complete,
+ Error,
+ Waiting,
+ WaitingResources
+ };
+ Status status;
+ enum ErrorType {
+ NoError,
+ AccessError,
+ GeneralError
+ };
+ ErrorType errorType;
+
+ QList<QDeclarativeError> errors;
+
+ QDeclarativeEnginePrivate::Imports imports;
+
+ QList<QDeclarativeCompositeTypeData *> dependants;
+
+ // Return a QDeclarativeComponent if the QDeclarativeCompositeTypeData is not in the Waiting
+ // state. The QDeclarativeComponent is owned by the QDeclarativeCompositeTypeData, so a
+ // reference should be kept to keep the QDeclarativeComponent alive.
+ QDeclarativeComponent *toComponent(QDeclarativeEngine *);
+ // Return a QDeclarativeCompiledData if possible, or 0 if an error
+ // occurs
+ QDeclarativeCompiledData *toCompiledComponent(QDeclarativeEngine *);
+
+ struct TypeReference
+ {
+ TypeReference();
+
+ QDeclarativeType *type;
+ QDeclarativeCompositeTypeData *unit;
+ };
+
+ QList<TypeReference> types;
+ QList<QDeclarativeCompositeTypeResource *> resources;
+
+ // Add or remove p as a waiter. When the QDeclarativeCompositeTypeData becomes
+ // ready, the QDeclarativeComponentPrivate::typeDataReady() method will be invoked on
+ // p. The waiter is automatically removed when the typeDataReady() method
+ // is invoked, so there is no need to call remWaiter() in this case.
+ void addWaiter(QDeclarativeComponentPrivate *p);
+ void remWaiter(QDeclarativeComponentPrivate *p);
+
+ qreal progress;
+
+private:
+ friend class QDeclarativeCompositeTypeManager;
+ friend class QDeclarativeCompiler;
+ friend class QDeclarativeDomDocument;
+
+ QDeclarativeScriptParser data;
+ QList<QDeclarativeComponentPrivate *> waiters;
+ QDeclarativeComponent *component;
+ QDeclarativeCompiledData *compiledComponent;
+};
+
+class QDeclarativeCompositeTypeResource : public QDeclarativeRefCount
+{
+public:
+ QDeclarativeCompositeTypeResource();
+ virtual ~QDeclarativeCompositeTypeResource();
+
+ enum Status {
+ Invalid,
+ Complete,
+ Error,
+ Waiting
+ };
+ Status status;
+
+ QList<QDeclarativeCompositeTypeData *> dependants;
+
+ QString url;
+ QByteArray data;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVECOMPOSITETYPEDATA_P_H
+
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
new file mode 100644
index 0000000..b90a598
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -0,0 +1,670 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecompositetypemanager_p.h"
+
+#include "qdeclarativecompositetypedata_p.h"
+#include "qdeclarativescriptparser_p.h"
+#include "qdeclarativeengine.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativecomponent.h"
+#include "qdeclarativecomponent_p.h"
+#include "qdeclarativecompiler_p.h"
+
+#include <QtNetwork/qnetworkreply.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qfile.h>
+
+QT_BEGIN_NAMESPACE
+
+#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 0))
+inline uint qHash(const QUrl &uri)
+{
+ return qHash(uri.toEncoded(QUrl::FormattingOption(0x100)));
+}
+#endif
+
+QDeclarativeCompositeTypeData::QDeclarativeCompositeTypeData()
+: status(Invalid), errorType(NoError), component(0), compiledComponent(0)
+{
+}
+
+QDeclarativeCompositeTypeData::~QDeclarativeCompositeTypeData()
+{
+ for (int ii = 0; ii < dependants.count(); ++ii)
+ dependants.at(ii)->release();
+
+ for (int ii = 0; ii < resources.count(); ++ii)
+ resources.at(ii)->release();
+
+ if (compiledComponent)
+ compiledComponent->release();
+
+ if (component)
+ delete component;
+}
+
+QDeclarativeCompositeTypeResource::QDeclarativeCompositeTypeResource()
+{
+}
+
+QDeclarativeCompositeTypeResource::~QDeclarativeCompositeTypeResource()
+{
+ for (int ii = 0; ii < dependants.count(); ++ii)
+ dependants.at(ii)->release();
+}
+
+void QDeclarativeCompositeTypeData::addWaiter(QDeclarativeComponentPrivate *p)
+{
+ waiters << p;
+}
+
+void QDeclarativeCompositeTypeData::remWaiter(QDeclarativeComponentPrivate *p)
+{
+ waiters.removeAll(p);
+}
+
+QDeclarativeComponent *QDeclarativeCompositeTypeData::toComponent(QDeclarativeEngine *engine)
+{
+ if (!component) {
+
+ QDeclarativeCompiledData *cc = toCompiledComponent(engine);
+ if (cc) {
+ component = new QDeclarativeComponent(engine, cc, -1, -1, 0);
+ cc->release();
+ } else {
+ component = new QDeclarativeComponent(engine, 0);
+ component->d_func()->url = imports.baseUrl();
+ component->d_func()->state.errors = errors;
+ }
+
+ }
+
+ return component;
+}
+
+QDeclarativeCompiledData *
+QDeclarativeCompositeTypeData::toCompiledComponent(QDeclarativeEngine *engine)
+{
+ if (status == Complete && !compiledComponent) {
+
+ compiledComponent = new QDeclarativeCompiledData(engine);
+ compiledComponent->url = imports.baseUrl();
+ compiledComponent->name = compiledComponent->url.toString();
+
+ QDeclarativeCompiler compiler;
+ if (!compiler.compile(engine, this, compiledComponent)) {
+ status = Error;
+ errors = compiler.errors();
+ compiledComponent->release();
+ compiledComponent = 0;
+ }
+
+ // Data is no longer needed once we have a compiled component
+ data.clear();
+ }
+
+ if (compiledComponent)
+ compiledComponent->addref();
+
+ return compiledComponent;
+}
+
+QDeclarativeCompositeTypeData::TypeReference::TypeReference()
+: type(0), unit(0)
+{
+}
+
+QDeclarativeCompositeTypeManager::QDeclarativeCompositeTypeManager(QDeclarativeEngine *e)
+: engine(e)
+{
+}
+
+QDeclarativeCompositeTypeManager::~QDeclarativeCompositeTypeManager()
+{
+ for (Components::Iterator iter = components.begin(); iter != components.end();) {
+ (*iter)->release();
+ iter = components.erase(iter);
+ }
+ for (Resources::Iterator iter = resources.begin(); iter != resources.end();) {
+ (*iter)->release();
+ iter = resources.erase(iter);
+ }
+}
+
+QDeclarativeCompositeTypeData *QDeclarativeCompositeTypeManager::get(const QUrl &url)
+{
+ QDeclarativeCompositeTypeData *unit = components.value(url);
+
+ if (!unit) {
+ unit = new QDeclarativeCompositeTypeData;
+ unit->status = QDeclarativeCompositeTypeData::Waiting;
+ unit->progress = 0.0;
+ unit->imports.setBaseUrl(url);
+ components.insert(url, unit);
+
+ loadSource(unit);
+ }
+
+ unit->addref();
+ return unit;
+}
+
+QDeclarativeCompositeTypeData *
+QDeclarativeCompositeTypeManager::getImmediate(const QByteArray &data, const QUrl &url)
+{
+ QDeclarativeCompositeTypeData *unit = new QDeclarativeCompositeTypeData;
+ unit->status = QDeclarativeCompositeTypeData::Waiting;
+ unit->imports.setBaseUrl(url);
+ setData(unit, data, url);
+ return unit;
+}
+
+void QDeclarativeCompositeTypeManager::clearCache()
+{
+ for (Components::Iterator iter = components.begin(); iter != components.end();) {
+ if ((*iter)->status != QDeclarativeCompositeTypeData::Waiting) {
+ (*iter)->release();
+ iter = components.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+
+ for (Resources::Iterator iter = resources.begin(); iter != resources.end();) {
+ if ((*iter)->status != QDeclarativeCompositeTypeResource::Waiting) {
+ (*iter)->release();
+ iter = resources.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+}
+
+void QDeclarativeCompositeTypeManager::replyFinished()
+{
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+
+ QDeclarativeCompositeTypeData *unit = components.value(reply->url());
+ Q_ASSERT(unit);
+
+ if (reply->error() != QNetworkReply::NoError) {
+ QString errorDescription;
+ // ### - Fill in error
+ errorDescription = QLatin1String("Network error for URL ") +
+ reply->url().toString();
+
+ unit->status = QDeclarativeCompositeTypeData::Error;
+ // ### FIXME
+ QDeclarativeError error;
+ error.setDescription(errorDescription);
+ unit->errorType = QDeclarativeCompositeTypeData::AccessError;
+ unit->errors << error;
+ doComplete(unit);
+
+ } else {
+ QByteArray data = reply->readAll();
+
+ setData(unit, data, reply->url());
+ }
+
+ reply->deleteLater();
+}
+
+void QDeclarativeCompositeTypeManager::resourceReplyFinished()
+{
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+
+ QDeclarativeCompositeTypeResource *resource = resources.value(reply->url());
+ Q_ASSERT(resource);
+
+ if (reply->error() != QNetworkReply::NoError) {
+
+ resource->status = QDeclarativeCompositeTypeResource::Error;
+
+ } else {
+
+ resource->status = QDeclarativeCompositeTypeResource::Complete;
+ resource->data = reply->readAll();
+
+ }
+
+ doComplete(resource);
+ reply->deleteLater();
+}
+
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
+void QDeclarativeCompositeTypeManager::loadResource(QDeclarativeCompositeTypeResource *resource)
+{
+ QUrl url(resource->url);
+
+ QString lf = toLocalFileOrQrc(url);
+ if (!lf.isEmpty()) {
+
+ QFile file(lf);
+ if (file.open(QFile::ReadOnly)) {
+ resource->data = file.readAll();
+ resource->status = QDeclarativeCompositeTypeResource::Complete;
+ } else {
+ resource->status = QDeclarativeCompositeTypeResource::Error;
+ }
+
+ } else {
+
+ QNetworkReply *reply =
+ engine->networkAccessManager()->get(QNetworkRequest(url));
+ QObject::connect(reply, SIGNAL(finished()),
+ this, SLOT(resourceReplyFinished()));
+
+ }
+}
+
+void QDeclarativeCompositeTypeManager::loadSource(QDeclarativeCompositeTypeData *unit)
+{
+ QUrl url(unit->imports.baseUrl());
+
+ QString lf = toLocalFileOrQrc(url);
+ if (!lf.isEmpty()) {
+
+ QFile file(lf);
+ if (file.open(QFile::ReadOnly)) {
+ QByteArray data = file.readAll();
+ setData(unit, data, url);
+ } else {
+ QString errorDescription;
+ // ### - Fill in error
+ errorDescription = QLatin1String("File error for URL ") + url.toString();
+ unit->status = QDeclarativeCompositeTypeData::Error;
+ // ### FIXME
+ QDeclarativeError error;
+ error.setDescription(errorDescription);
+ unit->errorType = QDeclarativeCompositeTypeData::AccessError;
+ unit->errors << error;
+ doComplete(unit);
+ }
+
+ } else {
+ QNetworkReply *reply =
+ engine->networkAccessManager()->get(QNetworkRequest(url));
+ QObject::connect(reply, SIGNAL(finished()),
+ this, SLOT(replyFinished()));
+ QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ }
+}
+
+void QDeclarativeCompositeTypeManager::requestProgress(qint64 received, qint64 total)
+{
+ if (total <= 0)
+ return;
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+
+ QDeclarativeCompositeTypeData *unit = components.value(reply->url());
+ Q_ASSERT(unit);
+
+ unit->progress = qreal(received)/total;
+
+ foreach (QDeclarativeComponentPrivate *comp, unit->waiters)
+ comp->updateProgress(unit->progress);
+}
+
+void QDeclarativeCompositeTypeManager::setData(QDeclarativeCompositeTypeData *unit,
+ const QByteArray &data,
+ const QUrl &url)
+{
+ bool ok = true;
+ if (!unit->data.parse(data, url)) {
+ ok = false;
+ unit->errors << unit->data.errors();
+ }
+
+ if (ok) {
+ compile(unit);
+ } else {
+ unit->status = QDeclarativeCompositeTypeData::Error;
+ unit->errorType = QDeclarativeCompositeTypeData::GeneralError;
+ doComplete(unit);
+ }
+}
+
+void QDeclarativeCompositeTypeManager::doComplete(QDeclarativeCompositeTypeData *unit)
+{
+ for (int ii = 0; ii < unit->dependants.count(); ++ii) {
+ checkComplete(unit->dependants.at(ii));
+ unit->dependants.at(ii)->release();
+ }
+ unit->dependants.clear();
+
+ while(!unit->waiters.isEmpty()) {
+ QDeclarativeComponentPrivate *p = unit->waiters.takeFirst();
+ p->typeDataReady();
+ }
+}
+
+void QDeclarativeCompositeTypeManager::doComplete(QDeclarativeCompositeTypeResource *resource)
+{
+ for (int ii = 0; ii < resource->dependants.count(); ++ii) {
+ checkComplete(resource->dependants.at(ii));
+ resource->dependants.at(ii)->release();
+ }
+ resource->dependants.clear();
+}
+
+void QDeclarativeCompositeTypeManager::checkComplete(QDeclarativeCompositeTypeData *unit)
+{
+ if (unit->status != QDeclarativeCompositeTypeData::Waiting
+ && unit->status != QDeclarativeCompositeTypeData::WaitingResources)
+ return;
+
+ int waiting = 0;
+ for (int ii = 0; ii < unit->resources.count(); ++ii) {
+ QDeclarativeCompositeTypeResource *r = unit->resources.at(ii);
+
+ if (!r)
+ continue;
+
+ if (r->status == QDeclarativeCompositeTypeResource::Error) {
+ unit->status = QDeclarativeCompositeTypeData::Error;
+ QDeclarativeError error;
+ error.setUrl(unit->imports.baseUrl());
+ error.setDescription(tr("Resource %1 unavailable").arg(r->url));
+ unit->errors << error;
+ doComplete(unit);
+ return;
+ } else if (r->status == QDeclarativeCompositeTypeResource::Waiting) {
+ waiting++;
+ }
+ }
+
+ if (waiting == 0) {
+ if (unit->status == QDeclarativeCompositeTypeData::WaitingResources) {
+ waiting += resolveTypes(unit);
+ if (unit->status != QDeclarativeCompositeTypeData::Error) {
+ if (waiting)
+ unit->status = QDeclarativeCompositeTypeData::Waiting;
+ } else {
+ return;
+ }
+ } else {
+ for (int ii = 0; ii < unit->types.count(); ++ii) {
+ QDeclarativeCompositeTypeData *u = unit->types.at(ii).unit;
+
+ if (!u)
+ continue;
+
+ if (u->status == QDeclarativeCompositeTypeData::Error) {
+ unit->status = QDeclarativeCompositeTypeData::Error;
+ unit->errors = u->errors;
+ doComplete(unit);
+ return;
+ } else if (u->status == QDeclarativeCompositeTypeData::Waiting) {
+ waiting++;
+ }
+ }
+ }
+ }
+
+ if (!waiting) {
+ unit->status = QDeclarativeCompositeTypeData::Complete;
+ doComplete(unit);
+ }
+}
+
+int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData *unit)
+{
+ // not called until all resources are loaded (they include import URLs)
+
+ int waiting = 0;
+
+ foreach (QDeclarativeScriptParser::Import imp, unit->data.imports()) {
+ QString qmldir;
+ if (imp.type == QDeclarativeScriptParser::Import::File && imp.qualifier.isEmpty()) {
+ QString importUrl = unit->imports.baseUrl().resolved(QUrl(imp.uri + QLatin1String("/qmldir"))).toString();
+ for (int ii = 0; ii < unit->resources.count(); ++ii) {
+ if (unit->resources.at(ii)->url == importUrl) {
+ qmldir = QString::fromUtf8(unit->resources.at(ii)->data);
+ break;
+ }
+ }
+ }
+
+ int vmaj = -1;
+ int vmin = -1;
+ if (!imp.version.isEmpty()) {
+ int dot = imp.version.indexOf(QLatin1Char('.'));
+ if (dot < 0) {
+ vmaj = imp.version.toInt();
+ vmin = 0;
+ } else {
+ vmaj = imp.version.left(dot).toInt();
+ vmin = imp.version.mid(dot+1).toInt();
+ }
+ }
+
+ if (!QDeclarativeEnginePrivate::get(engine)->
+ addToImport(&unit->imports, qmldir, imp.uri, imp.qualifier, vmaj, vmin, imp.type))
+ {
+ QDeclarativeError error;
+ error.setUrl(unit->imports.baseUrl());
+ error.setDescription(tr("Import %1 unavailable").arg(imp.uri));
+ unit->status = QDeclarativeCompositeTypeData::Error;
+ unit->errorType = QDeclarativeCompositeTypeData::GeneralError;
+ unit->errors << error;
+ doComplete(unit);
+ return 0;
+ }
+ }
+
+ QList<QDeclarativeScriptParser::TypeReference*> types = unit->data.referencedTypes();
+
+ for (int ii = 0; ii < types.count(); ++ii) {
+ QDeclarativeScriptParser::TypeReference *parserRef = types.at(ii);
+ QByteArray typeName = parserRef->name.toUtf8();
+
+ QDeclarativeCompositeTypeData::TypeReference ref;
+
+ QUrl url;
+ int majorVersion;
+ int minorVersion;
+ QDeclarativeEnginePrivate::ImportedNamespace *typeNamespace = 0;
+ if (!QDeclarativeEnginePrivate::get(engine)->resolveType(unit->imports, typeName, &ref.type, &url, &majorVersion, &minorVersion, &typeNamespace)
+ || typeNamespace)
+ {
+ // Known to not be a type:
+ // - known to be a namespace (Namespace {})
+ // - type with unknown namespace (UnknownNamespace.SomeType {})
+ QDeclarativeError error;
+ error.setUrl(unit->imports.baseUrl());
+ if (typeNamespace)
+ error.setDescription(tr("Namespace %1 cannot be used as a type").arg(QString::fromUtf8(typeName)));
+ else
+ error.setDescription(tr("%1 is not a type").arg(QString::fromUtf8(typeName)));
+ if (!parserRef->refObjects.isEmpty()) {
+ QDeclarativeParser::Object *obj = parserRef->refObjects.first();
+ error.setLine(obj->location.start.line);
+ error.setColumn(obj->location.start.column);
+ }
+ unit->status = QDeclarativeCompositeTypeData::Error;
+ unit->errorType = QDeclarativeCompositeTypeData::GeneralError;
+ unit->errors << error;
+ doComplete(unit);
+ return 0;
+ }
+
+ if (ref.type) {
+ foreach (QDeclarativeParser::Object *obj, parserRef->refObjects) {
+ // store namespace for DOM
+ obj->majorVersion = majorVersion;
+ obj->minorVersion = minorVersion;
+ }
+ unit->types << ref;
+ continue;
+ }
+
+ QDeclarativeCompositeTypeData *urlUnit = components.value(url);
+
+ if (!urlUnit) {
+ urlUnit = new QDeclarativeCompositeTypeData;
+ urlUnit->status = QDeclarativeCompositeTypeData::Waiting;
+ urlUnit->imports.setBaseUrl(url);
+ components.insert(url, urlUnit);
+
+ loadSource(urlUnit);
+ }
+
+ ref.unit = urlUnit;
+ switch(urlUnit->status) {
+ case QDeclarativeCompositeTypeData::Invalid:
+ case QDeclarativeCompositeTypeData::Error:
+ unit->status = QDeclarativeCompositeTypeData::Error;
+ {
+ QDeclarativeError error;
+ error.setUrl(unit->imports.baseUrl());
+ error.setDescription(tr("Type %1 unavailable").arg(QString::fromUtf8(typeName)));
+ if (!parserRef->refObjects.isEmpty()) {
+ QDeclarativeParser::Object *obj = parserRef->refObjects.first();
+ error.setLine(obj->location.start.line);
+ error.setColumn(obj->location.start.column);
+ }
+ unit->errors << error;
+ }
+ if (urlUnit->errorType != QDeclarativeCompositeTypeData::AccessError)
+ unit->errors << urlUnit->errors;
+ doComplete(unit);
+ return 0;
+
+ case QDeclarativeCompositeTypeData::Complete:
+ break;
+
+ case QDeclarativeCompositeTypeData::Waiting:
+ case QDeclarativeCompositeTypeData::WaitingResources:
+ unit->addref();
+ ref.unit->dependants << unit;
+ waiting++;
+ break;
+ }
+
+ unit->types << ref;
+ }
+ return waiting;
+}
+
+// ### Check ref counting in here
+void QDeclarativeCompositeTypeManager::compile(QDeclarativeCompositeTypeData *unit)
+{
+ int waiting = 0;
+
+ QList<QUrl> resourceList = unit->data.referencedResources();
+
+ foreach (QDeclarativeScriptParser::Import imp, unit->data.imports()) {
+ if (imp.type == QDeclarativeScriptParser::Import::File && imp.qualifier.isEmpty()) {
+ QUrl importUrl = unit->imports.baseUrl().resolved(QUrl(imp.uri + QLatin1String("/qmldir")));
+ if (toLocalFileOrQrc(importUrl).isEmpty()) {
+ // Import requires remote qmldir
+ resourceList.prepend(importUrl);
+ }
+ }
+ }
+
+ for (int ii = 0; ii < resourceList.count(); ++ii) {
+ QUrl url = unit->imports.baseUrl().resolved(resourceList.at(ii));
+
+ QDeclarativeCompositeTypeResource *resource = resources.value(url);
+
+ if (!resource) {
+ resource = new QDeclarativeCompositeTypeResource;
+ resource->status = QDeclarativeCompositeTypeResource::Waiting;
+ resource->url = url.toString();
+ resources.insert(url, resource);
+
+ loadResource(resource);
+ }
+
+ switch(resource->status) {
+ case QDeclarativeCompositeTypeResource::Invalid:
+ case QDeclarativeCompositeTypeResource::Error:
+ unit->status = QDeclarativeCompositeTypeData::Error;
+ {
+ QDeclarativeError error;
+ error.setUrl(unit->imports.baseUrl());
+ error.setDescription(tr("Resource %1 unavailable").arg(resource->url));
+ unit->errors << error;
+ }
+ doComplete(unit);
+ return;
+
+ case QDeclarativeCompositeTypeData::Complete:
+ break;
+
+ case QDeclarativeCompositeTypeData::Waiting:
+ unit->addref();
+ resource->dependants << unit;
+ waiting++;
+ break;
+ }
+
+ resource->addref();
+ unit->resources << resource;
+ }
+
+ if (waiting == 0) {
+ waiting += resolveTypes(unit);
+ if (unit->status != QDeclarativeCompositeTypeData::Error) {
+ if (!waiting) {
+ unit->status = QDeclarativeCompositeTypeData::Complete;
+ doComplete(unit);
+ } else {
+ unit->status = QDeclarativeCompositeTypeData::Waiting;
+ }
+ }
+ } else {
+ unit->status = QDeclarativeCompositeTypeData::WaitingResources;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager_p.h b/src/declarative/qml/qdeclarativecompositetypemanager_p.h
new file mode 100644
index 0000000..03d16b8
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecompositetypemanager_p.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECOMPOSITETYPEMANAGER_P_H
+#define QDECLARATIVECOMPOSITETYPEMANAGER_P_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 "qdeclarativescriptparser_p.h"
+#include "qdeclarativerefcount_p.h"
+#include "qdeclarativeerror.h"
+#include "qdeclarativeengine.h"
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCompiledData;
+class QDeclarativeComponentPrivate;
+class QDeclarativeComponent;
+class QDeclarativeDomDocument;
+
+class QDeclarativeCompositeTypeData;
+class QDeclarativeCompositeTypeResource;
+
+class QDeclarativeCompositeTypeManager : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeCompositeTypeManager(QDeclarativeEngine *);
+ ~QDeclarativeCompositeTypeManager();
+
+ // Return a QDeclarativeCompositeTypeData for url. The QDeclarativeCompositeTypeData may be
+ // cached.
+ QDeclarativeCompositeTypeData *get(const QUrl &url);
+ // Return a QDeclarativeCompositeTypeData for data, with the provided base url. The
+ // QDeclarativeCompositeTypeData will not be cached.
+ QDeclarativeCompositeTypeData *getImmediate(const QByteArray &data, const QUrl &url);
+
+ // Clear cached types. Only types that aren't in the Waiting state will
+ // be cleared.
+ void clearCache();
+
+private Q_SLOTS:
+ void replyFinished();
+ void resourceReplyFinished();
+ void requestProgress(qint64 received, qint64 total);
+
+private:
+ void loadSource(QDeclarativeCompositeTypeData *);
+ void loadResource(QDeclarativeCompositeTypeResource *);
+ void compile(QDeclarativeCompositeTypeData *);
+ void setData(QDeclarativeCompositeTypeData *, const QByteArray &, const QUrl &);
+
+ void doComplete(QDeclarativeCompositeTypeData *);
+ void doComplete(QDeclarativeCompositeTypeResource *);
+ void checkComplete(QDeclarativeCompositeTypeData *);
+ int resolveTypes(QDeclarativeCompositeTypeData *);
+
+ QDeclarativeEngine *engine;
+ typedef QHash<QUrl, QDeclarativeCompositeTypeData *> Components;
+ Components components;
+ typedef QHash<QUrl, QDeclarativeCompositeTypeResource *> Resources;
+ Resources resources;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVECOMPOSITETYPEMANAGER_P_H
+
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
new file mode 100644
index 0000000..b244cd8
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -0,0 +1,574 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecontext.h"
+#include "qdeclarativecontext_p.h"
+
+#include "qdeclarativeexpression_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativeengine.h"
+#include "qdeclarativecompiledbindings_p.h"
+#include "qdeclarativeinfo.h"
+
+#include <qscriptengine.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qdebug.h>
+
+#include <private/qscriptdeclarativeclass_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeContextPrivate::QDeclarativeContextPrivate()
+: parent(0), engine(0), isInternal(false), propertyNames(0),
+ notifyIndex(-1), highPriorityCount(0), imports(0), expressions(0), contextObjects(0),
+ idValues(0), idValueCount(0), optimizedBindings(0)
+{
+}
+
+void QDeclarativeContextPrivate::addScript(const QDeclarativeParser::Object::ScriptBlock &script, QObject *scopeObject)
+{
+ Q_Q(QDeclarativeContext);
+
+ if (!engine)
+ return;
+
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
+ scriptContext->pushScope(enginePriv->contextClass->newContext(q, scopeObject));
+
+ QScriptValue scope = scriptEngine->newObject();
+ scriptContext->setActivationObject(scope);
+
+ for (int ii = 0; ii < script.codes.count(); ++ii) {
+ scriptEngine->evaluate(script.codes.at(ii), script.files.at(ii), script.lineNumbers.at(ii));
+
+ if (scriptEngine->hasUncaughtException()) {
+ QDeclarativeError error;
+ QDeclarativeExpressionPrivate::exceptionToError(scriptEngine, error);
+ qWarning().nospace() << qPrintable(error.toString());
+ }
+ }
+
+ scriptEngine->popContext();
+
+ scripts.append(scope);
+}
+
+void QDeclarativeContextPrivate::destroyed(ContextGuard *guard)
+{
+ Q_Q(QDeclarativeContext);
+
+ // process of being deleted (which is *probably* why obj has been destroyed
+ // anyway), as we're about to get deleted which will invalidate all the
+ // expressions that could depend on us
+ QObject *parent = q->parent();
+ if (parent && QObjectPrivate::get(parent)->wasDeleted)
+ return;
+
+ while(guard->bindings) {
+ QObject *o = guard->bindings->target;
+ int mi = guard->bindings->methodIndex;
+ guard->bindings->clear();
+ if (o) o->qt_metacall(QMetaObject::InvokeMetaMethod, mi, 0);
+ }
+
+ for (int ii = 0; ii < idValueCount; ++ii) {
+ if (&idValues[ii] == guard) {
+ QMetaObject::activate(q, ii + notifyIndex, 0);
+ return;
+ }
+ }
+}
+
+void QDeclarativeContextPrivate::init()
+{
+ Q_Q(QDeclarativeContext);
+
+ if (parent)
+ parent->d_func()->childContexts.insert(q);
+}
+
+/*!
+ \class QDeclarativeContext
+ \since 4.7
+ \brief The QDeclarativeContext class defines a context within a QML engine.
+ \mainclass
+
+ Contexts allow data to be exposed to the QML components instantiated by the
+ QML engine.
+
+ Each QDeclarativeContext contains a set of properties, distinct from
+ its QObject properties, that allow data to be
+ explicitly bound to a context by name. The context properties are defined or
+ updated by calling QDeclarativeContext::setContextProperty(). The following example shows
+ a Qt model being bound to a context and then accessed from a QML file.
+
+ \code
+ QDeclarativeEngine engine;
+ QDeclarativeContext context(engine.rootContext());
+ context.setContextProperty("myModel", modelData);
+
+ QDeclarativeComponent component(&engine, "ListView { model=myModel }");
+ component.create(&context);
+ \endcode
+
+ To simplify binding and maintaining larger data sets, QObject's can be
+ added to a QDeclarativeContext. These objects are known as the context's default
+ objects. In this case all the properties of the QObject are
+ made available by name in the context, as though they were all individually
+ added by calling QDeclarativeContext::setContextProperty(). Changes to the property's
+ values are detected through the property's notify signal. This method is
+ also slightly more faster than manually adding property values.
+
+ The following example has the same effect as the one above, but it is
+ achieved using a default object.
+
+ \code
+ class MyDataSet : ... {
+ ...
+ Q_PROPERTY(QAbstractItemModel *myModel READ model NOTIFY modelChanged)
+ ...
+ };
+
+ MyDataSet myDataSet;
+ QDeclarativeEngine engine;
+ QDeclarativeContext context(engine.rootContext());
+ context.addDefaultObject(&myDataSet);
+
+ QDeclarativeComponent component(&engine, "ListView { model=myModel }");
+ component.create(&context);
+ \endcode
+
+ Default objects added first take precedence over those added later. All properties
+ added explicitly by QDeclarativeContext::setContextProperty() take precedence over default
+ object properties.
+
+ Contexts are hierarchal, with the \l {QDeclarativeEngine::rootContext()}{root context}
+ being created by the QDeclarativeEngine. A component instantiated in a given context
+ has access to that context's data, as well as the data defined by its
+ ancestor contexts. Data values (including those added implicitly by the
+ default objects) in a context override those in ancestor contexts. Data
+ that should be available to all components instantiated by the QDeclarativeEngine
+ should be added to the \l {QDeclarativeEngine::rootContext()}{root context}.
+
+ In the following example,
+
+ \code
+ QDeclarativeEngine engine;
+ QDeclarativeContext context1(engine.rootContext());
+ QDeclarativeContext context2(&context1);
+ QDeclarativeContext context3(&context2);
+
+ context1.setContextProperty("a", 12);
+ context2.setContextProperty("b", 13);
+ context3.setContextProperty("a", 14);
+ context3.setContextProperty("c", 14);
+ \endcode
+
+ a QML component instantiated in context1 would have access to the "a" data,
+ a QML component instantiated in context2 would have access to the "a" and
+ "b" data, and a QML component instantiated in context3 would have access to
+ the "a", "b" and "c" data - although its "a" data would return 14, unlike
+ that in context1 or context2.
+*/
+
+/*! \internal */
+QDeclarativeContext::QDeclarativeContext(QDeclarativeEngine *e, bool)
+: QObject(*(new QDeclarativeContextPrivate))
+{
+ Q_D(QDeclarativeContext);
+ d->engine = e;
+ d->init();
+}
+
+/*!
+ Create a new QDeclarativeContext as a child of \a engine's root context, and the
+ QObject \a parent.
+*/
+QDeclarativeContext::QDeclarativeContext(QDeclarativeEngine *engine, QObject *parent)
+: QObject(*(new QDeclarativeContextPrivate), parent)
+{
+ Q_D(QDeclarativeContext);
+ QDeclarativeContext *parentContext = engine?engine->rootContext():0;
+ d->parent = parentContext;
+ d->engine = parentContext->engine();
+ d->init();
+}
+
+/*!
+ Create a new QDeclarativeContext with the given \a parentContext, and the
+ QObject \a parent.
+*/
+QDeclarativeContext::QDeclarativeContext(QDeclarativeContext *parentContext, QObject *parent)
+: QObject(*(new QDeclarativeContextPrivate), parent)
+{
+ Q_D(QDeclarativeContext);
+ d->parent = parentContext;
+ d->engine = parentContext->engine();
+ d->init();
+}
+
+/*!
+ \internal
+*/
+QDeclarativeContext::QDeclarativeContext(QDeclarativeContext *parentContext, QObject *parent, bool)
+: QObject(*(new QDeclarativeContextPrivate), parent)
+{
+ Q_D(QDeclarativeContext);
+ d->parent = parentContext;
+ d->engine = parentContext->engine();
+ d->isInternal = true;
+ d->init();
+}
+
+/*!
+ Destroys the QDeclarativeContext.
+
+ Any expressions, or sub-contexts dependent on this context will be
+ invalidated, but not destroyed (unless they are parented to the QDeclarativeContext
+ object).
+ */
+QDeclarativeContext::~QDeclarativeContext()
+{
+ Q_D(QDeclarativeContext);
+ if (d->parent)
+ d->parent->d_func()->childContexts.remove(this);
+
+ for (QSet<QDeclarativeContext *>::ConstIterator iter = d->childContexts.begin();
+ iter != d->childContexts.end();
+ ++iter) {
+ (*iter)->d_func()->invalidateEngines();
+ (*iter)->d_func()->parent = 0;
+ }
+
+ QDeclarativeAbstractExpression *expression = d->expressions;
+ while (expression) {
+ QDeclarativeAbstractExpression *nextExpression = expression->m_nextExpression;
+
+ expression->m_context = 0;
+ expression->m_prevExpression = 0;
+ expression->m_nextExpression = 0;
+
+ expression = nextExpression;
+ }
+
+ while (d->contextObjects) {
+ QDeclarativeDeclarativeData *co = d->contextObjects;
+ d->contextObjects = d->contextObjects->nextContextObject;
+
+ co->context = 0;
+ co->nextContextObject = 0;
+ co->prevContextObject = 0;
+ }
+
+ if (d->propertyNames)
+ d->propertyNames->release();
+
+ if (d->imports)
+ d->imports->release();
+
+ if (d->optimizedBindings)
+ d->optimizedBindings->release();
+
+ delete [] d->idValues;
+}
+
+void QDeclarativeContextPrivate::invalidateEngines()
+{
+ if (!engine)
+ return;
+ engine = 0;
+ for (QSet<QDeclarativeContext *>::ConstIterator iter = childContexts.begin();
+ iter != childContexts.end();
+ ++iter) {
+ (*iter)->d_func()->invalidateEngines();
+ }
+}
+
+/*
+Refreshes all expressions that could possibly depend on this context.
+Refreshing flushes all context-tree dependent caches in the expressions, and should occur every
+time the context tree *structure* (not values) changes.
+*/
+void QDeclarativeContextPrivate::refreshExpressions()
+{
+ for (QSet<QDeclarativeContext *>::ConstIterator iter = childContexts.begin();
+ iter != childContexts.end();
+ ++iter) {
+ (*iter)->d_func()->refreshExpressions();
+ }
+
+ QDeclarativeAbstractExpression *expression = expressions;
+ while (expression) {
+ expression->refresh();
+ expression = expression->m_nextExpression;
+ }
+}
+
+/*!
+ Return the context's QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the
+ QDeclarativeEngine was destroyed.
+*/
+QDeclarativeEngine *QDeclarativeContext::engine() const
+{
+ Q_D(const QDeclarativeContext);
+ return d->engine;
+}
+
+/*!
+ Return the context's parent QDeclarativeContext, or 0 if this context has no
+ parent or if the parent has been destroyed.
+*/
+QDeclarativeContext *QDeclarativeContext::parentContext() const
+{
+ Q_D(const QDeclarativeContext);
+ return d->parent;
+}
+
+/*!
+ Add \a defaultObject to this context. The object will be added after
+ any existing default objects.
+*/
+void QDeclarativeContext::addDefaultObject(QObject *defaultObject)
+{
+ Q_D(QDeclarativeContext);
+ d->defaultObjects.prepend(defaultObject);
+}
+
+/*!
+ Set a the \a value of the \a name property on this context.
+*/
+void QDeclarativeContext::setContextProperty(const QString &name, const QVariant &value)
+{
+ Q_D(QDeclarativeContext);
+ if (d->notifyIndex == -1)
+ d->notifyIndex = this->metaObject()->methodCount();
+
+ if (d->engine) {
+ bool ok;
+ QObject *o = QDeclarativeEnginePrivate::get(d->engine)->toQObject(value, &ok);
+ if (ok) {
+ setContextProperty(name, o);
+ return;
+ }
+ }
+
+ if (!d->propertyNames) d->propertyNames = new QDeclarativeIntegerCache(d->engine);
+
+ int idx = d->propertyNames->value(name);
+ if (idx == -1) {
+ d->propertyNames->add(name, d->idValueCount + d->propertyValues.count());
+ d->propertyValues.append(value);
+
+ d->refreshExpressions();
+ } else {
+ d->propertyValues[idx] = value;
+ QMetaObject::activate(this, idx + d->notifyIndex, 0);
+ }
+}
+
+void QDeclarativeContextPrivate::setIdProperty(int idx, QObject *obj)
+{
+ if (notifyIndex == -1) {
+ Q_Q(QDeclarativeContext);
+ notifyIndex = q->metaObject()->methodCount();
+ }
+
+ idValues[idx].priv = this;
+ idValues[idx] = obj;
+}
+
+void QDeclarativeContextPrivate::setIdPropertyData(QDeclarativeIntegerCache *data)
+{
+ Q_ASSERT(!propertyNames);
+ propertyNames = data;
+ propertyNames->addref();
+
+ idValueCount = data->count();
+ idValues = new ContextGuard[idValueCount];
+}
+
+/*!
+ Set the \a value of the \a name property on this context.
+
+ QDeclarativeContext does \bold not take ownership of \a value.
+*/
+void QDeclarativeContext::setContextProperty(const QString &name, QObject *value)
+{
+ Q_D(QDeclarativeContext);
+ if (d->notifyIndex == -1)
+ d->notifyIndex = this->metaObject()->methodCount();
+
+ if (!d->propertyNames) d->propertyNames = new QDeclarativeIntegerCache(d->engine);
+ int idx = d->propertyNames->value(name);
+
+ if (idx == -1) {
+ d->propertyNames->add(name, d->idValueCount + d->propertyValues.count());
+ d->propertyValues.append(QVariant::fromValue(value));
+
+ d->refreshExpressions();
+ } else {
+ d->propertyValues[idx] = QVariant::fromValue(value);
+ QMetaObject::activate(this, idx + d->notifyIndex, 0);
+ }
+}
+
+/*!
+ Returns the value of the \a name property for this context
+ as a QVariant.
+ */
+QVariant QDeclarativeContext::contextProperty(const QString &name) const
+{
+ Q_D(const QDeclarativeContext);
+ QVariant value;
+ int idx = -1;
+ if (d->propertyNames)
+ idx = d->propertyNames->value(name);
+
+ if (idx == -1) {
+ QByteArray utf8Name = name.toUtf8();
+ for (int ii = d->defaultObjects.count() - 1; ii >= 0; --ii) {
+ QObject *obj = d->defaultObjects.at(ii);
+ QDeclarativePropertyCache::Data local;
+ QDeclarativePropertyCache::Data *property = QDeclarativePropertyCache::property(d->engine, obj, name, local);
+
+ if (property) {
+ value = obj->metaObject()->property(property->coreIndex).read(obj);
+ break;
+ }
+ }
+ if (!value.isValid() && parentContext())
+ value = parentContext()->contextProperty(name);
+ } else {
+ value = d->propertyValues[idx];
+ }
+
+ return value;
+}
+
+/*!
+ Resolves the URL \a src relative to the URL of the
+ containing component.
+
+ \sa QDeclarativeEngine::baseUrl(), setBaseUrl()
+*/
+QUrl QDeclarativeContext::resolvedUrl(const QUrl &src)
+{
+ Q_D(QDeclarativeContext);
+ QDeclarativeContext *ctxt = this;
+ if (src.isRelative() && !src.isEmpty()) {
+ if (ctxt) {
+ while(ctxt) {
+ if(ctxt->d_func()->url.isValid())
+ break;
+ else
+ ctxt = ctxt->parentContext();
+ }
+
+ if (ctxt)
+ return ctxt->d_func()->url.resolved(src);
+ else if (d->engine)
+ return d->engine->baseUrl().resolved(src);
+ }
+ return QUrl();
+ } else {
+ return src;
+ }
+}
+
+/*!
+ Explicitly sets the url resolvedUrl() will use for relative references to \a baseUrl.
+
+ Calling this function will override the url of the containing
+ component used by default.
+
+ \sa resolvedUrl()
+*/
+void QDeclarativeContext::setBaseUrl(const QUrl &baseUrl)
+{
+ d_func()->url = baseUrl;
+}
+
+/*!
+ Returns the base url of the component, or the containing component
+ if none is set.
+*/
+QUrl QDeclarativeContext::baseUrl() const
+{
+ const QDeclarativeContext* p = this;
+ while (p && p->d_func()->url.isEmpty()) {
+ p = p->parentContext();
+ }
+ if (p)
+ return p->d_func()->url;
+ else
+ return QUrl();
+}
+
+int QDeclarativeContextPrivate::context_count(QDeclarativeListProperty<QObject> *prop)
+{
+ QDeclarativeContext *context = static_cast<QDeclarativeContext*>(prop->object);
+ QDeclarativeContextPrivate *d = QDeclarativeContextPrivate::get(context);
+ int contextProperty = (int)(intptr_t)prop->data;
+
+ if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId<QList<QObject*> >()) {
+ return 0;
+ } else {
+ return ((const QList<QObject> *)d->propertyValues.at(contextProperty).constData())->count();
+ }
+}
+
+QObject *QDeclarativeContextPrivate::context_at(QDeclarativeListProperty<QObject> *prop, int index)
+{
+ QDeclarativeContext *context = static_cast<QDeclarativeContext*>(prop->object);
+ QDeclarativeContextPrivate *d = QDeclarativeContextPrivate::get(context);
+ int contextProperty = (int)(intptr_t)prop->data;
+
+ if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId<QList<QObject*> >()) {
+ return 0;
+ } else {
+ return ((const QList<QObject*> *)d->propertyValues.at(contextProperty).constData())->at(index);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecontext.h b/src/declarative/qml/qdeclarativecontext.h
new file mode 100644
index 0000000..0fb9bee
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecontext.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECONTEXT_H
+#define QDECLARATIVECONTEXT_H
+
+#include <QtCore/qurl.h>
+#include <QtCore/qobject.h>
+#include <QtScript/qscriptvalue.h>
+#include <QtCore/qmetatype.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QString;
+class QDeclarativeEngine;
+class QDeclarativeRefCount;
+class QDeclarativeContextPrivate;
+class QDeclarativeCompositeTypeData;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeContext : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeContext)
+
+public:
+ QDeclarativeContext(QDeclarativeEngine *parent, QObject *objParent=0);
+ QDeclarativeContext(QDeclarativeContext *parent, QObject *objParent=0);
+ virtual ~QDeclarativeContext();
+
+ QDeclarativeEngine *engine() const;
+ QDeclarativeContext *parentContext() const;
+
+ void addDefaultObject(QObject *);
+ void setContextProperty(const QString &, QObject *);
+ void setContextProperty(const QString &, const QVariant &);
+
+ QVariant contextProperty(const QString &) const;
+
+ QUrl resolvedUrl(const QUrl &);
+
+ void setBaseUrl(const QUrl &);
+ QUrl baseUrl() const;
+
+private:
+ friend class QDeclarativeVME;
+ friend class QDeclarativeEngine;
+ friend class QDeclarativeEnginePrivate;
+ friend class QDeclarativeExpression;
+ friend class QDeclarativeExpressionPrivate;
+ friend class QDeclarativeContextScriptClass;
+ friend class QDeclarativeObjectScriptClass;
+ friend class QDeclarativeComponent;
+ friend class QDeclarativeComponentPrivate;
+ friend class QDeclarativeScriptPrivate;
+ friend class QDeclarativeBoundSignalProxy;
+ QDeclarativeContext(QDeclarativeContext *parent, QObject *objParent, bool);
+ QDeclarativeContext(QDeclarativeEngine *, bool);
+};
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QList<QObject*>);
+
+QT_END_HEADER
+
+#endif // QDECLARATIVECONTEXT_H
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
new file mode 100644
index 0000000..8297280
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECONTEXT_P_H
+#define QDECLARATIVECONTEXT_P_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 "qdeclarativecontext.h"
+
+#include "qdeclarativedeclarativedata_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativeintegercache_p.h"
+#include "qdeclarativetypenamecache_p.h"
+
+#include <QtCore/qhash.h>
+#include <QtScript/qscriptvalue.h>
+#include <QtCore/qset.h>
+
+#include <private/qobject_p.h>
+#include "qdeclarativeguard_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeContext;
+class QDeclarativeExpression;
+class QDeclarativeEngine;
+class QDeclarativeExpression;
+class QDeclarativeExpressionPrivate;
+class QDeclarativeAbstractExpression;
+class QDeclarativeBinding_Id;
+class QDeclarativeCompiledBindings;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeContextPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeContext)
+public:
+ QDeclarativeContextPrivate();
+
+ QDeclarativeContext *parent;
+ QDeclarativeEngine *engine;
+
+ bool isInternal;
+
+ QDeclarativeIntegerCache *propertyNames;
+ QList<QVariant> propertyValues;
+ int notifyIndex;
+
+ QObjectList defaultObjects;
+ int highPriorityCount;
+
+ QList<QScriptValue> scripts;
+ void addScript(const QDeclarativeParser::Object::ScriptBlock &, QObject *);
+
+ QUrl url;
+
+ QDeclarativeTypeNameCache *imports;
+
+ void init();
+
+ void invalidateEngines();
+ void refreshExpressions();
+ QSet<QDeclarativeContext *> childContexts;
+
+ QDeclarativeAbstractExpression *expressions;
+
+ QDeclarativeDeclarativeData *contextObjects;
+
+ struct IdNotifier
+ {
+ inline IdNotifier();
+ inline ~IdNotifier();
+
+ inline void clear();
+
+ IdNotifier *next;
+ IdNotifier**prev;
+ QObject *target;
+ int methodIndex;
+ };
+
+ struct ContextGuard : public QDeclarativeGuard<QObject>
+ {
+ inline ContextGuard();
+ inline ContextGuard &operator=(QObject *obj);
+ inline virtual void objectDestroyed(QObject *);
+
+ QDeclarativeContextPrivate *priv;
+ IdNotifier *bindings;
+ };
+ ContextGuard *idValues;
+ int idValueCount;
+ void setIdProperty(int, QObject *);
+ void setIdPropertyData(QDeclarativeIntegerCache *);
+ void destroyed(ContextGuard *);
+
+ static QDeclarativeContextPrivate *get(QDeclarativeContext *context) {
+ return static_cast<QDeclarativeContextPrivate *>(QObjectPrivate::get(context));
+ }
+ static QDeclarativeContext *get(QDeclarativeContextPrivate *context) {
+ return static_cast<QDeclarativeContext *>(context->q_func());
+ }
+
+ QDeclarativeCompiledBindings *optimizedBindings;
+
+ // Only used for debugging
+ QList<QPointer<QObject> > instances;
+
+ static int context_count(QDeclarativeListProperty<QObject> *);
+ static QObject *context_at(QDeclarativeListProperty<QObject> *, int);
+};
+
+QDeclarativeContextPrivate::IdNotifier::IdNotifier()
+: next(0), prev(0), target(0), methodIndex(-1)
+{
+}
+
+QDeclarativeContextPrivate::IdNotifier::~IdNotifier()
+{
+ clear();
+}
+
+void QDeclarativeContextPrivate::IdNotifier::clear()
+{
+ if (next) next->prev = prev;
+ if (prev) *prev = next;
+ next = 0; prev = 0; target = 0;
+ methodIndex = -1;
+}
+
+QDeclarativeContextPrivate::ContextGuard::ContextGuard()
+: priv(0), bindings(0)
+{
+}
+
+QDeclarativeContextPrivate::ContextGuard &QDeclarativeContextPrivate::ContextGuard::operator=(QObject *obj)
+{
+ (QDeclarativeGuard<QObject>&)*this = obj; return *this;
+}
+
+void QDeclarativeContextPrivate::ContextGuard::objectDestroyed(QObject *)
+{
+ priv->destroyed(this);
+}
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVECONTEXT_P_H
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
new file mode 100644
index 0000000..7deed0b
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecontextscriptclass_p.h"
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativetypenamescriptclass_p.h"
+#include "qdeclarativelistscriptclass_p.h"
+#include "qdeclarativeguard_p.h"
+
+QT_BEGIN_NAMESPACE
+
+struct ContextData : public QScriptDeclarativeClass::Object {
+ ContextData() : isSharedContext(true) {}
+ ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), isSharedContext(false) {}
+ QDeclarativeGuard<QDeclarativeContext> context;
+ QDeclarativeGuard<QObject> scopeObject;
+ bool isSharedContext;
+
+ QDeclarativeContext *getContext(QDeclarativeEngine *engine) {
+ if (isSharedContext) {
+ return QDeclarativeEnginePrivate::get(engine)->sharedContext;
+ } else {
+ return context.data();
+ }
+ }
+
+ QObject *getScope(QDeclarativeEngine *engine) {
+ if (isSharedContext) {
+ return QDeclarativeEnginePrivate::get(engine)->sharedScope;
+ } else {
+ return scopeObject.data();
+ }
+ }
+};
+
+/*
+ The QDeclarativeContextScriptClass handles property access for a QDeclarativeContext
+ via QtScript.
+ */
+QDeclarativeContextScriptClass::QDeclarativeContextScriptClass(QDeclarativeEngine *bindEngine)
+: QDeclarativeScriptClass(QDeclarativeEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine),
+ lastScopeObject(0), lastContext(0), lastData(0), lastPropertyIndex(-1), lastDefaultObject(-1)
+{
+}
+
+QDeclarativeContextScriptClass::~QDeclarativeContextScriptClass()
+{
+}
+
+QScriptValue QDeclarativeContextScriptClass::newContext(QDeclarativeContext *context, QObject *scopeObject)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ return newObject(scriptEngine, this, new ContextData(context, scopeObject));
+}
+
+QScriptValue QDeclarativeContextScriptClass::newSharedContext()
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ return newObject(scriptEngine, this, new ContextData());
+}
+
+QDeclarativeContext *QDeclarativeContextScriptClass::contextFromValue(const QScriptValue &v)
+{
+ if (scriptClass(v) != this)
+ return 0;
+
+ ContextData *data = (ContextData *)object(v);
+ return data->getContext(engine);
+}
+
+QScriptClass::QueryFlags
+QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &name,
+ QScriptClass::QueryFlags flags)
+{
+ Q_UNUSED(flags);
+
+ lastScopeObject = 0;
+ lastContext = 0;
+ lastData = 0;
+ lastPropertyIndex = -1;
+ lastDefaultObject = -1;
+
+ QDeclarativeContext *bindContext = ((ContextData *)object)->getContext(engine);
+ QObject *scopeObject = ((ContextData *)object)->getScope(engine);
+ if (!bindContext)
+ return 0;
+
+ bool includeTypes = true;
+ while (bindContext) {
+ QScriptClass::QueryFlags rv =
+ queryProperty(bindContext, scopeObject, name, flags, includeTypes);
+ scopeObject = 0; // Only applies to the first context
+ includeTypes = false; // Only applies to the first context
+ if (rv) return rv;
+ bindContext = bindContext->parentContext();
+ }
+
+ return 0;
+}
+
+QScriptClass::QueryFlags
+QDeclarativeContextScriptClass::queryProperty(QDeclarativeContext *bindContext, QObject *scopeObject,
+ const Identifier &name,
+ QScriptClass::QueryFlags flags,
+ bool includeTypes)
+{
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QDeclarativeContextPrivate *cp = QDeclarativeContextPrivate::get(bindContext);
+
+ lastPropertyIndex = cp->propertyNames?cp->propertyNames->value(name):-1;
+ if (lastPropertyIndex != -1) {
+ lastContext = bindContext;
+ return QScriptClass::HandlesReadAccess;
+ }
+
+ if (includeTypes && cp->imports) {
+ QDeclarativeTypeNameCache::Data *data = cp->imports->data(name);
+
+ if (data) {
+ lastData = data;
+ lastContext = bindContext;
+ return QScriptClass::HandlesReadAccess;
+ }
+ }
+
+ for (int ii = 0; ii < cp->scripts.count(); ++ii) {
+ lastFunction = QScriptDeclarativeClass::function(cp->scripts.at(ii), name);
+ if (lastFunction.isValid()) {
+ lastContext = bindContext;
+ return QScriptClass::HandlesReadAccess;
+ }
+ }
+
+ if (scopeObject) {
+ QScriptClass::QueryFlags rv =
+ ep->objectClass->queryProperty(scopeObject, name, flags, bindContext,
+ QDeclarativeObjectScriptClass::ImplicitObject | QDeclarativeObjectScriptClass::SkipAttachedProperties);
+ if (rv) {
+ lastScopeObject = scopeObject;
+ lastContext = bindContext;
+ return rv;
+ }
+ }
+
+ for (int ii = cp->defaultObjects.count() - 1; ii >= 0; --ii) {
+ QScriptClass::QueryFlags rv =
+ ep->objectClass->queryProperty(cp->defaultObjects.at(ii), name, flags, bindContext,
+ QDeclarativeObjectScriptClass::ImplicitObject | QDeclarativeObjectScriptClass::SkipAttachedProperties);
+
+ if (rv) {
+ lastDefaultObject = ii;
+ lastContext = bindContext;
+ return rv;
+ }
+ }
+
+ return 0;
+}
+
+QDeclarativeContextScriptClass::ScriptValue
+QDeclarativeContextScriptClass::property(Object *object, const Identifier &name)
+{
+ Q_UNUSED(object);
+
+ QDeclarativeContext *bindContext = lastContext;
+ Q_ASSERT(bindContext);
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QDeclarativeContextPrivate *cp = QDeclarativeContextPrivate::get(bindContext);
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ if (lastScopeObject) {
+
+ return ep->objectClass->property(lastScopeObject, name);
+
+ } else if (lastData) {
+
+ if (lastData->type)
+ return Value(scriptEngine, ep->typeNameClass->newObject(cp->defaultObjects.at(0), lastData->type));
+ else
+ return Value(scriptEngine, ep->typeNameClass->newObject(cp->defaultObjects.at(0), lastData->typeNamespace));
+
+ } else if (lastPropertyIndex != -1) {
+
+ QScriptValue rv;
+ if (lastPropertyIndex < cp->idValueCount) {
+ rv = ep->objectClass->newQObject(cp->idValues[lastPropertyIndex].data());
+ } else {
+ const QVariant &value = cp->propertyValues.at(lastPropertyIndex);
+ if (value.userType() == qMetaTypeId<QList<QObject*> >()) {
+ rv = ep->listClass->newList(QDeclarativeListProperty<QObject>(bindContext, (void*)lastPropertyIndex, 0, QDeclarativeContextPrivate::context_count, QDeclarativeContextPrivate::context_at), qMetaTypeId<QDeclarativeListProperty<QObject> >());
+ } else {
+ rv = ep->scriptValueFromVariant(value);
+ }
+ }
+
+ ep->capturedProperties <<
+ QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex);
+
+ return Value(scriptEngine, rv);
+ } else if(lastDefaultObject != -1) {
+
+ // Default object property
+ return ep->objectClass->property(cp->defaultObjects.at(lastDefaultObject), name);
+
+ } else {
+
+ return Value(scriptEngine, lastFunction);
+
+ }
+}
+
+void QDeclarativeContextScriptClass::setProperty(Object *object, const Identifier &name,
+ const QScriptValue &value)
+{
+ Q_UNUSED(object);
+ Q_ASSERT(lastScopeObject || lastDefaultObject != -1);
+
+ QDeclarativeContext *bindContext = lastContext;
+ Q_ASSERT(bindContext);
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QDeclarativeContextPrivate *cp = QDeclarativeContextPrivate::get(bindContext);
+
+ if (lastScopeObject) {
+ ep->objectClass->setProperty(lastScopeObject, name, value, bindContext);
+ } else {
+ ep->objectClass->setProperty(cp->defaultObjects.at(lastDefaultObject), name, value,
+ bindContext);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass_p.h b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
new file mode 100644
index 0000000..26086ec
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECONTEXTSCRIPTCLASS_P_H
+#define QDECLARATIVECONTEXTSCRIPTCLASS_P_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 "qdeclarativetypenamecache_p.h"
+#include "qdeclarativescriptclass_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QDeclarativeContext;
+class QDeclarativeContextScriptClass : public QDeclarativeScriptClass
+{
+public:
+ QDeclarativeContextScriptClass(QDeclarativeEngine *);
+ ~QDeclarativeContextScriptClass();
+
+ QScriptValue newContext(QDeclarativeContext *, QObject * = 0);
+ QScriptValue newSharedContext();
+
+ QDeclarativeContext *contextFromValue(const QScriptValue &);
+
+protected:
+ virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
+ QScriptClass::QueryFlags flags);
+ virtual ScriptValue property(Object *, const Identifier &);
+ virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
+
+private:
+ QScriptClass::QueryFlags queryProperty(QDeclarativeContext *, QObject *scopeObject,
+ const Identifier &,
+ QScriptClass::QueryFlags flags,
+ bool includeTypes);
+
+ QDeclarativeEngine *engine;
+
+ QObject *lastScopeObject;
+ QDeclarativeContext *lastContext;
+ QDeclarativeTypeNameCache::Data *lastData;
+ int lastPropertyIndex;
+ int lastDefaultObject;
+ QScriptValue lastFunction;
+
+ uint m_id;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVECONTEXTSCRIPTCLASS_P_H
+
diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp
new file mode 100644
index 0000000..67f0963
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecustomparser.cpp
@@ -0,0 +1,263 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecustomparser_p.h"
+#include "qdeclarativecustomparser_p_p.h"
+
+#include "qdeclarativeparser_p.h"
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QDeclarativeParser;
+
+/*!
+ \class QDeclarativeCustomParser
+ \brief The QDeclarativeCustomParser class allows you to add new arbitrary types to QML.
+ \internal
+
+ By subclassing QDeclarativeCustomParser, you can add a parser for
+ building a particular type.
+
+ The subclass must implement compile() and setCustomData(), and register
+ itself in the meta type system by calling the macro:
+
+ \code
+ QML_REGISTER_CUSTOM_TYPE(Module, MajorVersion, MinorVersion, Name, TypeClass, ParserClass)
+ \endcode
+*/
+
+/*
+ \fn QByteArray QDeclarativeCustomParser::compile(const QList<QDeclarativeCustomParserProperty> & properties)
+
+ The custom parser processes \a properties, and returns
+ a QByteArray containing data meaningful only to the
+ custom parser; the type engine will pass this same data to
+ setCustomData() when making an instance of the data.
+
+ Errors must be reported via the error() functions.
+
+ 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 void QDeclarativeCustomParser::setCustomData(QObject *object, const QByteArray &data)
+
+ This function sets \a object to have the properties defined
+ by \a data, which is a block of data previously returned by a call
+ to compile().
+
+ The \a object will be an instance of the TypeClass specified by QML_REGISTER_CUSTOM_TYPE.
+*/
+
+QDeclarativeCustomParserNode
+QDeclarativeCustomParserNodePrivate::fromObject(QDeclarativeParser::Object *root)
+{
+ QDeclarativeCustomParserNode rootNode;
+ rootNode.d->name = root->typeName;
+ rootNode.d->location = root->location.start;
+
+ for(QHash<QByteArray, Property *>::Iterator iter = root->properties.begin();
+ iter != root->properties.end();
+ ++iter) {
+
+ Property *p = *iter;
+
+ rootNode.d->properties << fromProperty(p);
+ }
+
+ return rootNode;
+}
+
+QDeclarativeCustomParserProperty
+QDeclarativeCustomParserNodePrivate::fromProperty(QDeclarativeParser::Property *p)
+{
+ QDeclarativeCustomParserProperty prop;
+ prop.d->name = p->name;
+ prop.d->isList = (p->values.count() > 1);
+ prop.d->location = p->location.start;
+
+ if (p->value) {
+ QDeclarativeCustomParserNode node = fromObject(p->value);
+ QList<QDeclarativeCustomParserProperty> props = node.properties();
+ for (int ii = 0; ii < props.count(); ++ii)
+ prop.d->values << QVariant::fromValue(props.at(ii));
+ } else {
+ for(int ii = 0; ii < p->values.count(); ++ii) {
+ Value *v = p->values.at(ii);
+ v->type = QDeclarativeParser::Value::Literal;
+
+ if(v->object) {
+ QDeclarativeCustomParserNode node = fromObject(v->object);
+ prop.d->values << QVariant::fromValue(node);
+ } else {
+ prop.d->values << QVariant::fromValue(v->value);
+ }
+
+ }
+ }
+
+ return prop;
+}
+
+QDeclarativeCustomParserNode::QDeclarativeCustomParserNode()
+: d(new QDeclarativeCustomParserNodePrivate)
+{
+}
+
+QDeclarativeCustomParserNode::QDeclarativeCustomParserNode(const QDeclarativeCustomParserNode &other)
+: d(new QDeclarativeCustomParserNodePrivate)
+{
+ *this = other;
+}
+
+QDeclarativeCustomParserNode &QDeclarativeCustomParserNode::operator=(const QDeclarativeCustomParserNode &other)
+{
+ d->name = other.d->name;
+ d->properties = other.d->properties;
+ d->location = other.d->location;
+ return *this;
+}
+
+QDeclarativeCustomParserNode::~QDeclarativeCustomParserNode()
+{
+ delete d; d = 0;
+}
+
+QByteArray QDeclarativeCustomParserNode::name() const
+{
+ return d->name;
+}
+
+QList<QDeclarativeCustomParserProperty> QDeclarativeCustomParserNode::properties() const
+{
+ return d->properties;
+}
+
+QDeclarativeParser::Location QDeclarativeCustomParserNode::location() const
+{
+ return d->location;
+}
+
+QDeclarativeCustomParserProperty::QDeclarativeCustomParserProperty()
+: d(new QDeclarativeCustomParserPropertyPrivate)
+{
+}
+
+QDeclarativeCustomParserProperty::QDeclarativeCustomParserProperty(const QDeclarativeCustomParserProperty &other)
+: d(new QDeclarativeCustomParserPropertyPrivate)
+{
+ *this = other;
+}
+
+QDeclarativeCustomParserProperty &QDeclarativeCustomParserProperty::operator=(const QDeclarativeCustomParserProperty &other)
+{
+ d->name = other.d->name;
+ d->isList = other.d->isList;
+ d->values = other.d->values;
+ d->location = other.d->location;
+ return *this;
+}
+
+QDeclarativeCustomParserProperty::~QDeclarativeCustomParserProperty()
+{
+ delete d; d = 0;
+}
+
+QByteArray QDeclarativeCustomParserProperty::name() const
+{
+ return d->name;
+}
+
+bool QDeclarativeCustomParserProperty::isList() const
+{
+ return d->isList;
+}
+
+QDeclarativeParser::Location QDeclarativeCustomParserProperty::location() const
+{
+ return d->location;
+}
+
+QList<QVariant> QDeclarativeCustomParserProperty::assignedValues() const
+{
+ return d->values;
+}
+
+void QDeclarativeCustomParser::clearErrors()
+{
+ exceptions.clear();
+}
+
+/*!
+ Reports an error in parsing \a prop, with the given \a description.
+
+ An error is generated referring to the position of \a node in the source file.
+*/
+void QDeclarativeCustomParser::error(const QDeclarativeCustomParserProperty& prop, const QString& description)
+{
+ QDeclarativeError error;
+ QString exceptionDescription;
+ error.setLine(prop.location().line);
+ error.setColumn(prop.location().column);
+ error.setDescription(description);
+ exceptions << error;
+}
+
+/*!
+ Reports an error in parsing \a node, with the given \a description.
+
+ An error is generated referring to the position of \a node in the source file.
+*/
+void QDeclarativeCustomParser::error(const QDeclarativeCustomParserNode& node, const QString& description)
+{
+ QDeclarativeError error;
+ QString exceptionDescription;
+ error.setLine(node.location().line);
+ error.setColumn(node.location().column);
+ error.setDescription(description);
+ exceptions << error;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
new file mode 100644
index 0000000..cef1f3c
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecustomparser_p.h
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECUSTOMPARSER_H
+#define QDECLARATIVECUSTOMPARSER_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 "qdeclarativemetatype.h"
+#include "qdeclarativeerror.h"
+#include "qdeclarativeparser_p.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qxmlstream.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeCustomParserPropertyPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserProperty
+{
+public:
+ QDeclarativeCustomParserProperty();
+ QDeclarativeCustomParserProperty(const QDeclarativeCustomParserProperty &);
+ QDeclarativeCustomParserProperty &operator=(const QDeclarativeCustomParserProperty &);
+ ~QDeclarativeCustomParserProperty();
+
+ QByteArray name() const;
+ QDeclarativeParser::Location location() const;
+
+ bool isList() const;
+ // Will be one of QDeclarativeParser::Variant, QDeclarativeCustomParserProperty or
+ // QDeclarativeCustomParserNode
+ QList<QVariant> assignedValues() const;
+
+private:
+ friend class QDeclarativeCustomParserNodePrivate;
+ friend class QDeclarativeCustomParserPropertyPrivate;
+ QDeclarativeCustomParserPropertyPrivate *d;
+};
+
+class QDeclarativeCustomParserNodePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserNode
+{
+public:
+ QDeclarativeCustomParserNode();
+ QDeclarativeCustomParserNode(const QDeclarativeCustomParserNode &);
+ QDeclarativeCustomParserNode &operator=(const QDeclarativeCustomParserNode &);
+ ~QDeclarativeCustomParserNode();
+
+ QByteArray name() const;
+ QDeclarativeParser::Location location() const;
+
+ QList<QDeclarativeCustomParserProperty> properties() const;
+
+private:
+ friend class QDeclarativeCustomParserNodePrivate;
+ QDeclarativeCustomParserNodePrivate *d;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeCustomParser
+{
+public:
+ virtual ~QDeclarativeCustomParser() {}
+
+ void clearErrors();
+
+ virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &)=0;
+ virtual void setCustomData(QObject *, const QByteArray &)=0;
+
+ QList<QDeclarativeError> errors() const { return exceptions; }
+
+protected:
+ void error(const QDeclarativeCustomParserProperty&, const QString& description);
+ void error(const QDeclarativeCustomParserNode&, const QString& description);
+
+private:
+ QList<QDeclarativeError> exceptions;
+};
+
+#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
+ qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE)
+
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeclarativeCustomParserProperty)
+Q_DECLARE_METATYPE(QDeclarativeCustomParserNode)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/qml/qdeclarativecustomparser_p_p.h b/src/declarative/qml/qdeclarativecustomparser_p_p.h
new file mode 100644
index 0000000..b580db6
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecustomparser_p_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECUSTOMPARSER_P_H
+#define QDECLARATIVECUSTOMPARSER_P_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 "qdeclarativecustomparser_p.h"
+
+#include "qdeclarativeparser_p.h"
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCustomParserNodePrivate
+{
+public:
+ QByteArray name;
+ QList<QDeclarativeCustomParserProperty> properties;
+ QDeclarativeParser::Location location;
+
+ static QDeclarativeCustomParserNode fromObject(QDeclarativeParser::Object *);
+ static QDeclarativeCustomParserProperty fromProperty(QDeclarativeParser::Property *);
+};
+
+class QDeclarativeCustomParserPropertyPrivate
+{
+public:
+ QDeclarativeCustomParserPropertyPrivate()
+ : isList(false) {}
+
+ QByteArray name;
+ bool isList;
+ QDeclarativeParser::Location location;
+ QList<QVariant> values;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVECUSTOMPARSER_P_H
diff --git a/src/declarative/qml/qdeclarativedeclarativedata_p.h b/src/declarative/qml/qdeclarativedeclarativedata_p.h
new file mode 100644
index 0000000..2c92419
--- /dev/null
+++ b/src/declarative/qml/qdeclarativedeclarativedata_p.h
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEDECLARATIVEDATA_P_H
+#define QDECLARATIVEDECLARATIVEDATA_P_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 <QtScript/qscriptvalue.h>
+#include <private/qobject_p.h>
+#include "qdeclarativeguard_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCompiledData;
+class QDeclarativeAbstractBinding;
+class QDeclarativeContext;
+class QDeclarativePropertyCache;
+class Q_AUTOTEST_EXPORT QDeclarativeDeclarativeData : public QDeclarativeData
+{
+public:
+ QDeclarativeDeclarativeData(QDeclarativeContext *ctxt = 0)
+ : context(ctxt), bindings(0), nextContextObject(0), prevContextObject(0),
+ bindingBitsSize(0), bindingBits(0), outerContext(0), lineNumber(0),
+ columnNumber(0), deferredComponent(0), deferredIdx(0), attachedProperties(0),
+ propertyCache(0), guards(0) {}
+
+ virtual void destroyed(QObject *);
+
+ QDeclarativeContext *context;
+ QDeclarativeAbstractBinding *bindings;
+
+ // Linked list for QDeclarativeContext::contextObjects
+ QDeclarativeDeclarativeData *nextContextObject;
+ QDeclarativeDeclarativeData**prevContextObject;
+
+ int bindingBitsSize;
+ quint32 *bindingBits;
+ bool hasBindingBit(int) const;
+ void clearBindingBit(int);
+ void setBindingBit(QObject *obj, int);
+
+ QDeclarativeContext *outerContext; // Can't this be found from context?
+ ushort lineNumber;
+ ushort columnNumber;
+
+ QDeclarativeCompiledData *deferredComponent; // Can't this be found from the context?
+ unsigned int deferredIdx;
+
+ QHash<int, QObject *> *attachedProperties;
+
+ QScriptValue scriptValue;
+ QDeclarativePropertyCache *propertyCache;
+
+ QDeclarativeGuard<QObject> *guards;
+
+ static QDeclarativeDeclarativeData *get(const QObject *object, bool create = false) {
+ QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
+ if (priv->declarativeData) {
+ return static_cast<QDeclarativeDeclarativeData *>(priv->declarativeData);
+ } else if (create) {
+ priv->declarativeData = new QDeclarativeDeclarativeData;
+ return static_cast<QDeclarativeDeclarativeData *>(priv->declarativeData);
+ } else {
+ return 0;
+ }
+ }
+};
+
+template<class T>
+void QDeclarativeGuard<T>::addGuard()
+{
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(o, true);
+ next = data->guards;
+ if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = &next;
+ data->guards = reinterpret_cast<QDeclarativeGuard<QObject> *>(this);
+ prev = &data->guards;
+}
+
+template<class T>
+void QDeclarativeGuard<T>::remGuard()
+{
+ if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = prev;
+ *prev = next;
+ next = 0;
+ prev = 0;
+}
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEDECLARATIVEDATA_P_H
diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp
new file mode 100644
index 0000000..e730b92
--- /dev/null
+++ b/src/declarative/qml/qdeclarativedirparser.cpp
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativedirparser_p.h"
+#include "qdeclarativeerror.h"
+
+#include <QtCore/QTextStream>
+#include <QtCore/QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeDirParser::QDeclarativeDirParser()
+ : _isParsed(false)
+{
+}
+
+QDeclarativeDirParser::~QDeclarativeDirParser()
+{
+}
+
+QUrl QDeclarativeDirParser::url() const
+{
+ return _url;
+}
+
+void QDeclarativeDirParser::setUrl(const QUrl &url)
+{
+ _url = url;
+}
+
+QString QDeclarativeDirParser::source() const
+{
+ return _source;
+}
+
+void QDeclarativeDirParser::setSource(const QString &source)
+{
+ _isParsed = false;
+ _source = source;
+}
+
+bool QDeclarativeDirParser::isParsed() const
+{
+ return _isParsed;
+}
+
+bool QDeclarativeDirParser::parse()
+{
+ if (_isParsed)
+ return true;
+
+ _isParsed = true;
+ _errors.clear();
+ _plugins.clear();
+ _components.clear();
+
+ QTextStream stream(&_source);
+ int lineNumber = 0;
+
+ forever {
+ ++lineNumber;
+
+ const QString line = stream.readLine();
+ if (line.isNull())
+ break;
+
+ QString sections[3];
+ int sectionCount = 0;
+
+ int index = 0;
+ const int length = line.length();
+
+ while (index != length) {
+ const QChar ch = line.at(index);
+
+ if (ch.isSpace()) {
+ do { ++index; }
+ while (index != length && line.at(index).isSpace());
+
+ } else if (ch == QLatin1Char('#')) {
+ // recognized a comment
+ break;
+
+ } else {
+ const int start = index;
+
+ do { ++index; }
+ while (index != length && !line.at(index).isSpace());
+
+ const QString lexeme = line.mid(start, index - start);
+
+ if (sectionCount >= 3) {
+ reportError(lineNumber, start, QLatin1String("unexpected token"));
+
+ } else {
+ sections[sectionCount++] = lexeme;
+ }
+ }
+ }
+
+ if (sectionCount == 0) {
+ continue; // no sections, no party.
+
+ } else if (sections[0] == QLatin1String("plugin")) {
+ if (sectionCount < 2) {
+ reportError(lineNumber, -1,
+ QString::fromUtf8("plugin directive requires 2 arguments, but %1 were provided").arg(sectionCount + 1));
+
+ continue;
+ }
+
+ const Plugin entry(sections[1], sections[2]);
+
+ _plugins.append(entry);
+
+ } else if (sectionCount == 3) {
+ const QString &version = sections[1];
+ const int dotIndex = version.indexOf(QLatin1Char('.'));
+
+ if (dotIndex == -1) {
+ qWarning() << "expected '.'"; // ### use reportError
+
+ } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) {
+ qWarning() << "unexpected '.'"; // ### use reportError
+
+ } else {
+ bool validVersionNumber = false;
+ const int majorVersion = version.left(dotIndex).toInt(&validVersionNumber);
+
+ if (validVersionNumber) {
+ const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber);
+
+ if (validVersionNumber) {
+ const Component entry(sections[0], sections[2], majorVersion, minorVersion);
+
+ _components.append(entry);
+ }
+ }
+ }
+ } else {
+ // ### use reportError
+ qWarning() << "a component declaration requires 3 arguments, but" << (sectionCount + 1) << "were provided";
+ }
+ }
+
+ return hasError();
+}
+
+void QDeclarativeDirParser::reportError(int line, int column, const QString &description)
+{
+ QDeclarativeError error;
+ error.setUrl(_url);
+ error.setLine(line);
+ error.setColumn(column);
+ error.setDescription(description);
+ _errors.append(error);
+}
+
+bool QDeclarativeDirParser::hasError() const
+{
+ if (! _errors.isEmpty())
+ return true;
+
+ return false;
+}
+
+QList<QDeclarativeError> QDeclarativeDirParser::errors() const
+{
+ return _errors;
+}
+
+QList<QDeclarativeDirParser::Plugin> QDeclarativeDirParser::plugins() const
+{
+ return _plugins;
+}
+
+QList<QDeclarativeDirParser::Component> QDeclarativeDirParser::components() const
+{
+ return _components;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativedirparser_p.h b/src/declarative/qml/qdeclarativedirparser_p.h
new file mode 100644
index 0000000..5df7117
--- /dev/null
+++ b/src/declarative/qml/qdeclarativedirparser_p.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEDIRPARSER_P_H
+#define QDECLARATIVEDIRPARSER_P_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/QUrl>
+#include <QtCore/QHash>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeError;
+
+class QDeclarativeDirParser
+{
+ Q_DISABLE_COPY(QDeclarativeDirParser)
+
+public:
+ QDeclarativeDirParser();
+ ~QDeclarativeDirParser();
+
+ QUrl url() const;
+ void setUrl(const QUrl &url);
+
+ QString source() const;
+ void setSource(const QString &source);
+
+ bool isParsed() const;
+ bool parse();
+
+ bool hasError() const;
+ QList<QDeclarativeError> errors() const;
+
+ struct Plugin
+ {
+ Plugin() {}
+
+ Plugin(const QString &name, const QString &path)
+ : name(name), path(path) {}
+
+ QString name;
+ QString path;
+ };
+
+ struct Component
+ {
+ Component()
+ : majorVersion(0), minorVersion(0) {}
+
+ Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
+ : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {}
+
+ QString typeName;
+ QString fileName;
+ int majorVersion;
+ int minorVersion;
+ };
+
+ QList<Component> components() const;
+ QList<Plugin> plugins() const;
+
+private:
+ void reportError(int line, int column, const QString &message);
+
+private:
+ QList<QDeclarativeError> _errors;
+ QUrl _url;
+ QString _source;
+ QList<Component> _components;
+ QList<Plugin> _plugins;
+ unsigned _isParsed: 1;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEDIRPARSER_P_H
diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp
new file mode 100644
index 0000000..6c81f34
--- /dev/null
+++ b/src/declarative/qml/qdeclarativedom.cpp
@@ -0,0 +1,1836 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativedom_p.h"
+#include "qdeclarativedom_p_p.h"
+
+#include "qdeclarativecompositetypedata_p.h"
+#include "qdeclarativecompiler_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativescriptparser_p.h"
+#include "qdeclarativeglobal_p.h"
+
+#include <QtCore/QByteArray>
+#include <QtCore/QDebug>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeDomDocumentPrivate::QDeclarativeDomDocumentPrivate()
+: root(0)
+{
+}
+
+QDeclarativeDomDocumentPrivate::~QDeclarativeDomDocumentPrivate()
+{
+ if (root) root->release();
+}
+
+/*!
+ \class QDeclarativeDomDocument
+ \internal
+ \brief The QDeclarativeDomDocument class represents the root of a QML document
+
+ A QML document is a self-contained snippet of QML, usually contained in a
+ single file. Each document has a root object, accessible through
+ QDeclarativeDomDocument::rootObject().
+
+ The QDeclarativeDomDocument class allows the programmer to inspect a QML document by
+ calling QDeclarativeDomDocument::load().
+
+ The following example loads a QML file from disk, and prints out its root
+ object type and the properties assigned in the root object.
+ \code
+ QFile file(inputFileName);
+ file.open(QIODevice::ReadOnly);
+ QByteArray xmlData = file.readAll();
+
+ QDeclarativeDomDocument document;
+ document.load(qmlengine, xmlData);
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ qDebug() << rootObject.objectType();
+ foreach(QDeclarativeDomProperty property, rootObject.properties())
+ qDebug() << property.propertyName();
+ \endcode
+*/
+
+/*!
+ Construct an empty QDeclarativeDomDocument.
+*/
+QDeclarativeDomDocument::QDeclarativeDomDocument()
+: d(new QDeclarativeDomDocumentPrivate)
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomDocument.
+*/
+QDeclarativeDomDocument::QDeclarativeDomDocument(const QDeclarativeDomDocument &other)
+: d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomDocument
+*/
+QDeclarativeDomDocument::~QDeclarativeDomDocument()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomDocument.
+*/
+QDeclarativeDomDocument &QDeclarativeDomDocument::operator=(const QDeclarativeDomDocument &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Returns all import statements in qml.
+*/
+QList<QDeclarativeDomImport> QDeclarativeDomDocument::imports() const
+{
+ return d->imports;
+}
+
+/*!
+ Loads a QDeclarativeDomDocument from \a data. \a data should be valid QML
+ data. On success, true is returned. If the \a data is malformed, false
+ is returned and QDeclarativeDomDocument::errors() contains an error description.
+
+ \sa QDeclarativeDomDocument::loadError()
+*/
+bool QDeclarativeDomDocument::load(QDeclarativeEngine *engine, const QByteArray &data, const QUrl &url)
+{
+ d->errors.clear();
+ d->imports.clear();
+
+ QDeclarativeCompiledData *component = new QDeclarativeCompiledData(engine);
+ QDeclarativeCompiler compiler;
+
+ QDeclarativeCompositeTypeData *td = ((QDeclarativeEnginePrivate *)QDeclarativeEnginePrivate::get(engine))->typeManager.getImmediate(data, url);
+
+ if(td->status == QDeclarativeCompositeTypeData::Error) {
+ d->errors = td->errors;
+ td->release();
+ component->release();
+ return false;
+ } else if(td->status == QDeclarativeCompositeTypeData::Waiting ||
+ td->status == QDeclarativeCompositeTypeData::WaitingResources) {
+ QDeclarativeError error;
+ error.setDescription(QLatin1String("QDeclarativeDomDocument supports local types only"));
+ d->errors << error;
+ td->release();
+ component->release();
+ return false;
+ }
+
+ compiler.compile(engine, td, component);
+
+ if (compiler.isError()) {
+ d->errors = compiler.errors();
+ td->release();
+ component->release();
+ return false;
+ }
+
+ for (int i = 0; i < td->data.imports().size(); ++i) {
+ QDeclarativeScriptParser::Import parserImport = td->data.imports().at(i);
+ QDeclarativeDomImport domImport;
+ domImport.d->type = static_cast<QDeclarativeDomImportPrivate::Type>(parserImport.type);
+ domImport.d->uri = parserImport.uri;
+ domImport.d->qualifier = parserImport.qualifier;
+ domImport.d->version = parserImport.version;
+ d->imports += domImport;
+ }
+
+ if (td->data.tree()) {
+ d->root = td->data.tree();
+ d->root->addref();
+ }
+
+ component->release();
+ return true;
+}
+
+/*!
+ Returns the last load errors. The load errors will be reset after a
+ successful call to load().
+
+ \sa load()
+*/
+QList<QDeclarativeError> QDeclarativeDomDocument::errors() const
+{
+ return d->errors;
+}
+
+/*!
+ Returns the document's root object, or an invalid QDeclarativeDomObject if the
+ document has no root.
+
+ In the sample QML below, the root object will be the QDeclarativeItem type.
+ \qml
+Item {
+ Text {
+ text: "Hello World"
+ }
+}
+ \endqml
+*/
+QDeclarativeDomObject QDeclarativeDomDocument::rootObject() const
+{
+ QDeclarativeDomObject rv;
+ rv.d->object = d->root;
+ if (rv.d->object) rv.d->object->addref();
+ return rv;
+}
+
+QDeclarativeDomPropertyPrivate::QDeclarativeDomPropertyPrivate()
+: property(0)
+{
+}
+
+QDeclarativeDomPropertyPrivate::~QDeclarativeDomPropertyPrivate()
+{
+ if (property) property->release();
+}
+
+QDeclarativeDomDynamicPropertyPrivate::QDeclarativeDomDynamicPropertyPrivate():
+ valid(false)
+{
+}
+
+QDeclarativeDomDynamicPropertyPrivate::~QDeclarativeDomDynamicPropertyPrivate()
+{
+ if (valid && property.defaultValue) property.defaultValue->release();
+}
+
+/*!
+ \class QDeclarativeDomProperty
+ \internal
+ \brief The QDeclarativeDomProperty class represents one property assignment in the
+ QML DOM tree
+
+ Properties in QML can be assigned QML \l {QDeclarativeDomValue}{values}.
+
+ \sa QDeclarativeDomObject
+*/
+
+/*!
+ Construct an invalid QDeclarativeDomProperty.
+*/
+QDeclarativeDomProperty::QDeclarativeDomProperty()
+: d(new QDeclarativeDomPropertyPrivate)
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomProperty.
+*/
+QDeclarativeDomProperty::QDeclarativeDomProperty(const QDeclarativeDomProperty &other)
+: d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomProperty.
+*/
+QDeclarativeDomProperty::~QDeclarativeDomProperty()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomProperty.
+*/
+QDeclarativeDomProperty &QDeclarativeDomProperty::operator=(const QDeclarativeDomProperty &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Returns true if this is a valid QDeclarativeDomProperty, false otherwise.
+*/
+bool QDeclarativeDomProperty::isValid() const
+{
+ return d->property != 0;
+}
+
+
+/*!
+ Return the name of this property.
+
+ \qml
+Text {
+ x: 10
+ y: 10
+ font.bold: true
+}
+ \endqml
+
+ As illustrated above, a property name can be a simple string, such as "x" or
+ "y", or a more complex "dot property", such as "font.bold". In both cases
+ the full name is returned ("x", "y" and "font.bold") by this method.
+
+ For dot properties, a split version of the name can be accessed by calling
+ QDeclarativeDomProperty::propertyNameParts().
+
+ \sa QDeclarativeDomProperty::propertyNameParts()
+*/
+QByteArray QDeclarativeDomProperty::propertyName() const
+{
+ return d->propertyName;
+}
+
+/*!
+ Return the name of this property, split into multiple parts in the case
+ of dot properties.
+
+ \qml
+Text {
+ x: 10
+ y: 10
+ font.bold: true
+}
+ \endqml
+
+ For each of the properties shown above, this method would return ("x"),
+ ("y") and ("font", "bold").
+
+ \sa QDeclarativeDomProperty::propertyName()
+*/
+QList<QByteArray> QDeclarativeDomProperty::propertyNameParts() const
+{
+ if (d->propertyName.isEmpty()) return QList<QByteArray>();
+ else return d->propertyName.split('.');
+}
+
+/*!
+ Return true if this property is used as a default property in the QML
+ document.
+
+ \qml
+<Text text="hello"/>
+<Text>hello</Text>
+ \endqml
+
+ The above two examples return the same DOM tree, except that the second has
+ the default property flag set on the text property. Observe that whether
+ or not a property has isDefaultProperty set is determined by how the
+ property is used, and not only by whether the property is the types default
+ property.
+*/
+bool QDeclarativeDomProperty::isDefaultProperty() const
+{
+ return d->property && d->property->isDefault;
+}
+
+/*!
+ Returns the QDeclarativeDomValue that is assigned to this property, or an invalid
+ QDeclarativeDomValue if no value is assigned.
+*/
+QDeclarativeDomValue QDeclarativeDomProperty::value() const
+{
+ QDeclarativeDomValue rv;
+ if (d->property) {
+ rv.d->property = d->property;
+ rv.d->value = d->property->values.at(0);
+ rv.d->property->addref();
+ rv.d->value->addref();
+ }
+ return rv;
+}
+
+/*!
+ Returns the position in the input data where the property ID startd, or -1 if
+ the property is invalid.
+*/
+int QDeclarativeDomProperty::position() const
+{
+ if (d && d->property) {
+ return d->property->location.range.offset;
+ } else
+ return -1;
+}
+
+/*!
+ Returns the length in the input data from where the property ID started upto
+ the end of it, or -1 if the property is invalid.
+*/
+int QDeclarativeDomProperty::length() const
+{
+ if (d && d->property)
+ return d->property->location.range.length;
+ else
+ return -1;
+}
+
+/*!
+ Construct an invalid QDeclarativeDomDynamicProperty.
+*/
+QDeclarativeDomDynamicProperty::QDeclarativeDomDynamicProperty():
+ d(new QDeclarativeDomDynamicPropertyPrivate)
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomDynamicProperty.
+*/
+QDeclarativeDomDynamicProperty::QDeclarativeDomDynamicProperty(const QDeclarativeDomDynamicProperty &other):
+ d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomDynamicProperty.
+*/
+QDeclarativeDomDynamicProperty::~QDeclarativeDomDynamicProperty()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomDynamicProperty.
+*/
+QDeclarativeDomDynamicProperty &QDeclarativeDomDynamicProperty::operator=(const QDeclarativeDomDynamicProperty &other)
+{
+ d = other.d;
+ return *this;
+}
+
+bool QDeclarativeDomDynamicProperty::isValid() const
+{
+ return d && d->valid;
+}
+
+/*!
+ Return the name of this dynamic property.
+
+ \qml
+Item {
+ property int count: 10;
+}
+ \endqml
+
+ As illustrated above, a dynamic property name can have a name and a
+ default value ("10").
+*/
+QByteArray QDeclarativeDomDynamicProperty::propertyName() const
+{
+ if (isValid())
+ return d->property.name;
+ else
+ return QByteArray();
+}
+
+/*!
+ Returns the type of the dynamic property. Note that when the property is an
+ alias property, this will return -1. Use QDeclarativeDomProperty::isAlias() to check
+ if the property is an alias.
+*/
+int QDeclarativeDomDynamicProperty::propertyType() const
+{
+ if (isValid()) {
+ switch (d->property.type) {
+ case QDeclarativeParser::Object::DynamicProperty::Bool:
+ return QMetaType::type("bool");
+
+ case QDeclarativeParser::Object::DynamicProperty::Color:
+ return QMetaType::type("QColor");
+
+ case QDeclarativeParser::Object::DynamicProperty::Date:
+ return QMetaType::type("QDate");
+
+ case QDeclarativeParser::Object::DynamicProperty::Int:
+ return QMetaType::type("int");
+
+ case QDeclarativeParser::Object::DynamicProperty::Real:
+ return QMetaType::type("double");
+
+ case QDeclarativeParser::Object::DynamicProperty::String:
+ return QMetaType::type("QString");
+
+ case QDeclarativeParser::Object::DynamicProperty::Url:
+ return QMetaType::type("QUrl");
+
+ case QDeclarativeParser::Object::DynamicProperty::Variant:
+ return QMetaType::type("QVariant");
+
+ default:
+ break;
+ }
+ }
+
+ return -1;
+}
+
+QByteArray QDeclarativeDomDynamicProperty::propertyTypeName() const
+{
+ if (isValid())
+ return d->property.customType;
+
+ return QByteArray();
+}
+
+/*!
+ Return true if this property is used as a default property in the QML
+ document.
+
+ \qml
+<Text text="hello"/>
+<Text>hello</Text>
+ \endqml
+
+ The above two examples return the same DOM tree, except that the second has
+ the default property flag set on the text property. Observe that whether
+ or not a property has isDefaultProperty set is determined by how the
+ property is used, and not only by whether the property is the types default
+ property.
+*/
+bool QDeclarativeDomDynamicProperty::isDefaultProperty() const
+{
+ if (isValid())
+ return d->property.isDefaultProperty;
+ else
+ return false;
+}
+
+/*!
+ Returns the default value as a QDeclarativeDomProperty.
+*/
+QDeclarativeDomProperty QDeclarativeDomDynamicProperty::defaultValue() const
+{
+ QDeclarativeDomProperty rp;
+
+ if (isValid() && d->property.defaultValue) {
+ rp.d->property = d->property.defaultValue;
+ rp.d->propertyName = propertyName();
+ rp.d->property->addref();
+ }
+
+ return rp;
+}
+
+/*!
+ Returns true if this dynamic property is an alias for another property,
+ false otherwise.
+*/
+bool QDeclarativeDomDynamicProperty::isAlias() const
+{
+ if (isValid())
+ return d->property.type == QDeclarativeParser::Object::DynamicProperty::Alias;
+ else
+ return false;
+}
+
+/*!
+ Returns the position in the input data where the property ID startd, or 0 if
+ the property is invalid.
+*/
+int QDeclarativeDomDynamicProperty::position() const
+{
+ if (isValid()) {
+ return d->property.location.range.offset;
+ } else
+ return -1;
+}
+
+/*!
+ Returns the length in the input data from where the property ID started upto
+ the end of it, or 0 if the property is invalid.
+*/
+int QDeclarativeDomDynamicProperty::length() const
+{
+ if (isValid())
+ return d->property.location.range.length;
+ else
+ return -1;
+}
+
+QDeclarativeDomObjectPrivate::QDeclarativeDomObjectPrivate()
+: object(0)
+{
+}
+
+QDeclarativeDomObjectPrivate::~QDeclarativeDomObjectPrivate()
+{
+ if (object) object->release();
+}
+
+QDeclarativeDomObjectPrivate::Properties
+QDeclarativeDomObjectPrivate::properties() const
+{
+ Properties rv;
+
+ for (QHash<QByteArray, QDeclarativeParser::Property *>::ConstIterator iter =
+ object->properties.begin();
+ iter != object->properties.end();
+ ++iter) {
+
+ rv << properties(*iter);
+
+ }
+ return rv;
+}
+
+QDeclarativeDomObjectPrivate::Properties
+QDeclarativeDomObjectPrivate::properties(QDeclarativeParser::Property *property) const
+{
+ Properties rv;
+
+ if (property->value) {
+
+ for (QHash<QByteArray, QDeclarativeParser::Property *>::ConstIterator iter =
+ property->value->properties.begin();
+ iter != property->value->properties.end();
+ ++iter) {
+
+ rv << properties(*iter);
+
+ }
+
+ QByteArray name(property->name + '.');
+ for (Properties::Iterator iter = rv.begin(); iter != rv.end(); ++iter)
+ iter->second.prepend(name);
+
+ } else {
+ rv << qMakePair(property, property->name);
+ }
+
+ return rv;
+}
+
+/*!
+ \class QDeclarativeDomObject
+ \internal
+ \brief The QDeclarativeDomObject class represents an object instantiation.
+
+ Each object instantiated in a QML file has a corresponding QDeclarativeDomObject
+ node in the QML DOM.
+
+ In addition to the type information that determines the object to
+ instantiate, QDeclarativeDomObject's also have a set of associated QDeclarativeDomProperty's.
+ Each QDeclarativeDomProperty represents a QML property assignment on the instantiated
+ object. For example,
+
+ \qml
+QGraphicsWidget {
+ opacity: 0.5
+ size: "100x100"
+}
+ \endqml
+
+ describes a single QDeclarativeDomObject - "QGraphicsWidget" - with two properties,
+ "opacity" and "size". Obviously QGraphicsWidget has many more properties than just
+ these two, but the QML DOM representation only contains those assigned
+ values (or bindings) in the QML file.
+*/
+
+/*!
+ Construct an invalid QDeclarativeDomObject.
+*/
+QDeclarativeDomObject::QDeclarativeDomObject()
+: d(new QDeclarativeDomObjectPrivate)
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomObject.
+*/
+QDeclarativeDomObject::QDeclarativeDomObject(const QDeclarativeDomObject &other)
+: d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomObject.
+*/
+QDeclarativeDomObject::~QDeclarativeDomObject()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomObject.
+*/
+QDeclarativeDomObject &QDeclarativeDomObject::operator=(const QDeclarativeDomObject &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Returns true if this is a valid QDeclarativeDomObject, false otherwise.
+*/
+bool QDeclarativeDomObject::isValid() const
+{
+ return d->object != 0;
+}
+
+/*!
+ Returns the fully-qualified type name of this object.
+
+ For example, the type of this object would be "Qt/4.6/Rectangle".
+ \qml
+Rectangle { }
+ \endqml
+*/
+QByteArray QDeclarativeDomObject::objectType() const
+{
+ if (d->object) return d->object->typeName;
+ else return QByteArray();
+}
+
+/*!
+ Returns the type name as referenced in the qml file.
+
+ For example, the type of this object would be "Rectangle".
+ \qml
+Rectangle { }
+ \endqml
+*/
+QByteArray QDeclarativeDomObject::objectClassName() const
+{
+ if (d->object)
+ return d->object->className;
+ else
+ return QByteArray();
+}
+
+int QDeclarativeDomObject::objectTypeMajorVersion() const
+{
+ if (d->object)
+ return d->object->majorVersion;
+ else
+ return -1;
+}
+
+int QDeclarativeDomObject::objectTypeMinorVersion() const
+{
+ if (d->object)
+ return d->object->minorVersion;
+ else
+ return -1;
+}
+
+/*!
+ Returns the QML id assigned to this object, or an empty QByteArray if no id
+ has been assigned.
+
+ For example, the object id of this object would be "MyText".
+ \qml
+Text { id: myText }
+ \endqml
+*/
+QString QDeclarativeDomObject::objectId() const
+{
+ if (d->object) {
+ return d->object->id;
+ } else {
+ return QString();
+ }
+}
+
+/*!
+ Returns the list of assigned properties on this object.
+
+ In the following example, "text" and "x" properties would be returned.
+ \qml
+Text {
+ text: "Hello world!"
+ x: 100
+}
+ \endqml
+*/
+QList<QDeclarativeDomProperty> QDeclarativeDomObject::properties() const
+{
+ QList<QDeclarativeDomProperty> rv;
+
+ if (!d->object || isComponent())
+ return rv;
+
+ QDeclarativeDomObjectPrivate::Properties properties = d->properties();
+ for (int ii = 0; ii < properties.count(); ++ii) {
+
+ QDeclarativeDomProperty domProperty;
+ domProperty.d->property = properties.at(ii).first;
+ domProperty.d->property->addref();
+ domProperty.d->propertyName = properties.at(ii).second;
+ rv << domProperty;
+
+ }
+
+ if (d->object->defaultProperty) {
+ QDeclarativeDomProperty domProperty;
+ domProperty.d->property = d->object->defaultProperty;
+ domProperty.d->property->addref();
+ domProperty.d->propertyName = d->object->defaultProperty->name;
+ rv << domProperty;
+ }
+
+ return rv;
+}
+
+/*!
+ Returns the object's \a name property if a value has been assigned to
+ it, or an invalid QDeclarativeDomProperty otherwise.
+
+ In the example below, \c {object.property("source")} would return a valid
+ QDeclarativeDomProperty, and \c {object.property("tile")} an invalid QDeclarativeDomProperty.
+
+ \qml
+Image { source: "sample.jpg" }
+ \endqml
+*/
+QDeclarativeDomProperty QDeclarativeDomObject::property(const QByteArray &name) const
+{
+ QList<QDeclarativeDomProperty> props = properties();
+ for (int ii = 0; ii < props.count(); ++ii)
+ if (props.at(ii).propertyName() == name)
+ return props.at(ii);
+ return QDeclarativeDomProperty();
+}
+
+QList<QDeclarativeDomDynamicProperty> QDeclarativeDomObject::dynamicProperties() const
+{
+ QList<QDeclarativeDomDynamicProperty> properties;
+
+ for (int i = 0; i < d->object->dynamicProperties.size(); ++i) {
+ QDeclarativeDomDynamicProperty p;
+ p.d = new QDeclarativeDomDynamicPropertyPrivate;
+ p.d->property = d->object->dynamicProperties.at(i);
+ p.d->valid = true;
+
+ if (p.d->property.defaultValue)
+ p.d->property.defaultValue->addref();
+
+ properties.append(p);
+ }
+
+ return properties;
+}
+
+QDeclarativeDomDynamicProperty QDeclarativeDomObject::dynamicProperty(const QByteArray &name) const
+{
+ QDeclarativeDomDynamicProperty p;
+
+ if (!isValid())
+ return p;
+
+ for (int i = 0; i < d->object->dynamicProperties.size(); ++i) {
+ if (d->object->dynamicProperties.at(i).name == name) {
+ p.d = new QDeclarativeDomDynamicPropertyPrivate;
+ p.d->property = d->object->dynamicProperties.at(i);
+ if (p.d->property.defaultValue) p.d->property.defaultValue->addref();
+ p.d->valid = true;
+ }
+ }
+
+ return p;
+}
+
+/*!
+ Returns true if this object is a custom type. Custom types are special
+ types that allow embeddeding non-QML data, such as SVG or HTML data,
+ directly into QML files.
+
+ \note Currently this method will always return false, and is a placekeeper
+ for future functionality.
+
+ \sa QDeclarativeDomObject::customTypeData()
+*/
+bool QDeclarativeDomObject::isCustomType() const
+{
+ return false;
+}
+
+/*!
+ If this object represents a custom type, returns the data associated with
+ the custom type, otherwise returns an empty QByteArray().
+ QDeclarativeDomObject::isCustomType() can be used to check if this object represents
+ a custom type.
+*/
+QByteArray QDeclarativeDomObject::customTypeData() const
+{
+ return QByteArray();
+}
+
+/*!
+ Returns true if this object is a sub-component object. Sub-component
+ objects can be converted into QDeclarativeDomComponent instances by calling
+ QDeclarativeDomObject::toComponent().
+
+ \sa QDeclarativeDomObject::toComponent()
+*/
+bool QDeclarativeDomObject::isComponent() const
+{
+ return (d->object && d->object->typeName == "Qt/Component");
+}
+
+/*!
+ Returns a QDeclarativeDomComponent for this object if it is a sub-component, or
+ an invalid QDeclarativeDomComponent if not. QDeclarativeDomObject::isComponent() can be used
+ to check if this object represents a sub-component.
+
+ \sa QDeclarativeDomObject::isComponent()
+*/
+QDeclarativeDomComponent QDeclarativeDomObject::toComponent() const
+{
+ QDeclarativeDomComponent rv;
+ if (isComponent())
+ rv.d = d;
+ return rv;
+}
+
+/*!
+ Returns the position in the input data where the property assignment started
+, or -1 if the property is invalid.
+*/
+int QDeclarativeDomObject::position() const
+{
+ if (d && d->object)
+ return d->object->location.range.offset;
+ else
+ return -1;
+}
+
+/*!
+ Returns the length in the input data from where the property assignment star
+ted upto the end of it, or -1 if the property is invalid.
+*/
+int QDeclarativeDomObject::length() const
+{
+ if (d && d->object)
+ return d->object->location.range.length;
+ else
+ return -1;
+}
+
+// Returns the URL of the type, if it is an external type, or an empty URL if
+// not
+QUrl QDeclarativeDomObject::url() const
+{
+ if (d && d->object)
+ return d->object->url;
+ else
+ return QUrl();
+}
+
+QDeclarativeDomBasicValuePrivate::QDeclarativeDomBasicValuePrivate()
+: value(0)
+{
+}
+
+QDeclarativeDomBasicValuePrivate::~QDeclarativeDomBasicValuePrivate()
+{
+ if (value) value->release();
+}
+
+/*!
+ \class QDeclarativeDomValueLiteral
+ \internal
+ \brief The QDeclarativeDomValueLiteral class represents a literal value.
+
+ A literal value is a simple value, written inline with the QML. In the
+ example below, the "x", "y" and "color" properties are being assigned
+ literal values.
+
+ \qml
+Rectangle {
+ x: 10
+ y: 10
+ color: "red"
+}
+ \endqml
+*/
+
+/*!
+ Construct an empty QDeclarativeDomValueLiteral.
+*/
+QDeclarativeDomValueLiteral::QDeclarativeDomValueLiteral():
+ d(new QDeclarativeDomBasicValuePrivate)
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomValueLiteral.
+*/
+QDeclarativeDomValueLiteral::QDeclarativeDomValueLiteral(const QDeclarativeDomValueLiteral &other)
+: d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomValueLiteral.
+*/
+QDeclarativeDomValueLiteral::~QDeclarativeDomValueLiteral()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomValueLiteral.
+*/
+QDeclarativeDomValueLiteral &QDeclarativeDomValueLiteral::operator=(const QDeclarativeDomValueLiteral &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Return the literal value.
+
+ In the example below, the literal value will be the string "10".
+ \qml
+Rectangle { x: 10 }
+ \endqml
+*/
+QString QDeclarativeDomValueLiteral::literal() const
+{
+ if (d->value) return d->value->primitive();
+ else return QString();
+}
+
+/*!
+ \class QDeclarativeDomValueBinding
+ \internal
+ \brief The QDeclarativeDomValueBinding class represents a property binding.
+
+ A property binding is an ECMAScript expression assigned to a property. In
+ the example below, the "x" property is being assigned a property binding.
+
+ \qml
+Rectangle { x: Other.x }
+ \endqml
+*/
+
+/*!
+ Construct an empty QDeclarativeDomValueBinding.
+*/
+QDeclarativeDomValueBinding::QDeclarativeDomValueBinding():
+ d(new QDeclarativeDomBasicValuePrivate)
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomValueBinding.
+*/
+QDeclarativeDomValueBinding::QDeclarativeDomValueBinding(const QDeclarativeDomValueBinding &other)
+: d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomValueBinding.
+*/
+QDeclarativeDomValueBinding::~QDeclarativeDomValueBinding()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomValueBinding.
+*/
+QDeclarativeDomValueBinding &QDeclarativeDomValueBinding::operator=(const QDeclarativeDomValueBinding &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Return the binding expression.
+
+ In the example below, the string "Other.x" will be returned.
+ \qml
+Rectangle { x: Other.x }
+ \endqml
+*/
+QString QDeclarativeDomValueBinding::binding() const
+{
+ if (d->value)
+ return d->value->value.asScript();
+ else
+ return QString();
+}
+
+/*!
+ \class QDeclarativeDomValueValueSource
+ \internal
+ \brief The QDeclarativeDomValueValueSource class represents a value source assignment value.
+
+ In QML, value sources are special value generating types that may be
+ assigned to properties. Value sources inherit the QDeclarativePropertyValueSource
+ class. In the example below, the "x" property is being assigned the
+ NumberAnimation value source.
+
+ \qml
+Rectangle {
+ x: NumberAnimation {
+ from: 0
+ to: 100
+ repeat: true
+ running: true
+ }
+}
+ \endqml
+*/
+
+/*!
+ Construct an empty QDeclarativeDomValueValueSource.
+*/
+QDeclarativeDomValueValueSource::QDeclarativeDomValueValueSource():
+ d(new QDeclarativeDomBasicValuePrivate)
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomValueValueSource.
+*/
+QDeclarativeDomValueValueSource::QDeclarativeDomValueValueSource(const QDeclarativeDomValueValueSource &other)
+: d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomValueValueSource.
+*/
+QDeclarativeDomValueValueSource::~QDeclarativeDomValueValueSource()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomValueValueSource.
+*/
+QDeclarativeDomValueValueSource &QDeclarativeDomValueValueSource::operator=(const QDeclarativeDomValueValueSource &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Return the value source object.
+
+ In the example below, an object representing the NumberAnimation will be
+ returned.
+ \qml
+Rectangle {
+ x: NumberAnimation {
+ from: 0
+ to: 100
+ repeat: true
+ running: true
+ }
+}
+ \endqml
+*/
+QDeclarativeDomObject QDeclarativeDomValueValueSource::object() const
+{
+ QDeclarativeDomObject rv;
+ if (d->value) {
+ rv.d->object = d->value->object;
+ rv.d->object->addref();
+ }
+ return rv;
+}
+
+/*!
+ \class QDeclarativeDomValueValueInterceptor
+ \internal
+ \brief The QDeclarativeDomValueValueInterceptor class represents a value interceptor assignment value.
+
+ In QML, value interceptor are special write-intercepting types that may be
+ assigned to properties. Value interceptor inherit the QDeclarativePropertyValueInterceptor
+ class. In the example below, the "x" property is being assigned the
+ Behavior value interceptor.
+
+ \qml
+Rectangle {
+ x: Behavior { NumberAnimation { duration: 500 } }
+}
+ \endqml
+*/
+
+/*!
+ Construct an empty QDeclarativeDomValueValueInterceptor.
+*/
+QDeclarativeDomValueValueInterceptor::QDeclarativeDomValueValueInterceptor():
+ d(new QDeclarativeDomBasicValuePrivate)
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomValueValueInterceptor.
+*/
+QDeclarativeDomValueValueInterceptor::QDeclarativeDomValueValueInterceptor(const QDeclarativeDomValueValueInterceptor &other)
+: d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomValueValueInterceptor.
+*/
+QDeclarativeDomValueValueInterceptor::~QDeclarativeDomValueValueInterceptor()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomValueValueInterceptor.
+*/
+QDeclarativeDomValueValueInterceptor &QDeclarativeDomValueValueInterceptor::operator=(const QDeclarativeDomValueValueInterceptor &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Return the value interceptor object.
+
+ In the example below, an object representing the Behavior will be
+ returned.
+ \qml
+Rectangle {
+ x: Behavior { NumberAnimation { duration: 500 } }
+}
+ \endqml
+*/
+QDeclarativeDomObject QDeclarativeDomValueValueInterceptor::object() const
+{
+ QDeclarativeDomObject rv;
+ if (d->value) {
+ rv.d->object = d->value->object;
+ rv.d->object->addref();
+ }
+ return rv;
+}
+
+QDeclarativeDomValuePrivate::QDeclarativeDomValuePrivate()
+: property(0), value(0)
+{
+}
+
+QDeclarativeDomValuePrivate::~QDeclarativeDomValuePrivate()
+{
+ if (property) property->release();
+ if (value) value->release();
+}
+
+/*!
+ \class QDeclarativeDomValue
+ \internal
+ \brief The QDeclarativeDomValue class represents a generic Qml value.
+
+ QDeclarativeDomValue's can be assigned to QML \l {QDeclarativeDomProperty}{properties}. In
+ QML, properties can be assigned various different values, including basic
+ literals, property bindings, property value sources, objects and lists of
+ values. The QDeclarativeDomValue class allows a programmer to determine the specific
+ value type being assigned and access more detailed information through a
+ corresponding value type class.
+
+ For example, in the following example,
+
+ \qml
+Text {
+ text: "Hello World!"
+ y: Other.y
+}
+ \endqml
+
+ The text property is being assigned a literal, and the y property a property
+ binding. To output the values assigned to the text and y properties in the
+ above example from C++,
+
+ \code
+ QDeclarativeDomDocument document;
+ QDeclarativeDomObject root = document.rootObject();
+
+ QDeclarativeDomProperty text = root.property("text");
+ if (text.value().isLiteral()) {
+ QDeclarativeDomValueLiteral literal = text.value().toLiteral();
+ qDebug() << literal.literal();
+ }
+
+ QDeclarativeDomProperty y = root.property("y");
+ if (y.value().isBinding()) {
+ QDeclarativeDomValueBinding binding = y.value().toBinding();
+ qDebug() << binding.binding();
+ }
+ \endcode
+*/
+
+/*!
+ Construct an invalid QDeclarativeDomValue.
+*/
+QDeclarativeDomValue::QDeclarativeDomValue()
+: d(new QDeclarativeDomValuePrivate)
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomValue.
+*/
+QDeclarativeDomValue::QDeclarativeDomValue(const QDeclarativeDomValue &other)
+: d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomValue
+*/
+QDeclarativeDomValue::~QDeclarativeDomValue()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomValue.
+*/
+QDeclarativeDomValue &QDeclarativeDomValue::operator=(const QDeclarativeDomValue &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ \enum QDeclarativeDomValue::Type
+
+ The type of the QDeclarativeDomValue node.
+
+ \value Invalid The QDeclarativeDomValue is invalid.
+ \value Literal The QDeclarativeDomValue is a literal value assignment. Use QDeclarativeDomValue::toLiteral() to access the type instance.
+ \value PropertyBinding The QDeclarativeDomValue is a property binding. Use QDeclarativeDomValue::toBinding() to access the type instance.
+ \value ValueSource The QDeclarativeDomValue is a property value source. Use QDeclarativeDomValue::toValueSource() to access the type instance.
+ \value ValueInterceptor The QDeclarativeDomValue is a property value interceptor. Use QDeclarativeDomValue::toValueInterceptor() to access the type instance.
+ \value Object The QDeclarativeDomValue is an object assignment. Use QDeclarativeDomValue::toObject() to access the type instnace.
+ \value List The QDeclarativeDomValue is a list of other values. Use QDeclarativeDomValue::toList() to access the type instance.
+*/
+
+/*!
+ Returns the type of this QDeclarativeDomValue.
+*/
+QDeclarativeDomValue::Type QDeclarativeDomValue::type() const
+{
+ if (d->property)
+ if (QDeclarativeMetaType::isList(d->property->type) ||
+ (d->property && d->property->values.count() > 1))
+ return List;
+
+ QDeclarativeParser::Value *value = d->value;
+ if (!value && !d->property)
+ return Invalid;
+
+ switch(value->type) {
+ case QDeclarativeParser::Value::Unknown:
+ return Invalid;
+ case QDeclarativeParser::Value::Literal:
+ return Literal;
+ case QDeclarativeParser::Value::PropertyBinding:
+ return PropertyBinding;
+ case QDeclarativeParser::Value::ValueSource:
+ return ValueSource;
+ case QDeclarativeParser::Value::ValueInterceptor:
+ return ValueInterceptor;
+ case QDeclarativeParser::Value::CreatedObject:
+ return Object;
+ case QDeclarativeParser::Value::SignalObject:
+ return Invalid;
+ case QDeclarativeParser::Value::SignalExpression:
+ return Literal;
+ case QDeclarativeParser::Value::Id:
+ return Literal;
+ }
+ return Invalid;
+}
+
+/*!
+ Returns true if this is an invalid value, otherwise false.
+*/
+bool QDeclarativeDomValue::isInvalid() const
+{
+ return type() == Invalid;
+}
+
+/*!
+ Returns true if this is a literal value, otherwise false.
+*/
+bool QDeclarativeDomValue::isLiteral() const
+{
+ return type() == Literal;
+}
+
+/*!
+ Returns true if this is a property binding value, otherwise false.
+*/
+bool QDeclarativeDomValue::isBinding() const
+{
+ return type() == PropertyBinding;
+}
+
+/*!
+ Returns true if this is a value source value, otherwise false.
+*/
+bool QDeclarativeDomValue::isValueSource() const
+{
+ return type() == ValueSource;
+}
+
+/*!
+ Returns true if this is a value interceptor value, otherwise false.
+*/
+bool QDeclarativeDomValue::isValueInterceptor() const
+{
+ return type() == ValueInterceptor;
+}
+
+/*!
+ Returns true if this is an object value, otherwise false.
+*/
+bool QDeclarativeDomValue::isObject() const
+{
+ return type() == Object;
+}
+
+/*!
+ Returns true if this is a list value, otherwise false.
+*/
+bool QDeclarativeDomValue::isList() const
+{
+ return type() == List;
+}
+
+/*!
+ Returns a QDeclarativeDomValueLiteral if this value is a literal type, otherwise
+ returns an invalid QDeclarativeDomValueLiteral.
+
+ \sa QDeclarativeDomValue::type()
+*/
+QDeclarativeDomValueLiteral QDeclarativeDomValue::toLiteral() const
+{
+ QDeclarativeDomValueLiteral rv;
+ if (type() == Literal) {
+ rv.d->value = d->value;
+ rv.d->value->addref();
+ }
+ return rv;
+}
+
+/*!
+ Returns a QDeclarativeDomValueBinding if this value is a property binding type,
+ otherwise returns an invalid QDeclarativeDomValueBinding.
+
+ \sa QDeclarativeDomValue::type()
+*/
+QDeclarativeDomValueBinding QDeclarativeDomValue::toBinding() const
+{
+ QDeclarativeDomValueBinding rv;
+ if (type() == PropertyBinding) {
+ rv.d->value = d->value;
+ rv.d->value->addref();
+ }
+ return rv;
+}
+
+/*!
+ Returns a QDeclarativeDomValueValueSource if this value is a property value source
+ type, otherwise returns an invalid QDeclarativeDomValueValueSource.
+
+ \sa QDeclarativeDomValue::type()
+*/
+QDeclarativeDomValueValueSource QDeclarativeDomValue::toValueSource() const
+{
+ QDeclarativeDomValueValueSource rv;
+ if (type() == ValueSource) {
+ rv.d->value = d->value;
+ rv.d->value->addref();
+ }
+ return rv;
+}
+
+/*!
+ Returns a QDeclarativeDomValueValueInterceptor if this value is a property value interceptor
+ type, otherwise returns an invalid QDeclarativeDomValueValueInterceptor.
+
+ \sa QDeclarativeDomValue::type()
+*/
+QDeclarativeDomValueValueInterceptor QDeclarativeDomValue::toValueInterceptor() const
+{
+ QDeclarativeDomValueValueInterceptor rv;
+ if (type() == ValueInterceptor) {
+ rv.d->value = d->value;
+ rv.d->value->addref();
+ }
+ return rv;
+}
+
+/*!
+ Returns a QDeclarativeDomObject if this value is an object assignment type, otherwise
+ returns an invalid QDeclarativeDomObject.
+
+ \sa QDeclarativeDomValue::type()
+*/
+QDeclarativeDomObject QDeclarativeDomValue::toObject() const
+{
+ QDeclarativeDomObject rv;
+ if (type() == Object) {
+ rv.d->object = d->value->object;
+ rv.d->object->addref();
+ }
+ return rv;
+}
+
+/*!
+ Returns a QDeclarativeDomList if this value is a list type, otherwise returns an
+ invalid QDeclarativeDomList.
+
+ \sa QDeclarativeDomValue::type()
+*/
+QDeclarativeDomList QDeclarativeDomValue::toList() const
+{
+ QDeclarativeDomList rv;
+ if (type() == List) {
+ rv.d = d;
+ }
+ return rv;
+}
+
+/*!
+ Returns the position in the input data where the property value startd, or -1
+ if the value is invalid.
+*/
+int QDeclarativeDomValue::position() const
+{
+ if (type() == Invalid)
+ return -1;
+ else
+ return d->value->location.range.offset;
+}
+
+/*!
+ Returns the length in the input data from where the property value started u
+pto the end of it, or -1 if the value is invalid.
+*/
+int QDeclarativeDomValue::length() const
+{
+ if (type() == Invalid)
+ return -1;
+ else
+ return d->value->location.range.length;
+}
+
+/*!
+ \class QDeclarativeDomList
+ \internal
+ \brief The QDeclarativeDomList class represents a list of values assigned to a QML property.
+
+ Lists of values can be assigned to properties. For example, the following
+ example assigns multiple objects to Item's "children" property
+ \qml
+Item {
+ children: [
+ Text { },
+ Rectangle { }
+ ]
+}
+ \endqml
+
+ Lists can also be implicitly created by assigning multiple
+ \l {QDeclarativeDomValueValueSource}{value sources} or constants to a property.
+ \qml
+Item {
+ x: 10
+ x: NumberAnimation {
+ running: false
+ from: 0
+ to: 100
+ }
+}
+ \endqml
+*/
+
+/*!
+ Construct an empty QDeclarativeDomList.
+*/
+QDeclarativeDomList::QDeclarativeDomList()
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomList.
+*/
+QDeclarativeDomList::QDeclarativeDomList(const QDeclarativeDomList &other)
+: d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomList.
+*/
+QDeclarativeDomList::~QDeclarativeDomList()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomList.
+*/
+QDeclarativeDomList &QDeclarativeDomList::operator=(const QDeclarativeDomList &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Returns the list of QDeclarativeDomValue's.
+*/
+QList<QDeclarativeDomValue> QDeclarativeDomList::values() const
+{
+ QList<QDeclarativeDomValue> rv;
+ if (!d->property)
+ return rv;
+
+ for (int ii = 0; ii < d->property->values.count(); ++ii) {
+ QDeclarativeDomValue v;
+ v.d->value = d->property->values.at(ii);
+ v.d->value->addref();
+ rv << v;
+ }
+
+ return rv;
+}
+
+/*!
+ Returns the position in the input data where the list started, or -1 if
+ the property is invalid.
+*/
+int QDeclarativeDomList::position() const
+{
+ if (d && d->property) {
+ return d->property->listValueRange.offset;
+ } else
+ return -1;
+}
+
+/*!
+ Returns the length in the input data from where the list started upto
+ the end of it, or 0 if the property is invalid.
+*/
+int QDeclarativeDomList::length() const
+{
+ if (d && d->property)
+ return d->property->listValueRange.length;
+ else
+ return -1;
+}
+
+/*!
+ Returns a list of positions of the commas in the QML file.
+*/
+QList<int> QDeclarativeDomList:: commaPositions() const
+{
+ if (d && d->property)
+ return d->property->listCommaPositions;
+ else
+ return QList<int>();
+}
+
+/*!
+ \class QDeclarativeDomComponent
+ \internal
+ \brief The QDeclarativeDomComponent class represents sub-component within a QML document.
+
+ Sub-components are QDeclarativeComponents defined within a QML document. The
+ following example shows the definition of a sub-component with the id
+ "listDelegate".
+
+ \qml
+Item {
+ Component {
+ id: listDelegate
+ Text {
+ text: modelData.text
+ }
+ }
+}
+ \endqml
+
+ Like QDeclarativeDomDocument's, components contain a single root object.
+*/
+
+/*!
+ Construct an empty QDeclarativeDomComponent.
+*/
+QDeclarativeDomComponent::QDeclarativeDomComponent()
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomComponent.
+*/
+QDeclarativeDomComponent::QDeclarativeDomComponent(const QDeclarativeDomComponent &other)
+: QDeclarativeDomObject(other)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomComponent.
+*/
+QDeclarativeDomComponent::~QDeclarativeDomComponent()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomComponent.
+*/
+QDeclarativeDomComponent &QDeclarativeDomComponent::operator=(const QDeclarativeDomComponent &other)
+{
+ static_cast<QDeclarativeDomObject &>(*this) = other;
+ return *this;
+}
+
+/*!
+ Returns the component's root object.
+
+ In the example below, the root object is the "Text" object.
+ \qml
+Item {
+ Component {
+ id: listDelegate
+ Text {
+ text: modelData.text
+ }
+ }
+}
+ \endqml
+*/
+QDeclarativeDomObject QDeclarativeDomComponent::componentRoot() const
+{
+ QDeclarativeDomObject rv;
+ if (d->object) {
+ QDeclarativeParser::Object *obj = 0;
+ if (d->object->defaultProperty &&
+ d->object->defaultProperty->values.count() == 1 &&
+ d->object->defaultProperty->values.at(0)->object)
+ obj = d->object->defaultProperty->values.at(0)->object;
+
+ if (obj) {
+ rv.d->object = obj;
+ rv.d->object->addref();
+ }
+ }
+
+ return rv;
+}
+
+QDeclarativeDomImportPrivate::QDeclarativeDomImportPrivate()
+: type(File)
+{
+}
+
+QDeclarativeDomImportPrivate::~QDeclarativeDomImportPrivate()
+{
+}
+
+/*!
+ \class QDeclarativeDomImport
+ \internal
+ \brief The QDeclarativeDomImport class represents an import statement.
+*/
+
+/*!
+ Construct an empty QDeclarativeDomImport.
+*/
+QDeclarativeDomImport::QDeclarativeDomImport()
+: d(new QDeclarativeDomImportPrivate)
+{
+}
+
+/*!
+ Create a copy of \a other QDeclarativeDomImport.
+*/
+QDeclarativeDomImport::QDeclarativeDomImport(const QDeclarativeDomImport &other)
+: d(other.d)
+{
+}
+
+/*!
+ Destroy the QDeclarativeDomImport.
+*/
+QDeclarativeDomImport::~QDeclarativeDomImport()
+{
+}
+
+/*!
+ Assign \a other to this QDeclarativeDomImport.
+*/
+QDeclarativeDomImport &QDeclarativeDomImport::operator=(const QDeclarativeDomImport &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Returns the type of the import.
+ */
+QDeclarativeDomImport::Type QDeclarativeDomImport::type() const
+{
+ return static_cast<QDeclarativeDomImport::Type>(d->type);
+}
+
+/*!
+ Returns the URI of the import (e.g. 'subdir' or 'com.nokia.Qt')
+ */
+QString QDeclarativeDomImport::uri() const
+{
+ return d->uri;
+}
+
+/*!
+ Returns the version specified by the import. An empty string if no version was specified.
+ */
+QString QDeclarativeDomImport::version() const
+{
+ return d->version;
+}
+
+/*!
+ Returns the (optional) qualifier string (the token following the 'as' keyword) of the import.
+ */
+QString QDeclarativeDomImport::qualifier() const
+{
+ return d->qualifier;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativedom_p.h b/src/declarative/qml/qdeclarativedom_p.h
new file mode 100644
index 0000000..6043ead
--- /dev/null
+++ b/src/declarative/qml/qdeclarativedom_p.h
@@ -0,0 +1,360 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEDOM_P_H
+#define QDECLARATIVEDOM_P_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 "qdeclarativeerror.h"
+
+#include <QtCore/qlist.h>
+#include <QtCore/qshareddata.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QString;
+class QByteArray;
+class QDeclarativeDomObject;
+class QDeclarativeDomList;
+class QDeclarativeDomValue;
+class QDeclarativeEngine;
+class QDeclarativeDomComponent;
+class QDeclarativeDomImport;
+class QIODevice;
+
+class QDeclarativeDomDocumentPrivate;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDomDocument
+{
+public:
+ QDeclarativeDomDocument();
+ QDeclarativeDomDocument(const QDeclarativeDomDocument &);
+ ~QDeclarativeDomDocument();
+ QDeclarativeDomDocument &operator=(const QDeclarativeDomDocument &);
+
+ QList<QDeclarativeDomImport> imports() const;
+
+ QList<QDeclarativeError> errors() const;
+ bool load(QDeclarativeEngine *, const QByteArray &, const QUrl & = QUrl());
+
+ QDeclarativeDomObject rootObject() const;
+
+private:
+ QSharedDataPointer<QDeclarativeDomDocumentPrivate> d;
+};
+
+class QDeclarativeDomPropertyPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeDomProperty
+{
+public:
+ QDeclarativeDomProperty();
+ QDeclarativeDomProperty(const QDeclarativeDomProperty &);
+ ~QDeclarativeDomProperty();
+ QDeclarativeDomProperty &operator=(const QDeclarativeDomProperty &);
+
+ bool isValid() const;
+
+ QByteArray propertyName() const;
+ QList<QByteArray> propertyNameParts() const;
+
+ bool isDefaultProperty() const;
+
+ QDeclarativeDomValue value() const;
+
+ int position() const;
+ int length() const;
+
+private:
+ friend class QDeclarativeDomObject;
+ friend class QDeclarativeDomDynamicProperty;
+ QSharedDataPointer<QDeclarativeDomPropertyPrivate> d;
+};
+
+class QDeclarativeDomDynamicPropertyPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeDomDynamicProperty
+{
+public:
+ QDeclarativeDomDynamicProperty();
+ QDeclarativeDomDynamicProperty(const QDeclarativeDomDynamicProperty &);
+ ~QDeclarativeDomDynamicProperty();
+ QDeclarativeDomDynamicProperty &operator=(const QDeclarativeDomDynamicProperty &);
+
+ bool isValid() const;
+
+ QByteArray propertyName() const;
+ int propertyType() const;
+ QByteArray propertyTypeName() const;
+
+ bool isDefaultProperty() const;
+ QDeclarativeDomProperty defaultValue() const;
+
+ bool isAlias() const;
+
+ int position() const;
+ int length() const;
+
+private:
+ friend class QDeclarativeDomObject;
+ QSharedDataPointer<QDeclarativeDomDynamicPropertyPrivate> d;
+};
+
+class QDeclarativeDomObjectPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeDomObject
+{
+public:
+ QDeclarativeDomObject();
+ QDeclarativeDomObject(const QDeclarativeDomObject &);
+ ~QDeclarativeDomObject();
+ QDeclarativeDomObject &operator=(const QDeclarativeDomObject &);
+
+ bool isValid() const;
+
+ QByteArray objectType() const;
+ QByteArray objectClassName() const;
+
+ int objectTypeMajorVersion() const;
+ int objectTypeMinorVersion() const;
+
+ QString objectId() const;
+
+ QList<QDeclarativeDomProperty> properties() const;
+ QDeclarativeDomProperty property(const QByteArray &) const;
+
+ QList<QDeclarativeDomDynamicProperty> dynamicProperties() const;
+ QDeclarativeDomDynamicProperty dynamicProperty(const QByteArray &) const;
+
+ bool isCustomType() const;
+ QByteArray customTypeData() const;
+
+ bool isComponent() const;
+ QDeclarativeDomComponent toComponent() const;
+
+ int position() const;
+ int length() const;
+
+ QUrl url() const;
+private:
+ friend class QDeclarativeDomDocument;
+ friend class QDeclarativeDomComponent;
+ friend class QDeclarativeDomValue;
+ friend class QDeclarativeDomValueValueSource;
+ friend class QDeclarativeDomValueValueInterceptor;
+ QSharedDataPointer<QDeclarativeDomObjectPrivate> d;
+};
+
+class QDeclarativeDomValuePrivate;
+class QDeclarativeDomBasicValuePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeDomValueLiteral
+{
+public:
+ QDeclarativeDomValueLiteral();
+ QDeclarativeDomValueLiteral(const QDeclarativeDomValueLiteral &);
+ ~QDeclarativeDomValueLiteral();
+ QDeclarativeDomValueLiteral &operator=(const QDeclarativeDomValueLiteral &);
+
+ QString literal() const;
+
+private:
+ friend class QDeclarativeDomValue;
+ QSharedDataPointer<QDeclarativeDomBasicValuePrivate> d;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDomValueBinding
+{
+public:
+ QDeclarativeDomValueBinding();
+ QDeclarativeDomValueBinding(const QDeclarativeDomValueBinding &);
+ ~QDeclarativeDomValueBinding();
+ QDeclarativeDomValueBinding &operator=(const QDeclarativeDomValueBinding &);
+
+ QString binding() const;
+
+private:
+ friend class QDeclarativeDomValue;
+ QSharedDataPointer<QDeclarativeDomBasicValuePrivate> d;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDomValueValueSource
+{
+public:
+ QDeclarativeDomValueValueSource();
+ QDeclarativeDomValueValueSource(const QDeclarativeDomValueValueSource &);
+ ~QDeclarativeDomValueValueSource();
+ QDeclarativeDomValueValueSource &operator=(const QDeclarativeDomValueValueSource &);
+
+ QDeclarativeDomObject object() const;
+
+private:
+ friend class QDeclarativeDomValue;
+ QSharedDataPointer<QDeclarativeDomBasicValuePrivate> d;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDomValueValueInterceptor
+{
+public:
+ QDeclarativeDomValueValueInterceptor();
+ QDeclarativeDomValueValueInterceptor(const QDeclarativeDomValueValueInterceptor &);
+ ~QDeclarativeDomValueValueInterceptor();
+ QDeclarativeDomValueValueInterceptor &operator=(const QDeclarativeDomValueValueInterceptor &);
+
+ QDeclarativeDomObject object() const;
+
+private:
+ friend class QDeclarativeDomValue;
+ QSharedDataPointer<QDeclarativeDomBasicValuePrivate> d;
+};
+
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDomComponent : public QDeclarativeDomObject
+{
+public:
+ QDeclarativeDomComponent();
+ QDeclarativeDomComponent(const QDeclarativeDomComponent &);
+ ~QDeclarativeDomComponent();
+ QDeclarativeDomComponent &operator=(const QDeclarativeDomComponent &);
+
+ QDeclarativeDomObject componentRoot() const;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDomValue
+{
+public:
+ enum Type {
+ Invalid,
+ Literal,
+ PropertyBinding,
+ ValueSource,
+ ValueInterceptor,
+ Object,
+ List
+ };
+
+ QDeclarativeDomValue();
+ QDeclarativeDomValue(const QDeclarativeDomValue &);
+ ~QDeclarativeDomValue();
+ QDeclarativeDomValue &operator=(const QDeclarativeDomValue &);
+
+ Type type() const;
+
+ bool isInvalid() const;
+ bool isLiteral() const;
+ bool isBinding() const;
+ bool isValueSource() const;
+ bool isValueInterceptor() const;
+ bool isObject() const;
+ bool isList() const;
+
+ QDeclarativeDomValueLiteral toLiteral() const;
+ QDeclarativeDomValueBinding toBinding() const;
+ QDeclarativeDomValueValueSource toValueSource() const;
+ QDeclarativeDomValueValueInterceptor toValueInterceptor() const;
+ QDeclarativeDomObject toObject() const;
+ QDeclarativeDomList toList() const;
+
+ int position() const;
+ int length() const;
+
+private:
+ friend class QDeclarativeDomProperty;
+ friend class QDeclarativeDomList;
+ QSharedDataPointer<QDeclarativeDomValuePrivate> d;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeDomList
+{
+public:
+ QDeclarativeDomList();
+ QDeclarativeDomList(const QDeclarativeDomList &);
+ ~QDeclarativeDomList();
+ QDeclarativeDomList &operator=(const QDeclarativeDomList &);
+
+ QList<QDeclarativeDomValue> values() const;
+
+ int position() const;
+ int length() const;
+
+ QList<int> commaPositions() const;
+
+private:
+ friend class QDeclarativeDomValue;
+ QSharedDataPointer<QDeclarativeDomValuePrivate> d;
+};
+
+class QDeclarativeDomImportPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeDomImport
+{
+public:
+ enum Type { Library, File };
+
+ QDeclarativeDomImport();
+ QDeclarativeDomImport(const QDeclarativeDomImport &);
+ ~QDeclarativeDomImport();
+ QDeclarativeDomImport &operator=(const QDeclarativeDomImport &);
+
+ Type type() const;
+ QString uri() const;
+ QString version() const;
+ QString qualifier() const;
+
+private:
+ friend class QDeclarativeDomDocument;
+ QSharedDataPointer<QDeclarativeDomImportPrivate> d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEDOM_P_H
diff --git a/src/declarative/qml/qdeclarativedom_p_p.h b/src/declarative/qml/qdeclarativedom_p_p.h
new file mode 100644
index 0000000..a065282
--- /dev/null
+++ b/src/declarative/qml/qdeclarativedom_p_p.h
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEDOM_P_P_H
+#define QDECLARATIVEDOM_P_P_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 "qdeclarativeparser_p.h"
+
+#include <QtCore/QtGlobal>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeDomDocumentPrivate : public QSharedData
+{
+public:
+ QDeclarativeDomDocumentPrivate();
+ QDeclarativeDomDocumentPrivate(const QDeclarativeDomDocumentPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QDeclarativeDomDocumentPrivate();
+
+ QList<QDeclarativeError> errors;
+ QList<QDeclarativeDomImport> imports;
+ QDeclarativeParser::Object *root;
+ QList<int> automaticSemicolonOffsets;
+};
+
+class QDeclarativeDomObjectPrivate : public QSharedData
+{
+public:
+ QDeclarativeDomObjectPrivate();
+ QDeclarativeDomObjectPrivate(const QDeclarativeDomObjectPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QDeclarativeDomObjectPrivate();
+
+ typedef QList<QPair<QDeclarativeParser::Property *, QByteArray> > Properties;
+ Properties properties() const;
+ Properties properties(QDeclarativeParser::Property *) const;
+
+ QDeclarativeParser::Object *object;
+};
+
+class QDeclarativeDomPropertyPrivate : public QSharedData
+{
+public:
+ QDeclarativeDomPropertyPrivate();
+ QDeclarativeDomPropertyPrivate(const QDeclarativeDomPropertyPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QDeclarativeDomPropertyPrivate();
+
+ QByteArray propertyName;
+ QDeclarativeParser::Property *property;
+};
+
+class QDeclarativeDomDynamicPropertyPrivate : public QSharedData
+{
+public:
+ QDeclarativeDomDynamicPropertyPrivate();
+ QDeclarativeDomDynamicPropertyPrivate(const QDeclarativeDomDynamicPropertyPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QDeclarativeDomDynamicPropertyPrivate();
+
+ bool valid;
+ QDeclarativeParser::Object::DynamicProperty property;
+};
+
+class QDeclarativeDomValuePrivate : public QSharedData
+{
+public:
+ QDeclarativeDomValuePrivate();
+ QDeclarativeDomValuePrivate(const QDeclarativeDomValuePrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QDeclarativeDomValuePrivate();
+
+ QDeclarativeParser::Property *property;
+ QDeclarativeParser::Value *value;
+};
+
+class QDeclarativeDomBasicValuePrivate : public QSharedData
+{
+public:
+ QDeclarativeDomBasicValuePrivate();
+ QDeclarativeDomBasicValuePrivate(const QDeclarativeDomBasicValuePrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QDeclarativeDomBasicValuePrivate();
+
+ QDeclarativeParser::Value *value;
+};
+
+class QDeclarativeDomImportPrivate : public QSharedData
+{
+public:
+ QDeclarativeDomImportPrivate();
+ QDeclarativeDomImportPrivate(const QDeclarativeDomImportPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QDeclarativeDomImportPrivate();
+
+ enum Type { Library, File };
+
+ Type type;
+ QString uri;
+ QString version;
+ QString qualifier;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEDOM_P_P_H
+
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
new file mode 100644
index 0000000..4575536
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -0,0 +1,1901 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativeengine.h"
+
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativecompiler_p.h"
+#include "qdeclarativeglobalscriptclass_p.h"
+#include "qdeclarative.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarativeexpression.h"
+#include "qdeclarativecomponent.h"
+#include "qdeclarativemetaproperty_p.h"
+#include "qdeclarativebinding_p_p.h"
+#include "qdeclarativevme_p.h"
+#include "qdeclarativeenginedebug_p.h"
+#include "qdeclarativestringconverters_p.h"
+#include "qdeclarativexmlhttprequest_p.h"
+#include "qdeclarativesqldatabase_p.h"
+#include "qdeclarativetypenamescriptclass_p.h"
+#include "qdeclarativelistscriptclass_p.h"
+#include "qdeclarativescriptstring.h"
+#include "qdeclarativeglobal_p.h"
+#include "qdeclarativeworkerscript_p.h"
+#include "qdeclarativecomponent_p.h"
+#include "qdeclarativescriptclass_p.h"
+#include "qdeclarativenetworkaccessmanagerfactory.h"
+#include "qdeclarativeimageprovider.h"
+#include "qdeclarativedirparser_p.h"
+#include "qdeclarativeextensioninterface.h"
+#include "qdeclarativelist_p.h"
+
+#include <qfxperf_p_p.h>
+
+#include <QtCore/qmetaobject.h>
+#include <QScriptClass>
+#include <QNetworkReply>
+#include <QNetworkRequest>
+#include <QNetworkAccessManager>
+#include <QDesktopServices>
+#include <QTimer>
+#include <QList>
+#include <QPair>
+#include <QDebug>
+#include <QMetaObject>
+#include <QStack>
+#include <QPluginLoader>
+#include <QtCore/qlibraryinfo.h>
+#include <QtCore/qthreadstorage.h>
+#include <QtCore/qthread.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qmutex.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/qsound.h>
+#include <QGraphicsObject>
+#include <QtCore/qcryptographichash.h>
+
+#include <private/qobject_p.h>
+#include <private/qscriptdeclarativeclass_p.h>
+
+#include <private/qdeclarativeitemsmodule_p.h>
+#include <private/qdeclarativeutilmodule_p.h>
+
+#ifdef Q_OS_WIN // for %APPDATA%
+#include <qt_windows.h>
+#include <qlibrary.h>
+
+#define CSIDL_APPDATA 0x001a // <username>\Application Data
+#endif
+
+Q_DECLARE_METATYPE(QDeclarativeMetaProperty)
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
+
+/*!
+ \qmlclass QtObject QObject
+ \since 4.7
+ \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.
+
+ 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.
+
+ See \l{scripting.html#accessing-child-qobjects}{Accessing Child QObjects}
+ in the scripting documentation for details how objectName can be used from
+ scripts.
+*/
+
+struct StaticQtMetaObject : public QObject
+{
+ static const QMetaObject *get()
+ { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
+};
+
+static bool qt_QmlQtModule_registered = false;
+
+void QDeclarativeEnginePrivate::defineModule()
+{
+ QML_REGISTER_TYPE(Qt,4,6,Component,QDeclarativeComponent);
+ QML_REGISTER_TYPE(Qt,4,6,QtObject,QObject);
+ QML_REGISTER_TYPE(Qt,4,6,WorkerScript,QDeclarativeWorkerScript);
+ QML_REGISTER_TYPE(Qt,4,6,WorkerListModel,QDeclarativeWorkerListModel);
+
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeBinding);
+}
+
+QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
+: captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false),
+ contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0),
+ globalClass(0), cleanup(0), erroredBindings(0), inProgressCreations(0),
+ scriptEngine(this), workerScriptEngine(0), componentAttacheds(0), inBeginCreate(false),
+ networkAccessManager(0), networkAccessManagerFactory(0),
+ typeManager(e), uniqueId(1)
+{
+ if (!qt_QmlQtModule_registered) {
+ qt_QmlQtModule_registered = true;
+ QDeclarativeItemModule::defineModule();
+ QDeclarativeUtilModule::defineModule();
+ QDeclarativeEnginePrivate::defineModule();
+ }
+ globalClass = new QDeclarativeGlobalScriptClass(&scriptEngine);
+ fileImportPath.append(QLibraryInfo::location(QLibraryInfo::DataPath)+QDir::separator()+QLatin1String("qml"));
+
+ // env import paths
+ QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
+ if (!envImportPath.isEmpty()) {
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ QLatin1Char pathSep(';');
+#else
+ QLatin1Char pathSep(':');
+#endif
+ foreach (const QString &path, QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts)) {
+ QString canonicalPath = QDir(path).canonicalPath();
+ if (!canonicalPath.isEmpty() && !environmentImportPath.contains(canonicalPath))
+ environmentImportPath.append(canonicalPath);
+ }
+ }
+}
+
+QUrl QDeclarativeScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url)
+{
+ if (p) {
+ QDeclarativeContext *ctxt = QDeclarativeEnginePrivate::get(this)->getContext(context);
+ Q_ASSERT(ctxt);
+ return ctxt->resolvedUrl(url);
+ }
+ return baseUrl.resolved(url);
+}
+
+QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *priv)
+: p(priv), sqlQueryClass(0), namedNodeMapClass(0), nodeListClass(0)
+{
+ // Note that all documentation for stuff put on the global object goes in
+ // doc/src/declarative/globalobject.qdoc
+
+ bool mainthread = priv != 0;
+
+ QScriptValue qtObject =
+ newQMetaObject(StaticQtMetaObject::get());
+ globalObject().setProperty(QLatin1String("Qt"), qtObject);
+
+ offlineStoragePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation).replace(QLatin1Char('/'), QDir::separator())
+ + QDir::separator() + QLatin1String("QML")
+ + QDir::separator() + QLatin1String("OfflineStorage");
+
+
+ qt_add_qmlxmlhttprequest(this);
+ 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.
+ // XXX When the above a done some better way, that way should also be
+ // XXX used to add Qt.Sound class.
+
+
+ //types
+ qtObject.setProperty(QLatin1String("rgba"), newFunction(QDeclarativeEnginePrivate::rgba, 4));
+ qtObject.setProperty(QLatin1String("hsla"), newFunction(QDeclarativeEnginePrivate::hsla, 4));
+ qtObject.setProperty(QLatin1String("rect"), newFunction(QDeclarativeEnginePrivate::rect, 4));
+ qtObject.setProperty(QLatin1String("point"), newFunction(QDeclarativeEnginePrivate::point, 2));
+ qtObject.setProperty(QLatin1String("size"), newFunction(QDeclarativeEnginePrivate::size, 2));
+ qtObject.setProperty(QLatin1String("vector3d"), newFunction(QDeclarativeEnginePrivate::vector, 3));
+
+ if (mainthread) {
+ //color helpers
+ qtObject.setProperty(QLatin1String("lighter"), newFunction(QDeclarativeEnginePrivate::lighter, 1));
+ qtObject.setProperty(QLatin1String("darker"), newFunction(QDeclarativeEnginePrivate::darker, 1));
+ qtObject.setProperty(QLatin1String("tint"), newFunction(QDeclarativeEnginePrivate::tint, 2));
+ }
+
+ //misc methods
+ qtObject.setProperty(QLatin1String("closestAngle"), newFunction(QDeclarativeEnginePrivate::closestAngle, 2));
+ qtObject.setProperty(QLatin1String("playSound"), newFunction(QDeclarativeEnginePrivate::playSound, 1));
+ qtObject.setProperty(QLatin1String("openUrlExternally"),newFunction(QDeclarativeEnginePrivate::desktopOpenUrl, 1));
+ qtObject.setProperty(QLatin1String("md5"),newFunction(QDeclarativeEnginePrivate::md5, 1));
+ qtObject.setProperty(QLatin1String("btoa"),newFunction(QDeclarativeEnginePrivate::btoa, 1));
+ qtObject.setProperty(QLatin1String("atob"),newFunction(QDeclarativeEnginePrivate::atob, 1));
+ qtObject.setProperty(QLatin1String("quit"), newFunction(QDeclarativeEnginePrivate::quit, 0));
+ qtObject.setProperty(QLatin1String("resolvedUrl"),newFunction(QDeclarativeScriptEngine::resolvedUrl, 1));
+
+ //firebug/webkit compat
+ QScriptValue consoleObject = newObject();
+ consoleObject.setProperty(QLatin1String("log"),newFunction(QDeclarativeEnginePrivate::consoleLog, 1));
+ consoleObject.setProperty(QLatin1String("debug"),newFunction(QDeclarativeEnginePrivate::consoleLog, 1));
+ globalObject().setProperty(QLatin1String("console"), consoleObject);
+
+ if (mainthread) {
+ globalObject().setProperty(QLatin1String("createQmlObject"),
+ newFunction(QDeclarativeEnginePrivate::createQmlObject, 1));
+ globalObject().setProperty(QLatin1String("createComponent"),
+ newFunction(QDeclarativeEnginePrivate::createComponent, 1));
+ }
+
+ // translation functions need to be installed
+ // before the global script class is constructed (QTBUG-6437)
+ installTranslatorFunctions();
+}
+
+QDeclarativeScriptEngine::~QDeclarativeScriptEngine()
+{
+ delete sqlQueryClass;
+ delete nodeListClass;
+ delete namedNodeMapClass;
+}
+
+QScriptValue QDeclarativeScriptEngine::resolvedUrl(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ QString arg = ctxt->argument(0).toString();
+ QUrl r = QDeclarativeScriptEngine::get(engine)->resolvedUrl(ctxt,QUrl(arg));
+ return QScriptValue(r.toString());
+}
+
+QNetworkAccessManager *QDeclarativeScriptEngine::networkAccessManager()
+{
+ return p->getNetworkAccessManager();
+}
+
+QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate()
+{
+ while (cleanup) {
+ QDeclarativeCleanup *c = cleanup;
+ cleanup = c->next;
+ if (cleanup) cleanup->prev = &cleanup;
+ c->next = 0;
+ c->prev = 0;
+ c->clear();
+ }
+
+ delete rootContext;
+ rootContext = 0;
+ delete contextClass;
+ contextClass = 0;
+ delete objectClass;
+ objectClass = 0;
+ delete valueTypeClass;
+ valueTypeClass = 0;
+ delete typeNameClass;
+ typeNameClass = 0;
+ delete listClass;
+ listClass = 0;
+ delete globalClass;
+ globalClass = 0;
+
+ for(int ii = 0; ii < bindValues.count(); ++ii)
+ clear(bindValues[ii]);
+ for(int ii = 0; ii < parserStatus.count(); ++ii)
+ clear(parserStatus[ii]);
+ for(QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.constBegin(); iter != m_compositeTypes.constEnd(); ++iter)
+ (*iter)->release();
+ for(QHash<const QMetaObject *, QDeclarativePropertyCache *>::Iterator iter = propertyCache.begin(); iter != propertyCache.end(); ++iter)
+ (*iter)->release();
+
+}
+
+void QDeclarativeEnginePrivate::clear(SimpleList<QDeclarativeAbstractBinding> &bvs)
+{
+ bvs.clear();
+}
+
+void QDeclarativeEnginePrivate::clear(SimpleList<QDeclarativeParserStatus> &pss)
+{
+ for (int ii = 0; ii < pss.count; ++ii) {
+ QDeclarativeParserStatus *ps = pss.at(ii);
+ if(ps)
+ ps->d = 0;
+ }
+ pss.clear();
+}
+
+Q_GLOBAL_STATIC(QDeclarativeEngineDebugServer, qmlEngineDebugServer);
+
+void QDeclarativeEnginePrivate::init()
+{
+ Q_Q(QDeclarativeEngine);
+ qRegisterMetaType<QVariant>("QVariant");
+ qRegisterMetaType<QDeclarativeScriptString>("QDeclarativeScriptString");
+ qRegisterMetaType<QScriptValue>("QScriptValue");
+
+ contextClass = new QDeclarativeContextScriptClass(q);
+ objectClass = new QDeclarativeObjectScriptClass(q);
+ valueTypeClass = new QDeclarativeValueTypeScriptClass(q);
+ typeNameClass = new QDeclarativeTypeNameScriptClass(q);
+ listClass = new QDeclarativeListScriptClass(q);
+ rootContext = new QDeclarativeContext(q,true);
+
+ if (QCoreApplication::instance()->thread() == q->thread() &&
+ QDeclarativeEngineDebugServer::isDebuggingEnabled()) {
+ qmlEngineDebugServer();
+ isDebugging = true;
+ QDeclarativeEngineDebugServer::addEngine(q);
+
+ qmlEngineDebugServer()->waitForClients();
+ }
+}
+
+QDeclarativeWorkerScriptEngine *QDeclarativeEnginePrivate::getWorkerScriptEngine()
+{
+ Q_Q(QDeclarativeEngine);
+ if (!workerScriptEngine)
+ workerScriptEngine = new QDeclarativeWorkerScriptEngine(q);
+ return workerScriptEngine;
+}
+
+/*!
+ \class QDeclarativeEngine
+ \since 4.7
+ \brief The QDeclarativeEngine class provides an environment for instantiating QML components.
+ \mainclass
+
+ Each QML component is instantiated in a QDeclarativeContext. QDeclarativeContext's are
+ essential for passing data to QML components. In QML, contexts are arranged
+ hierarchically and this hierarchy is managed by the QDeclarativeEngine.
+
+ Prior to creating any QML components, an application must have created a
+ QDeclarativeEngine to gain access to a QML context. The following example shows how
+ to create a simple Text item.
+
+ \code
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6\nText { text: \"Hello world!\" }", QUrl());
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create());
+
+ //add item to view, etc
+ ...
+ \endcode
+
+ In this case, the Text item will be created in the engine's
+ \l {QDeclarativeEngine::rootContext()}{root context}.
+
+ \sa QDeclarativeComponent QDeclarativeContext
+*/
+
+/*!
+ Create a new QDeclarativeEngine with the given \a parent.
+*/
+QDeclarativeEngine::QDeclarativeEngine(QObject *parent)
+: QObject(*new QDeclarativeEnginePrivate(this), parent)
+{
+ Q_D(QDeclarativeEngine);
+ d->init();
+}
+
+/*!
+ Destroys the QDeclarativeEngine.
+
+ Any QDeclarativeContext's created on this engine will be invalidated, but not
+ destroyed (unless they are parented to the QDeclarativeEngine object).
+*/
+QDeclarativeEngine::~QDeclarativeEngine()
+{
+ Q_D(QDeclarativeEngine);
+ if (d->isDebugging)
+ QDeclarativeEngineDebugServer::remEngine(this);
+}
+
+/*! \fn void QDeclarativeEngine::quit()
+ This signal is emitted when the QDeclarativeEngine quits.
+ */
+
+/*!
+ Clears the engine's internal component cache.
+
+ Normally the QDeclarativeEngine caches components loaded from qml files. This method
+ clears this cache and forces the component to be reloaded.
+ */
+void QDeclarativeEngine::clearComponentCache()
+{
+ Q_D(QDeclarativeEngine);
+ d->typeManager.clearCache();
+}
+
+/*!
+ Returns the engine's root context.
+
+ The root context is automatically created by the QDeclarativeEngine. Data that
+ should be available to all QML component instances instantiated by the
+ engine should be put in the root context.
+
+ Additional data that should only be available to a subset of component
+ instances should be added to sub-contexts parented to the root context.
+*/
+QDeclarativeContext *QDeclarativeEngine::rootContext()
+{
+ Q_D(QDeclarativeEngine);
+ return d->rootContext;
+}
+
+/*!
+ Sets the \a factory to use for creating QNetworkAccessManager(s).
+
+ QNetworkAccessManager is used for all network access by QML.
+ By implementing a factory it is possible to create custom
+ QNetworkAccessManager with specialized caching, proxy and
+ cookie support.
+
+ The factory must be set before exceuting the engine.
+*/
+void QDeclarativeEngine::setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory *factory)
+{
+ Q_D(QDeclarativeEngine);
+ QMutexLocker locker(&d->mutex);
+ d->networkAccessManagerFactory = factory;
+}
+
+/*!
+ Returns the current QDeclarativeNetworkAccessManagerFactory.
+
+ \sa setNetworkAccessManagerFactory()
+*/
+QDeclarativeNetworkAccessManagerFactory *QDeclarativeEngine::networkAccessManagerFactory() const
+{
+ Q_D(const QDeclarativeEngine);
+ return d->networkAccessManagerFactory;
+}
+
+QNetworkAccessManager *QDeclarativeEnginePrivate::createNetworkAccessManager(QObject *parent) const
+{
+ QMutexLocker locker(&mutex);
+ QNetworkAccessManager *nam;
+ if (networkAccessManagerFactory) {
+ nam = networkAccessManagerFactory->create(parent);
+ } else {
+ nam = new QNetworkAccessManager(parent);
+ }
+
+ return nam;
+}
+
+QNetworkAccessManager *QDeclarativeEnginePrivate::getNetworkAccessManager() const
+{
+ Q_Q(const QDeclarativeEngine);
+ if (!networkAccessManager)
+ networkAccessManager = createNetworkAccessManager(const_cast<QDeclarativeEngine*>(q));
+ return networkAccessManager;
+}
+
+/*!
+ Returns a common QNetworkAccessManager which can be used by any QML element
+ instantiated by this engine.
+
+ If a QDeclarativeNetworkAccessManagerFactory has been set and a QNetworkAccessManager
+ has not yet been created, the QDeclarativeNetworkAccessManagerFactory will be used
+ to create the QNetworkAccessManager; otherwise the returned QNetworkAccessManager
+ will have no proxy or cache set.
+
+ \sa setNetworkAccessManagerFactory()
+*/
+QNetworkAccessManager *QDeclarativeEngine::networkAccessManager() const
+{
+ Q_D(const QDeclarativeEngine);
+ return d->getNetworkAccessManager();
+}
+
+/*!
+ Sets the \a provider to use for images requested via the \e image: url
+ scheme, with host \a providerId.
+
+ QDeclarativeImageProvider allows images to be provided to QML asynchronously.
+ The image request will be run in a low priority thread. This allows
+ potentially costly image loading to be done in the background, without
+ affecting the performance of the UI.
+
+ Note that images loaded from a QDeclarativeImageProvider are cached by
+ QPixmapCache, similar to any image loaded by QML.
+
+ The QDeclarativeEngine assumes ownership of the provider.
+
+ This example creates a provider with id \e colors:
+
+ \snippet examples/declarative/imageprovider/main.cpp 0
+
+ \snippet examples/declarative/imageprovider/view.qml 0
+
+ \sa removeImageProvider()
+*/
+void QDeclarativeEngine::addImageProvider(const QString &providerId, QDeclarativeImageProvider *provider)
+{
+ Q_D(QDeclarativeEngine);
+ QMutexLocker locker(&d->mutex);
+ d->imageProviders.insert(providerId, provider);
+}
+
+/*!
+ Returns the QDeclarativeImageProvider set for \a providerId.
+*/
+QDeclarativeImageProvider *QDeclarativeEngine::imageProvider(const QString &providerId) const
+{
+ Q_D(const QDeclarativeEngine);
+ QMutexLocker locker(&d->mutex);
+ return d->imageProviders.value(providerId);
+}
+
+/*!
+ Removes the QDeclarativeImageProvider for \a providerId.
+
+ Returns the provider if it was found; otherwise returns 0.
+
+ \sa addImageProvider()
+*/
+void QDeclarativeEngine::removeImageProvider(const QString &providerId)
+{
+ Q_D(QDeclarativeEngine);
+ QMutexLocker locker(&d->mutex);
+ delete d->imageProviders.take(providerId);
+}
+
+QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url)
+{
+ QMutexLocker locker(&mutex);
+ QImage image;
+ QDeclarativeImageProvider *provider = imageProviders.value(url.host());
+ if (provider)
+ image = provider->request(url.path().mid(1));
+ return image;
+}
+
+/*!
+ Return the base URL for this engine. The base URL is only used to resolve
+ components when a relative URL is passed to the QDeclarativeComponent constructor.
+
+ If a base URL has not been explicitly set, this method returns the
+ application's current working directory.
+
+ \sa setBaseUrl()
+*/
+QUrl QDeclarativeEngine::baseUrl() const
+{
+ Q_D(const QDeclarativeEngine);
+ if (d->baseUrl.isEmpty()) {
+ return QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
+ } else {
+ return d->baseUrl;
+ }
+}
+
+/*!
+ Set the base URL for this engine to \a url.
+
+ \sa baseUrl()
+*/
+void QDeclarativeEngine::setBaseUrl(const QUrl &url)
+{
+ Q_D(QDeclarativeEngine);
+ d->baseUrl = url;
+}
+
+/*!
+ Returns the QDeclarativeContext for the \a object, or 0 if no context has been set.
+
+ When the QDeclarativeEngine instantiates a QObject, the context is set automatically.
+ */
+QDeclarativeContext *QDeclarativeEngine::contextForObject(const QObject *object)
+{
+ if(!object)
+ return 0;
+
+ QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
+
+ QDeclarativeDeclarativeData *data =
+ static_cast<QDeclarativeDeclarativeData *>(priv->declarativeData);
+
+ if (!data)
+ return 0;
+ else if (data->outerContext)
+ return data->outerContext;
+ else
+ return data->context;
+}
+
+/*!
+ Sets the QDeclarativeContext 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.
+
+ When the QDeclarativeEngine instantiates a QObject, the context is set automatically.
+ */
+void QDeclarativeEngine::setContextForObject(QObject *object, QDeclarativeContext *context)
+{
+ if (!object || !context)
+ return;
+
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object, true);
+ if (data->context) {
+ qWarning("QDeclarativeEngine::setContextForObject(): Object already has a QDeclarativeContext");
+ return;
+ }
+
+ data->context = context;
+ data->nextContextObject = context->d_func()->contextObjects;
+ if (data->nextContextObject)
+ data->nextContextObject->prevContextObject = &data->nextContextObject;
+ data->prevContextObject = &context->d_func()->contextObjects;
+ context->d_func()->contextObjects = data;
+}
+
+void qmlExecuteDeferred(QObject *object)
+{
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object);
+
+ if (data && data->deferredComponent) {
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context->engine());
+
+ QDeclarativeComponentPrivate::ConstructionState state;
+ QDeclarativeComponentPrivate::beginDeferred(data->context, ep, object, &state);
+
+ data->deferredComponent->release();
+ data->deferredComponent = 0;
+
+ QDeclarativeComponentPrivate::complete(ep, &state);
+
+ if (!state.errors.isEmpty())
+ qWarning() << state.errors;
+
+ }
+}
+
+QDeclarativeContext *qmlContext(const QObject *obj)
+{
+ return QDeclarativeEngine::contextForObject(obj);
+}
+
+QDeclarativeEngine *qmlEngine(const QObject *obj)
+{
+ QDeclarativeContext *context = QDeclarativeEngine::contextForObject(obj);
+ return context?context->engine():0;
+}
+
+QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create)
+{
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object);
+ if (!data)
+ return 0; // Attached properties are only on objects created by QML
+
+ QObject *rv = data->attachedProperties?data->attachedProperties->value(id):0;
+ if (rv || !create)
+ return rv;
+
+ QDeclarativeAttachedPropertiesFunc pf = QDeclarativeMetaType::attachedPropertiesFuncById(id);
+ if (!pf)
+ return 0;
+
+ rv = pf(const_cast<QObject *>(object));
+
+ if (rv) {
+ if (!data->attachedProperties)
+ data->attachedProperties = new QHash<int, QObject *>();
+ data->attachedProperties->insert(id, rv);
+ }
+
+ return rv;
+}
+
+void QDeclarativeDeclarativeData::destroyed(QObject *object)
+{
+ if (deferredComponent)
+ deferredComponent->release();
+ if (attachedProperties)
+ delete attachedProperties;
+
+ if (nextContextObject)
+ nextContextObject->prevContextObject = prevContextObject;
+ if (prevContextObject)
+ *prevContextObject = nextContextObject;
+
+ QDeclarativeAbstractBinding *binding = bindings;
+ while (binding) {
+ QDeclarativeAbstractBinding *next = binding->m_nextBinding;
+ binding->m_prevBinding = 0;
+ binding->m_nextBinding = 0;
+ binding->destroy();
+ binding = next;
+ }
+
+ if (bindingBits)
+ free(bindingBits);
+
+ if (propertyCache)
+ propertyCache->release();
+
+ QDeclarativeGuard<QObject> *guard = guards;
+ while (guard) {
+ QDeclarativeGuard<QObject> *g = guard;
+ guard = guard->next;
+ g->o = 0;
+ g->prev = 0;
+ g->next = 0;
+ g->objectDestroyed(object);
+ }
+
+ delete this;
+}
+
+bool QDeclarativeDeclarativeData::hasBindingBit(int bit) const
+{
+ if (bindingBitsSize > bit)
+ return bindingBits[bit / 32] & (1 << (bit % 32));
+ else
+ return false;
+}
+
+void QDeclarativeDeclarativeData::clearBindingBit(int bit)
+{
+ if (bindingBitsSize > bit)
+ bindingBits[bit / 32] &= ~(1 << (bit % 32));
+}
+
+void QDeclarativeDeclarativeData::setBindingBit(QObject *obj, int bit)
+{
+ if (bindingBitsSize <= bit) {
+ int props = obj->metaObject()->propertyCount();
+ Q_ASSERT(bit < props);
+
+ int arraySize = (props + 31) / 32;
+ int oldArraySize = bindingBitsSize / 32;
+
+ bindingBits = (quint32 *)realloc(bindingBits,
+ arraySize * sizeof(quint32));
+
+ memset(bindingBits + oldArraySize,
+ 0x00,
+ sizeof(quint32) * (arraySize - oldArraySize));
+
+ bindingBitsSize = arraySize * 32;
+ }
+
+ bindingBits[bit / 32] |= (1 << (bit % 32));
+}
+
+/*!
+ Creates a QScriptValue allowing you to use \a object in QML script.
+ \a engine is the QDeclarativeEngine it is to be created in.
+
+ The QScriptValue returned is a QtScript Object, not a QtScript QObject, due
+ to the special needs of QML requiring more functionality than a standard
+ QtScript QObject.
+*/
+QScriptValue QDeclarativeEnginePrivate::qmlScriptObject(QObject* object,
+ QDeclarativeEngine* engine)
+{
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+ return enginePriv->objectClass->newQObject(object);
+}
+
+/*!
+ Returns the QDeclarativeContext for the executing QScript \a ctxt.
+*/
+QDeclarativeContext *QDeclarativeEnginePrivate::getContext(QScriptContext *ctxt)
+{
+ QScriptValue scopeNode = QScriptDeclarativeClass::scopeChainValue(ctxt, -3);
+ Q_ASSERT(scopeNode.isValid());
+ Q_ASSERT(QScriptDeclarativeClass::scriptClass(scopeNode) == contextClass);
+ return contextClass->contextFromValue(scopeNode);
+}
+
+QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt,
+ QScriptEngine *engine)
+{
+ QDeclarativeEnginePrivate *activeEnginePriv =
+ static_cast<QDeclarativeScriptEngine*>(engine)->p;
+ QDeclarativeEngine* activeEngine = activeEnginePriv->q_func();
+
+ QDeclarativeContext* context = activeEnginePriv->getContext(ctxt);
+ Q_ASSERT(context);
+ if(ctxt->argumentCount() != 1) {
+ return engine->nullValue();
+ }else{
+ QString arg = ctxt->argument(0).toString();
+ if (arg.isEmpty())
+ return engine->nullValue();
+ QUrl url = QUrl(context->resolvedUrl(QUrl(arg)));
+ QDeclarativeComponent *c = new QDeclarativeComponent(activeEngine, url, activeEngine);
+ c->setCreationContext(context);
+ return activeEnginePriv->objectClass->newQObject(c, qMetaTypeId<QDeclarativeComponent*>());
+ }
+}
+
+QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ QDeclarativeEnginePrivate *activeEnginePriv =
+ static_cast<QDeclarativeScriptEngine*>(engine)->p;
+ QDeclarativeEngine* activeEngine = activeEnginePriv->q_func();
+
+ if(ctxt->argumentCount() < 2 || ctxt->argumentCount() > 3)
+ return engine->nullValue();
+
+ QDeclarativeContext* context = activeEnginePriv->getContext(ctxt);
+ Q_ASSERT(context);
+
+ QString qml = ctxt->argument(0).toString();
+ if (qml.isEmpty())
+ return engine->nullValue();
+
+ QUrl url;
+ if(ctxt->argumentCount() > 2)
+ url = QUrl(ctxt->argument(2).toString());
+ else
+ url = QUrl(QLatin1String("inline"));
+
+ if (url.isValid() && url.isRelative())
+ url = context->resolvedUrl(url);
+
+ QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1));
+ if(!parentArg)
+ return engine->nullValue();
+
+ QDeclarativeComponent component(activeEngine);
+ component.setData(qml.toUtf8(), url);
+
+ if(component.isError()) {
+ QList<QDeclarativeError> errors = component.errors();
+ qWarning().nospace() << "QDeclarativeEngine::createQmlObject():";
+ foreach (const QDeclarativeError &error, errors)
+ qWarning().nospace() << " " << error;
+
+ return engine->nullValue();
+ }
+
+ if (!component.isReady()) {
+ qWarning().nospace() << "QDeclarativeEngine::createQmlObject(): Component is not ready";
+
+ return engine->nullValue();
+ }
+
+ QObject *obj = component.create(context);
+
+ if(component.isError()) {
+ QList<QDeclarativeError> errors = component.errors();
+ qWarning().nospace() << "QDeclarativeEngine::createQmlObject():";
+ foreach (const QDeclarativeError &error, errors)
+ qWarning().nospace() << " " << error;
+
+ return engine->nullValue();
+ }
+
+ Q_ASSERT(obj);
+
+ obj->setParent(parentArg);
+ QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj);
+ QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parentArg);
+ if(gobj && gparent)
+ gobj->setParentItem(gparent);
+
+ return qmlScriptObject(obj, activeEngine);
+}
+
+QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() != 3)
+ return engine->nullValue();
+ qsreal x = ctxt->argument(0).toNumber();
+ qsreal y = ctxt->argument(1).toNumber();
+ qsreal z = ctxt->argument(2).toNumber();
+ return engine->newVariant(qVariantFromValue(QVector3D(x, y, z)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ int argCount = ctxt->argumentCount();
+ if(argCount < 3 || argCount > 4)
+ return engine->nullValue();
+ qsreal r = ctxt->argument(0).toNumber();
+ qsreal g = ctxt->argument(1).toNumber();
+ qsreal b = ctxt->argument(2).toNumber();
+ qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1;
+
+ if (r < 0 || r > 1 || g < 0 || g > 1 || b < 0 || b > 1 || a < 0 || a > 1)
+ return engine->nullValue();
+
+ return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromRgbF(r, g, b, a)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ int argCount = ctxt->argumentCount();
+ if(argCount < 3 || argCount > 4)
+ return engine->nullValue();
+ qsreal h = ctxt->argument(0).toNumber();
+ qsreal s = ctxt->argument(1).toNumber();
+ qsreal l = ctxt->argument(2).toNumber();
+ qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1;
+
+ if (h < 0 || h > 1 || s < 0 || s > 1 || l < 0 || l > 1 || a < 0 || a > 1)
+ return engine->nullValue();
+
+ return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromHslF(h, s, l, a)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() != 4)
+ return engine->nullValue();
+
+ qsreal x = ctxt->argument(0).toNumber();
+ qsreal y = ctxt->argument(1).toNumber();
+ qsreal w = ctxt->argument(2).toNumber();
+ qsreal h = ctxt->argument(3).toNumber();
+
+ if (w < 0 || h < 0)
+ return engine->nullValue();
+
+ return qScriptValueFromValue(engine, qVariantFromValue(QRectF(x, y, w, h)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() != 2)
+ return engine->nullValue();
+ qsreal x = ctxt->argument(0).toNumber();
+ qsreal y = ctxt->argument(1).toNumber();
+ return qScriptValueFromValue(engine, qVariantFromValue(QPointF(x, y)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() != 2)
+ return engine->nullValue();
+ qsreal w = ctxt->argument(0).toNumber();
+ qsreal h = ctxt->argument(1).toNumber();
+ return qScriptValueFromValue(engine, qVariantFromValue(QSizeF(w, h)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() != 1)
+ return engine->nullValue();
+ QVariant v = ctxt->argument(0).toVariant();
+ QColor color;
+ if (v.userType() == QVariant::Color)
+ color = v.value<QColor>();
+ else if (v.userType() == QVariant::String) {
+ bool ok;
+ color = QDeclarativeStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok)
+ return engine->nullValue();
+ } else
+ return engine->nullValue();
+ color = color.lighter();
+ return qScriptValueFromValue(engine, qVariantFromValue(color));
+}
+
+QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() != 1)
+ return engine->nullValue();
+ QVariant v = ctxt->argument(0).toVariant();
+ QColor color;
+ if (v.userType() == QVariant::Color)
+ color = v.value<QColor>();
+ else if (v.userType() == QVariant::String) {
+ bool ok;
+ color = QDeclarativeStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok)
+ return engine->nullValue();
+ } else
+ return engine->nullValue();
+ color = color.darker();
+ return qScriptValueFromValue(engine, qVariantFromValue(color));
+}
+
+QScriptValue QDeclarativeEnginePrivate::playSound(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if (ctxt->argumentCount() != 1)
+ return engine->undefinedValue();
+
+ QUrl url(ctxt->argument(0).toString());
+
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+ if (url.isRelative()) {
+ QDeclarativeContext *context = enginePriv->getContext(ctxt);
+ if (!context)
+ return engine->undefinedValue();
+
+ url = context->resolvedUrl(url);
+ }
+
+ if (url.scheme() == QLatin1String("file")) {
+
+ QSound::play(url.toLocalFile());
+
+ }
+ return engine->undefinedValue();
+}
+
+QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e)
+{
+ if(ctxt->argumentCount() < 1)
+ return e->newVariant(QVariant(false));
+ bool ret = QDesktopServices::openUrl(QUrl(ctxt->argument(0).toString()));
+ return e->newVariant(QVariant(ret));
+}
+
+QScriptValue QDeclarativeEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *)
+{
+ QByteArray data;
+
+ if (ctxt->argumentCount() >= 1)
+ data = ctxt->argument(0).toString().toUtf8();
+
+ QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5);
+
+ return QScriptValue(QLatin1String(result.toHex()));
+}
+
+QScriptValue QDeclarativeEnginePrivate::btoa(QScriptContext *ctxt, QScriptEngine *)
+{
+ QByteArray data;
+
+ if (ctxt->argumentCount() >= 1)
+ data = ctxt->argument(0).toString().toUtf8();
+
+ return QScriptValue(QLatin1String(data.toBase64()));
+}
+
+QScriptValue QDeclarativeEnginePrivate::atob(QScriptContext *ctxt, QScriptEngine *)
+{
+ QByteArray data;
+
+ if (ctxt->argumentCount() >= 1)
+ data = ctxt->argument(0).toString().toUtf8();
+
+ return QScriptValue(QLatin1String(QByteArray::fromBase64(data)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::consoleLog(QScriptContext *ctxt, QScriptEngine *e)
+{
+ if(ctxt->argumentCount() < 1)
+ return e->newVariant(QVariant(false));
+
+ QByteArray msg;
+
+ for (int i=0; i<ctxt->argumentCount(); ++i) {
+ if (!msg.isEmpty()) msg += ' ';
+ msg += ctxt->argument(i).toString().toLocal8Bit();
+ // does not support firebug "%[a-z]" formatting, since firebug really
+ // does just ignore the format letter, which makes it pointless.
+ }
+
+ qDebug("%s",msg.constData());
+
+ return e->newVariant(QVariant(true));
+}
+
+void QDeclarativeEnginePrivate::sendQuit ()
+{
+ Q_Q(QDeclarativeEngine);
+ emit q->quit();
+}
+
+QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptEngine *e)
+{
+ QDeclarativeEnginePrivate *qe = get (e);
+ qe->sendQuit ();
+ return QScriptValue();
+}
+
+QScriptValue QDeclarativeEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e)
+{
+ if(ctxt->argumentCount() < 2)
+ return e->newVariant(QVariant(0.0));
+ qreal a = ctxt->argument(0).toNumber();
+ qreal b = ctxt->argument(1).toNumber();
+ qreal ret = b;
+ qreal diff = b-a;
+ while(diff > 180.0){
+ ret -= 360.0;
+ diff -= 360.0;
+ }
+ while(diff < -180.0){
+ ret += 360.0;
+ diff += 360.0;
+ }
+ return e->newVariant(QVariant(ret));
+}
+
+QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() != 2)
+ return engine->nullValue();
+ //get color
+ QVariant v = ctxt->argument(0).toVariant();
+ QColor color;
+ if (v.userType() == QVariant::Color)
+ color = v.value<QColor>();
+ else if (v.userType() == QVariant::String) {
+ bool ok;
+ color = QDeclarativeStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok)
+ return engine->nullValue();
+ } else
+ return engine->nullValue();
+
+ //get tint color
+ v = ctxt->argument(1).toVariant();
+ QColor tintColor;
+ if (v.userType() == QVariant::Color)
+ tintColor = v.value<QColor>();
+ else if (v.userType() == QVariant::String) {
+ bool ok;
+ tintColor = QDeclarativeStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok)
+ return engine->nullValue();
+ } else
+ return engine->nullValue();
+
+ //tint
+ QColor finalColor;
+ int a = tintColor.alpha();
+ if (a == 0xFF)
+ finalColor = tintColor;
+ else if (a == 0x00)
+ finalColor = color;
+ else {
+ uint src = tintColor.rgba();
+ uint dest = color.rgba();
+
+ uint res = (((a * (src & 0xFF00FF)) +
+ ((0xFF - a) * (dest & 0xFF00FF))) >> 8) & 0xFF00FF;
+ res |= (((a * ((src >> 8) & 0xFF00FF)) +
+ ((0xFF - a) * ((dest >> 8) & 0xFF00FF)))) & 0xFF00FF00;
+ if ((src & 0xFF000000) == 0xFF000000)
+ res |= 0xFF000000;
+
+ finalColor = QColor::fromRgba(res);
+ }
+
+ return qScriptValueFromValue(engine, qVariantFromValue(finalColor));
+}
+
+
+QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &val)
+{
+ if (val.userType() == qMetaTypeId<QDeclarativeListReference>()) {
+ QDeclarativeListReferencePrivate *p = QDeclarativeListReferencePrivate::get((QDeclarativeListReference*)val.constData());
+ if (p->object) {
+ return listClass->newList(p->property, p->propertyType);
+ } else {
+ return scriptEngine.nullValue();
+ }
+ }
+
+ bool objOk;
+ QObject *obj = QDeclarativeMetaType::toQObject(val, &objOk);
+ if (objOk) {
+ return objectClass->newQObject(obj);
+ } else {
+ return qScriptValueFromValue(&scriptEngine, val);
+ }
+}
+
+QVariant QDeclarativeEnginePrivate::scriptValueToVariant(const QScriptValue &val)
+{
+ QScriptDeclarativeClass *dc = QScriptDeclarativeClass::scriptClass(val);
+ if (dc == objectClass)
+ return QVariant::fromValue(objectClass->toQObject(val));
+ else if (dc == contextClass)
+ return QVariant();
+
+ QScriptDeclarativeClass *sc = QScriptDeclarativeClass::scriptClass(val);
+ if (!sc) {
+ return val.toVariant();
+ } else if (sc == valueTypeClass) {
+ return valueTypeClass->toVariant(val);
+ } else {
+ return QVariant();
+ }
+}
+
+QDeclarativeScriptClass::QDeclarativeScriptClass(QScriptEngine *engine)
+: QScriptDeclarativeClass(engine)
+{
+}
+
+QVariant QDeclarativeScriptClass::toVariant(QDeclarativeEngine *engine, const QScriptValue &val)
+{
+ QDeclarativeEnginePrivate *ep =
+ static_cast<QDeclarativeEnginePrivate *>(QObjectPrivate::get(engine));
+
+ return ep->scriptValueToVariant(val);
+}
+
+// XXX this beyonds in QUrl::toLocalFile()
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
+/////////////////////////////////////////////////////////////
+struct QDeclarativeEnginePrivate::ImportedNamespace {
+ QStringList uris;
+ QStringList urls;
+ QList<int> majversions;
+ QList<int> minversions;
+ QList<bool> isLibrary;
+ QList<QString> qmlDirContent;
+
+ bool find(const QByteArray& type, int *vmajor, int *vminor, QDeclarativeType** type_return, QUrl* url_return) const
+ {
+ for (int i=0; i<urls.count(); ++i) {
+ int vmaj = majversions.at(i);
+ int vmin = minversions.at(i);
+
+ QByteArray qt = uris.at(i).toUtf8();
+ qt += '/';
+ qt += type;
+
+ if (qmlImportTrace())
+ qDebug() << "Look in" << qt;
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType(qt,vmaj,vmin);
+ if (t) {
+ if (vmajor) *vmajor = vmaj;
+ if (vminor) *vminor = vmin;
+ if (qmlImportTrace())
+ qDebug() << "Found" << qt;
+ if (type_return)
+ *type_return = t;
+ return true;
+ }
+
+ QUrl url = QUrl(urls.at(i) + QLatin1Char('/') + QString::fromUtf8(type) + QLatin1String(".qml"));
+ QString qmldircontent = qmlDirContent.at(i);
+ if (vmaj>=0 || !qmldircontent.isEmpty()) {
+ // Check version file - XXX cache these in QDeclarativeEngine!
+ if (qmldircontent.isEmpty()) {
+ QFile qmldir(toLocalFileOrQrc(QUrl(urls.at(i)+QLatin1String("/qmldir"))));
+ if (qmldir.open(QIODevice::ReadOnly)) {
+ qmldircontent = QString::fromUtf8(qmldir.readAll());
+ }
+ }
+
+ const QString typeName = QString::fromUtf8(type);
+
+ QDeclarativeDirParser qmldirParser;
+ qmldirParser.setUrl(url);
+ qmldirParser.setSource(qmldircontent);
+ qmldirParser.parse();
+
+ foreach (const QDeclarativeDirParser::Component &c, qmldirParser.components()) { // ### TODO: cache the components
+ if (c.majorVersion < vmaj || (c.majorVersion == vmaj && vmin >= c.minorVersion)) {
+ if (c.typeName == typeName) {
+ if (url_return)
+ *url_return = url.resolved(QUrl(c.fileName));
+
+ return true;
+ }
+ }
+ }
+
+ } else {
+ // XXX search non-files too! (eg. zip files, see QT-524)
+ QFileInfo f(toLocalFileOrQrc(url));
+ if (f.exists()) {
+ if (url_return)
+ *url_return = url;
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+};
+
+class QDeclarativeImportsPrivate {
+public:
+ QDeclarativeImportsPrivate() : ref(1)
+ {
+ }
+
+ ~QDeclarativeImportsPrivate()
+ {
+ foreach (QDeclarativeEnginePrivate::ImportedNamespace* s, set.values())
+ delete s;
+ }
+
+ QSet<QString> qmlDirFilesForWhichPluginsHaveBeenLoaded;
+
+ bool add(const QUrl& base, const QString& qmldircontent, const QString& uri, const QString& prefix, int vmaj, int vmin, QDeclarativeScriptParser::Import::Type importType, const QStringList& importPath, QDeclarativeEngine *engine)
+ {
+ QDeclarativeEnginePrivate::ImportedNamespace *s;
+ if (prefix.isEmpty()) {
+ s = &unqualifiedset;
+ } else {
+ s = set.value(prefix);
+ if (!s)
+ set.insert(prefix,(s=new QDeclarativeEnginePrivate::ImportedNamespace));
+ }
+ QString url = uri;
+ if (importType == QDeclarativeScriptParser::Import::Library) {
+ url.replace(QLatin1Char('.'), QLatin1Char('/'));
+ bool found = false;
+ QString content;
+ QString dir;
+
+ // user import paths
+ QStringList paths;
+
+ // base..
+ paths += QFileInfo(base.toLocalFile()).path();
+ paths += importPath;
+ paths += QDeclarativeEnginePrivate::get(engine)->environmentImportPath;
+
+ foreach (const QString &p, paths) {
+ dir = p+QLatin1Char('/')+url;
+ QFileInfo fi(dir+QLatin1String("/qmldir"));
+ const QString absoluteFilePath = fi.absoluteFilePath();
+
+ if (fi.isFile()) {
+ found = true;
+
+ url = QUrl::fromLocalFile(fi.absolutePath()).toString();
+
+ QFile file(absoluteFilePath);
+ if (file.open(QFile::ReadOnly))
+ content = QString::fromUtf8(file.readAll());
+
+ if (! qmlDirFilesForWhichPluginsHaveBeenLoaded.contains(absoluteFilePath)) {
+ qmlDirFilesForWhichPluginsHaveBeenLoaded.insert(absoluteFilePath);
+
+ QDeclarativeDirParser qmldirParser;
+ qmldirParser.setSource(content);
+ qmldirParser.parse();
+
+ foreach (const QDeclarativeDirParser::Plugin &plugin, qmldirParser.plugins()) {
+ QString resolvedFilePath = QDeclarativeEnginePrivate::get(engine)->resolvePlugin(dir + QDir::separator() + plugin.path,
+ plugin.name);
+
+ if (!resolvedFilePath.isEmpty())
+ engine->importExtension(resolvedFilePath, uri);
+ }
+ }
+
+ break;
+ }
+ }
+
+ } else {
+ url = base.resolved(QUrl(url)).toString();
+ }
+
+ s->uris.prepend(uri);
+ s->urls.prepend(url);
+ s->majversions.prepend(vmaj);
+ s->minversions.prepend(vmin);
+ s->isLibrary.prepend(importType == QDeclarativeScriptParser::Import::Library);
+ s->qmlDirContent.prepend(qmldircontent);
+ return true;
+ }
+
+ bool find(const QByteArray& type, int *vmajor, int *vminor, QDeclarativeType** type_return, QUrl* url_return)
+ {
+ QDeclarativeEnginePrivate::ImportedNamespace *s = 0;
+ int slash = type.indexOf('/');
+ if (slash >= 0) {
+ s = set.value(QString::fromUtf8(type.left(slash)));
+ if (!s)
+ return false; // qualifier must be a namespace
+ int nslash = type.indexOf('/',slash+1);
+ if (nslash > 0)
+ return false; // only single qualification allowed
+ } else {
+ s = &unqualifiedset;
+ }
+ QByteArray unqualifiedtype = slash < 0 ? type : type.mid(slash+1); // common-case opt (QString::mid works fine, but slower)
+ if (s) {
+ if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return))
+ return true;
+ if (s->urls.count() == 1 && !s->isLibrary[0] && url_return) {
+ *url_return = QUrl(s->urls[0]+QLatin1Char('/')).resolved(QUrl(QString::fromUtf8(unqualifiedtype) + QLatin1String(".qml")));
+ return true;
+ }
+
+ }
+ if (url_return) {
+ *url_return = base.resolved(QUrl(QString::fromUtf8(type + ".qml")));
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ QDeclarativeEnginePrivate::ImportedNamespace *findNamespace(const QString& type)
+ {
+ return set.value(type);
+ }
+
+ QUrl base;
+ int ref;
+
+private:
+ friend struct QDeclarativeEnginePrivate::Imports;
+ QDeclarativeEnginePrivate::ImportedNamespace unqualifiedset;
+ QHash<QString,QDeclarativeEnginePrivate::ImportedNamespace* > set;
+};
+
+QDeclarativeEnginePrivate::Imports::Imports(const Imports &copy) :
+ d(copy.d)
+{
+ ++d->ref;
+}
+
+QDeclarativeEnginePrivate::Imports &QDeclarativeEnginePrivate::Imports::operator =(const Imports &copy)
+{
+ ++copy.d->ref;
+ if (--d->ref == 0)
+ delete d;
+ d = copy.d;
+ return *this;
+}
+
+QDeclarativeEnginePrivate::Imports::Imports() :
+ d(new QDeclarativeImportsPrivate)
+{
+}
+
+QDeclarativeEnginePrivate::Imports::~Imports()
+{
+ if (--d->ref == 0)
+ delete d;
+}
+
+#include "qdeclarativemetatype.h"
+#include "qdeclarativetypenamecache_p.h"
+
+static QDeclarativeTypeNameCache *cacheForNamespace(QDeclarativeEngine *engine, const QDeclarativeEnginePrivate::ImportedNamespace &set, QDeclarativeTypeNameCache *cache)
+{
+ if (!cache)
+ cache = new QDeclarativeTypeNameCache(engine);
+
+ QList<QDeclarativeType *> types = QDeclarativeMetaType::qmlTypes();
+
+ for (int ii = 0; ii < set.uris.count(); ++ii) {
+ QByteArray base = set.uris.at(ii).toUtf8() + '/';
+ int major = set.majversions.at(ii);
+ int minor = set.minversions.at(ii);
+
+ foreach (QDeclarativeType *type, types) {
+ if (type->qmlTypeName().startsWith(base) &&
+ type->qmlTypeName().lastIndexOf('/') == (base.length() - 1) &&
+ type->availableInVersion(major,minor))
+ {
+ QString name = QString::fromUtf8(type->qmlTypeName().mid(base.length()));
+
+ cache->add(name, type);
+ }
+ }
+ }
+
+ return cache;
+}
+
+QDeclarativeTypeNameCache *QDeclarativeEnginePrivate::Imports::cache(QDeclarativeEngine *engine) const
+{
+ const QDeclarativeEnginePrivate::ImportedNamespace &set = d->unqualifiedset;
+
+ QDeclarativeTypeNameCache *cache = new QDeclarativeTypeNameCache(engine);
+
+ for (QHash<QString,QDeclarativeEnginePrivate::ImportedNamespace* >::ConstIterator iter = d->set.begin();
+ iter != d->set.end(); ++iter) {
+
+ QDeclarativeTypeNameCache::Data *d = cache->data(iter.key());
+ if (d) {
+ if (!d->typeNamespace)
+ cacheForNamespace(engine, *(*iter), d->typeNamespace);
+ } else {
+ QDeclarativeTypeNameCache *nc = cacheForNamespace(engine, *(*iter), 0);
+ cache->add(iter.key(), nc);
+ nc->release();
+ }
+ }
+
+ cacheForNamespace(engine, set, cache);
+
+ return cache;
+}
+
+/*
+QStringList QDeclarativeEnginePrivate::Imports::unqualifiedSet() const
+{
+ QStringList rv;
+
+ const QDeclarativeEnginePrivate::ImportedNamespace &set = d->unqualifiedset;
+
+ for (int ii = 0; ii < set.urls.count(); ++ii) {
+ if (set.isBuiltin.at(ii))
+ rv << set.urls.at(ii);
+ }
+
+ return rv;
+}
+*/
+
+/*!
+ Sets the base URL to be used for all relative file imports added.
+*/
+void QDeclarativeEnginePrivate::Imports::setBaseUrl(const QUrl& url)
+{
+ d->base = url;
+}
+
+/*!
+ Returns the base URL to be used for all relative file imports added.
+*/
+QUrl QDeclarativeEnginePrivate::Imports::baseUrl() const
+{
+ return d->base;
+}
+
+/*!
+ Adds \a path as a directory where installed QML components are
+ defined in a URL-based directory structure.
+
+ For example, if you add \c /opt/MyApp/lib/qml and then load QML
+ that imports \c com.mycompany.Feature, then QDeclarativeEngine will look
+ in \c /opt/MyApp/lib/qml/com/mycompany/Feature/ for the components
+ provided by that module (and in the case of versioned imports,
+ for the \c qmldir file definiting the type version mapping.
+
+ By default, only the "qml" subdirectory of QLibraryInfo::location(QLibraryInfo::DataPath)
+ is included on the import path.
+*/
+void QDeclarativeEngine::addImportPath(const QString& path)
+{
+ if (qmlImportTrace())
+ qDebug() << "QDeclarativeEngine::addImportPath" << path;
+ Q_D(QDeclarativeEngine);
+ d->fileImportPath.prepend(path);
+}
+
+/*!
+ Imports the given \a extension into this QDeclarativeEngine. Returns
+ true if the extension was successfully imported.
+
+ \sa QDeclarativeExtensionInterface
+*/
+bool QDeclarativeEngine::importExtension(const QString &fileName, const QString &uri)
+{
+ QPluginLoader loader(fileName);
+
+ if (QDeclarativeExtensionInterface *iface = qobject_cast<QDeclarativeExtensionInterface *>(loader.instance())) {
+ iface->initialize(this, uri.toUtf8().constData());
+ return true;
+ }
+
+ return false;
+}
+
+/*!
+ \property QDeclarativeEngine::offlineStoragePath
+ \brief the directory for storing offline user data
+
+ Returns the directory where SQL and other offline
+ storage is placed.
+
+ QDeclarativeWebView and the SQL databases created with openDatabase()
+ are stored here.
+
+ The default is QML/OfflineStorage in the platform-standard
+ user application data directory.
+
+ Note that the path may not currently exist on the filesystem, so
+ callers wanting to \e create new files at this location should create
+ it first - see QDir::mkpath().
+*/
+void QDeclarativeEngine::setOfflineStoragePath(const QString& dir)
+{
+ Q_D(QDeclarativeEngine);
+ d->scriptEngine.offlineStoragePath = dir;
+}
+
+QString QDeclarativeEngine::offlineStoragePath() const
+{
+ Q_D(const QDeclarativeEngine);
+ return d->scriptEngine.offlineStoragePath;
+}
+
+/*!
+ \internal
+
+ Returns the result of the merge of \a baseName with \a dir, \a suffixes, and \a prefix.
+ */
+QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName,
+ const QStringList &suffixes,
+ const QString &prefix)
+{
+ foreach (const QString &suffix, suffixes) {
+ QString pluginFileName = prefix;
+
+ pluginFileName += baseName;
+ pluginFileName += QLatin1Char('.');
+ pluginFileName += suffix;
+
+ QFileInfo fileInfo(dir, pluginFileName);
+
+ if (fileInfo.exists())
+ return fileInfo.absoluteFilePath();
+ }
+
+ return QString();
+}
+
+/*!
+ \internal
+
+ Returns the result of the merge of \a baseName with \a dir and the platform suffix.
+
+ \table
+ \header \i Platform \i Valid suffixes
+ \row \i Windows \i \c .dll
+ \row \i Unix/Linux \i \c .so
+ \row \i AIX \i \c .a
+ \row \i HP-UX \i \c .sl, \c .so (HP-UXi)
+ \row \i Mac OS X \i \c .dylib, \c .bundle, \c .so
+ \row \i Symbian \i \c .dll
+ \endtable
+
+ Version number on unix are ignored.
+*/
+QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName)
+{
+#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+ return resolvePlugin(dir, baseName, QStringList(QLatin1String("dll")));
+#elif defined(Q_OS_SYMBIAN)
+ return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dll") << QLatin1String("qtplugin"));
+#else
+
+# if defined(Q_OS_DARWIN)
+
+ return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dylib") << QLatin1String("so") << QLatin1String("bundle"),
+ QLatin1String("lib"));
+# else // Generic Unix
+ QStringList validSuffixList;
+
+# if defined(Q_OS_HPUX)
+/*
+ See "HP-UX Linker and Libraries User's Guide", section "Link-time Differences between PA-RISC and IPF":
+ "In PA-RISC (PA-32 and PA-64) shared libraries are suffixed with .sl. In IPF (32-bit and 64-bit),
+ the shared libraries are suffixed with .so. For compatibility, the IPF linker also supports the .sl suffix."
+ */
+ validSuffixList << QLatin1String("sl");
+# if defined __ia64
+ validSuffixList << QLatin1String("so");
+# endif
+# elif defined(Q_OS_AIX)
+ validSuffixList << QLatin1String("a") << QLatin1String("so");
+# elif defined(Q_OS_UNIX)
+ validSuffixList << QLatin1String("so");
+# endif
+
+ // Examples of valid library names:
+ // libfoo.so
+
+ return resolvePlugin(dir, baseName, validSuffixList, QLatin1String("lib"));
+# endif
+
+#endif
+}
+
+/*!
+ \internal
+
+ Adds information to \a imports such that subsequent calls to resolveType()
+ will resolve types qualified by \a prefix by considering types found at the given \a uri.
+
+ The uri is either a directory (if importType is FileImport), or a URI resolved using paths
+ added via addImportPath() (if importType is LibraryImport).
+
+ The \a prefix may be empty, in which case the import location is considered for
+ unqualified types.
+
+ The base URL must already have been set with Import::setBaseUrl().
+*/
+bool QDeclarativeEnginePrivate::addToImport(Imports* imports, const QString& qmldircontent, const QString& uri, const QString& prefix, int vmaj, int vmin, QDeclarativeScriptParser::Import::Type importType) const
+{
+ QDeclarativeEngine *engine = QDeclarativeEnginePrivate::get(const_cast<QDeclarativeEnginePrivate *>(this));
+ bool ok = imports->d->add(imports->d->base,qmldircontent,uri,prefix,vmaj,vmin,importType,fileImportPath, engine);
+ if (qmlImportTrace())
+ qDebug() << "QDeclarativeEngine::addToImport(" << imports << uri << prefix << vmaj << '.' << vmin << (importType==QDeclarativeScriptParser::Import::Library? "Library" : "File") << ": " << ok;
+ return ok;
+}
+
+/*!
+ \internal
+
+ Using the given \a imports, the given (namespace qualified) \a type is resolved to either
+ an ImportedNamespace stored at \a ns_return,
+ a QDeclarativeType stored at \a type_return, or
+ a component located at \a url_return.
+
+ If any return pointer is 0, the corresponding search is not done.
+
+ \sa addToImport()
+*/
+bool QDeclarativeEnginePrivate::resolveType(const Imports& imports, const QByteArray& type, QDeclarativeType** type_return, QUrl* url_return, int *vmaj, int *vmin, ImportedNamespace** ns_return) const
+{
+ ImportedNamespace* ns = imports.d->findNamespace(QString::fromUtf8(type));
+ if (ns) {
+ if (qmlImportTrace())
+ qDebug() << "QDeclarativeEngine::resolveType" << type << "is namespace for" << ns->urls;
+ if (ns_return)
+ *ns_return = ns;
+ return true;
+ }
+ if (type_return || url_return) {
+ if (imports.d->find(type,vmaj,vmin,type_return,url_return)) {
+ if (qmlImportTrace()) {
+ if (type_return && *type_return)
+ qDebug() << "QDeclarativeEngine::resolveType" << type << '=' << (*type_return)->typeName();
+ if (url_return)
+ qDebug() << "QDeclarativeEngine::resolveType" << type << '=' << *url_return;
+ }
+ return true;
+ }
+ if (qmlImportTrace())
+ qDebug() << "QDeclarativeEngine::resolveType" << type << "not found";
+ }
+ return false;
+}
+
+/*!
+ \internal
+
+ Searching \e only in the namespace \a ns (previously returned in a call to
+ resolveType(), \a type is found and returned to either
+ a QDeclarativeType stored at \a type_return, or
+ a component located at \a url_return.
+
+ If either return pointer is 0, the corresponding search is not done.
+*/
+void QDeclarativeEnginePrivate::resolveTypeInNamespace(ImportedNamespace* ns, const QByteArray& type, QDeclarativeType** type_return, QUrl* url_return, int *vmaj, int *vmin ) const
+{
+ ns->find(type,vmaj,vmin,type_return,url_return);
+}
+
+static void voidptr_destructor(void *v)
+{
+ void **ptr = (void **)v;
+ delete ptr;
+}
+
+static void *voidptr_constructor(const void *v)
+{
+ if (!v) {
+ return new void*;
+ } else {
+ return new void*(*(void **)v);
+ }
+}
+
+void QDeclarativeEnginePrivate::registerCompositeType(QDeclarativeCompiledData *data)
+{
+ QByteArray name = data->root->className();
+
+ QByteArray ptr = name + '*';
+ QByteArray lst = "QDeclarativeListProperty<" + name + ">";
+
+ int ptr_type = QMetaType::registerType(ptr.constData(), voidptr_destructor,
+ voidptr_constructor);
+ int lst_type = QMetaType::registerType(lst.constData(), voidptr_destructor,
+ voidptr_constructor);
+
+ m_qmlLists.insert(lst_type, ptr_type);
+ m_compositeTypes.insert(ptr_type, data);
+ data->addref();
+}
+
+bool QDeclarativeEnginePrivate::isList(int t) const
+{
+ return m_qmlLists.contains(t) || QDeclarativeMetaType::isList(t);
+}
+
+int QDeclarativeEnginePrivate::listType(int t) const
+{
+ QHash<int, int>::ConstIterator iter = m_qmlLists.find(t);
+ if (iter != m_qmlLists.end())
+ return *iter;
+ else
+ return QDeclarativeMetaType::listType(t);
+}
+
+bool QDeclarativeEnginePrivate::isQObject(int t)
+{
+ return m_compositeTypes.contains(t) || QDeclarativeMetaType::isQObject(t);
+}
+
+QObject *QDeclarativeEnginePrivate::toQObject(const QVariant &v, bool *ok) const
+{
+ int t = v.userType();
+ if (m_compositeTypes.contains(t)) {
+ if (ok) *ok = true;
+ return *(QObject **)(v.constData());
+ } else {
+ return QDeclarativeMetaType::toQObject(v, ok);
+ }
+}
+
+QDeclarativeMetaType::TypeCategory QDeclarativeEnginePrivate::typeCategory(int t) const
+{
+ if (m_compositeTypes.contains(t))
+ return QDeclarativeMetaType::Object;
+ else if (m_qmlLists.contains(t))
+ return QDeclarativeMetaType::List;
+ else
+ return QDeclarativeMetaType::typeCategory(t);
+}
+
+const QMetaObject *QDeclarativeEnginePrivate::rawMetaObjectForType(int t) const
+{
+ QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.find(t);
+ if (iter != m_compositeTypes.end()) {
+ return (*iter)->root;
+ } else {
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(t);
+ return type?type->baseMetaObject():0;
+ }
+}
+
+const QMetaObject *QDeclarativeEnginePrivate::metaObjectForType(int t) const
+{
+ QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.find(t);
+ if (iter != m_compositeTypes.end()) {
+ return (*iter)->root;
+ } else {
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(t);
+ return type?type->metaObject():0;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeengine.h b/src/declarative/qml/qdeclarativeengine.h
new file mode 100644
index 0000000..fd66358
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeengine.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEENGINE_H
+#define QDECLARATIVEENGINE_H
+
+#include <QtCore/qurl.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qmap.h>
+#include <QtScript/qscriptvalue.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeComponent;
+class QDeclarativeEnginePrivate;
+class QDeclarativeImportsPrivate;
+class QDeclarativeExpression;
+class QDeclarativeContext;
+class QDeclarativeType;
+class QUrl;
+class QScriptEngine;
+class QScriptContext;
+class QDeclarativeImageProvider;
+class QNetworkAccessManager;
+class QDeclarativeNetworkAccessManagerFactory;
+class Q_DECLARATIVE_EXPORT QDeclarativeEngine : public QObject
+{
+ Q_PROPERTY(QString offlineStoragePath READ offlineStoragePath WRITE setOfflineStoragePath)
+ Q_OBJECT
+public:
+ QDeclarativeEngine(QObject *p = 0);
+ virtual ~QDeclarativeEngine();
+
+ QDeclarativeContext *rootContext();
+
+ void clearComponentCache();
+
+ void addImportPath(const QString& dir);
+ bool importExtension(const QString &fileName, const QString &uri);
+
+ void setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory *);
+ QDeclarativeNetworkAccessManagerFactory *networkAccessManagerFactory() const;
+
+ QNetworkAccessManager *networkAccessManager() const;
+
+ void addImageProvider(const QString &id, QDeclarativeImageProvider *);
+ QDeclarativeImageProvider *imageProvider(const QString &id) const;
+ void removeImageProvider(const QString &id);
+
+ void setOfflineStoragePath(const QString& dir);
+ QString offlineStoragePath() const;
+
+ QUrl baseUrl() const;
+ void setBaseUrl(const QUrl &);
+
+ static QDeclarativeContext *contextForObject(const QObject *);
+ static void setContextForObject(QObject *, QDeclarativeContext *);
+
+Q_SIGNALS:
+ void quit ();
+
+private:
+ Q_DECLARE_PRIVATE(QDeclarativeEngine)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEENGINE_H
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
new file mode 100644
index 0000000..7c9d833
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -0,0 +1,340 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEENGINE_P_H
+#define QDECLARATIVEENGINE_P_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 "qdeclarativeengine.h"
+
+#include "qdeclarativeclassfactory_p.h"
+#include "qdeclarativecompositetypemanager_p.h"
+#include "qpodvector_p.h"
+#include "qdeclarative.h"
+#include "qdeclarativevaluetype_p.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarativeexpression.h"
+#include "qdeclarativemetaproperty_p.h"
+#include "qdeclarativepropertycache_p.h"
+#include "qdeclarativeobjectscriptclass_p.h"
+#include "qdeclarativecontextscriptclass_p.h"
+#include "qdeclarativevaluetypescriptclass_p.h"
+
+#include <QtScript/QScriptClass>
+#include <QtScript/QScriptValue>
+#include <QtScript/QScriptString>
+#include <QtCore/qstring.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qpair.h>
+#include <QtCore/qstack.h>
+#include <QtCore/qmutex.h>
+#include <QtScript/qscriptengine.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeContext;
+class QDeclarativeEngine;
+class QDeclarativeContextPrivate;
+class QDeclarativeExpression;
+class QDeclarativeContextScriptClass;
+class QDeclarativeObjectScriptClass;
+class QDeclarativeTypeNameScriptClass;
+class QDeclarativeValueTypeScriptClass;
+class QScriptEngineDebugger;
+class QNetworkReply;
+class QNetworkAccessManager;
+class QDeclarativeNetworkAccessManagerFactory;
+class QDeclarativeAbstractBinding;
+class QScriptDeclarativeClass;
+class QDeclarativeTypeNameScriptClass;
+class QDeclarativeTypeNameCache;
+class QDeclarativeComponentAttached;
+class QDeclarativeListScriptClass;
+class QDeclarativeCleanup;
+class QDeclarativeDelayedError;
+class QDeclarativeWorkerScriptEngine;
+class QDeclarativeGlobalScriptClass;
+class QDir;
+
+class QDeclarativeScriptEngine : public QScriptEngine
+{
+public:
+ QDeclarativeScriptEngine(QDeclarativeEnginePrivate *priv);
+ virtual ~QDeclarativeScriptEngine();
+
+ QUrl resolvedUrl(QScriptContext *context, const QUrl& url); // resolved against p's context, or baseUrl if no p
+ static QScriptValue resolvedUrl(QScriptContext *ctxt, QScriptEngine *engine);
+
+ static QDeclarativeScriptEngine *get(QScriptEngine* e) { return static_cast<QDeclarativeScriptEngine*>(e); }
+
+ QDeclarativeEnginePrivate *p;
+
+ // User by SQL API
+ QScriptClass *sqlQueryClass;
+ QString offlineStoragePath;
+
+ // Used by DOM Core 3 API
+ QScriptClass *namedNodeMapClass;
+ QScriptClass *nodeListClass;
+
+ QUrl baseUrl;
+
+ virtual QNetworkAccessManager *networkAccessManager();
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeEnginePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeEngine)
+public:
+ QDeclarativeEnginePrivate(QDeclarativeEngine *);
+ ~QDeclarativeEnginePrivate();
+
+ void init();
+
+ struct CapturedProperty {
+ CapturedProperty(QObject *o, int c, int n)
+ : object(o), coreIndex(c), notifyIndex(n) {}
+
+ QObject *object;
+ int coreIndex;
+ int notifyIndex;
+ };
+ bool captureProperties;
+ QPODVector<CapturedProperty> capturedProperties;
+
+ QDeclarativeContext *rootContext;
+ QDeclarativeExpression *currentExpression;
+ bool isDebugging;
+
+ struct ImportedNamespace;
+ QDeclarativeContextScriptClass *contextClass;
+ QDeclarativeContext *sharedContext;
+ QObject *sharedScope;
+ QDeclarativeObjectScriptClass *objectClass;
+ QDeclarativeValueTypeScriptClass *valueTypeClass;
+ QDeclarativeTypeNameScriptClass *typeNameClass;
+ QDeclarativeListScriptClass *listClass;
+ // Global script class
+ QDeclarativeGlobalScriptClass *globalClass;
+
+ // Registered cleanup handlers
+ QDeclarativeCleanup *cleanup;
+
+ // Bindings that have had errors during startup
+ QDeclarativeDelayedError *erroredBindings;
+ int inProgressCreations;
+
+ QDeclarativeScriptEngine scriptEngine;
+
+ QDeclarativeWorkerScriptEngine *getWorkerScriptEngine();
+ QDeclarativeWorkerScriptEngine *workerScriptEngine;
+
+ QUrl baseUrl;
+
+ template<class T>
+ struct SimpleList {
+ SimpleList()
+ : count(0), values(0) {}
+ SimpleList(int r)
+ : count(0), values(new T*[r]) {}
+
+ int count;
+ T **values;
+
+ void append(T *v) {
+ values[count++] = v;
+ }
+
+ T *at(int idx) const {
+ return values[idx];
+ }
+
+ void clear() {
+ delete [] values;
+ }
+ };
+
+ static void clear(SimpleList<QDeclarativeAbstractBinding> &);
+ static void clear(SimpleList<QDeclarativeParserStatus> &);
+
+ QList<SimpleList<QDeclarativeAbstractBinding> > bindValues;
+ QList<SimpleList<QDeclarativeParserStatus> > parserStatus;
+ QDeclarativeComponentAttached *componentAttacheds;
+
+ bool inBeginCreate;
+
+ QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const;
+ QNetworkAccessManager *getNetworkAccessManager() const;
+ mutable QNetworkAccessManager *networkAccessManager;
+ mutable QDeclarativeNetworkAccessManagerFactory *networkAccessManagerFactory;
+
+ QHash<QString,QDeclarativeImageProvider*> imageProviders;
+ QImage getImageFromProvider(const QUrl &url);
+
+ mutable QMutex mutex;
+
+ QDeclarativeCompositeTypeManager typeManager;
+ QStringList fileImportPath;
+ QString offlineStoragePath;
+
+ mutable quint32 uniqueId;
+ quint32 getUniqueId() const {
+ return uniqueId++;
+ }
+
+ QDeclarativeValueTypeFactory valueTypes;
+
+ QHash<const QMetaObject *, QDeclarativePropertyCache *> propertyCache;
+ QDeclarativePropertyCache *cache(QObject *obj) {
+ Q_Q(QDeclarativeEngine);
+ if (!obj || QObjectPrivate::get(obj)->metaObject) return 0;
+ const QMetaObject *mo = obj->metaObject();
+ QDeclarativePropertyCache *rv = propertyCache.value(mo);
+ if (!rv) {
+ rv = QDeclarativePropertyCache::create(q, mo);
+ propertyCache.insert(mo, rv);
+ }
+ return rv;
+ }
+
+ // ### This whole class is embarrassing
+ struct Imports {
+ Imports();
+ ~Imports();
+ Imports(const Imports &copy);
+ Imports &operator =(const Imports &copy);
+
+ void setBaseUrl(const QUrl& url);
+ QUrl baseUrl() const;
+
+ QDeclarativeTypeNameCache *cache(QDeclarativeEngine *) const;
+
+ private:
+ friend class QDeclarativeEnginePrivate;
+ QDeclarativeImportsPrivate *d;
+ };
+
+
+ QStringList environmentImportPath;
+
+ QString resolvePlugin(const QDir &dir, const QString &baseName,
+ const QStringList &suffixes,
+ const QString &prefix = QString());
+ QString resolvePlugin(const QDir &dir, const QString &baseName);
+
+
+ bool addToImport(Imports*, const QString& qmlDirContent,const QString& uri, const QString& prefix, int vmaj, int vmin, QDeclarativeScriptParser::Import::Type importType) const;
+ bool resolveType(const Imports&, const QByteArray& type,
+ QDeclarativeType** type_return, QUrl* url_return,
+ int *version_major, int *version_minor,
+ ImportedNamespace** ns_return) const;
+ void resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type,
+ QDeclarativeType** type_return, QUrl* url_return,
+ int *version_major, int *version_minor ) const;
+
+
+ void registerCompositeType(QDeclarativeCompiledData *);
+
+ bool isQObject(int);
+ QObject *toQObject(const QVariant &, bool *ok = 0) const;
+ QDeclarativeMetaType::TypeCategory typeCategory(int) const;
+ bool isList(int) const;
+ int listType(int) const;
+ const QMetaObject *rawMetaObjectForType(int) const;
+ const QMetaObject *metaObjectForType(int) const;
+ QHash<int, int> m_qmlLists;
+ QHash<int, QDeclarativeCompiledData *> m_compositeTypes;
+
+ QScriptValue scriptValueFromVariant(const QVariant &);
+ QVariant scriptValueToVariant(const QScriptValue &);
+
+ void sendQuit ();
+
+ static QScriptValue qmlScriptObject(QObject*, QDeclarativeEngine*);
+
+ static QScriptValue createComponent(QScriptContext*, QScriptEngine*);
+ static QScriptValue createQmlObject(QScriptContext*, QScriptEngine*);
+ static QScriptValue vector(QScriptContext*, QScriptEngine*);
+ static QScriptValue rgba(QScriptContext*, QScriptEngine*);
+ static QScriptValue hsla(QScriptContext*, QScriptEngine*);
+ static QScriptValue point(QScriptContext*, QScriptEngine*);
+ static QScriptValue size(QScriptContext*, QScriptEngine*);
+ static QScriptValue rect(QScriptContext*, QScriptEngine*);
+
+ static QScriptValue lighter(QScriptContext*, QScriptEngine*);
+ static QScriptValue darker(QScriptContext*, QScriptEngine*);
+ static QScriptValue tint(QScriptContext*, QScriptEngine*);
+
+ static QScriptValue closestAngle(QScriptContext*, QScriptEngine*);
+ static QScriptValue playSound(QScriptContext*, QScriptEngine*);
+ static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*);
+ static QScriptValue md5(QScriptContext*, QScriptEngine*);
+ static QScriptValue btoa(QScriptContext*, QScriptEngine*);
+ static QScriptValue atob(QScriptContext*, QScriptEngine*);
+ static QScriptValue consoleLog(QScriptContext*, QScriptEngine*);
+ static QScriptValue quit(QScriptContext*, QScriptEngine*);
+
+ static QScriptEngine *getScriptEngine(QDeclarativeEngine *e) { return &e->d_func()->scriptEngine; }
+ static QDeclarativeEngine *getEngine(QScriptEngine *e) { return static_cast<QDeclarativeScriptEngine*>(e)->p->q_func(); }
+ static QDeclarativeEnginePrivate *get(QDeclarativeEngine *e) { return e->d_func(); }
+ static QDeclarativeEnginePrivate *get(QDeclarativeContext *c) { return (c && c->engine()) ? QDeclarativeEnginePrivate::get(c->engine()) : 0; }
+ static QDeclarativeEnginePrivate *get(QScriptEngine *e) { return static_cast<QDeclarativeScriptEngine*>(e)->p; }
+ static QDeclarativeEngine *get(QDeclarativeEnginePrivate *p) { return p->q_func(); }
+ QDeclarativeContext *getContext(QScriptContext *);
+
+ static void defineModule();
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEENGINE_P_H
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
new file mode 100644
index 0000000..e4579a6
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -0,0 +1,456 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeenginedebug_p.h"
+
+#include "qdeclarativeboundsignal_p.h"
+#include "qdeclarativeengine.h"
+#include "qdeclarativemetatype.h"
+#include "qdeclarativemetaproperty.h"
+#include "qdeclarativebinding_p.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativewatcher_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qmetaobject.h>
+
+QT_BEGIN_NAMESPACE
+
+QList<QDeclarativeEngine *> QDeclarativeEngineDebugServer::m_engines;
+QDeclarativeEngineDebugServer::QDeclarativeEngineDebugServer(QObject *parent)
+: QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), parent),
+ m_watch(new QDeclarativeWatcher(this))
+{
+ QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)),
+ this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant)));
+}
+
+QDataStream &operator<<(QDataStream &ds,
+ const QDeclarativeEngineDebugServer::QDeclarativeObjectData &data)
+{
+ ds << data.url << data.lineNumber << data.columnNumber << data.objectName
+ << data.objectType << data.objectId << data.contextId;
+ return ds;
+}
+
+QDataStream &operator>>(QDataStream &ds,
+ QDeclarativeEngineDebugServer::QDeclarativeObjectData &data)
+{
+ ds >> data.url >> data.lineNumber >> data.columnNumber >> data.objectName
+ >> data.objectType >> data.objectId >> data.contextId;
+ return ds;
+}
+
+QDataStream &operator<<(QDataStream &ds,
+ const QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &data)
+{
+ ds << (int)data.type << data.name << data.value << data.valueTypeName
+ << data.binding << data.hasNotifySignal;
+ return ds;
+}
+
+QDataStream &operator>>(QDataStream &ds,
+ QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &data)
+{
+ int type;
+ ds >> type >> data.name >> data.value >> data.valueTypeName
+ >> data.binding >> data.hasNotifySignal;
+ data.type = (QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Type)type;
+ return ds;
+}
+
+QDeclarativeEngineDebugServer::QDeclarativeObjectProperty
+QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx)
+{
+ QDeclarativeObjectProperty rv;
+
+ QMetaProperty prop = obj->metaObject()->property(propIdx);
+
+ rv.type = QDeclarativeObjectProperty::Unknown;
+ rv.valueTypeName = QString::fromUtf8(prop.typeName());
+ rv.name = QString::fromUtf8(prop.name());
+ rv.hasNotifySignal = prop.hasNotifySignal();
+ QDeclarativeAbstractBinding *binding = QDeclarativeMetaProperty(obj, rv.name).binding();
+ if (binding)
+ rv.binding = binding->expression();
+
+ QVariant value = prop.read(obj);
+ rv.value = valueContents(value);
+
+ if (QVariant::Type(prop.userType()) < QVariant::UserType) {
+ rv.type = QDeclarativeObjectProperty::Basic;
+ } else if (QDeclarativeMetaType::isQObject(prop.userType())) {
+ rv.type = QDeclarativeObjectProperty::Object;
+ } else if (QDeclarativeMetaType::isList(prop.userType())) {
+ rv.type = QDeclarativeObjectProperty::List;
+ }
+
+ return rv;
+}
+
+QVariant QDeclarativeEngineDebugServer::valueContents(const QVariant &value) const
+{
+ int userType = value.userType();
+ if (QVariant::Type(userType) < QVariant::UserType)
+ return value;
+
+ /*
+ if (QDeclarativeMetaType::isList(userType)) {
+ int count = QDeclarativeMetaType::listCount(value);
+ QVariantList contents;
+ for (int i=0; i<count; i++)
+ contents << valueContents(QDeclarativeMetaType::listAt(value, i));
+ return contents;
+ } else */
+ if (QDeclarativeMetaType::isQObject(userType)) {
+ QObject *o = QDeclarativeMetaType::toQObject(value);
+ if (o) {
+ QString name = o->objectName();
+ if (name.isEmpty())
+ name = QLatin1String("<unnamed object>");
+ return name;
+ }
+ }
+
+ return QLatin1String("<unknown value>");
+}
+
+void QDeclarativeEngineDebugServer::buildObjectDump(QDataStream &message,
+ QObject *object, bool recur)
+{
+ message << objectData(object);
+
+ // Some children aren't added to an object until particular properties are read
+ // - e.g. child state objects aren't added until the 'states' property is read -
+ // but this should only affect internal objects that aren't shown by the
+ // debugger anyway.
+
+ QObjectList children = object->children();
+
+ int childrenCount = children.count();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ if (qobject_cast<QDeclarativeContext*>(children[ii]) || QDeclarativeBoundSignal::cast(children[ii]))
+ --childrenCount;
+ }
+
+ message << childrenCount << recur;
+
+ QList<QDeclarativeObjectProperty> fakeProperties;
+
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QObject *child = children.at(ii);
+ if (qobject_cast<QDeclarativeContext*>(child))
+ continue;
+ QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
+ if (signal) {
+ QDeclarativeObjectProperty prop;
+ prop.type = QDeclarativeObjectProperty::SignalProperty;
+ prop.hasNotifySignal = false;
+ QDeclarativeExpression *expr = signal->expression();
+ if (expr) {
+ prop.value = expr->expression();
+ QObject *scope = expr->scopeObject();
+ if (scope) {
+ QString sig = QLatin1String(scope->metaObject()->method(signal->index()).signature());
+ int lparen = sig.indexOf(QLatin1Char('('));
+ if (lparen >= 0) {
+ QString methodName = sig.mid(0, lparen);
+ prop.name = QLatin1String("on") + methodName[0].toUpper()
+ + methodName.mid(1);
+ }
+ }
+ }
+ fakeProperties << prop;
+ } else {
+ if (recur)
+ buildObjectDump(message, child, recur);
+ else
+ message << objectData(child);
+ }
+ }
+
+ message << (object->metaObject()->propertyCount() + fakeProperties.count());
+
+ for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii)
+ message << propertyData(object, ii);
+
+ for (int ii = 0; ii < fakeProperties.count(); ++ii)
+ message << fakeProperties[ii];
+}
+
+void QDeclarativeEngineDebugServer::buildObjectList(QDataStream &message,
+ QDeclarativeContext *ctxt)
+{
+ QDeclarativeContextPrivate *p = (QDeclarativeContextPrivate *)QObjectPrivate::get(ctxt);
+
+ QString ctxtName = ctxt->objectName();
+ int ctxtId = QDeclarativeDebugService::idForObject(ctxt);
+
+ message << ctxtName << ctxtId;
+
+ int count = 0;
+
+ for (QSet<QDeclarativeContext *>::ConstIterator iter = p->childContexts.begin();
+ iter != p->childContexts.end(); ++iter) {
+ QDeclarativeContextPrivate *p = (QDeclarativeContextPrivate *)QObjectPrivate::get(*iter);
+ if (p->isInternal)
+ continue;
+ ++count;
+ }
+
+ message << count;
+
+ for (QSet<QDeclarativeContext *>::ConstIterator iter = p->childContexts.begin();
+ iter != p->childContexts.end(); ++iter) {
+ QDeclarativeContextPrivate *p = (QDeclarativeContextPrivate *)QObjectPrivate::get(*iter);
+ if (p->isInternal)
+ continue;
+ buildObjectList(message, *iter);
+ }
+
+ // Clean deleted objects
+ for (int ii = 0; ii < p->instances.count(); ++ii) {
+ if (!p->instances.at(ii)) {
+ p->instances.removeAt(ii);
+ --ii;
+ }
+ }
+
+ message << p->instances.count();
+ for (int ii = 0; ii < p->instances.count(); ++ii) {
+ message << objectData(p->instances.at(ii));
+ }
+}
+
+QDeclarativeEngineDebugServer::QDeclarativeObjectData
+QDeclarativeEngineDebugServer::objectData(QObject *object)
+{
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object);
+ QDeclarativeObjectData rv;
+ if (ddata) {
+ rv.url = ddata->outerContext->baseUrl();
+ rv.lineNumber = ddata->lineNumber;
+ rv.columnNumber = ddata->columnNumber;
+ } else {
+ rv.lineNumber = -1;
+ rv.columnNumber = -1;
+ }
+
+ rv.objectName = object->objectName();
+ rv.objectId = QDeclarativeDebugService::idForObject(object);
+ rv.contextId = QDeclarativeDebugService::idForObject(qmlContext(object));
+
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
+ if (type) {
+ QString typeName = QLatin1String(type->qmlTypeName());
+ int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
+ rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1);
+ } else {
+ rv.objectType = QString::fromUtf8(object->metaObject()->className());
+ int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_"));
+ if (marker != -1)
+ rv.objectType = rv.objectType.left(marker);
+ }
+
+ return rv;
+}
+
+void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
+{
+ QDataStream ds(message);
+
+ QByteArray type;
+ ds >> type;
+
+ //qDebug() << "QDeclarativeEngineDebugServer::messageReceived()" << type;
+
+ if (type == "LIST_ENGINES") {
+ int queryId;
+ ds >> queryId;
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("LIST_ENGINES_R");
+ rs << queryId << m_engines.count();
+
+ for (int ii = 0; ii < m_engines.count(); ++ii) {
+ QDeclarativeEngine *engine = m_engines.at(ii);
+
+ QString engineName = engine->objectName();
+ int engineId = QDeclarativeDebugService::idForObject(engine);
+
+ rs << engineName << engineId;
+ }
+
+ sendMessage(reply);
+ } else if (type == "LIST_OBJECTS") {
+ int queryId;
+ int engineId = -1;
+ ds >> queryId >> engineId;
+
+ QDeclarativeEngine *engine =
+ qobject_cast<QDeclarativeEngine *>(QDeclarativeDebugService::objectForId(engineId));
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("LIST_OBJECTS_R") << queryId;
+
+ if (engine)
+ buildObjectList(rs, engine->rootContext());
+
+ sendMessage(reply);
+ } else if (type == "FETCH_OBJECT") {
+ int queryId;
+ int objectId;
+ bool recurse;
+
+ ds >> queryId >> objectId >> recurse;
+
+ QObject *object = QDeclarativeDebugService::objectForId(objectId);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("FETCH_OBJECT_R") << queryId;
+
+ if (object)
+ buildObjectDump(rs, object, recurse);
+
+ sendMessage(reply);
+ } else if (type == "WATCH_OBJECT") {
+ int queryId;
+ int objectId;
+
+ ds >> queryId >> objectId;
+ bool ok = m_watch->addWatch(queryId, objectId);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("WATCH_OBJECT_R") << queryId << ok;
+
+ sendMessage(reply);
+ } else if (type == "WATCH_PROPERTY") {
+ int queryId;
+ int objectId;
+ QByteArray property;
+
+ ds >> queryId >> objectId >> property;
+ bool ok = m_watch->addWatch(queryId, objectId, property);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok;
+
+ sendMessage(reply);
+ } else if (type == "WATCH_EXPR_OBJECT") {
+ int queryId;
+ int debugId;
+ QString expr;
+
+ ds >> queryId >> debugId >> expr;
+ bool ok = m_watch->addWatch(queryId, debugId, expr);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok;
+
+ sendMessage(reply);
+ } else if (type == "NO_WATCH") {
+ int queryId;
+
+ ds >> queryId;
+ m_watch->removeWatch(queryId);
+ } else if (type == "EVAL_EXPRESSION") {
+ int queryId;
+ int objectId;
+ QString expr;
+
+ ds >> queryId >> objectId >> expr;
+
+ QObject *object = QDeclarativeDebugService::objectForId(objectId);
+ QDeclarativeContext *context = qmlContext(object);
+ QVariant result;
+ if (object && context) {
+ QDeclarativeExpression exprObj(context, expr, object);
+ bool undefined = false;
+ QVariant value = exprObj.value(&undefined);
+ if (undefined)
+ result = QLatin1String("<undefined>");
+ else
+ result = valueContents(value);
+ } else {
+ result = QLatin1String("<unknown context>");
+ }
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result;
+
+ sendMessage(reply);
+ }
+}
+
+void QDeclarativeEngineDebugServer::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+
+ rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value);
+
+ sendMessage(reply);
+}
+
+void QDeclarativeEngineDebugServer::addEngine(QDeclarativeEngine *engine)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(!m_engines.contains(engine));
+
+ m_engines.append(engine);
+}
+
+void QDeclarativeEngineDebugServer::remEngine(QDeclarativeEngine *engine)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(m_engines.contains(engine));
+
+ m_engines.removeAll(engine);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h
new file mode 100644
index 0000000..89da399
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeenginedebug_p.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEENGINEDEBUG_P_H
+#define QDECLARATIVEENGINEDEBUG_P_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 "../debugger/qdeclarativedebugservice_p.h"
+
+#include <QtCore/qurl.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QDeclarativeContext;
+class QDeclarativeWatcher;
+class QDataStream;
+
+class QDeclarativeEngineDebugServer : public QDeclarativeDebugService
+{
+ Q_OBJECT
+public:
+ QDeclarativeEngineDebugServer(QObject * = 0);
+
+ struct QDeclarativeObjectData {
+ QUrl url;
+ int lineNumber;
+ int columnNumber;
+ QString objectName;
+ QString objectType;
+ int objectId;
+ int contextId;
+ };
+
+ struct QDeclarativeObjectProperty {
+ enum Type { Unknown, Basic, Object, List, SignalProperty };
+ Type type;
+ QString name;
+ QVariant value;
+ QString valueTypeName;
+ QString binding;
+ bool hasNotifySignal;
+ };
+
+ static void addEngine(QDeclarativeEngine *);
+ static void remEngine(QDeclarativeEngine *);
+
+protected:
+ virtual void messageReceived(const QByteArray &);
+
+private Q_SLOTS:
+ void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value);
+
+private:
+ void buildObjectList(QDataStream &, QDeclarativeContext *);
+ void buildObjectDump(QDataStream &, QObject *, bool);
+ QDeclarativeObjectData objectData(QObject *);
+ QDeclarativeObjectProperty propertyData(QObject *, int);
+ QVariant valueContents(const QVariant &defaultValue) const;
+
+ static QList<QDeclarativeEngine *> m_engines;
+ QDeclarativeWatcher *m_watch;
+};
+Q_DECLARATIVE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugServer::QDeclarativeObjectData &);
+Q_DECLARATIVE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugServer::QDeclarativeObjectData &);
+Q_DECLARATIVE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &);
+Q_DECLARATIVE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &);
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEENGINEDEBUG_P_H
+
diff --git a/src/declarative/qml/qdeclarativeerror.cpp b/src/declarative/qml/qdeclarativeerror.cpp
new file mode 100644
index 0000000..7e8aac0
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeerror.cpp
@@ -0,0 +1,258 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeerror.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QDeclarativeError
+ \since 4.7
+ \brief The QDeclarativeError class encapsulates a QML error
+*/
+class QDeclarativeErrorPrivate
+{
+public:
+ QDeclarativeErrorPrivate();
+
+ QUrl url;
+ QString description;
+ int line;
+ int column;
+};
+
+QDeclarativeErrorPrivate::QDeclarativeErrorPrivate()
+: line(-1), column(-1)
+{
+}
+
+/*!
+ Create an empty error object.
+*/
+QDeclarativeError::QDeclarativeError()
+: d(0)
+{
+}
+
+/*!
+ Create a copy of \a other.
+*/
+QDeclarativeError::QDeclarativeError(const QDeclarativeError &other)
+: d(0)
+{
+ *this = other;
+}
+
+/*!
+ Assign \a other to this error object.
+*/
+QDeclarativeError &QDeclarativeError::operator=(const QDeclarativeError &other)
+{
+ if (!other.d) {
+ delete d;
+ d = 0;
+ } else {
+ if (!d) d = new QDeclarativeErrorPrivate;
+ d->url = other.d->url;
+ d->description = other.d->description;
+ d->line = other.d->line;
+ d->column = other.d->column;
+ }
+ return *this;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeError::~QDeclarativeError()
+{
+ delete d; d = 0;
+}
+
+/*!
+ Return true if this error is valid, otherwise false.
+*/
+bool QDeclarativeError::isValid() const
+{
+ return d != 0;
+}
+
+/*!
+ Return the url for the file that caused this error.
+*/
+QUrl QDeclarativeError::url() const
+{
+ if (d) return d->url;
+ else return QUrl();
+}
+
+/*!
+ Set the \a url for the file that caused this error.
+*/
+void QDeclarativeError::setUrl(const QUrl &url)
+{
+ if (!d) d = new QDeclarativeErrorPrivate;
+ d->url = url;
+}
+
+/*!
+ Return the error description.
+*/
+QString QDeclarativeError::description() const
+{
+ if (d) return d->description;
+ else return QString();
+}
+
+/*!
+ Set the error \a description.
+*/
+void QDeclarativeError::setDescription(const QString &description)
+{
+ if (!d) d = new QDeclarativeErrorPrivate;
+ d->description = description;
+}
+
+/*!
+ Return the error line number.
+*/
+int QDeclarativeError::line() const
+{
+ if (d) return d->line;
+ else return -1;
+}
+
+/*!
+ Set the error \a line number.
+*/
+void QDeclarativeError::setLine(int line)
+{
+ if (!d) d = new QDeclarativeErrorPrivate;
+ d->line = line;
+}
+
+/*!
+ Return the error column number.
+*/
+int QDeclarativeError::column() const
+{
+ if (d) return d->column;
+ else return -1;
+}
+
+/*!
+ Set the error \a column number.
+*/
+void QDeclarativeError::setColumn(int column)
+{
+ if (!d) d = new QDeclarativeErrorPrivate;
+ d->column = column;
+}
+
+/*!
+ Return the error as a human readable string.
+*/
+QString QDeclarativeError::toString() const
+{
+ QString rv;
+ rv = url().toString() + QLatin1Char(':') + QString::number(line());
+ if(column() != -1)
+ rv += QLatin1Char(':') + QString::number(column());
+
+ rv += QLatin1String(": ") + description();
+
+ return rv;
+}
+
+/*!
+ \relates QDeclarativeError
+ \fn QDebug operator<<(QDebug debug, const QDeclarativeError &error)
+
+ Output a human readable version of \a error to \a debug.
+*/
+
+QDebug operator<<(QDebug debug, const QDeclarativeError &error)
+{
+ debug << qPrintable(error.toString());
+
+ QUrl url = error.url();
+
+ if (error.line() > 0 && url.scheme() == QLatin1String("file")) {
+ QString file = url.toLocalFile();
+ QFile f(file);
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray data = f.readAll();
+ QTextStream stream(data, QIODevice::ReadOnly);
+ stream.setCodec("UTF-8");
+ const QString code = stream.readAll();
+ const QStringList lines = code.split(QLatin1Char('\n'));
+
+ if (lines.count() >= error.line()) {
+ const QString &line = lines.at(error.line() - 1);
+ debug << "\n " << qPrintable(line);
+
+ if(error.column() > 0) {
+ int column = qMax(0, error.column() - 1);
+ column = qMin(column, line.length());
+
+ QByteArray ind;
+ ind.reserve(column);
+ for (int i = 0; i < column; ++i) {
+ const QChar ch = line.at(i);
+ if (ch.isSpace())
+ ind.append(ch.unicode());
+ else
+ ind.append(' ');
+ }
+ ind.append('^');
+ debug << "\n " << ind.constData();
+ }
+ }
+ }
+ }
+ return debug;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeerror.h b/src/declarative/qml/qdeclarativeerror.h
new file mode 100644
index 0000000..04d5ff2
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeerror.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEERROR_H
+#define QDECLARATIVEERROR_H
+
+#include <QtCore/qurl.h>
+#include <QtCore/qstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDebug;
+class QDeclarativeErrorPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeError
+{
+public:
+ QDeclarativeError();
+ QDeclarativeError(const QDeclarativeError &);
+ QDeclarativeError &operator=(const QDeclarativeError &);
+ ~QDeclarativeError();
+
+ bool isValid() const;
+
+ QUrl url() const;
+ void setUrl(const QUrl &);
+ QString description() const;
+ void setDescription(const QString &);
+ int line() const;
+ void setLine(int);
+ int column() const;
+ void setColumn(int);
+
+ QString toString() const;
+private:
+ QDeclarativeErrorPrivate *d;
+};
+
+QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, const QDeclarativeError &error);
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEERROR_H
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
new file mode 100644
index 0000000..ae1e790
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -0,0 +1,810 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeexpression.h"
+#include "qdeclarativeexpression_p.h"
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativerewrite_p.h"
+#include "qdeclarativecompiler_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtScript/qscriptprogram.h>
+
+#include <private/qscriptdeclarativeclass_p.h>
+
+QT_BEGIN_NAMESPACE
+
+bool QDeclarativeDelayedError::addError(QDeclarativeEnginePrivate *e)
+{
+ if (!e || prevError) return false;
+
+ if (e->inProgressCreations == 0) return false; // Not in construction
+
+ prevError = &e->erroredBindings;
+ nextError = e->erroredBindings;
+ e->erroredBindings = this;
+ if (nextError) nextError->prevError = &nextError;
+
+ return true;
+}
+
+QDeclarativeExpressionData::QDeclarativeExpressionData()
+: q(0), dataRef(0), expressionFunctionValid(false), expressionRewritten(false), me(0),
+ trackChange(false), isShared(false), line(-1), guardList(0), guardListLength(0)
+{
+}
+
+QDeclarativeExpressionData::~QDeclarativeExpressionData()
+{
+ if (guardList) { delete [] guardList; guardList = 0; }
+ if (dataRef) dataRef->release();
+}
+
+QDeclarativeExpressionPrivate::QDeclarativeExpressionPrivate()
+: data(new QDeclarativeExpressionData)
+{
+ data->q = this;
+}
+
+QDeclarativeExpressionPrivate::QDeclarativeExpressionPrivate(QDeclarativeExpressionData *d)
+: data(d)
+{
+ data->q = this;
+}
+
+QDeclarativeExpressionPrivate::~QDeclarativeExpressionPrivate()
+{
+ if (data) { data->q = 0; data->release(); data = 0; }
+}
+
+void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, const QString &expr,
+ QObject *me)
+{
+ data->expression = expr;
+
+ data->QDeclarativeAbstractExpression::setContext(ctxt);
+ data->me = me;
+}
+
+void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr, QDeclarativeRefCount *rc,
+ QObject *me, const QString &url, int lineNumber)
+{
+ data->url = url;
+ data->line = lineNumber;
+
+ if (data->dataRef) data->dataRef->release();
+ data->dataRef = rc;
+ if (data->dataRef) data->dataRef->addref();
+
+ quint32 *exprData = (quint32 *)expr;
+ QDeclarativeCompiledData *dd = (QDeclarativeCompiledData *)rc;
+
+ data->expressionRewritten = true;
+ data->expression = QString::fromRawData((QChar *)(exprData + 2), exprData[1]);
+
+ int progIdx = *(exprData);
+ bool isShared = progIdx & 0x80000000;
+ progIdx &= 0x7FFFFFFF;
+
+ QDeclarativeEngine *engine = ctxt->engine();
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ if (isShared) {
+
+ if (!dd->cachedClosures.at(progIdx)) {
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
+ scriptContext->pushScope(ep->contextClass->newSharedContext());
+ dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line));
+ scriptEngine->popContext();
+ }
+
+ data->expressionFunction = *dd->cachedClosures.at(progIdx);
+ data->isShared = true;
+ data->expressionFunctionValid = true;
+
+ } else {
+
+#if !defined(Q_OS_SYMBIAN) //XXX Why doesn't this work?
+ if (!dd->cachedPrograms.at(progIdx)) {
+ dd->cachedPrograms[progIdx] =
+ new QScriptProgram(data->expression, data->url, data->line);
+ }
+
+ data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx));
+#else
+ data->expressionFunction = evalInObjectScope(ctxt, me, data->expression);
+#endif
+
+ data->expressionFunctionValid = true;
+ }
+
+ data->QDeclarativeAbstractExpression::setContext(ctxt);
+ data->me = me;
+}
+
+QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object,
+ const QString &program)
+{
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine());
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
+ scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ QScriptValue rv = ep->scriptEngine.evaluate(program);
+ ep->scriptEngine.popContext();
+ return rv;
+}
+
+QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object,
+ const QScriptProgram &program)
+{
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine());
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
+ scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ QScriptValue rv = ep->scriptEngine.evaluate(program);
+ ep->scriptEngine.popContext();
+ return rv;
+}
+
+/*!
+ \class QDeclarativeExpression
+ \since 4.7
+ \brief The QDeclarativeExpression class evaluates JavaScript in a QML context.
+*/
+
+/*!
+ Create an invalid QDeclarativeExpression.
+
+ As the expression will not have an associated QDeclarativeContext, this will be a
+ null expression object and its value will always be an invalid QVariant.
+ */
+QDeclarativeExpression::QDeclarativeExpression()
+: QObject(*new QDeclarativeExpressionPrivate, 0)
+{
+}
+
+/*! \internal */
+QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, void *expr,
+ QDeclarativeRefCount *rc, QObject *me,
+ const QString &url, int lineNumber,
+ QDeclarativeExpressionPrivate &dd)
+: QObject(dd, 0)
+{
+ Q_D(QDeclarativeExpression);
+ d->init(ctxt, expr, rc, me, url, lineNumber);
+}
+
+/*!
+ Create a QDeclarativeExpression object.
+
+ The \a expression JavaScript will be executed in the \a ctxt QDeclarativeContext.
+ If specified, the \a scope object's properties will also be in scope during
+ the expression's execution.
+*/
+QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, const QString &expression,
+ QObject *scope)
+: QObject(*new QDeclarativeExpressionPrivate, 0)
+{
+ Q_D(QDeclarativeExpression);
+ d->init(ctxt, expression, scope);
+}
+
+/*! \internal */
+QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, const QString &expression,
+ QObject *scope, QDeclarativeExpressionPrivate &dd)
+: QObject(dd, 0)
+{
+ Q_D(QDeclarativeExpression);
+ d->init(ctxt, expression, scope);
+}
+
+/*!
+ Destroy the QDeclarativeExpression instance.
+*/
+QDeclarativeExpression::~QDeclarativeExpression()
+{
+}
+
+/*!
+ Returns the QDeclarativeEngine this expression is associated with, or 0 if there
+ is no association or the QDeclarativeEngine has been destroyed.
+*/
+QDeclarativeEngine *QDeclarativeExpression::engine() const
+{
+ Q_D(const QDeclarativeExpression);
+ return d->data->context()?d->data->context()->engine():0;
+}
+
+/*!
+ Returns the QDeclarativeContext this expression is associated with, or 0 if there
+ is no association or the QDeclarativeContext has been destroyed.
+*/
+QDeclarativeContext *QDeclarativeExpression::context() const
+{
+ Q_D(const QDeclarativeExpression);
+ return d->data->context();
+}
+
+/*!
+ Returns the expression string.
+*/
+QString QDeclarativeExpression::expression() const
+{
+ Q_D(const QDeclarativeExpression);
+ return d->data->expression;
+}
+
+/*!
+ Set the expression to \a expression.
+*/
+void QDeclarativeExpression::setExpression(const QString &expression)
+{
+ Q_D(QDeclarativeExpression);
+
+ d->clearGuards();
+
+ d->data->expression = expression;
+ d->data->expressionFunctionValid = false;
+ d->data->expressionRewritten = false;
+ d->data->expressionFunction = QScriptValue();
+}
+
+void QDeclarativeExpressionPrivate::exceptionToError(QScriptEngine *scriptEngine,
+ QDeclarativeError &error)
+{
+ if (scriptEngine->hasUncaughtException() &&
+ scriptEngine->uncaughtException().isError()) {
+
+ QString fileName;
+ int lineNumber = scriptEngine->uncaughtExceptionLineNumber();
+
+ QScriptValue exception = scriptEngine->uncaughtException();
+ QLatin1String fileNameProp("fileName");
+
+ if (!exception.property(fileNameProp).toString().isEmpty()){
+ fileName = exception.property(fileNameProp).toString();
+ } else {
+ fileName = QLatin1String("<Unknown File>");
+ }
+
+ error.setUrl(QUrl(fileName));
+ error.setLine(lineNumber);
+ error.setColumn(-1);
+ error.setDescription(exception.toString());
+ } else {
+ error = QDeclarativeError();
+ }
+}
+
+QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bool *isUndefined)
+{
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::BindValueQt> perfqt;
+#endif
+
+ QDeclarativeExpressionData *data = this->data;
+ QDeclarativeContextPrivate *ctxtPriv = data->context()->d_func();
+ QDeclarativeEngine *engine = data->context()->engine();
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+
+ if (secondaryScope)
+ ctxtPriv->defaultObjects.append(secondaryScope);
+
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ if (!data->expressionFunctionValid) {
+
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
+ scriptContext->pushScope(ep->contextClass->newContext(data->context(), data->me));
+
+ if (data->expressionRewritten) {
+ data->expressionFunction = scriptEngine->evaluate(data->expression,
+ data->url, data->line);
+ } else {
+ QDeclarativeRewrite::RewriteBinding rewriteBinding;
+
+ bool ok = true;
+ const QString code = rewriteBinding(data->expression, &ok);
+ if (!ok) {
+ scriptEngine->popContext();
+ return QVariant();
+ }
+ data->expressionFunction = scriptEngine->evaluate(code, data->url, data->line);
+ }
+
+ scriptEngine->popContext();
+ data->expressionFunctionValid = true;
+ }
+
+ QDeclarativeContext *oldSharedContext = 0;
+ QObject *oldSharedScope = 0;
+ if (data->isShared) {
+ oldSharedContext = ep->sharedContext;
+ oldSharedScope = ep->sharedScope;
+ ep->sharedContext = data->context();
+ ep->sharedScope = data->me;
+ }
+
+ QScriptValue svalue = data->expressionFunction.call();
+
+ if (data->isShared) {
+ ep->sharedContext = oldSharedContext;
+ ep->sharedScope = oldSharedScope;
+ }
+
+ if (isUndefined)
+ *isUndefined = svalue.isUndefined() || scriptEngine->hasUncaughtException();
+
+ // Handle exception
+ if (scriptEngine->hasUncaughtException()) {
+ exceptionToError(scriptEngine, data->error);
+ scriptEngine->clearExceptions();
+ return QVariant();
+ } else {
+ data->error = QDeclarativeError();
+ }
+
+ if (secondaryScope) {
+ QObject *last = ctxtPriv->defaultObjects.takeLast();
+ Q_ASSERT(last == secondaryScope);
+ Q_UNUSED(last);
+ }
+
+ QVariant rv;
+
+ if (svalue.isArray()) {
+ int length = svalue.property(QLatin1String("length")).toInt32();
+ if (length && svalue.property(0).isObject()) {
+ QList<QObject *> list;
+ for (int ii = 0; ii < length; ++ii) {
+ QScriptValue arrayItem = svalue.property(ii);
+ QObject *d = arrayItem.toQObject();
+ list << d;
+ }
+ rv = QVariant::fromValue(list);
+ }
+ } else if (svalue.isObject() &&
+ ep->objectClass->scriptClass(svalue) == ep->objectClass) {
+ QObject *o = svalue.toQObject();
+ int type = QMetaType::QObjectStar;
+ // If the object is null, we extract the predicted type. While this isn't
+ // 100% reliable, in many cases it gives us better error messages if we
+ // assign this null-object to an incompatible property
+ if (!o) type = ep->objectClass->objectType(svalue);
+
+ return QVariant(type, &o);
+ }
+
+ if (rv.isNull())
+ rv = svalue.toVariant();
+
+ return rv;
+}
+
+QVariant QDeclarativeExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined)
+{
+ Q_Q(QDeclarativeExpression);
+
+ QVariant rv;
+ if (!q->engine()) {
+ qWarning("QDeclarativeExpression: Attempted to evaluate an expression in an invalid context");
+ return rv;
+ }
+
+ if (data->expression.isEmpty())
+ return rv;
+
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::BindValue> perf;
+#endif
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(q->engine());
+
+ QDeclarativeExpression *lastCurrentExpression = ep->currentExpression;
+ bool lastCaptureProperties = ep->captureProperties;
+ QPODVector<QDeclarativeEnginePrivate::CapturedProperty> lastCapturedProperties;
+ ep->capturedProperties.copyAndClear(lastCapturedProperties);
+
+ ep->currentExpression = q;
+ ep->captureProperties = data->trackChange;
+
+ // This object might be deleted during the eval
+ QDeclarativeExpressionData *localData = data;
+ localData->addref();
+
+ rv = evalQtScript(secondaryScope, isUndefined);
+
+ ep->currentExpression = lastCurrentExpression;
+ ep->captureProperties = lastCaptureProperties;
+
+ // Check if we were deleted
+ if (localData->q) {
+ if ((!data->trackChange || !ep->capturedProperties.count()) && data->guardList) {
+ clearGuards();
+ } else if(data->trackChange) {
+ updateGuards(ep->capturedProperties);
+ }
+ }
+
+ localData->release();
+
+ lastCapturedProperties.copyAndClear(ep->capturedProperties);
+
+ return rv;
+}
+
+/*!
+ Returns the value of the expression, or an invalid QVariant if the
+ expression is invalid or has an error.
+
+ \a isUndefined is set to true if the expression resulted in an
+ undefined value.
+
+ \sa hasError(), error()
+*/
+QVariant QDeclarativeExpression::value(bool *isUndefined)
+{
+ Q_D(QDeclarativeExpression);
+ return d->value(0, isUndefined);
+}
+
+/*!
+Returns true if the valueChanged() signal is emitted when the expression's evaluated
+value changes.
+*/
+bool QDeclarativeExpression::notifyOnValueChanged() const
+{
+ Q_D(const QDeclarativeExpression);
+ return d->data->trackChange;
+}
+
+/*!
+Sets whether the valueChanged() signal is emitted when the expression's evaluated
+value changes.
+
+If true, the QDeclarativeExpression will monitor properties involved in the expression's
+evaluation, and emit QDeclarativeExpression::valueChanged() if they have changed. This allows
+an application to ensure that any value associated with the result of the expression
+remains up to date.
+
+If false, the QDeclarativeExpression will not montitor properties involved in the expression's
+evaluation, and QDeclarativeExpression::valueChanged() will never be emitted. This is more efficient
+if an application wants a "one off" evaluation of the expression.
+
+By default, notifyOnChange is false.
+*/
+void QDeclarativeExpression::setNotifyOnValueChanged(bool notifyOnChange)
+{
+ Q_D(QDeclarativeExpression);
+ d->data->trackChange = notifyOnChange;
+}
+
+/*!
+ Returns the source file URL for this expression. The source location must
+ have been previously set by calling setSourceLocation().
+*/
+QString QDeclarativeExpression::sourceFile() const
+{
+ Q_D(const QDeclarativeExpression);
+ return d->data->url;
+}
+
+/*!
+ Returns the source file line number for this expression. The source location
+ must have been previously set by calling setSourceLocation().
+*/
+int QDeclarativeExpression::lineNumber() const
+{
+ Q_D(const QDeclarativeExpression);
+ return d->data->line;
+}
+
+/*!
+ Set the location of this expression to \a line of \a url. This information
+ is used by the script engine.
+*/
+void QDeclarativeExpression::setSourceLocation(const QString &url, int line)
+{
+ Q_D(QDeclarativeExpression);
+ d->data->url = url;
+ d->data->line = line;
+}
+
+/*!
+ Returns the expression's scope object, if provided, otherwise 0.
+
+ In addition to data provided by the expression's QDeclarativeContext, the scope
+ object's properties are also in scope during the expression's evaluation.
+*/
+QObject *QDeclarativeExpression::scopeObject() const
+{
+ Q_D(const QDeclarativeExpression);
+ return d->data->me;
+}
+
+/*!
+ Returns true if the last call to value() resulted in an error,
+ otherwise false.
+
+ \sa error(), clearError()
+*/
+bool QDeclarativeExpression::hasError() const
+{
+ Q_D(const QDeclarativeExpression);
+ return d->data->error.isValid();
+}
+
+/*!
+ Clear any expression errors. Calls to hasError() following this will
+ return false.
+
+ \sa hasError(), error()
+*/
+void QDeclarativeExpression::clearError()
+{
+ Q_D(QDeclarativeExpression);
+ d->data->error = QDeclarativeError();
+}
+
+/*!
+ Return any error from the last call to value(). If there was no error,
+ this returns an invalid QDeclarativeError instance.
+
+ \sa hasError(), clearError()
+*/
+
+QDeclarativeError QDeclarativeExpression::error() const
+{
+ Q_D(const QDeclarativeExpression);
+ return d->data->error;
+}
+
+/*! \internal */
+void QDeclarativeExpression::__q_notify()
+{
+ Q_D(QDeclarativeExpression);
+ d->emitValueChanged();
+}
+
+void QDeclarativeExpressionPrivate::clearGuards()
+{
+ Q_Q(QDeclarativeExpression);
+
+ static int notifyIdx = -1;
+ if (notifyIdx == -1)
+ notifyIdx =
+ QDeclarativeExpression::staticMetaObject.indexOfMethod("__q_notify()");
+
+ for (int ii = 0; ii < data->guardListLength; ++ii) {
+ if (data->guardList[ii].data()) {
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
+ QMetaObject::disconnectOne(data->guardList[ii].data(),
+ data->guardList[ii].notifyIndex,
+ q, notifyIdx);
+#else
+ // QTBUG-6781
+ QMetaObject::disconnect(data->guardList[ii].data(),
+ data->guardList[ii].notifyIndex,
+ q, notifyIdx);
+#endif
+ }
+ }
+
+ delete [] data->guardList; data->guardList = 0;
+ data->guardListLength = 0;
+}
+
+void QDeclarativeExpressionPrivate::updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty> &properties)
+{
+ //clearGuards();
+ Q_Q(QDeclarativeExpression);
+
+ static int notifyIdx = -1;
+ if (notifyIdx == -1)
+ notifyIdx =
+ QDeclarativeExpression::staticMetaObject.indexOfMethod("__q_notify()");
+
+ QDeclarativeExpressionData::SignalGuard *newGuardList = 0;
+
+ if (properties.count() != data->guardListLength)
+ newGuardList = new QDeclarativeExpressionData::SignalGuard[properties.count()];
+
+ bool outputWarningHeader = false;
+ int hit = 0;
+ for (int ii = 0; ii < properties.count(); ++ii) {
+ const QDeclarativeEnginePrivate::CapturedProperty &property = properties.at(ii);
+
+ bool needGuard = true;
+ if (ii >= data->guardListLength) {
+ // New guard
+ } else if(data->guardList[ii].data() == property.object &&
+ data->guardList[ii].notifyIndex == property.notifyIndex) {
+ // Cache hit
+ if (!data->guardList[ii].isDuplicate ||
+ (data->guardList[ii].isDuplicate && hit == ii)) {
+ needGuard = false;
+ ++hit;
+ }
+ } else if(data->guardList[ii].data() && !data->guardList[ii].isDuplicate) {
+ // Cache miss
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
+ QMetaObject::disconnectOne(data->guardList[ii].data(),
+ data->guardList[ii].notifyIndex,
+ q, notifyIdx);
+#else
+ // QTBUG-6781
+ QMetaObject::disconnect(data->guardList[ii].data(),
+ data->guardList[ii].notifyIndex,
+ q, notifyIdx);
+#endif
+ }
+ /* else {
+ // Cache miss, but nothing to do
+ } */
+
+ if (needGuard) {
+ if (!newGuardList) {
+ newGuardList = new QDeclarativeExpressionData::SignalGuard[properties.count()];
+ for (int jj = 0; jj < ii; ++jj)
+ newGuardList[jj] = data->guardList[jj];
+ }
+
+ if (property.notifyIndex != -1) {
+ bool existing = false;
+ for (int jj = 0; !existing && jj < ii; ++jj)
+ existing = newGuardList[jj].data() == property.object &&
+ newGuardList[jj].notifyIndex == property.notifyIndex;
+
+ newGuardList[ii] = property.object;
+ newGuardList[ii].notifyIndex = property.notifyIndex;
+ if (existing)
+ newGuardList[ii].isDuplicate = true;
+ else
+ QMetaObject::connect(property.object, property.notifyIndex,
+ q, notifyIdx);
+ } else {
+ if (!outputWarningHeader) {
+ outputWarningHeader = true;
+ qWarning() << "QDeclarativeExpression: Expression" << q->expression()
+ << "depends on non-NOTIFYable properties:";
+ }
+
+ const QMetaObject *metaObj = property.object->metaObject();
+ QMetaProperty metaProp = metaObj->property(property.coreIndex);
+
+ qWarning().nospace() << " " << metaObj->className()
+ << "::" << metaProp.name();
+ }
+ } else if (newGuardList) {
+ newGuardList[ii] = data->guardList[ii];
+ }
+ }
+
+ for (int ii = properties.count(); ii < data->guardListLength; ++ii) {
+ if (data->guardList[ii].data() && !data->guardList[ii].isDuplicate) {
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
+ QMetaObject::disconnectOne(data->guardList[ii].data(),
+ data->guardList[ii].notifyIndex,
+ q, notifyIdx);
+#else
+ // QTBUG-6781
+ QMetaObject::disconnect(data->guardList[ii].data(),
+ data->guardList[ii].notifyIndex,
+ q, notifyIdx);
+#endif
+ }
+ }
+
+ if (newGuardList) {
+ if (data->guardList) delete [] data->guardList;
+ data->guardList = newGuardList;
+ data->guardListLength = properties.count();
+ }
+}
+
+/*!
+ \fn void QDeclarativeExpression::valueChanged()
+
+ Emitted each time the expression value changes from the last time it was
+ evaluated. The expression must have been evaluated at least once (by
+ calling QDeclarativeExpression::value()) before this signal will be emitted.
+*/
+
+void QDeclarativeExpressionPrivate::emitValueChanged()
+{
+ Q_Q(QDeclarativeExpression);
+ emit q->valueChanged();
+}
+
+QDeclarativeAbstractExpression::QDeclarativeAbstractExpression()
+: m_context(0), m_prevExpression(0), m_nextExpression(0)
+{
+}
+
+QDeclarativeAbstractExpression::~QDeclarativeAbstractExpression()
+{
+ if (m_prevExpression) {
+ *m_prevExpression = m_nextExpression;
+ if (m_nextExpression)
+ m_nextExpression->m_prevExpression = m_prevExpression;
+ }
+}
+
+QDeclarativeContext *QDeclarativeAbstractExpression::context() const
+{
+ return m_context;
+}
+
+void QDeclarativeAbstractExpression::setContext(QDeclarativeContext *context)
+{
+ if (m_prevExpression) {
+ *m_prevExpression = m_nextExpression;
+ if (m_nextExpression)
+ m_nextExpression->m_prevExpression = m_prevExpression;
+ m_prevExpression = 0;
+ m_nextExpression = 0;
+ }
+
+ m_context = context;
+
+ if (m_context) {
+ QDeclarativeContextPrivate *cp =
+ static_cast<QDeclarativeContextPrivate *>(QObjectPrivate::get(m_context));
+ m_nextExpression = cp->expressions;
+ if (m_nextExpression)
+ m_nextExpression->m_prevExpression = &m_nextExpression;
+ m_prevExpression = &cp->expressions;
+ cp->expressions = this;
+ }
+}
+
+void QDeclarativeAbstractExpression::refresh()
+{
+}
+
+bool QDeclarativeAbstractExpression::isValid() const
+{
+ return m_context != 0;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qdeclarativeexpression.h b/src/declarative/qml/qdeclarativeexpression.h
new file mode 100644
index 0000000..911d328
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeexpression.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEEXPRESSION_H
+#define QDECLARATIVEEXPRESSION_H
+
+#include "qdeclarativeerror.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QString;
+class QDeclarativeRefCount;
+class QDeclarativeEngine;
+class QDeclarativeContext;
+class QDeclarativeExpressionPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeExpression : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeExpression();
+ QDeclarativeExpression(QDeclarativeContext *, const QString &, QObject *);
+ virtual ~QDeclarativeExpression();
+
+ QDeclarativeEngine *engine() const;
+ QDeclarativeContext *context() const;
+
+ QString expression() const;
+ void setExpression(const QString &);
+
+ bool notifyOnValueChanged() const;
+ void setNotifyOnValueChanged(bool);
+
+ QString sourceFile() const;
+ int lineNumber() const;
+ void setSourceLocation(const QString &fileName, int line);
+
+ QObject *scopeObject() const;
+
+ bool hasError() const;
+ void clearError();
+ QDeclarativeError error() const;
+
+ QVariant value(bool *isUndefined = 0);
+
+Q_SIGNALS:
+ void valueChanged();
+
+protected:
+ QDeclarativeExpression(QDeclarativeContext *, const QString &, QObject *,
+ QDeclarativeExpressionPrivate &dd);
+ QDeclarativeExpression(QDeclarativeContext *, void *, QDeclarativeRefCount *rc, QObject *me, const QString &,
+ int, QDeclarativeExpressionPrivate &dd);
+
+private Q_SLOTS:
+ void __q_notify();
+
+private:
+ Q_DECLARE_PRIVATE(QDeclarativeExpression)
+ friend class QDeclarativeDebugger;
+ friend class QDeclarativeContext;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEEXPRESSION_H
+
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h
new file mode 100644
index 0000000..91ac4c0
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeexpression_p.h
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEEXPRESSION_P_H
+#define QDECLARATIVEEXPRESSION_P_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 "qdeclarativeexpression.h"
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativeguard_p.h"
+
+#include <QtScript/qscriptvalue.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeAbstractExpression
+{
+public:
+ QDeclarativeAbstractExpression();
+ virtual ~QDeclarativeAbstractExpression();
+
+ bool isValid() const;
+
+ QDeclarativeContext *context() const;
+ void setContext(QDeclarativeContext *);
+
+ virtual void refresh();
+
+private:
+ friend class QDeclarativeContext;
+ friend class QDeclarativeContextPrivate;
+ QDeclarativeContext *m_context;
+ QDeclarativeAbstractExpression **m_prevExpression;
+ QDeclarativeAbstractExpression *m_nextExpression;
+};
+
+class QDeclarativeDelayedError
+{
+public:
+ inline QDeclarativeDelayedError() : nextError(0), prevError(0) {}
+ inline ~QDeclarativeDelayedError() { removeError(); }
+
+ QDeclarativeError error;
+
+ bool addError(QDeclarativeEnginePrivate *);
+
+ inline void removeError() {
+ if (!prevError) return;
+ if (nextError) nextError->prevError = prevError;
+ *prevError = nextError;
+ nextError = 0;
+ prevError = 0;
+ }
+
+private:
+ QDeclarativeDelayedError *nextError;
+ QDeclarativeDelayedError **prevError;
+};
+
+class QDeclarativeExpressionData : public QDeclarativeAbstractExpression, public QDeclarativeDelayedError, public QDeclarativeRefCount
+{
+public:
+ QDeclarativeExpressionData();
+ virtual ~QDeclarativeExpressionData();
+
+ QDeclarativeExpressionPrivate *q;
+
+ QDeclarativeRefCount *dataRef;
+ QString expression;
+ bool expressionFunctionValid:1;
+ bool expressionRewritten:1;
+ QScriptValue expressionFunction;
+
+ QObject *me;
+ bool trackChange;
+
+ bool isShared;
+
+ QString url; // This is a QString for a reason. QUrls are slooooooow...
+ int line;
+
+ struct SignalGuard : public QDeclarativeGuard<QObject> {
+ SignalGuard() : isDuplicate(false), notifyIndex(-1) {}
+
+ SignalGuard &operator=(QObject *obj) {
+ QDeclarativeGuard<QObject>::operator=(obj);
+ return *this;
+ }
+ SignalGuard &operator=(const SignalGuard &o) {
+ QDeclarativeGuard<QObject>::operator=(o);
+ isDuplicate = o.isDuplicate;
+ notifyIndex = o.notifyIndex;
+ return *this;
+ }
+
+ bool isDuplicate:1;
+ int notifyIndex:31;
+ };
+ SignalGuard *guardList;
+ int guardListLength;
+};
+
+class QDeclarativeExpression;
+class QString;
+class QDeclarativeExpressionPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeExpression)
+public:
+ QDeclarativeExpressionPrivate();
+ QDeclarativeExpressionPrivate(QDeclarativeExpressionData *);
+ ~QDeclarativeExpressionPrivate();
+
+ void init(QDeclarativeContext *, const QString &, QObject *);
+ void init(QDeclarativeContext *, void *, QDeclarativeRefCount *, QObject *, const QString &, int);
+
+ QDeclarativeExpressionData *data;
+
+ QVariant value(QObject *secondaryScope = 0, bool *isUndefined = 0);
+ QVariant evalQtScript(QObject *secondaryScope, bool *isUndefined = 0);
+
+ void updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty> &properties);
+ void clearGuards();
+
+ static QDeclarativeExpressionPrivate *get(QDeclarativeExpression *expr) {
+ return static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr));
+ }
+ static QDeclarativeExpression *get(QDeclarativeExpressionPrivate *expr) {
+ return expr->q_func();
+ }
+
+ virtual void emitValueChanged();
+
+ static void exceptionToError(QScriptEngine *, QDeclarativeError &);
+ static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &);
+ static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &);
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEEXPRESSION_P_H
diff --git a/src/declarative/qml/qdeclarativeextensioninterface.h b/src/declarative/qml/qdeclarativeextensioninterface.h
new file mode 100644
index 0000000..a8ae064
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeextensioninterface.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEEXTENSIONINTERFACE_H
+#define QDECLARATIVEEXTENSIONINTERFACE_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeEngine;
+
+struct Q_DECLARATIVE_EXPORT QDeclarativeExtensionInterface
+{
+ virtual ~QDeclarativeExtensionInterface() {}
+ virtual void initialize(QDeclarativeEngine *engine, const char *uri) = 0;
+};
+
+Q_DECLARE_INTERFACE(QDeclarativeExtensionInterface, "com.trolltech.Qt.QDeclarativeExtensionInterface/1.0")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEEXTENSIONINTERFACE_H
diff --git a/src/declarative/qml/qdeclarativeextensionplugin.cpp b/src/declarative/qml/qdeclarativeextensionplugin.cpp
new file mode 100644
index 0000000..6af3a6d
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeextensionplugin.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeextensionplugin.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \since 4.7
+ \class QDeclarativeExtensionPlugin
+ \brief The QDeclarativeExtensionPlugin class provides an abstract base for custom QML extension plugins.
+
+ \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 initialize()
+ function, and exporting the class using the Q_EXPORT_PLUGIN2()
+ macro. See \l {How to Create Qt Plugins} for details.
+
+ \sa QDeclarativeEngine::importExtension()
+*/
+
+/*!
+ \fn void QDeclarativeExtensionPlugin::initialize(QDeclarativeEngine *engine)
+
+ Initializes the extension specified in the given \a engine.
+*/
+
+/*!
+ Constructs a QML extension plugin with the given \a parent.
+
+ Note that this constructor is invoked automatically by the
+ Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
+ explicitly.
+*/
+QDeclarativeExtensionPlugin::QDeclarativeExtensionPlugin(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QDeclarativeExtensionPlugin::~QDeclarativeExtensionPlugin()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeextensionplugin.h b/src/declarative/qml/qdeclarativeextensionplugin.h
new file mode 100644
index 0000000..79df52b
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeextensionplugin.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEEXTENSIONPLUGIN_H
+#define QDECLARATIVEEXTENSIONPLUGIN_H
+
+#include <QtCore/qplugin.h>
+
+#include "qdeclarativeextensioninterface.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeEngine;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeExtensionPlugin : public QObject, public QDeclarativeExtensionInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativeExtensionInterface)
+public:
+ explicit QDeclarativeExtensionPlugin(QObject *parent = 0);
+ ~QDeclarativeExtensionPlugin();
+
+ virtual void initialize(QDeclarativeEngine *engine, const char *uri) = 0;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEEXTENSIONPLUGIN_H
diff --git a/src/declarative/qml/qdeclarativeglobal_p.h b/src/declarative/qml/qdeclarativeglobal_p.h
new file mode 100644
index 0000000..bbdc91c
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeglobal_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEGLOBAL_H
+#define QDECLARATIVEGLOBAL_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/QObject>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+#define DEFINE_BOOL_CONFIG_OPTION(name, var) \
+ static bool name() \
+ { \
+ static enum { Yes, No, Unknown } status = Unknown; \
+ if (status == Unknown) { \
+ QByteArray v = qgetenv(#var); \
+ bool value = !v.isEmpty() && v != "0" && v != "false"; \
+ if (value) status = Yes; \
+ else status = No; \
+ } \
+ return status == Yes; \
+ }
+
+struct QDeclarativeGraphics_DerivedObject : public QObject
+{
+ void setParent_noEvent(QObject *parent) {
+ bool sce = d_ptr->sendChildEvents;
+ d_ptr->sendChildEvents = false;
+ setParent(parent);
+ d_ptr->sendChildEvents = sce;
+ }
+};
+
+/*!
+ Makes the \a object a child of \a parent. Note that when using this method,
+ neither \a parent nor the object's previous parent (if it had one) will
+ receive ChildRemoved or ChildAdded events.
+*/
+inline void QDeclarativeGraphics_setParent_noEvent(QObject *object, QObject *parent)
+{
+ static_cast<QDeclarativeGraphics_DerivedObject *>(object)->setParent_noEvent(parent);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEGLOBAL_H
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
new file mode 100644
index 0000000..5b06b42
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeglobalscriptclass_p.h"
+
+#include <QtScript/qscriptstring.h>
+#include <QtScript/qscriptengine.h>
+#include <QtScript/qscriptvalueiterator.h>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ Used to prevent any writes to the global object.
+*/
+QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engine)
+: QScriptClass(engine)
+{
+ QScriptValue v = engine->newObject();
+ globalObject = engine->globalObject();
+
+ QScriptValueIterator iter(globalObject);
+ while (iter.hasNext()) {
+ iter.next();
+ v.setProperty(iter.scriptName(), iter.value());
+ }
+
+ v.setScriptClass(this);
+ engine->setGlobalObject(v);
+}
+
+QScriptClass::QueryFlags
+QDeclarativeGlobalScriptClass::queryProperty(const QScriptValue &object,
+ const QScriptString &name,
+ QueryFlags flags, uint *id)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(name);
+ Q_UNUSED(flags);
+ Q_UNUSED(id);
+ return HandlesReadAccess | HandlesWriteAccess;
+}
+
+QScriptValue
+QDeclarativeGlobalScriptClass::property(const QScriptValue &object,
+ const QScriptString &name,
+ uint id)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(name);
+ Q_UNUSED(id);
+ return engine()->undefinedValue();
+}
+
+void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object,
+ const QScriptString &name,
+ uint id, const QScriptValue &value)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(id);
+ Q_UNUSED(value);
+ QString error = QLatin1String("Invalid write to global property \"") +
+ name.toString() + QLatin1Char('\"');
+ engine()->currentContext()->throwError(error);
+}
+
+void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value)
+{
+ QScriptValue v = engine()->newObject();
+ globalObject = engine()->globalObject();
+
+ QScriptValueIterator iter(globalObject);
+ while (iter.hasNext()) {
+ iter.next();
+ v.setProperty(iter.scriptName(), iter.value());
+ }
+
+ v.setProperty(name, value);
+ v.setScriptClass(this);
+ engine()->setGlobalObject(v);
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
new file mode 100644
index 0000000..a33cf5e
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEGLOBALSCRIPTCLASS_P_H
+#define QDECLARATIVEGLOBALSCRIPTCLASS_P_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 <QtScript/qscriptclass.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_AUTOTEST_EXPORT QDeclarativeGlobalScriptClass : public QScriptClass
+{
+public:
+ QDeclarativeGlobalScriptClass(QScriptEngine *);
+
+ virtual QueryFlags queryProperty(const QScriptValue &object,
+ const QScriptString &name,
+ QueryFlags flags, uint *id);
+
+ virtual QScriptValue property(const QScriptValue &object,
+ const QScriptString &name, uint id);
+
+ virtual void setProperty(QScriptValue &object, const QScriptString &name,
+ uint id, const QScriptValue &value);
+
+ void explicitSetProperty(const QString &, const QScriptValue &);
+
+private:
+ QScriptValue globalObject;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEGLOBALSCRIPTCLASS_P_H
diff --git a/src/declarative/qml/qdeclarativeguard_p.h b/src/declarative/qml/qdeclarativeguard_p.h
new file mode 100644
index 0000000..9d82d01
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeguard_p.h
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEGUARD_P_H
+#define QDECLARATIVEGUARD_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QObject;
+template<class T>
+class QDeclarativeGuard
+{
+ QObject *o;
+ QDeclarativeGuard<QObject> *next;
+ QDeclarativeGuard<QObject> **prev;
+ friend class QDeclarativeDeclarativeData;
+public:
+ inline QDeclarativeGuard();
+ inline QDeclarativeGuard(T *);
+ inline QDeclarativeGuard(const QDeclarativeGuard<T> &);
+ inline virtual ~QDeclarativeGuard();
+
+ inline QDeclarativeGuard<T> &operator=(const QDeclarativeGuard<T> &o);
+ inline QDeclarativeGuard<T> &operator=(T *);
+
+ inline bool isNull() const
+ { return !o; }
+
+ inline T* operator->() const
+ { return static_cast<T*>(const_cast<QObject*>(o)); }
+ inline T& operator*() const
+ { return *static_cast<T*>(const_cast<QObject*>(o)); }
+ inline operator T*() const
+ { return static_cast<T*>(const_cast<QObject*>(o)); }
+ inline T* data() const
+ { return static_cast<T*>(const_cast<QObject*>(o)); }
+
+protected:
+ virtual void objectDestroyed(T *) {}
+
+private:
+ inline void addGuard();
+ inline void remGuard();
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeclarativeGuard<QObject>);
+
+#include "qdeclarativedeclarativedata_p.h"
+
+QT_BEGIN_NAMESPACE
+
+template<class T>
+QDeclarativeGuard<T>::QDeclarativeGuard()
+: o(0), next(0), prev(0)
+{
+}
+
+template<class T>
+QDeclarativeGuard<T>::QDeclarativeGuard(T *g)
+: o(g), next(0), prev(0)
+{
+ if (o) addGuard();
+}
+
+template<class T>
+QDeclarativeGuard<T>::QDeclarativeGuard(const QDeclarativeGuard<T> &g)
+: o(g.o), next(0), prev(0)
+{
+ if (o) addGuard();
+}
+
+template<class T>
+QDeclarativeGuard<T>::~QDeclarativeGuard()
+{
+ if (prev) remGuard();
+ o = 0;
+}
+
+template<class T>
+QDeclarativeGuard<T> &QDeclarativeGuard<T>::operator=(const QDeclarativeGuard<T> &g)
+{
+ if (g.o != o) {
+ if (prev) remGuard();
+ o = g.o;
+ if (o) addGuard();
+ }
+ return *this;
+}
+
+template<class T>
+QDeclarativeGuard<T> &QDeclarativeGuard<T>::operator=(T *g)
+{
+ if (g != o) {
+ if (prev) remGuard();
+ o = g;
+ if (o) addGuard();
+ }
+ return *this;
+}
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEGUARD_P_H
diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp
new file mode 100644
index 0000000..daa2e87
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeimageprovider.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeimageprovider.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QDeclarativeImageProvider
+ \brief The QDeclarativeImageProvider class provides an interface for threaded image requests.
+
+ Note: the request() method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+
+ \sa QDeclarativeEngine::addImageProvider()
+*/
+QDeclarativeImageProvider::~QDeclarativeImageProvider()
+{
+}
+
+/*!
+ \fn QImage QDeclarativeImageProvider::request(const QString &id)
+
+ Implement this method to return the image with \a id.
+
+ Note: this method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeimageprovider.h b/src/declarative/qml/qdeclarativeimageprovider.h
new file mode 100644
index 0000000..6ee7bcf
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeimageprovider.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEIMAGEPROVIDER_H
+#define QDECLARATIVEIMAGEPROVIDER_H
+
+#include <QtGui/qimage.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QDeclarativeImageProvider
+{
+public:
+ virtual ~QDeclarativeImageProvider();
+ virtual QImage request(const QString &id) = 0;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEIMAGEPROVIDER
diff --git a/src/declarative/qml/qdeclarativeinfo.cpp b/src/declarative/qml/qdeclarativeinfo.cpp
new file mode 100644
index 0000000..41d09c4
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeinfo.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeinfo.h"
+
+#include "qdeclarativedeclarativedata_p.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarativemetatype.h"
+
+#include <QCoreApplication>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \fn QDeclarativeInfo qmlInfo(const QObject *object)
+
+ \brief Prints warnings messages that include the file and line number for QML types.
+
+ When QML types display warning messages, it improves traceability
+ if they include the QML file and line number on which the
+ particular instance was instantiated.
+
+ To include the file and line number, an object must be passed. If
+ the file and line number is not available for that instance
+ (either it was not instantiated by the QML engine or location
+ information is disabled), "unknown location" will be used instead.
+
+ For example,
+
+ \code
+ qmlInfo(object) << tr("component property is a write-once property");
+ \endcode
+
+ prints
+
+ \code
+ QML MyCustomType (unknown location): component property is a write-once property
+ \endcode
+*/
+
+QDeclarativeInfo::QDeclarativeInfo(const QObject *object)
+: QDebug(QtWarningMsg)
+{
+ QString pos = QLatin1String("QML");
+ if (object) {
+ pos += QLatin1Char(' ');
+
+ QString typeName;
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
+ if (type) {
+ typeName = QLatin1String(type->qmlTypeName());
+ int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
+ if (lastSlash != -1)
+ typeName = typeName.mid(lastSlash+1);
+ } else {
+ typeName = QString::fromUtf8(object->metaObject()->className());
+ int marker = typeName.indexOf(QLatin1String("_QMLTYPE_"));
+ if (marker != -1)
+ typeName = typeName.left(marker);
+ }
+
+ pos += typeName;
+ }
+ QDeclarativeDeclarativeData *ddata = object?QDeclarativeDeclarativeData::get(object):0;
+ pos += QLatin1String(" (");
+ if (ddata) {
+ if (ddata->outerContext) {
+ pos += ddata->outerContext->baseUrl().toString();
+ pos += QLatin1Char(':');
+ pos += QString::number(ddata->lineNumber);
+ pos += QLatin1Char(':');
+ pos += QString::number(ddata->columnNumber);
+ } else {
+ pos += QCoreApplication::translate("QDeclarativeInfo","unknown location");
+ }
+ } else {
+ pos += QCoreApplication::translate("QDeclarativeInfo","unknown location");
+ }
+ pos += QLatin1Char(')');
+ *this << pos;
+ nospace();
+}
+
+QDeclarativeInfo::~QDeclarativeInfo()
+{
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeinfo.h b/src/declarative/qml/qdeclarativeinfo.h
new file mode 100644
index 0000000..8f69f73
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeinfo.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEINFO_H
+#define QDECLARATIVEINFO_H
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QDeclarativeInfo : public QDebug
+{
+public:
+ QDeclarativeInfo(const QObject *);
+ ~QDeclarativeInfo();
+
+ inline QDeclarativeInfo &operator<<(QChar t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(QBool t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(bool t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(char t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(signed short t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(unsigned short t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(signed int t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(unsigned int t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(signed long t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(unsigned long t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(qint64 t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(quint64 t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(float t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(double t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(const char* t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(const QString & t) { QDebug::operator<<(t.toLocal8Bit().constData()); return *this; }
+ inline QDeclarativeInfo &operator<<(const QStringRef & t) { return operator<<(t.toString()); }
+ inline QDeclarativeInfo &operator<<(const QLatin1String &t) { QDebug::operator<<(t.latin1()); return *this; }
+ inline QDeclarativeInfo &operator<<(const QByteArray & t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(const void * t) { QDebug::operator<<(t); return *this; }
+ inline QDeclarativeInfo &operator<<(QTextStreamFunction f) { QDebug::operator<<(f); return *this; }
+ inline QDeclarativeInfo &operator<<(QTextStreamManipulator m) { QDebug::operator<<(m); return *this; }
+};
+
+Q_DECLARATIVE_EXPORT inline QDeclarativeInfo qmlInfo(const QObject *me)
+{
+ return QDeclarativeInfo(me);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEINFO_H
diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp
new file mode 100644
index 0000000..cf485fe
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeinstruction.cpp
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeinstruction_p.h"
+
+#include "qdeclarativecompiler_p.h"
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
+{
+ QByteArray lineNumber = QByteArray::number(instr->line);
+ if (instr->line == (unsigned short)-1)
+ lineNumber = "NA";
+ const char *line = lineNumber.constData();
+
+ switch(instr->type) {
+ case QDeclarativeInstruction::Init:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "INIT\t\t\t" << instr->init.bindingsSize << "\t" << instr->init.parserStatusSize << "\t" << instr->init.contextCache << "\t" << instr->init.compiledBinding;
+ break;
+ case QDeclarativeInstruction::CreateObject:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "CREATE\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className;
+ break;
+ case QDeclarativeInstruction::SetId:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "SETID\t\t\t" << instr->setId.value << "\t\t\t" << primitives.at(instr->setId.value);
+ break;
+ case QDeclarativeInstruction::SetDefault:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "SET_DEFAULT";
+ break;
+ case QDeclarativeInstruction::CreateComponent:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "CREATE_COMPONENT\t" << instr->createComponent.count;
+ break;
+ case QDeclarativeInstruction::StoreMetaObject:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_META\t\t" << instr->storeMeta.data;
+ break;
+
+ case QDeclarativeInstruction::StoreFloat:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_FLOAT\t\t" << instr->storeFloat.propertyIndex << "\t" << instr->storeFloat.value;
+ break;
+ case QDeclarativeInstruction::StoreDouble:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
+ break;
+ case QDeclarativeInstruction::StoreInteger:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
+ break;
+ case QDeclarativeInstruction::StoreBool:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
+ break;
+ case QDeclarativeInstruction::StoreString:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_STRING\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
+ break;
+ case QDeclarativeInstruction::StoreUrl:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_URL\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << primitives.at(instr->storeUrl.value);
+ break;
+ case QDeclarativeInstruction::StoreColor:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_COLOR\t\t" << instr->storeColor.propertyIndex << "\t\t\t" << QString::number(instr->storeColor.value, 16);
+ break;
+ case QDeclarativeInstruction::StoreDate:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_DATE\t\t" << instr->storeDate.propertyIndex << "\t" << instr->storeDate.value;
+ break;
+ case QDeclarativeInstruction::StoreTime:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_TIME\t\t" << instr->storeTime.propertyIndex << "\t" << instr->storeTime.valueIndex;
+ break;
+ case QDeclarativeInstruction::StoreDateTime:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_DATETIME\t\t" << instr->storeDateTime.propertyIndex << "\t" << instr->storeDateTime.valueIndex;
+ break;
+ case QDeclarativeInstruction::StorePoint:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_POINT\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
+ break;
+ case QDeclarativeInstruction::StorePointF:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_POINTF\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
+ break;
+ case QDeclarativeInstruction::StoreSize:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SIZE\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
+ break;
+ case QDeclarativeInstruction::StoreSizeF:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SIZEF\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
+ break;
+ case QDeclarativeInstruction::StoreRect:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_RECT\t\t" << instr->storeRect.propertyIndex << "\t" << instr->storeRect.valueIndex;
+ break;
+ case QDeclarativeInstruction::StoreRectF:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_RECTF\t\t" << instr->storeRect.propertyIndex << "\t" << instr->storeRect.valueIndex;
+ break;
+ case QDeclarativeInstruction::StoreVector3D:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VECTOR3D\t\t" << instr->storeVector3D.propertyIndex << "\t" << instr->storeVector3D.valueIndex;
+ break;
+ case QDeclarativeInstruction::StoreVariant:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
+ break;
+ case QDeclarativeInstruction::StoreObject:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
+ break;
+ case QDeclarativeInstruction::StoreVariantObject:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT_OBJECT\t" << instr->storeObject.propertyIndex;
+ break;
+ case QDeclarativeInstruction::StoreInterface:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_INTERFACE\t\t" << instr->storeObject.propertyIndex;
+ break;
+
+ case QDeclarativeInstruction::StoreSignal:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value << "\t\t" << primitives.at(instr->storeSignal.value);
+ break;
+ case QDeclarativeInstruction::StoreScript:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SCRIPT\t\t" << instr->storeScript.value;
+ break;
+ case QDeclarativeInstruction::StoreScriptString:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SCRIPT_STRING\t" << instr->storeScriptString.propertyIndex << "\t" << instr->storeScriptString.value << "\t" << instr->storeScriptString.scope;
+ break;
+
+ case QDeclarativeInstruction::AssignSignalObject:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal << "\t\t\t" << datas.at(instr->assignSignalObject.signal);
+ break;
+ case QDeclarativeInstruction::AssignCustomType:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.valueIndex;
+ break;
+
+ case QDeclarativeInstruction::StoreBinding:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
+ break;
+ case QDeclarativeInstruction::StoreCompiledBinding:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_COMPILED_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
+ break;
+ case QDeclarativeInstruction::StoreValueSource:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property << "\t" << instr->assignValueSource.castValue;
+ break;
+ case QDeclarativeInstruction::StoreValueInterceptor:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VALUE_INTERCEPTOR\t" << instr->assignValueInterceptor.property << "\t" << instr->assignValueInterceptor.castValue;
+ break;
+
+ case QDeclarativeInstruction::BeginObject:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "BEGIN\t\t\t" << instr->begin.castValue;
+ break;
+ case QDeclarativeInstruction::StoreObjectQList:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_OBJECT_QLIST";
+ break;
+ case QDeclarativeInstruction::AssignObjectList:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "ASSIGN_OBJECT_LIST";
+ break;
+ case QDeclarativeInstruction::FetchAttached:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH_ATTACHED\t\t" << instr->fetchAttached.id;
+ break;
+ case QDeclarativeInstruction::FetchQList:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH_QLIST\t\t" << instr->fetch.property;
+ break;
+ case QDeclarativeInstruction::FetchObject:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH\t\t\t" << instr->fetch.property;
+ break;
+ case QDeclarativeInstruction::FetchValueType:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type;
+ break;
+ case QDeclarativeInstruction::PopFetchedObject:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "POP";
+ break;
+ case QDeclarativeInstruction::PopQList:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "POP_QLIST";
+ break;
+ case QDeclarativeInstruction::PopValueType:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "POP_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type;
+ break;
+ case QDeclarativeInstruction::Defer:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "DEFER" << "\t\t\t" << instr->defer.deferCount;
+ break;
+ default:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "XXX UNKOWN INSTRUCTION" << "\t" << instr->type;
+ break;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
new file mode 100644
index 0000000..d8af6a7
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -0,0 +1,319 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEINSTRUCTION_P_H
+#define QDECLARATIVEINSTRUCTION_P_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>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCompiledData;
+class Q_DECLARATIVE_EXPORT QDeclarativeInstruction
+{
+public:
+ enum Type {
+ //
+ // Object Creation
+ //
+ // CreateObject - Create a new object instance and push it on the
+ // object stack
+ // SetId - Set the id of the object on the top of the object stack
+ // SetDefault - Sets the instance on the top of the object stack to
+ // be the context's default object.
+ // StoreMetaObject - Assign the dynamic metaobject to object on the
+ // top of the stack.
+ Init, /* init */
+ CreateObject, /* create */
+ SetId, /* setId */
+ SetDefault,
+ CreateComponent, /* createComponent */
+ StoreMetaObject, /* storeMeta */
+
+ //
+ // Precomputed single assignment
+ //
+ // StoreFloat - Store a float in a core property
+ // StoreDouble - Store a double in a core property
+ // StoreInteger - Store a int or uint in a core property
+ // StoreBool - Store a bool in a core property
+ // StoreString - Store a QString in a core property
+ // StoreUrl - Store a QUrl in a core property
+ // StoreColor - Store a QColor in a core property
+ // StoreDate - Store a QDate in a core property
+ // StoreTime - Store a QTime in a core property
+ // StoreDateTime - Store a QDateTime in a core property
+ // StoreVariant - Store a QVariant in a core property
+ // StoreObject - Pop the object on the top of the object stack and
+ // store it in a core property
+ StoreFloat, /* storeFloat */
+ StoreDouble, /* storeDouble */
+ StoreInteger, /* storeInteger */
+ StoreBool, /* storeBool */
+ StoreString, /* storeString */
+ StoreUrl, /* storeUrl */
+ StoreColor, /* storeColor */
+ StoreDate, /* storeDate */
+ StoreTime, /* storeTime */
+ StoreDateTime, /* storeDateTime */
+ StorePoint, /* storeRealPair */
+ StorePointF, /* storeRealPair */
+ StoreSize, /* storeRealPair */
+ StoreSizeF, /* storeRealPair */
+ StoreRect, /* storeRect */
+ StoreRectF, /* storeRect */
+ StoreVector3D, /* storeVector3D */
+ StoreVariant, /* storeString */
+ StoreObject, /* storeObject */
+ StoreVariantObject, /* storeObject */
+ StoreInterface, /* storeObject */
+
+ StoreSignal, /* storeSignal */
+ StoreScript, /* storeScript */
+ StoreScriptString, /* storeScriptString */
+
+ //
+ // Unresolved single assignment
+ //
+ AssignSignalObject, /* assignSignalObject */
+ AssignCustomType, /* assignCustomType */
+
+ StoreBinding, /* assignBinding */
+ StoreCompiledBinding, /* assignBinding */
+ StoreValueSource, /* assignValueSource */
+ StoreValueInterceptor, /* assignValueInterceptor */
+
+ BeginObject, /* begin */
+
+ StoreObjectQList, /* NA */
+ AssignObjectList, /* NA */
+
+ FetchAttached, /* fetchAttached */
+ FetchQList, /* fetch */
+ FetchObject, /* fetch */
+ FetchValueType, /* fetchValue */
+
+ //
+ // Stack manipulation
+ //
+ // PopFetchedObject - Remove an object from the object stack
+ // PopQList - Remove a list from the list stack
+ PopFetchedObject,
+ PopQList,
+ PopValueType, /* fetchValue */
+
+ //
+ // Deferred creation
+ //
+ Defer, /* defer */
+ };
+ QDeclarativeInstruction()
+ : line(0) {}
+
+ Type type;
+ unsigned short line;
+ union {
+ struct {
+ int bindingsSize;
+ int parserStatusSize;
+ int contextCache;
+ int compiledBinding;
+ } init;
+ struct {
+ int type;
+ int data;
+ int bindingBits;
+ ushort column;
+ } create;
+ struct {
+ int data;
+ int aliasData;
+ int propertyCache;
+ } storeMeta;
+ struct {
+ int value;
+ int index;
+ } setId;
+ struct {
+ int property;
+ int owner;
+ int castValue;
+ } assignValueSource;
+ struct {
+ int property;
+ int owner;
+ int castValue;
+ } assignValueInterceptor;
+ struct {
+ unsigned int property;
+ int value;
+ short context;
+ short owner;
+ } assignBinding;
+ struct {
+ int property;
+ int id;
+ } assignIdOptBinding;
+ struct {
+ int property;
+ int contextIdx;
+ short context;
+ short notifyIdx;
+ } assignObjPropBinding;
+ struct {
+ int property;
+ } fetch;
+ struct {
+ int property;
+ int type;
+ } fetchValue;
+ struct {
+ int property;
+ int type;
+ } fetchQmlList;
+ struct {
+ int castValue;
+ } begin;
+ struct {
+ int propertyIndex;
+ float value;
+ } storeFloat;
+ struct {
+ int propertyIndex;
+ double value;
+ } storeDouble;
+ struct {
+ int propertyIndex;
+ int value;
+ } storeInteger;
+ struct {
+ int propertyIndex;
+ bool value;
+ } storeBool;
+ struct {
+ int propertyIndex;
+ int value;
+ } storeString;
+ struct {
+ int propertyIndex;
+ int value;
+ int scope;
+ } storeScriptString;
+ struct {
+ int value;
+ } storeScript;
+ struct {
+ int propertyIndex;
+ int value;
+ } storeUrl;
+ struct {
+ int propertyIndex;
+ unsigned int value;
+ } storeColor;
+ struct {
+ int propertyIndex;
+ int value;
+ } storeDate;
+ struct {
+ int propertyIndex;
+ int valueIndex;
+ } storeTime;
+ struct {
+ int propertyIndex;
+ int valueIndex;
+ } storeDateTime;
+ struct {
+ int propertyIndex;
+ int valueIndex;
+ } storeRealPair;
+ struct {
+ int propertyIndex;
+ int valueIndex;
+ } storeRect;
+ struct {
+ int propertyIndex;
+ int valueIndex;
+ } storeVector3D;
+ struct {
+ int propertyIndex;
+ } storeObject;
+ struct {
+ int propertyIndex;
+ int valueIndex;
+ } assignCustomType;
+ struct {
+ int signalIndex;
+ int value;
+ } storeSignal;
+ struct {
+ int signal;
+ } assignSignalObject;
+ struct {
+ int count;
+ ushort column;
+ int endLine;
+ int metaObject;
+ } createComponent;
+ struct {
+ int id;
+ } fetchAttached;
+ struct {
+ int deferCount;
+ } defer;
+ };
+
+ void dump(QDeclarativeCompiledData *);
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEINSTRUCTION_P_H
diff --git a/src/declarative/qml/qdeclarativeintegercache.cpp b/src/declarative/qml/qdeclarativeintegercache.cpp
new file mode 100644
index 0000000..7fa4b0c
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeintegercache.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeintegercache_p.h"
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativemetatype.h"
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeIntegerCache::QDeclarativeIntegerCache(QDeclarativeEngine *e)
+: QDeclarativeCleanup(e), engine(e)
+{
+}
+
+QDeclarativeIntegerCache::~QDeclarativeIntegerCache()
+{
+ clear();
+}
+
+void QDeclarativeIntegerCache::clear()
+{
+ qDeleteAll(stringCache);
+ stringCache.clear();
+ identifierCache.clear();
+ engine = 0;
+}
+
+void QDeclarativeIntegerCache::add(const QString &id, int value)
+{
+ Q_ASSERT(!stringCache.contains(id));
+
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+
+ // ### use contextClass
+ Data *d = new Data(enginePriv->objectClass->createPersistentIdentifier(id), value);
+
+ stringCache.insert(id, d);
+ identifierCache.insert(d->identifier, d);
+}
+
+int QDeclarativeIntegerCache::value(const QString &id)
+{
+ Data *d = stringCache.value(id);
+ return d?d->value:-1;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeintegercache_p.h b/src/declarative/qml/qdeclarativeintegercache_p.h
new file mode 100644
index 0000000..b57565e
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeintegercache_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEINTEGERCACHE_P_H
+#define QDECLARATIVEINTEGERCACHE_P_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 "qdeclarativerefcount_p.h"
+#include "qdeclarativecleanup_p.h"
+
+#include <QtCore/qhash.h>
+
+#include <private/qscriptdeclarativeclass_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeType;
+class QDeclarativeEngine;
+class QDeclarativeIntegerCache : public QDeclarativeRefCount, public QDeclarativeCleanup
+{
+public:
+ QDeclarativeIntegerCache(QDeclarativeEngine *);
+ virtual ~QDeclarativeIntegerCache();
+
+ inline int count() const;
+ void add(const QString &, int);
+ int value(const QString &);
+ inline int value(const QScriptDeclarativeClass::Identifier &id) const;
+
+protected:
+ virtual void clear();
+
+private:
+ struct Data : public QScriptDeclarativeClass::PersistentIdentifier {
+ Data(const QScriptDeclarativeClass::PersistentIdentifier &i, int v)
+ : QScriptDeclarativeClass::PersistentIdentifier(i), value(v) {}
+
+ int value;
+ };
+
+ typedef QHash<QString, Data *> StringCache;
+ typedef QHash<QScriptDeclarativeClass::Identifier, Data *> IdentifierCache;
+
+ StringCache stringCache;
+ IdentifierCache identifierCache;
+ QDeclarativeEngine *engine;
+};
+
+int QDeclarativeIntegerCache::value(const QScriptDeclarativeClass::Identifier &id) const
+{
+ Data *d = identifierCache.value(id);
+ return d?d->value:-1;
+}
+
+int QDeclarativeIntegerCache::count() const
+{
+ return stringCache.count();
+}
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEINTEGERCACHE_P_H
+
diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp
new file mode 100644
index 0000000..4c9586c
--- /dev/null
+++ b/src/declarative/qml/qdeclarativelist.cpp
@@ -0,0 +1,312 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativelist.h"
+#include "qdeclarativelist_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativemetaproperty_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeListReferencePrivate::QDeclarativeListReferencePrivate()
+: propertyType(-1), refCount(1)
+{
+}
+
+QDeclarativeListReference QDeclarativeListReferencePrivate::init(const QDeclarativeListProperty<QObject> &prop, int propType, QDeclarativeEngine *engine)
+{
+ QDeclarativeListReference rv;
+
+ if (!prop.object) return rv;
+
+ QDeclarativeEnginePrivate *p = engine?QDeclarativeEnginePrivate::get(engine):0;
+
+ int listType = p?p->listType(propType):QDeclarativeMetaType::listType(propType);
+ if (listType == -1) return rv;
+
+ rv.d = new QDeclarativeListReferencePrivate;
+ rv.d->object = prop.object;
+ rv.d->elementType = p?p->rawMetaObjectForType(listType):QDeclarativeMetaType::qmlType(listType)->baseMetaObject();
+ rv.d->property = prop;
+ rv.d->propertyType = propType;
+
+ return rv;
+}
+
+void QDeclarativeListReferencePrivate::addref()
+{
+ Q_ASSERT(refCount > 0);
+ ++refCount;
+}
+
+void QDeclarativeListReferencePrivate::release()
+{
+ Q_ASSERT(refCount > 0);
+ --refCount;
+ if (!refCount)
+ delete this;
+}
+
+QDeclarativeListReference::QDeclarativeListReference()
+: d(0)
+{
+}
+
+QDeclarativeListReference::QDeclarativeListReference(QObject *o, const char *property, QDeclarativeEngine *engine)
+: d(0)
+{
+ if (!o || !property) return;
+
+ QDeclarativePropertyCache::Data local;
+ QDeclarativePropertyCache::Data *data = QDeclarativePropertyCache::property(engine, o, QLatin1String(property), local);
+
+ if (!data || !(data->flags & QDeclarativePropertyCache::Data::IsQList)) return;
+
+ QDeclarativeEnginePrivate *p = engine?QDeclarativeEnginePrivate::get(engine):0;
+
+ int listType = p?p->listType(data->propType):QDeclarativeMetaType::listType(data->propType);
+ if (listType == -1) return;
+
+ d = new QDeclarativeListReferencePrivate;
+ d->object = o;
+ d->elementType = p?p->rawMetaObjectForType(listType):QDeclarativeMetaType::qmlType(listType)->baseMetaObject();
+ d->propertyType = data->propType;
+
+ void *args[] = { &d->property, 0 };
+ QMetaObject::metacall(o, QMetaObject::ReadProperty, data->coreIndex, args);
+}
+
+QDeclarativeListReference::QDeclarativeListReference(const QDeclarativeListReference &o)
+: d(o.d)
+{
+ if (d) d->addref();
+}
+
+QDeclarativeListReference &QDeclarativeListReference::operator=(const QDeclarativeListReference &o)
+{
+ if (o.d) o.d->addref();
+ if (d) d->release();
+ d = o.d;
+ return *this;
+}
+
+QDeclarativeListReference::~QDeclarativeListReference()
+{
+ if (d) d->release();
+}
+
+bool QDeclarativeListReference::isValid() const
+{
+ return d && d->object;
+}
+
+QObject *QDeclarativeListReference::object() const
+{
+ if (isValid()) return d->object;
+ else return 0;
+}
+
+const QMetaObject *QDeclarativeListReference::listElementType() const
+{
+ if (isValid()) return d->elementType;
+ else return 0;
+}
+
+bool QDeclarativeListReference::canAppend() const
+{
+ return (isValid() && d->property.append);
+}
+
+bool QDeclarativeListReference::canAt() const
+{
+ return (isValid() && d->property.at);
+}
+
+bool QDeclarativeListReference::canClear() const
+{
+ return (isValid() && d->property.clear);
+}
+
+bool QDeclarativeListReference::canCount() const
+{
+ return (isValid() && d->property.count);
+}
+
+bool QDeclarativeListReference::append(QObject *o) const
+{
+ if (!canAppend()) return false;
+
+ if (o && !QDeclarativeMetaPropertyPrivate::canConvert(o->metaObject(), d->elementType))
+ return false;
+
+ d->property.append(&d->property, o);
+
+ return true;
+}
+
+QObject *QDeclarativeListReference::at(int index) const
+{
+ if (!canAt()) return 0;
+
+ return d->property.at(&d->property, index);
+}
+
+bool QDeclarativeListReference::clear() const
+{
+ if (!canClear()) return false;
+
+ d->property.clear(&d->property);
+
+ return true;
+}
+
+int QDeclarativeListReference::count() const
+{
+ if (!canCount()) return 0;
+
+ return d->property.count(&d->property);
+}
+
+/*!
+\class QDeclarativeListProperty
+\brief The QDeclarativeListProperty class allows applications to explose list-like
+properties to QML.
+
+QML has many list properties, where more than one object value can be assigned.
+The use of a list property from QML looks like this:
+
+\code
+FruitBasket {
+ fruit: [
+ Apple {},
+ Orange{},
+ Banana {}
+ ]
+}
+\endcode
+
+The QDeclarativeListProperty encapsulates a group of function pointers that represet the
+set of actions QML can perform on the list - adding items, retrieving items and
+clearing the list. In the future, additional operations may be supported. All
+list properties must implement the append operation, but the rest are optional.
+
+To provide a list property, a C++ class must implement the operation callbacks,
+and then return an appropriate QDeclarativeListProperty value from the property getter.
+List properties should have no setter. In the example above, the Q_PROPERTY()
+declarative will look like this:
+
+\code
+Q_PROPERTY(QDeclarativeListProperty<Fruit> fruit READ fruit);
+\endcode
+
+QML list properties are typesafe - in this case \c {Fruit} is a QObject type that
+\c {Apple}, \c {Orange} and \c {Banana} all derive from.
+*/
+
+/*!
+\fn QDeclarativeListProperty::QDeclarativeListProperty()
+\internal
+*/
+
+/*!
+\fn QDeclarativeListProperty::QDeclarativeListProperty(QObject *object, QList<T *> &list)
+
+Convenience constructor for making a QDeclarativeListProperty value from an existing
+QList \a list. The \a list reference must remain valid for as long as \a object
+exists. \a object must be provided.
+
+Generally this constructor should not be used in production code, as a
+writable QList violates QML's memory management rules. However, this constructor
+can very useful while prototyping.
+*/
+
+/*!
+\fn QDeclarativeListProperty::QDeclarativeListProperty(QObject *object, void *data, AppendFunction append,
+ CountFunction count = 0, AtFunction at = 0,
+ ClearFunction clear = 0)
+
+Construct a QDeclarativeListProperty from a set of operation functions. An opaque \a data handle
+may be passed which can be accessed from within the operation functions. The list property
+remains valid while \a object exists.
+
+The \a append operation is compulsory and must be provided, while the \a count, \a at and
+\a clear methods are optional.
+*/
+
+/*!
+\typedef QDeclarativeListProperty::AppendFunction
+
+Synonym for \c {void (*)(QDeclarativeListProperty<T> *property, T *value)}.
+
+Append the \a value to the list \a property.
+*/
+
+/*!
+\typedef QDeclarativeListProperty::CountFunction
+
+Synonym for \c {int (*)(QDeclarativeListProperty<T> *property)}.
+
+Return the number of elements in the list \a property.
+*/
+
+/*!
+\fn bool QDeclarativeListProperty::operator==(const QDeclarativeListProperty &other) const
+
+Returns true if this QDeclarativeListProperty is equal to \a other, otherwise false.
+*/
+
+/*!
+\typedef QDeclarativeListProperty::AtFunction
+
+Synonym for \c {T *(*)(QDeclarativeListProperty<T> *property, int index)}.
+
+Return the element at position \a index in the list \a property.
+*/
+
+/*!
+\typedef QDeclarativeListProperty::ClearFunction
+
+Synonym for \c {void (*)(QDeclarativeListProperty<T> *property)}.
+
+Clear the list \a property.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h
new file mode 100644
index 0000000..fb877b4
--- /dev/null
+++ b/src/declarative/qml/qdeclarativelist.h
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVELIST_H
+#define QDECLARATIVELIST_H
+
+#include "qdeclarativeprivate.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+template<typename T>
+struct QDeclarativeListProperty {
+ typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*);
+ typedef int (*CountFunction)(QDeclarativeListProperty<T> *);
+ typedef T *(*AtFunction)(QDeclarativeListProperty<T> *, int);
+ typedef void (*ClearFunction)(QDeclarativeListProperty<T> *);
+
+ QDeclarativeListProperty()
+ : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {}
+ QDeclarativeListProperty(QObject *o, QList<T *> &list)
+ : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at),
+ clear(qlist_clear), dummy1(0), dummy2(0) {}
+ QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0,
+ ClearFunction r = 0)
+ : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {}
+
+ bool operator==(const QDeclarativeListProperty &o) const {
+ return object == o.object &&
+ data == o.data &&
+ append == o.append &&
+ count == o.count &&
+ at == o.at &&
+ clear == o.clear;
+ }
+
+ QObject *object;
+ void *data;
+
+ AppendFunction append;
+
+ CountFunction count;
+ AtFunction at;
+
+ ClearFunction clear;
+
+ void *dummy1;
+ void *dummy2;
+
+private:
+ static void qlist_append(QDeclarativeListProperty *p, T *v) {
+ ((QList<T *> *)p->data)->append(v);
+ }
+ static int qlist_count(QDeclarativeListProperty *p) {
+ return ((QList<T *> *)p->data)->count();
+ }
+ static T *qlist_at(QDeclarativeListProperty *p, int idx) {
+ return ((QList<T *> *)p->data)->at(idx);
+ }
+ static void qlist_clear(QDeclarativeListProperty *p) {
+ return ((QList<T *> *)p->data)->clear();
+ }
+};
+
+class QDeclarativeEngine;
+class QDeclarativeListReferencePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeListReference
+{
+public:
+ QDeclarativeListReference();
+ QDeclarativeListReference(QObject *, const char *property, QDeclarativeEngine * = 0);
+ QDeclarativeListReference(const QDeclarativeListReference &);
+ QDeclarativeListReference &operator=(const QDeclarativeListReference &);
+ ~QDeclarativeListReference();
+
+ bool isValid() const;
+
+ QObject *object() const;
+ const QMetaObject *listElementType() const;
+
+ bool canAppend() const;
+ bool canAt() const;
+ bool canClear() const;
+ bool canCount() const;
+
+ bool append(QObject *) const;
+ QObject *at(int) const;
+ bool clear() const;
+ int count() const;
+
+private:
+ friend class QDeclarativeListReferencePrivate;
+ QDeclarativeListReferencePrivate* d;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeclarativeListReference);
+
+QT_END_HEADER
+
+#endif // QDECLARATIVELIST_H
diff --git a/src/declarative/qml/qdeclarativelist_p.h b/src/declarative/qml/qdeclarativelist_p.h
new file mode 100644
index 0000000..45a805a
--- /dev/null
+++ b/src/declarative/qml/qdeclarativelist_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVELIST_P_H
+#define QDECLARATIVELIST_P_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 "qdeclarativelist.h"
+#include "qdeclarativeguard_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeListReferencePrivate
+{
+public:
+ QDeclarativeListReferencePrivate();
+
+ static QDeclarativeListReference init(const QDeclarativeListProperty<QObject> &, int, QDeclarativeEngine *);
+
+ QDeclarativeGuard<QObject> object;
+ const QMetaObject *elementType;
+ QDeclarativeListProperty<QObject> property;
+ int propertyType;
+
+ void addref();
+ void release();
+ int refCount;
+
+ static inline QDeclarativeListReferencePrivate *get(QDeclarativeListReference *ref) {
+ return ref->d;
+ }
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVELIST_P_H
diff --git a/src/declarative/qml/qdeclarativelistscriptclass.cpp b/src/declarative/qml/qdeclarativelistscriptclass.cpp
new file mode 100644
index 0000000..ea04ad9
--- /dev/null
+++ b/src/declarative/qml/qdeclarativelistscriptclass.cpp
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativelistscriptclass_p.h"
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativeguard_p.h"
+#include "qdeclarativelist_p.h"
+
+QT_BEGIN_NAMESPACE
+
+struct ListData : public QScriptDeclarativeClass::Object {
+ QDeclarativeGuard<QObject> object;
+ QDeclarativeListProperty<QObject> property;
+ int propertyType;
+};
+
+QDeclarativeListScriptClass::QDeclarativeListScriptClass(QDeclarativeEngine *e)
+: QDeclarativeScriptClass(QDeclarativeEnginePrivate::getScriptEngine(e)), engine(e)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+ Q_UNUSED(scriptEngine);
+
+ m_lengthId = createPersistentIdentifier(QLatin1String("length"));
+}
+
+QDeclarativeListScriptClass::~QDeclarativeListScriptClass()
+{
+}
+
+QScriptValue QDeclarativeListScriptClass::newList(QObject *object, int propId, int propType)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ if (!object || propId == -1)
+ return scriptEngine->nullValue();
+
+ ListData *data = new ListData;
+ data->object = object;
+ data->propertyType = propType;
+ void *args[] = { &data->property, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, propId, args);
+
+ return newObject(scriptEngine, this, data);
+}
+
+QScriptValue QDeclarativeListScriptClass::newList(const QDeclarativeListProperty<QObject> &prop, int propType)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ ListData *data = new ListData;
+ data->object = prop.object;
+ data->property = prop;
+ data->propertyType = propType;
+
+ return newObject(scriptEngine, this, data);
+}
+
+QScriptClass::QueryFlags
+QDeclarativeListScriptClass::queryProperty(Object *object, const Identifier &name,
+ QScriptClass::QueryFlags flags)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(flags);
+ if (name == m_lengthId.identifier)
+ return QScriptClass::HandlesReadAccess;
+
+ bool ok = false;
+ quint32 idx = toArrayIndex(name, &ok);
+
+ if (ok) {
+ lastIndex = idx;
+ return QScriptClass::HandlesReadAccess;
+ } else {
+ return 0;
+ }
+}
+
+QDeclarativeListScriptClass::ScriptValue QDeclarativeListScriptClass::property(Object *obj, const Identifier &name)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+
+ ListData *data = (ListData *)obj;
+ if (!data->object)
+ return Value();
+
+ quint32 count = data->property.count?data->property.count(&data->property):0;
+
+ if (name == m_lengthId.identifier)
+ return Value(scriptEngine, count);
+ else if (lastIndex < count && data->property.at)
+ return Value(scriptEngine, enginePriv->objectClass->newQObject(data->property.at(&data->property, lastIndex)));
+ else
+ return Value();
+}
+
+QVariant QDeclarativeListScriptClass::toVariant(Object *obj, bool *ok)
+{
+ ListData *data = (ListData *)obj;
+
+ if (!data->object) {
+ if (ok) *ok = false;
+ return QVariant();
+ }
+
+ return QVariant::fromValue(QDeclarativeListReferencePrivate::init(data->property, data->propertyType, engine));
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qdeclarativelistscriptclass_p.h b/src/declarative/qml/qdeclarativelistscriptclass_p.h
new file mode 100644
index 0000000..68c680d
--- /dev/null
+++ b/src/declarative/qml/qdeclarativelistscriptclass_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVELISTSCRIPTCLASS_P_H
+#define QDECLARATIVELISTSCRIPTCLASS_P_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 <private/qdeclarativescriptclass_p.h>
+#include "qdeclarativelist.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QDeclarativeListScriptClass : public QDeclarativeScriptClass
+{
+public:
+ QDeclarativeListScriptClass(QDeclarativeEngine *);
+ ~QDeclarativeListScriptClass();
+
+ QScriptValue newList(QObject *, int, int);
+ QScriptValue newList(const QDeclarativeListProperty<QObject> &, int);
+
+protected:
+ virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
+ QScriptClass::QueryFlags flags);
+ virtual ScriptValue property(Object *, const Identifier &);
+ virtual QVariant toVariant(Object *, bool *ok);
+
+private:
+ PersistentIdentifier m_lengthId;
+ QDeclarativeEngine *engine;
+
+ quint32 lastIndex;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVELISTSCRIPTCLASS_P_H
+
diff --git a/src/declarative/qml/qdeclarativemetaproperty.cpp b/src/declarative/qml/qdeclarativemetaproperty.cpp
new file mode 100644
index 0000000..e94ce8c
--- /dev/null
+++ b/src/declarative/qml/qdeclarativemetaproperty.cpp
@@ -0,0 +1,1238 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativemetaproperty.h"
+#include "qdeclarativemetaproperty_p.h"
+
+#include "qdeclarativecompositetypedata_p.h"
+#include "qdeclarative.h"
+#include "qdeclarativebinding_p.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativeboundsignal_p.h"
+#include "qdeclarativeengine.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativedeclarativedata_p.h"
+#include "qdeclarativestringconverters_p.h"
+#include "qdeclarativelist_p.h"
+
+#include <QStringList>
+#include <QtCore/qdebug.h>
+
+#include <math.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QDeclarativeMetaProperty
+ \brief The QDeclarativeMetaProperty class abstracts accessing QML properties.
+ \internal
+ */
+
+/*!
+ Create an invalid QDeclarativeMetaProperty.
+*/
+QDeclarativeMetaProperty::QDeclarativeMetaProperty()
+: d(new QDeclarativeMetaPropertyPrivate)
+{
+ d->q = this;
+}
+
+/*! \internal */
+QDeclarativeMetaProperty::~QDeclarativeMetaProperty()
+{
+ delete d; d = 0;
+}
+
+/*!
+ Creates a QDeclarativeMetaProperty for the default property of \a obj. If there is no
+ default property, an invalid QDeclarativeMetaProperty will be created.
+ */
+QDeclarativeMetaProperty::QDeclarativeMetaProperty(QObject *obj)
+: d(new QDeclarativeMetaPropertyPrivate)
+{
+ d->q = this;
+ d->initDefault(obj);
+}
+
+/*!
+ \internal
+ Creates a QDeclarativeMetaProperty for the default property of \a obj. If there is no
+ default property, an invalid QDeclarativeMetaProperty will be created.
+ */
+QDeclarativeMetaProperty::QDeclarativeMetaProperty(QObject *obj, QDeclarativeContext *ctxt)
+: d(new QDeclarativeMetaPropertyPrivate)
+{
+ d->q = this;
+ d->context = ctxt;
+ d->initDefault(obj);
+}
+
+/*!
+ Initialize from the default property of \a obj
+*/
+void QDeclarativeMetaPropertyPrivate::initDefault(QObject *obj)
+{
+ if (!obj)
+ return;
+
+ QMetaProperty p = QDeclarativeMetaType::defaultProperty(obj);
+ core.load(p);
+ if (core.isValid()) {
+ isDefaultProperty = true;
+ object = obj;
+ }
+}
+
+/*!
+ Creates a QDeclarativeMetaProperty for the property \a name of \a obj.
+ */
+QDeclarativeMetaProperty::QDeclarativeMetaProperty(QObject *obj, const QString &name)
+: d(new QDeclarativeMetaPropertyPrivate)
+{
+ d->q = this;
+ d->initProperty(obj, name);
+ if (!isValid()) d->object = 0;
+}
+
+/*!
+ \internal
+ Creates a QDeclarativeMetaProperty for the property \a name of \a obj.
+ */
+QDeclarativeMetaProperty::QDeclarativeMetaProperty(QObject *obj, const QString &name, QDeclarativeContext *ctxt)
+: d(new QDeclarativeMetaPropertyPrivate)
+{
+ d->q = this;
+ d->context = ctxt;
+ d->initProperty(obj, name);
+ if (!isValid()) { d->object = 0; d->context = 0; }
+}
+
+void QDeclarativeMetaPropertyPrivate::initProperty(QObject *obj, const QString &name)
+{
+ QDeclarativeEnginePrivate *enginePrivate = 0;
+ if (context && context->engine())
+ enginePrivate = QDeclarativeEnginePrivate::get(context->engine());
+
+ object = obj;
+
+ if (name.isEmpty() || !obj)
+ return;
+
+ if (enginePrivate && name.at(0).isUpper()) {
+ // Attached property
+ // ### What about qualified types?
+ QDeclarativeTypeNameCache *tnCache = QDeclarativeContextPrivate::get(context)->imports;
+ if (tnCache) {
+ QDeclarativeTypeNameCache::Data *d = tnCache->data(name);
+ if (d && d->type && d->type->attachedPropertiesFunction()) {
+ attachedFunc = d->type->index();
+ }
+ }
+ return;
+
+ } else if (name.count() >= 3 &&
+ name.at(0) == QChar(QLatin1Char('o')) &&
+ name.at(1) == QChar(QLatin1Char('n')) &&
+ name.at(2).isUpper()) {
+ // Signal
+ QString signalName = name.mid(2);
+ signalName[0] = signalName.at(0).toLower();
+
+ QMetaMethod method = findSignal(obj, signalName);
+ if (method.signature()) {
+ core.load(method);
+ return;
+ }
+ }
+
+ // Property
+ QDeclarativePropertyCache::Data local;
+ QDeclarativePropertyCache::Data *property =
+ QDeclarativePropertyCache::property(context?context->engine():0, obj, name, local);
+ if (property && !(property->flags & QDeclarativePropertyCache::Data::IsFunction))
+ core = *property;
+}
+
+/*!
+ Create a copy of \a other.
+*/
+QDeclarativeMetaProperty::QDeclarativeMetaProperty(const QDeclarativeMetaProperty &other)
+: d(new QDeclarativeMetaPropertyPrivate(*other.d))
+{
+ d->q = this;
+}
+
+/*!
+ \enum QDeclarativeMetaProperty::PropertyCategory
+
+ This enum specifies a category of QML property.
+
+ \value Unknown The category is unknown. This will never be returned from propertyCategory()
+ \value InvalidProperty The property is invalid.
+ \value Bindable The property is a QDeclarativeBinding.
+ \value List The property is a QList pointer
+ \value Object The property is a QObject derived type pointer
+ \value Normal The property is none of the above.
+ */
+
+/*!
+ \enum QDeclarativeMetaProperty::Type
+
+ This enum specifies a type of QML property.
+
+ \value Invalid The property is invalid.
+ \value Property The property is a regular Qt property.
+ \value SignalProperty The property is a signal property.
+ \value Default The property is the default property.
+ \value Attached The property is an attached property.
+*/
+
+/*!
+ Returns the property category.
+*/
+QDeclarativeMetaProperty::PropertyCategory QDeclarativeMetaProperty::propertyCategory() const
+{
+ return d->propertyCategory();
+}
+
+QDeclarativeMetaProperty::PropertyCategory
+QDeclarativeMetaPropertyPrivate::propertyCategory() const
+{
+ uint type = q->type();
+
+ if (type & QDeclarativeMetaProperty::ValueTypeProperty) {
+ return QDeclarativeMetaProperty::Normal;
+ } else if (type & QDeclarativeMetaProperty::Attached) {
+ return QDeclarativeMetaProperty::Object;
+ } else if (type & QDeclarativeMetaProperty::Property) {
+ int type = propertyType();
+ if (type == QVariant::Invalid)
+ return QDeclarativeMetaProperty::InvalidProperty;
+ else if ((uint)type < QVariant::UserType)
+ return QDeclarativeMetaProperty::Normal;
+ else if (type == qMetaTypeId<QDeclarativeBinding *>())
+ return QDeclarativeMetaProperty::Bindable;
+ else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived)
+ return QDeclarativeMetaProperty::Object;
+ else if (core.flags & QDeclarativePropertyCache::Data::IsQList)
+ return QDeclarativeMetaProperty::List;
+ else
+ return QDeclarativeMetaProperty::Normal;
+ } else {
+ return QDeclarativeMetaProperty::InvalidProperty;
+ }
+}
+
+/*!
+ Returns the type name of the property, or 0 if the property has no type
+ name.
+*/
+const char *QDeclarativeMetaProperty::propertyTypeName() const
+{
+ if (type() & ValueTypeProperty) {
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->context);
+ QDeclarativeValueType *valueType = 0;
+ if (ep) valueType = ep->valueTypes[d->core.propType];
+ else valueType = QDeclarativeValueTypeFactory::valueType(d->core.propType);
+ Q_ASSERT(valueType);
+
+ const char *rv = valueType->metaObject()->property(d->valueType.valueTypeCoreIdx).typeName();
+
+ if (!ep) delete valueType;
+
+ return rv;
+ } else if (d->object && type() & Property && d->core.isValid()) {
+ return d->object->metaObject()->property(d->core.coreIndex).typeName();
+ } else {
+ return 0;
+ }
+}
+
+/*!
+ Returns true if \a other and this QDeclarativeMetaProperty represent the same
+ property.
+*/
+bool QDeclarativeMetaProperty::operator==(const QDeclarativeMetaProperty &other) const
+{
+ // category is intentially omitted here as it is generated
+ // from the other members
+ return d->object == other.d->object &&
+ d->core == other.d->core &&
+ d->valueType == other.d->valueType &&
+ d->attachedFunc == other.d->attachedFunc;
+}
+
+/*!
+ Returns the QVariant type of the property, or QVariant::Invalid if the
+ property has no QVariant type.
+*/
+int QDeclarativeMetaProperty::propertyType() const
+{
+ return d->propertyType();
+}
+
+int QDeclarativeMetaPropertyPrivate::propertyType() const
+{
+ uint type = q->type();
+ if (type & QDeclarativeMetaProperty::ValueTypeProperty) {
+ return valueType.valueTypePropType;
+ } else if (type & QDeclarativeMetaProperty::Attached) {
+ return qMetaTypeId<QObject *>();
+ } else if (type & QDeclarativeMetaProperty::Property) {
+ if (core.propType == (int)QVariant::LastType)
+ return qMetaTypeId<QVariant>();
+ else
+ return core.propType;
+ } else {
+ return QVariant::Invalid;
+ }
+}
+
+/*!
+ Returns the type of the property.
+*/
+QDeclarativeMetaProperty::Type QDeclarativeMetaProperty::type() const
+{
+ if (d->core.flags & QDeclarativePropertyCache::Data::IsFunction)
+ return SignalProperty;
+ else if (d->attachedFunc != -1)
+ return Attached;
+ else if (d->valueType.valueTypeCoreIdx != -1)
+ return (Type)(Property | ValueTypeProperty);
+ else if (d->core.isValid())
+ return (Type)(Property | ((d->isDefaultProperty)?Default:0));
+ else
+ return Invalid;
+}
+
+/*!
+ Returns true if this QDeclarativeMetaProperty represents a regular Qt property.
+*/
+bool QDeclarativeMetaProperty::isProperty() const
+{
+ return type() & Property;
+}
+
+/*!
+ Returns true if this QDeclarativeMetaProperty represents a default property.
+*/
+bool QDeclarativeMetaProperty::isDefault() const
+{
+ return type() & Default;
+}
+
+/*!
+ Returns the QDeclarativeMetaProperty's QObject.
+*/
+QObject *QDeclarativeMetaProperty::object() const
+{
+ return d->object;
+}
+
+/*!
+ Assign \a other to this QDeclarativeMetaProperty.
+*/
+QDeclarativeMetaProperty &QDeclarativeMetaProperty::operator=(const QDeclarativeMetaProperty &other)
+{
+ d->context = other.d->context;
+ d->object = other.d->object;
+
+ d->isDefaultProperty = other.d->isDefaultProperty;
+ d->isNameCached = other.d->isNameCached;
+ d->core = other.d->core;
+ d->nameCache = other.d->nameCache;
+
+ d->valueType = other.d->valueType;
+
+ d->attachedFunc = other.d->attachedFunc;
+ return *this;
+}
+
+/*!
+ Returns true if the property is writable, otherwise false.
+*/
+bool QDeclarativeMetaProperty::isWritable() const
+{
+ QDeclarativeMetaProperty::PropertyCategory category = propertyCategory();
+
+ if (!d->object)
+ return false;
+ if (category == List)
+ return true;
+ else if (type() & SignalProperty)
+ return false;
+ else if (d->core.isValid() && d->object)
+ return d->core.flags & QDeclarativePropertyCache::Data::IsWritable;
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property is designable, otherwise false.
+*/
+bool QDeclarativeMetaProperty::isDesignable() const
+{
+ if (type() & Property && d->core.isValid() && d->object)
+ return d->object->metaObject()->property(d->core.coreIndex).isDesignable();
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property is resettable, otherwise false.
+*/
+bool QDeclarativeMetaProperty::isResettable() const
+{
+ if (type() & Property && d->core.isValid() && d->object)
+ return d->core.flags & QDeclarativePropertyCache::Data::IsResettable;
+ else
+ return false;
+}
+
+/*!
+ Returns true if the QDeclarativeMetaProperty refers to a valid property, otherwise
+ false.
+*/
+bool QDeclarativeMetaProperty::isValid() const
+{
+ return type() != Invalid;
+}
+
+/*!
+ Return the name of this QML property.
+*/
+QString QDeclarativeMetaProperty::name() const
+{
+ if (!d->isNameCached) {
+ // ###
+ if (!d->object) {
+ } else if (type() & ValueTypeProperty) {
+ QString rv = d->core.name(d->object) + QLatin1Char('.');
+
+ QDeclarativeEnginePrivate *ep = d->context?QDeclarativeEnginePrivate::get(d->context->engine()):0;
+ QDeclarativeValueType *valueType = 0;
+ if (ep) valueType = ep->valueTypes[d->core.propType];
+ else valueType = QDeclarativeValueTypeFactory::valueType(d->core.propType);
+ Q_ASSERT(valueType);
+
+ rv += QString::fromUtf8(valueType->metaObject()->property(d->valueType.valueTypeCoreIdx).name());
+
+ if (!ep) delete valueType;
+
+ d->nameCache = rv;
+ } else if (type() & SignalProperty) {
+ QString name = QLatin1String("on") + d->core.name(d->object);
+ name[2] = name.at(2).toUpper();
+ d->nameCache = name;
+ } else {
+ d->nameCache = d->core.name(d->object);
+ }
+ d->isNameCached = true;
+ }
+
+ return d->nameCache;
+}
+
+/*!
+ Returns the \l{QMetaProperty} {Qt property} associated with
+ this QML property.
+ */
+QMetaProperty QDeclarativeMetaProperty::property() const
+{
+ if (type() & Property && d->core.isValid() && d->object)
+ return d->object->metaObject()->property(d->core.coreIndex);
+ else
+ return QMetaProperty();
+}
+
+/*!
+ Return the QMetaMethod for this property if it is a SignalProperty,
+ otherwise returns an invalid QMetaMethod.
+*/
+QMetaMethod QDeclarativeMetaProperty::method() const
+{
+ if (type() & SignalProperty && d->object)
+ return d->object->metaObject()->method(d->core.coreIndex);
+ else
+ return QMetaMethod();
+}
+
+
+/*!
+ Returns the binding associated with this property, or 0 if no binding
+ exists.
+*/
+QDeclarativeAbstractBinding *QDeclarativeMetaProperty::binding() const
+{
+ if (!isProperty() || (type() & Attached) || !d->object)
+ return 0;
+
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(d->object);
+ if (!data)
+ return 0;
+
+ if (!data->hasBindingBit(d->core.coreIndex))
+ return 0;
+
+ QDeclarativeAbstractBinding *binding = data->bindings;
+ while (binding) {
+ // ### This wont work for value types
+ if (binding->propertyIndex() == d->core.coreIndex)
+ return binding;
+ binding = binding->m_nextBinding;
+ }
+ return 0;
+}
+
+/*!
+ Set the binding associated with this property to \a newBinding. Returns
+ the existing binding (if any), otherwise 0.
+
+ \a newBinding will be enabled, and the returned binding (if any) will be
+ disabled.
+
+ Ownership of \a newBinding transfers to QML. Ownership of the return value
+ is assumed by the caller.
+
+ \a flags is passed through to the binding and is used for the initial update (when
+ the binding sets the intial value, it will use these flags for the write).
+*/
+QDeclarativeAbstractBinding *
+QDeclarativeMetaProperty::setBinding(QDeclarativeAbstractBinding *newBinding, QDeclarativeMetaProperty::WriteFlags flags) const
+{
+ if (!isProperty() || (type() & Attached) || !d->object) {
+ if (newBinding)
+ newBinding->destroy();
+ return 0;
+ }
+
+ return d->setBinding(d->object, d->core, newBinding, flags);
+}
+
+QDeclarativeAbstractBinding *
+QDeclarativeMetaPropertyPrivate::setBinding(QObject *object, const QDeclarativePropertyCache::Data &core,
+ QDeclarativeAbstractBinding *newBinding, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object, 0 != newBinding);
+
+ if (data && data->hasBindingBit(core.coreIndex)) {
+ QDeclarativeAbstractBinding *binding = data->bindings;
+ while (binding) {
+ // ### This wont work for value types
+ if (binding->propertyIndex() == core.coreIndex) {
+ binding->setEnabled(false);
+
+ if (newBinding)
+ newBinding->setEnabled(true, flags);
+
+ return binding; // ### QDeclarativeAbstractBinding;
+ }
+
+ binding = binding->m_nextBinding;
+ }
+ }
+
+ if (newBinding)
+ newBinding->setEnabled(true, flags);
+
+ return 0;
+}
+/*!
+ Returns the expression associated with this signal property, or 0 if no
+ signal expression exists.
+*/
+QDeclarativeExpression *QDeclarativeMetaProperty::signalExpression() const
+{
+ if (!(type() & SignalProperty))
+ return 0;
+
+ const QObjectList &children = d->object->children();
+
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QObject *child = children.at(ii);
+
+ QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
+ if (signal && signal->index() == coreIndex())
+ return signal->expression();
+ }
+
+ return 0;
+}
+
+/*!
+ Set the signal expression associated with this signal property to \a expr.
+ Returns the existing signal expression (if any), otherwise 0.
+
+ Ownership of \a expr transfers to QML. Ownership of the return value is
+ assumed by the caller.
+*/
+QDeclarativeExpression *QDeclarativeMetaProperty::setSignalExpression(QDeclarativeExpression *expr) const
+{
+ if (!(type() & SignalProperty)) {
+ delete expr;
+ return 0;
+ }
+
+ const QObjectList &children = d->object->children();
+
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QObject *child = children.at(ii);
+
+ QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
+ if (signal && signal->index() == coreIndex())
+ return signal->setExpression(expr);
+ }
+
+ if (expr) {
+ QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(d->object, method(), d->object);
+ return signal->setExpression(expr);
+ } else {
+ return 0;
+ }
+}
+
+QMetaMethod QDeclarativeMetaPropertyPrivate::findSignal(QObject *obj, const QString &name)
+{
+ const QMetaObject *mo = obj->metaObject();
+
+ int methods = mo->methodCount();
+ for (int ii = methods - 1; ii >= 0; --ii) {
+ QMetaMethod method = mo->method(ii);
+ QString methodName = QString::fromUtf8(method.signature());
+ int idx = methodName.indexOf(QLatin1Char('('));
+ methodName = methodName.left(idx);
+
+ if (methodName == name)
+ return method;
+ }
+ return QMetaMethod();
+}
+
+QObject *QDeclarativeMetaPropertyPrivate::attachedObject() const
+{
+ if (attachedFunc == -1)
+ return 0;
+ else
+ return qmlAttachedPropertiesObjectById(attachedFunc, object);
+}
+
+/*!
+ Returns the property value.
+*/
+QVariant QDeclarativeMetaProperty::read() const
+{
+ if (!d->object)
+ return QVariant();
+
+ if (type() & SignalProperty) {
+
+ return QVariant();
+
+ } else if (type() & Property || type() & Attached) {
+
+ return d->readValueProperty();
+
+ }
+ return QVariant();
+}
+
+QVariant QDeclarativeMetaPropertyPrivate::readValueProperty()
+{
+ uint type = q->type();
+ if (type & QDeclarativeMetaProperty::Attached) {
+
+ return QVariant::fromValue(attachedObject());
+
+ } else if(type & QDeclarativeMetaProperty::ValueTypeProperty) {
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context);
+ QDeclarativeValueType *valueType = 0;
+ if (ep) valueType = ep->valueTypes[core.propType];
+ else valueType = QDeclarativeValueTypeFactory::valueType(core.propType);
+ Q_ASSERT(valueType);
+
+ valueType->read(object, core.coreIndex);
+
+ QVariant rv =
+ valueType->metaObject()->property(this->valueType.valueTypeCoreIdx).read(valueType);
+
+ if (!ep) delete valueType;
+ return rv;
+
+ } else if(core.flags & QDeclarativePropertyCache::Data::IsQList) {
+
+ QDeclarativeListProperty<QObject> prop;
+ void *args[] = { &prop, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
+ return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, context?context->engine():0));
+
+ } else {
+
+ return object->metaObject()->property(core.coreIndex).read(object.data());
+
+ }
+}
+
+//###
+//writeEnumProperty MIRRORS the relelvant bit of QMetaProperty::write AND MUST BE KEPT IN SYNC!
+//###
+bool QDeclarativeMetaPropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags)
+{
+ if (!object || !prop.isWritable())
+ return false;
+
+ QVariant v = value;
+ if (prop.isEnumType()) {
+ QMetaEnum menum = prop.enumerator();
+ if (v.userType() == QVariant::String
+#ifdef QT3_SUPPORT
+ || v.userType() == QVariant::CString
+#endif
+ ) {
+ if (prop.isFlagType())
+ v = QVariant(menum.keysToValue(value.toByteArray()));
+ else
+ v = QVariant(menum.keyToValue(value.toByteArray()));
+ } else if (v.userType() != QVariant::Int && v.userType() != QVariant::UInt) {
+ int enumMetaTypeId = QMetaType::type(QByteArray(menum.scope()) + "::" + menum.name());
+ if ((enumMetaTypeId == 0) || (v.userType() != enumMetaTypeId) || !v.constData())
+ return false;
+ v = QVariant(*reinterpret_cast<const int *>(v.constData()));
+ }
+ v.convert(QVariant::Int);
+ }
+
+ // the status variable is changed by qt_metacall to indicate what it did
+ // this feature is currently only used by QtDBus and should not be depended
+ // upon. Don't change it without looking into QDBusAbstractInterface first
+ // -1 (unchanged): normal qt_metacall, result stored in argv[0]
+ // changed: result stored directly in value, return the value of status
+ int status = -1;
+ void *argv[] = { v.data(), &v, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, idx, argv);
+ return status;
+}
+
+bool QDeclarativeMetaPropertyPrivate::writeValueProperty(const QVariant &value,
+ QDeclarativeMetaProperty::WriteFlags flags)
+{
+ // Remove any existing bindings on this property
+ if (!(flags & QDeclarativeMetaProperty::DontRemoveBinding)) {
+ QDeclarativeAbstractBinding *binding = q->setBinding(0);
+ if (binding) binding->destroy();
+ }
+
+ bool rv = false;
+ uint type = q->type();
+ if (type & QDeclarativeMetaProperty::ValueTypeProperty) {
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context);
+
+ QDeclarativeValueType *writeBack = 0;
+ if (ep) {
+ writeBack = ep->valueTypes[core.propType];
+ } else {
+ writeBack = QDeclarativeValueTypeFactory::valueType(core.propType);
+ }
+
+ writeBack->read(object, core.coreIndex);
+
+ QDeclarativePropertyCache::Data data = core;
+ data.flags = valueType.flags;
+ data.coreIndex = valueType.valueTypeCoreIdx;
+ data.propType = valueType.valueTypePropType;
+ rv = write(writeBack, data, value, context, flags);
+
+ writeBack->write(object, core.coreIndex, flags);
+ if (!ep) delete writeBack;
+
+ } else {
+
+ rv = write(object, core, value, context, flags);
+
+ }
+
+ return rv;
+}
+
+bool QDeclarativeMetaPropertyPrivate::write(QObject *object, const QDeclarativePropertyCache::Data &property,
+ const QVariant &value, QDeclarativeContext *context,
+ QDeclarativeMetaProperty::WriteFlags flags)
+{
+ int coreIdx = property.coreIndex;
+ int status = -1; //for dbus
+
+ if (property.flags & QDeclarativePropertyCache::Data::IsEnumType) {
+ QMetaProperty prop = object->metaObject()->property(property.coreIndex);
+ QVariant v = value;
+ // Enum values come through the script engine as doubles
+ if (value.userType() == QVariant::Double) {
+ double integral;
+ double fractional = modf(value.toDouble(), &integral);
+ if (qFuzzyIsNull(fractional))
+ v.convert(QVariant::Int);
+ }
+ return writeEnumProperty(prop, coreIdx, object, v, flags);
+ }
+
+ int propertyType = property.propType;
+ int variantType = value.userType();
+
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(context);
+
+ if (propertyType == QVariant::Url) {
+
+ QUrl u;
+ bool found = false;
+ if (variantType == QVariant::Url) {
+ u = value.toUrl();
+ found = true;
+ } else if (variantType == QVariant::ByteArray) {
+ u = QUrl(QString::fromUtf8(value.toByteArray()));
+ found = true;
+ } else if (variantType == QVariant::String) {
+ u = QUrl(value.toString());
+ found = true;
+ }
+
+ if (!found)
+ return false;
+
+ if (context && u.isRelative() && !u.isEmpty())
+ u = context->resolvedUrl(u);
+ int status = -1;
+ void *argv[] = { &u, 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, argv);
+
+ } else if (variantType == propertyType) {
+
+ void *a[] = { (void *)value.constData(), 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
+
+ } else if (qMetaTypeId<QVariant>() == propertyType) {
+
+ void *a[] = { (void *)&value, 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
+
+ } else if (property.flags & QDeclarativePropertyCache::Data::IsQObjectDerived) {
+
+ const QMetaObject *valMo = rawMetaObjectForType(enginePriv, value.userType());
+
+ if (!valMo)
+ return false;
+
+ QObject *o = *(QObject **)value.constData();
+ const QMetaObject *propMo = rawMetaObjectForType(enginePriv, propertyType);
+
+ if (o) valMo = o->metaObject();
+
+ if (canConvert(valMo, propMo)) {
+ void *args[] = { &o, 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx,
+ args);
+ } else if (!o && canConvert(propMo, valMo)) {
+ // In the case of a null QObject, we assign the null if there is
+ // any change that the null variant type could be up or down cast to
+ // the property type.
+ void *args[] = { &o, 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx,
+ args);
+ } else {
+ return false;
+ }
+
+ } else if (property.flags & QDeclarativePropertyCache::Data::IsQList) {
+
+ const QMetaObject *listType = 0;
+ if (enginePriv) {
+ listType = enginePriv->rawMetaObjectForType(enginePriv->listType(property.propType));
+ } else {
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(QDeclarativeMetaType::listType(property.propType));
+ if (!type) return false;
+ listType = type->baseMetaObject();
+ }
+ if (!listType) return false;
+
+ QDeclarativeListProperty<void> prop;
+ void *args[] = { &prop, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, coreIdx, args);
+
+ if (!prop.clear) return false;
+
+ prop.clear(&prop);
+
+ if (value.userType() == qMetaTypeId<QList<QObject *> >()) {
+ const QList<QObject *> &list = qvariant_cast<QList<QObject *> >(value);
+
+ for (int ii = 0; ii < list.count(); ++ii) {
+ QObject *o = list.at(ii);
+ if (!canConvert(o->metaObject(), listType))
+ o = 0;
+ prop.append(&prop, (void *)o);
+ }
+ } else {
+ QObject *o = enginePriv?enginePriv->toQObject(value):QDeclarativeMetaType::toQObject(value);
+ if (!canConvert(o->metaObject(), listType))
+ o = 0;
+ prop.append(&prop, (void *)o);
+ }
+
+ } else {
+ Q_ASSERT(variantType != propertyType);
+
+ QVariant v = value;
+ if (v.convert((QVariant::Type)propertyType)) {
+ void *a[] = { (void *)v.constData(), 0, &status, &flags};
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
+ } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) {
+ QDeclarativeMetaType::StringConverter con = QDeclarativeMetaType::customStringConverter(propertyType);
+ if (!con)
+ return false;
+
+ QVariant v = con(value.toString());
+ if (v.userType() == propertyType) {
+ void *a[] = { (void *)v.constData(), 0, &status, &flags};
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
+ }
+ } else if (variantType == QVariant::String) {
+ bool ok = false;
+ QVariant v = QDeclarativeStringConverters::variantFromString(value.toString(), propertyType, &ok);
+ if (!ok)
+ return false;
+
+ void *a[] = { (void *)v.constData(), 0, &status, &flags};
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
+ } else {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+const QMetaObject *QDeclarativeMetaPropertyPrivate::rawMetaObjectForType(QDeclarativeEnginePrivate *engine, int userType)
+{
+ if (engine) {
+ return engine->rawMetaObjectForType(userType);
+ } else {
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(userType);
+ return type?type->baseMetaObject():0;
+ }
+}
+
+/*!
+ Set the property value to \a value.
+*/
+bool QDeclarativeMetaProperty::write(const QVariant &value) const
+{
+ return write(value, 0);
+}
+
+/*!
+ Resets the property value.
+*/
+bool QDeclarativeMetaProperty::reset() const
+{
+ if (isResettable()) {
+ void *args[] = { 0 };
+ QMetaObject::metacall(d->object, QMetaObject::ResetProperty, d->core.coreIndex, args);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool QDeclarativeMetaProperty::write(const QVariant &value, QDeclarativeMetaProperty::WriteFlags flags) const
+{
+ if (d->object && type() & Property && d->core.isValid() && isWritable())
+ return d->writeValueProperty(value, flags);
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property has a change notifier signal, otherwise false.
+*/
+bool QDeclarativeMetaProperty::hasChangedNotifier() const
+{
+ if (type() & Property && !(type() & Attached) && d->object) {
+ return d->object->metaObject()->property(d->core.coreIndex).hasNotifySignal();
+ }
+ return false;
+}
+
+/*!
+ Returns true if the property needs a change notifier signal for bindings
+ to remain upto date, false otherwise.
+
+ Some properties, such as attached properties or those whose value never
+ changes, do not require a change notifier.
+*/
+bool QDeclarativeMetaProperty::needsChangedNotifier() const
+{
+ return type() & Property && !(type() & Attached) &&
+ !property().isConstant();
+}
+
+/*!
+ Connects the property's change notifier signal to the
+ specified \a method of the \a dest object and returns
+ true. Returns false if this metaproperty does not
+ represent a regular Qt property or if it has no
+ change notifier signal, or if the \a dest object does
+ not have the specified \a method.
+*/
+bool QDeclarativeMetaProperty::connectNotifier(QObject *dest, int method) const
+{
+ if (!(type() & Property) || (type() & Attached) || !d->object)
+ return false;
+
+ QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
+ if (prop.hasNotifySignal()) {
+ return QMetaObject::connect(d->object, prop.notifySignalIndex(), dest, method, Qt::DirectConnection);
+ } else {
+ return false;
+ }
+}
+
+/*!
+ Connects the property's change notifier signal to the
+ specified \a slot of the \a dest object and returns
+ true. Returns false if this metaproperty does not
+ represent a regular Qt property or if it has no
+ change notifier signal, or if the \a dest object does
+ not have the specified \a slot.
+*/
+bool QDeclarativeMetaProperty::connectNotifier(QObject *dest, const char *slot) const
+{
+ if (!(type() & Property) || (type() & Attached) || !d->object)
+ return false;
+
+ QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
+ if (prop.hasNotifySignal()) {
+ QByteArray signal(QByteArray("2") + prop.notifySignal().signature());
+ return QObject::connect(d->object, signal.constData(), dest, slot);
+ } else {
+ return false;
+ }
+}
+
+/*!
+ Return the Qt metaobject index of the property.
+*/
+int QDeclarativeMetaProperty::coreIndex() const
+{
+ return d->core.coreIndex;
+}
+
+/*! \internal */
+int QDeclarativeMetaProperty::valueTypeCoreIndex() const
+{
+ return d->valueType.valueTypeCoreIdx;
+}
+
+Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes);
+
+
+struct SerializedData {
+ QDeclarativeMetaProperty::Type type;
+ QDeclarativePropertyCache::Data core;
+};
+
+struct ValueTypeSerializedData : public SerializedData {
+ QDeclarativePropertyCache::ValueTypeData valueType;
+};
+
+QByteArray QDeclarativeMetaPropertyPrivate::saveValueType(const QMetaObject *metaObject, int index,
+ const QMetaObject *subObject, int subIndex)
+{
+ QMetaProperty prop = metaObject->property(index);
+ QMetaProperty subProp = subObject->property(subIndex);
+
+ ValueTypeSerializedData sd;
+ sd.type = QDeclarativeMetaProperty::ValueTypeProperty;
+ sd.core.load(metaObject->property(index));
+ sd.valueType.flags = QDeclarativePropertyCache::Data::flagsForProperty(subProp);
+ sd.valueType.valueTypeCoreIdx = subIndex;
+ sd.valueType.valueTypePropType = subProp.userType();
+
+ QByteArray rv((const char *)&sd, sizeof(sd));
+
+ return rv;
+}
+
+QByteArray QDeclarativeMetaPropertyPrivate::saveProperty(const QMetaObject *metaObject, int index)
+{
+ SerializedData sd;
+ sd.type = QDeclarativeMetaProperty::Property;
+ sd.core.load(metaObject->property(index));
+
+ QByteArray rv((const char *)&sd, sizeof(sd));
+ return rv;
+}
+
+QDeclarativeMetaProperty
+QDeclarativeMetaPropertyPrivate::restore(const QByteArray &data, QObject *object, QDeclarativeContext *ctxt)
+{
+ QDeclarativeMetaProperty prop;
+
+ if (data.isEmpty())
+ return prop;
+
+ prop.d->object = object;
+ prop.d->context = ctxt;
+
+ const SerializedData *sd = (const SerializedData *)data.constData();
+ if (sd->type == QDeclarativeMetaProperty::Property) {
+ prop.d->core = sd->core;
+ } else if(sd->type == QDeclarativeMetaProperty::ValueTypeProperty) {
+ const ValueTypeSerializedData *vt = (const ValueTypeSerializedData *)sd;
+ prop.d->core = vt->core;
+ prop.d->valueType = vt->valueType;
+ }
+
+ return prop;
+}
+
+/*!
+ \internal
+
+ Creates a QDeclarativeMetaProperty for the property \a name of \a obj. Unlike
+ the QDeclarativeMetaProperty(QObject*, QString, QDeclarativeContext*) constructor, this static function
+ will correctly handle dot properties, including value types and attached properties.
+*/
+QDeclarativeMetaProperty QDeclarativeMetaProperty::createProperty(QObject *obj,
+ const QString &name,
+ QDeclarativeContext *context)
+{
+ QDeclarativeTypeNameCache *typeNameCache = context?QDeclarativeContextPrivate::get(context)->imports:0;
+
+ QStringList path = name.split(QLatin1Char('.'));
+ QObject *object = obj;
+
+ for (int jj = 0; jj < path.count() - 1; ++jj) {
+ const QString &pathName = path.at(jj);
+
+ if (QDeclarativeTypeNameCache::Data *data = typeNameCache?typeNameCache->data(pathName):0) {
+ if (data->type) {
+ QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
+ if (!func)
+ return QDeclarativeMetaProperty();
+ object = qmlAttachedPropertiesObjectById(data->type->index(), object);
+ if (!object)
+ return QDeclarativeMetaProperty();
+ continue;
+ } else {
+ Q_ASSERT(data->typeNamespace);
+ ++jj;
+ data = data->typeNamespace->data(path.at(jj));
+ if (!data || !data->type)
+ return QDeclarativeMetaProperty();
+ QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
+ if (!func)
+ return QDeclarativeMetaProperty();
+ object = qmlAttachedPropertiesObjectById(data->type->index(), object);
+ if (!object)
+ return QDeclarativeMetaProperty();
+ continue;
+ }
+ }
+
+ QDeclarativeMetaProperty prop(object, pathName, context);
+
+ if (jj == path.count() - 2 && prop.propertyType() < (int)QVariant::UserType &&
+ qmlValueTypes()->valueTypes[prop.propertyType()]) {
+ // We're now at a value type property. We can use a global valuetypes array as we
+ // never actually use the objects, just look up their properties.
+ QObject *typeObject =
+ qmlValueTypes()->valueTypes[prop.propertyType()];
+ int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
+ if (idx == -1)
+ return QDeclarativeMetaProperty();
+ QMetaProperty vtProp = typeObject->metaObject()->property(idx);
+
+ QDeclarativeMetaProperty p = prop;
+ p.d->valueType.valueTypeCoreIdx = idx;
+ p.d->valueType.valueTypePropType = vtProp.userType();
+ return p;
+ }
+
+ QObject *objVal = QDeclarativeMetaType::toQObject(prop.read());
+ if (!objVal)
+ return QDeclarativeMetaProperty();
+ object = objVal;
+ }
+
+ const QString &propName = path.last();
+ QDeclarativeMetaProperty prop(object, propName, context);
+ if (!prop.isValid())
+ return QDeclarativeMetaProperty();
+ else
+ return prop;
+}
+
+/*!
+ Returns true if lhs and rhs refer to the same metaobject data
+*/
+bool QDeclarativeMetaPropertyPrivate::equal(const QMetaObject *lhs, const QMetaObject *rhs)
+{
+ return lhs == rhs || (1 && lhs && rhs && lhs->d.stringdata == rhs->d.stringdata);
+}
+
+/*!
+ Returns true if from inherits to.
+*/
+bool QDeclarativeMetaPropertyPrivate::canConvert(const QMetaObject *from, const QMetaObject *to)
+{
+ if (from && to == &QObject::staticMetaObject)
+ return true;
+
+ while (from) {
+ if (equal(from, to))
+ return true;
+ from = from->superClass();
+ }
+
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativemetaproperty.h b/src/declarative/qml/qdeclarativemetaproperty.h
new file mode 100644
index 0000000..4dd6668
--- /dev/null
+++ b/src/declarative/qml/qdeclarativemetaproperty.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEMETAPROPERTY_H
+#define QDECLARATIVEMETAPROPERTY_H
+
+#include <QtCore/qmetaobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QObject;
+class QDeclarativeAbstractBinding;
+class QDeclarativeExpression;
+class QStringList;
+class QVariant;
+struct QMetaObject;
+class QDeclarativeContext;
+class QDeclarativeEngine;
+
+class QDeclarativeMetaPropertyPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeMetaProperty
+{
+public:
+ enum PropertyCategory {
+ Unknown,
+ InvalidProperty,
+ Bindable,
+ List,
+ Object,
+ Normal
+ };
+ QDeclarativeMetaProperty();
+ QDeclarativeMetaProperty(QObject *);
+ QDeclarativeMetaProperty(QObject *, const QString &);
+ QDeclarativeMetaProperty(QObject *, QDeclarativeContext *);
+ QDeclarativeMetaProperty(QObject *, const QString &, QDeclarativeContext *);
+ QDeclarativeMetaProperty(const QDeclarativeMetaProperty &);
+ QDeclarativeMetaProperty &operator=(const QDeclarativeMetaProperty &);
+ ~QDeclarativeMetaProperty();
+
+ QString name() const;
+
+ QVariant read() const;
+ bool write(const QVariant &) const;
+ enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02 };
+ Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
+ bool write(const QVariant &, QDeclarativeMetaProperty::WriteFlags) const;
+ bool reset() const;
+
+ bool hasChangedNotifier() const;
+ bool needsChangedNotifier() const;
+ bool connectNotifier(QObject *dest, const char *slot) const;
+ bool connectNotifier(QObject *dest, int method) const;
+
+ QMetaMethod method() const;
+
+ enum Type { Invalid = 0x00,
+ Property = 0x01,
+ SignalProperty = 0x02,
+ Default = 0x08,
+ Attached = 0x10,
+ ValueTypeProperty = 0x20 };
+
+ Type type() const;
+ bool isProperty() const;
+ bool isDefault() const;
+ bool isWritable() const;
+ bool isDesignable() const;
+ bool isResettable() const;
+ bool isValid() const;
+ QObject *object() const;
+
+ PropertyCategory propertyCategory() const;
+
+ int propertyType() const;
+ const char *propertyTypeName() const;
+
+ bool operator==(const QDeclarativeMetaProperty &) const;
+
+ QMetaProperty property() const;
+
+ QDeclarativeAbstractBinding *binding() const;
+ QDeclarativeAbstractBinding *setBinding(QDeclarativeAbstractBinding *,
+ QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::DontRemoveBinding) const;
+
+ QDeclarativeExpression *signalExpression() const;
+ QDeclarativeExpression *setSignalExpression(QDeclarativeExpression *) const;
+
+ static QDeclarativeMetaProperty createProperty(QObject *, const QString &, QDeclarativeContext *context=0);
+
+ int coreIndex() const;
+ int valueTypeCoreIndex() const;
+private:
+ friend class QDeclarativeEnginePrivate;
+ friend class QDeclarativeMetaPropertyPrivate;
+ QDeclarativeMetaPropertyPrivate *d;
+};
+typedef QList<QDeclarativeMetaProperty> QDeclarativeMetaProperties;
+ Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeMetaProperty::WriteFlags)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEMETAPROPERTY_H
diff --git a/src/declarative/qml/qdeclarativemetaproperty_p.h b/src/declarative/qml/qdeclarativemetaproperty_p.h
new file mode 100644
index 0000000..9fd5ed2
--- /dev/null
+++ b/src/declarative/qml/qdeclarativemetaproperty_p.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEMETAPROPERTY_P_H
+#define QDECLARATIVEMETAPROPERTY_P_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 "qdeclarativemetaproperty.h"
+
+#include "qdeclarativepropertycache_p.h"
+#include "qdeclarativeguard_p.h"
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeContext;
+class QDeclarativeEnginePrivate;
+class QDeclarativeMetaPropertyPrivate
+{
+public:
+ QDeclarativeMetaPropertyPrivate()
+ : q(0), context(0), object(0), isDefaultProperty(false), isNameCached(false),
+ attachedFunc(-1) {}
+
+ QDeclarativeMetaPropertyPrivate(const QDeclarativeMetaPropertyPrivate &other)
+ : q(0), context(other.context), object(other.object),
+ isDefaultProperty(other.isDefaultProperty), isNameCached(other.isNameCached),
+ core(other.core), nameCache(other.nameCache),
+ valueType(other.valueType), attachedFunc(other.attachedFunc) {}
+
+ QDeclarativeMetaProperty *q;
+ QDeclarativeContext *context;
+ QDeclarativeGuard<QObject> object;
+
+ bool isDefaultProperty:1;
+ bool isNameCached:1;
+ QDeclarativePropertyCache::Data core;
+ QString nameCache;
+
+ // Describes the "virtual" value-type sub-property.
+ QDeclarativePropertyCache::ValueTypeData valueType;
+
+ // The attached property accessor
+ int attachedFunc;
+
+ void initProperty(QObject *obj, const QString &name);
+ void initDefault(QObject *obj);
+
+ QObject *attachedObject() const;
+ QMetaMethod findSignal(QObject *, const QString &);
+
+ int propertyType() const;
+ QDeclarativeMetaProperty::PropertyCategory propertyCategory() const;
+
+ QVariant readValueProperty();
+ bool writeValueProperty(const QVariant &, QDeclarativeMetaProperty::WriteFlags);
+
+ static const QMetaObject *rawMetaObjectForType(QDeclarativeEnginePrivate *, int);
+ static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags);
+ static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContext *,
+ QDeclarativeMetaProperty::WriteFlags flags = 0);
+ static QDeclarativeAbstractBinding *setBinding(QObject *, const QDeclarativePropertyCache::Data &, QDeclarativeAbstractBinding *,
+ QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::DontRemoveBinding);
+
+ static QByteArray saveValueType(const QMetaObject *, int,
+ const QMetaObject *, int);
+ static QByteArray saveProperty(const QMetaObject *, int);
+ static QDeclarativeMetaProperty restore(const QByteArray &, QObject *, QDeclarativeContext * = 0);
+
+ static bool equal(const QMetaObject *, const QMetaObject *);
+ static bool canConvert(const QMetaObject *from, const QMetaObject *to);
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEMETAPROPERTY_P_H
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
new file mode 100644
index 0000000..8f78843
--- /dev/null
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -0,0 +1,1153 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativemetatype.h"
+
+#include "qdeclarativeproxymetaobject_p.h"
+#include "qdeclarativecustomparser_p.h"
+#include "qdeclarativeguard_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qmetaobject.h>
+#include <QtCore/qbitarray.h>
+#include <QtCore/qreadwritelock.h>
+#include <qmetatype.h>
+#include <qobjectdefs.h>
+#include <qdatetime.h>
+#include <qbytearray.h>
+#include <qreadwritelock.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qvector.h>
+#include <qlocale.h>
+#include <QtCore/qcryptographichash.h>
+#include <QtScript/qscriptvalue.h>
+
+#include <ctype.h>
+
+#ifdef QT_BOOTSTRAPPED
+# ifndef QT_NO_GEOM_VARIANT
+# define QT_NO_GEOM_VARIANT
+# endif
+#else
+# include <qbitarray.h>
+# include <qurl.h>
+# include <qvariant.h>
+#endif
+
+#ifndef QT_NO_GEOM_VARIANT
+# include <qsize.h>
+# include <qpoint.h>
+# include <qrect.h>
+# include <qline.h>
+# include <qvector3d.h>
+#endif
+#define NS(x) QT_PREPEND_NAMESPACE(x)
+
+QT_BEGIN_NAMESPACE
+
+struct QDeclarativeMetaTypeData
+{
+ ~QDeclarativeMetaTypeData();
+ QList<QDeclarativeType *> types;
+ typedef QHash<int, QDeclarativeType *> Ids;
+ Ids idToType;
+ typedef QHash<QByteArray, QDeclarativeType *> Names;
+ Names nameToType;
+ typedef QHash<const QMetaObject *, QDeclarativeType *> MetaObjects;
+ MetaObjects metaObjectToType;
+ typedef QHash<int, QDeclarativeMetaType::StringConverter> StringConverters;
+ StringConverters stringConverters;
+
+ QBitArray objects;
+ QBitArray interfaces;
+ QBitArray lists;
+};
+Q_GLOBAL_STATIC(QDeclarativeMetaTypeData, metaTypeData)
+Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock)
+
+QDeclarativeMetaTypeData::~QDeclarativeMetaTypeData()
+{
+ for (int i = 0; i < types.count(); ++i)
+ delete types.at(i);
+}
+
+class QDeclarativeTypePrivate
+{
+public:
+ QDeclarativeTypePrivate();
+
+ void init() const;
+
+ bool m_isInterface : 1;
+ const char *m_iid;
+ QByteArray m_name;
+ int m_version_maj;
+ int m_version_min;
+ int m_typeId; int m_listId;
+ QObject *(*m_newFunc)();
+ const QMetaObject *m_baseMetaObject;
+ QDeclarativeAttachedPropertiesFunc m_attachedPropertiesFunc;
+ const QMetaObject *m_attachedPropertiesType;
+ int m_parserStatusCast;
+ int m_propertyValueSourceCast;
+ int m_propertyValueInterceptorCast;
+ QDeclarativePrivate::CreateFunc m_extFunc;
+ const QMetaObject *m_extMetaObject;
+ int m_index;
+ QDeclarativeCustomParser *m_customParser;
+ mutable volatile bool m_isSetup:1;
+ mutable QList<QDeclarativeProxyMetaObject::ProxyData> m_metaObjects;
+};
+
+QDeclarativeTypePrivate::QDeclarativeTypePrivate()
+: m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0),
+ m_newFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_attachedPropertiesType(0),
+ m_parserStatusCast(-1), m_propertyValueSourceCast(-1), m_propertyValueInterceptorCast(-1),
+ m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0), m_isSetup(false)
+{
+}
+
+
+QDeclarativeType::QDeclarativeType(int type, int listType, const char *iid, int index)
+: d(new QDeclarativeTypePrivate)
+{
+ d->m_isInterface = true;
+ d->m_iid = iid;
+ d->m_typeId = type;
+ d->m_listId = listType;
+ d->m_newFunc = 0;
+ d->m_index = index;
+ d->m_isSetup = true;
+ d->m_version_maj = 0;
+ d->m_version_min = 0;
+}
+
+QDeclarativeType::QDeclarativeType(int type, int listType,
+ QObject *(*newFunc)(), const char *qmlName,
+ int version_maj, int version_min,
+ const QMetaObject *metaObject,
+ QDeclarativeAttachedPropertiesFunc attachedPropertiesFunc,
+ const QMetaObject *attachedType,
+ int parserStatusCast, int propertyValueSourceCast, int propertyValueInterceptorCast,
+ QDeclarativePrivate::CreateFunc extFunc,
+ const QMetaObject *extMetaObject, int index,
+ QDeclarativeCustomParser *customParser)
+: d(new QDeclarativeTypePrivate)
+{
+ d->m_name = qmlName;
+ d->m_version_maj = version_maj;
+ d->m_version_min = version_min;
+ d->m_typeId = type;
+ d->m_listId = listType;
+ d->m_newFunc = newFunc;
+ d->m_baseMetaObject = metaObject;
+ d->m_attachedPropertiesFunc = attachedPropertiesFunc;
+ d->m_attachedPropertiesType = attachedType;
+ d->m_parserStatusCast = parserStatusCast;
+ d->m_propertyValueSourceCast = propertyValueSourceCast;
+ d->m_propertyValueInterceptorCast = propertyValueInterceptorCast;
+ d->m_extFunc = extFunc;
+ d->m_index = index;
+ d->m_customParser = customParser;
+
+ if (extMetaObject)
+ d->m_extMetaObject = extMetaObject;
+}
+
+QDeclarativeType::~QDeclarativeType()
+{
+ delete d->m_customParser;
+ delete d;
+}
+
+int QDeclarativeType::majorVersion() const
+{
+ return d->m_version_maj;
+}
+
+int QDeclarativeType::minorVersion() const
+{
+ return d->m_version_min;
+}
+
+bool QDeclarativeType::availableInVersion(int vmajor, int vminor) const
+{
+ return vmajor > d->m_version_maj || (vmajor == d->m_version_maj && vminor >= d->m_version_min);
+}
+
+void QDeclarativeTypePrivate::init() const
+{
+ if (m_isSetup) return;
+
+ QWriteLocker lock(metaTypeDataLock());
+ if (m_isSetup)
+ return;
+
+ // Setup extended meta object
+ // XXX - very inefficient
+ const QMetaObject *mo = m_baseMetaObject;
+ if (m_extFunc) {
+ QMetaObject *mmo = new QMetaObject;
+ *mmo = *m_extMetaObject;
+ mmo->d.superdata = mo;
+ QDeclarativeProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0, 0 };
+ m_metaObjects << data;
+ }
+
+ mo = mo->d.superdata;
+ while(mo) {
+ QDeclarativeType *t = metaTypeData()->metaObjectToType.value(mo);
+ if (t) {
+ if (t->d->m_extFunc) {
+ QMetaObject *mmo = new QMetaObject;
+ *mmo = *t->d->m_extMetaObject;
+ mmo->d.superdata = m_baseMetaObject;
+ if (!m_metaObjects.isEmpty())
+ m_metaObjects.last().metaObject->d.superdata = mmo;
+ QDeclarativeProxyMetaObject::ProxyData data = { mmo, t->d->m_extFunc, 0, 0 };
+ m_metaObjects << data;
+ }
+ }
+ mo = mo->d.superdata;
+ }
+
+ for (int ii = 0; ii < m_metaObjects.count(); ++ii) {
+ m_metaObjects[ii].propertyOffset =
+ m_metaObjects.at(ii).metaObject->propertyOffset();
+ m_metaObjects[ii].methodOffset =
+ m_metaObjects.at(ii).metaObject->methodOffset();
+ }
+
+ m_isSetup = true;
+ lock.unlock();
+}
+
+QByteArray QDeclarativeType::typeName() const
+{
+ if (d->m_baseMetaObject)
+ return d->m_baseMetaObject->className();
+ else
+ return QByteArray();
+}
+
+QByteArray QDeclarativeType::qmlTypeName() const
+{
+ return d->m_name;
+}
+
+QObject *QDeclarativeType::create() const
+{
+ d->init();
+
+ QObject *rv = d->m_newFunc();
+ if (rv && !d->m_metaObjects.isEmpty())
+ (void *)new QDeclarativeProxyMetaObject(rv, &d->m_metaObjects);
+
+ return rv;
+}
+
+QDeclarativeCustomParser *QDeclarativeType::customParser() const
+{
+ return d->m_customParser;
+}
+
+bool QDeclarativeType::isInterface() const
+{
+ return d->m_isInterface;
+}
+
+int QDeclarativeType::typeId() const
+{
+ return d->m_typeId;
+}
+
+int QDeclarativeType::qListTypeId() const
+{
+ return d->m_listId;
+}
+
+const QMetaObject *QDeclarativeType::metaObject() const
+{
+ d->init();
+
+ if (d->m_metaObjects.isEmpty())
+ return d->m_baseMetaObject;
+ else
+ return d->m_metaObjects.first().metaObject;
+
+}
+
+const QMetaObject *QDeclarativeType::baseMetaObject() const
+{
+ return d->m_baseMetaObject;
+}
+
+QDeclarativeAttachedPropertiesFunc QDeclarativeType::attachedPropertiesFunction() const
+{
+ return d->m_attachedPropertiesFunc;
+}
+
+const QMetaObject *QDeclarativeType::attachedPropertiesType() const
+{
+ return d->m_attachedPropertiesType;
+}
+
+int QDeclarativeType::parserStatusCast() const
+{
+ return d->m_parserStatusCast;
+}
+
+int QDeclarativeType::propertyValueSourceCast() const
+{
+ return d->m_propertyValueSourceCast;
+}
+
+int QDeclarativeType::propertyValueInterceptorCast() const
+{
+ return d->m_propertyValueInterceptorCast;
+}
+
+const char *QDeclarativeType::interfaceIId() const
+{
+ return d->m_iid;
+}
+
+int QDeclarativeType::index() const
+{
+ return d->m_index;
+}
+
+int QDeclarativeMetaType::registerInterface(const QDeclarativePrivate::MetaTypeIds &id,
+ const char *iid)
+{
+ QWriteLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+
+ int index = data->types.count();
+
+ QDeclarativeType *type = new QDeclarativeType(id.typeId, id.listId, iid, index);
+
+ data->types.append(type);
+ data->idToType.insert(type->typeId(), type);
+ data->idToType.insert(type->qListTypeId(), type);
+ // XXX No insertMulti, so no multi-version interfaces?
+ if (!type->qmlTypeName().isEmpty())
+ data->nameToType.insert(type->qmlTypeName(), type);
+
+ if (data->interfaces.size() <= id.typeId)
+ data->interfaces.resize(id.typeId + 16);
+ if (data->lists.size() <= id.listId)
+ data->lists.resize(id.listId + 16);
+ data->interfaces.setBit(id.typeId, true);
+ data->lists.setBit(id.listId, true);
+
+ return index;
+}
+
+int QDeclarativeMetaType::registerType(const QDeclarativePrivate::MetaTypeIds &id, QObject *(*func)(),
+ const char *uri, int version_maj, int version_min, const char *cname,
+ const QMetaObject *mo, QDeclarativeAttachedPropertiesFunc attach, const QMetaObject *attachMo,
+ int pStatus, int object, int valueSource, int valueInterceptor, QDeclarativePrivate::CreateFunc extFunc, const QMetaObject *extmo, QDeclarativeCustomParser *parser)
+{
+ Q_UNUSED(object);
+
+ if (cname) {
+ for (int ii = 0; cname[ii]; ++ii) {
+ if (!isalnum(cname[ii])) {
+ qWarning("QDeclarativeMetaType: Invalid QML name %s", cname);
+ return -1;
+ }
+ }
+ }
+
+ QWriteLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ int index = data->types.count();
+
+ QByteArray name = uri;
+ if (uri)
+ name += '/';
+ name += cname;
+
+ QDeclarativeType *type = new QDeclarativeType(id.typeId, id.listId,
+ func, name, version_maj, version_min, mo, attach, attachMo, pStatus,
+ valueSource, valueInterceptor, extFunc, extmo, index, parser);
+
+ data->types.append(type);
+ data->idToType.insert(type->typeId(), type);
+ data->idToType.insert(type->qListTypeId(), type);
+
+ if (!type->qmlTypeName().isEmpty())
+ data->nameToType.insertMulti(type->qmlTypeName(), type);
+
+ data->metaObjectToType.insert(type->baseMetaObject(), type);
+
+ if (data->objects.size() <= id.typeId)
+ data->objects.resize(id.typeId + 16);
+ if (data->lists.size() <= id.listId)
+ data->lists.resize(id.listId + 16);
+ data->objects.setBit(id.typeId, true);
+ data->lists.setBit(id.listId, true);
+
+ return index;
+}
+
+QObject *QDeclarativeMetaType::toQObject(const QVariant &v, bool *ok)
+{
+ if (!isQObject(v.userType())) {
+ if (ok) *ok = false;
+ return 0;
+ }
+
+ if (ok) *ok = true;
+
+ return *(QObject **)v.constData();
+}
+
+bool QDeclarativeMetaType::isQObject(int userType)
+{
+ if (userType == QMetaType::QObjectStar)
+ return true;
+
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ return userType >= 0 && userType < data->objects.size() && data->objects.testBit(userType);
+}
+
+/*
+ Returns the item type for a list of type \a id.
+ */
+int QDeclarativeMetaType::listType(int id)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ QDeclarativeType *type = data->idToType.value(id);
+ if (type && type->qListTypeId() == id)
+ return type->typeId();
+ else
+ return 0;
+}
+
+int QDeclarativeMetaType::attachedPropertiesFuncId(const QMetaObject *mo)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+
+ QDeclarativeType *type = data->metaObjectToType.value(mo);
+ if (type && type->attachedPropertiesFunction())
+ return type->index();
+ else
+ return -1;
+}
+
+QDeclarativeAttachedPropertiesFunc QDeclarativeMetaType::attachedPropertiesFuncById(int id)
+{
+ if (id < 0)
+ return 0;
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ return data->types.at(id)->attachedPropertiesFunction();
+}
+
+QMetaProperty QDeclarativeMetaType::defaultProperty(const QMetaObject *metaObject)
+{
+ int idx = metaObject->indexOfClassInfo("DefaultProperty");
+ if (-1 == idx)
+ return QMetaProperty();
+
+ QMetaClassInfo info = metaObject->classInfo(idx);
+ if (!info.value())
+ return QMetaProperty();
+
+ idx = metaObject->indexOfProperty(info.value());
+ if (-1 == idx)
+ return QMetaProperty();
+
+ return metaObject->property(idx);
+}
+
+QMetaProperty QDeclarativeMetaType::defaultProperty(QObject *obj)
+{
+ if (!obj)
+ return QMetaProperty();
+
+ const QMetaObject *metaObject = obj->metaObject();
+ return defaultProperty(metaObject);
+}
+
+QMetaMethod QDeclarativeMetaType::defaultMethod(const QMetaObject *metaObject)
+{
+ int idx = metaObject->indexOfClassInfo("DefaultMethod");
+ if (-1 == idx)
+ return QMetaMethod();
+
+ QMetaClassInfo info = metaObject->classInfo(idx);
+ if (!info.value())
+ return QMetaMethod();
+
+ idx = metaObject->indexOfMethod(info.value());
+ if (-1 == idx)
+ return QMetaMethod();
+
+ return metaObject->method(idx);
+}
+
+QMetaMethod QDeclarativeMetaType::defaultMethod(QObject *obj)
+{
+ if (!obj)
+ return QMetaMethod();
+
+ const QMetaObject *metaObject = obj->metaObject();
+ return defaultMethod(metaObject);
+}
+
+QDeclarativeMetaType::TypeCategory QDeclarativeMetaType::typeCategory(int userType)
+{
+ if (userType < 0)
+ return Unknown;
+ if (userType == QMetaType::QObjectStar)
+ return Object;
+
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ if (userType < data->objects.size() && data->objects.testBit(userType))
+ return Object;
+ else if (userType < data->lists.size() && data->lists.testBit(userType))
+ return List;
+ else
+ return Unknown;
+}
+
+bool QDeclarativeMetaType::isInterface(int userType)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ return userType >= 0 && userType < data->interfaces.size() && data->interfaces.testBit(userType);
+}
+
+const char *QDeclarativeMetaType::interfaceIId(int userType)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ QDeclarativeType *type = data->idToType.value(userType);
+ lock.unlock();
+ if (type && type->isInterface() && type->typeId() == userType)
+ return type->interfaceIId();
+ else
+ return 0;
+}
+
+bool QDeclarativeMetaType::isList(int userType)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ return userType >= 0 && userType < data->lists.size() && data->lists.testBit(userType);
+}
+
+/*!
+ A custom string convertor allows you to specify a function pointer that
+ returns a variant of \a type. For example, if you have written your own icon
+ class that you want to support as an object property assignable in QML:
+
+ \code
+ int type = qRegisterMetaType<SuperIcon>("SuperIcon");
+ QML::addCustomStringConvertor(type, &SuperIcon::pixmapFromString);
+ \endcode
+
+ The function pointer must be of the form:
+ \code
+ QVariant (*StringConverter)(const QString &);
+ \endcode
+ */
+void QDeclarativeMetaType::registerCustomStringConverter(int type, StringConverter converter)
+{
+ QWriteLocker lock(metaTypeDataLock());
+
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ if (data->stringConverters.contains(type))
+ return;
+ data->stringConverters.insert(type, converter);
+}
+
+/*!
+ Return the custom string converter for \a type, previously installed through
+ registerCustomStringConverter()
+ */
+QDeclarativeMetaType::StringConverter QDeclarativeMetaType::customStringConverter(int type)
+{
+ QReadLocker lock(metaTypeDataLock());
+
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ return data->stringConverters.value(type);
+}
+
+/*!
+ Returns the type (if any) of URI-qualified named \a name in version specified
+ by \a version_major and \a version_minor.
+*/
+QDeclarativeType *QDeclarativeMetaType::qmlType(const QByteArray &name, int version_major, int version_minor)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+
+ QList<QDeclarativeType*> types = data->nameToType.values(name);
+ foreach (QDeclarativeType *t, types) {
+ // XXX version_major<0 just a kludge for QDeclarativeMetaPropertyPrivate::initProperty
+ if (version_major<0 || t->availableInVersion(version_major,version_minor))
+ return t;
+ }
+ return 0;
+}
+
+/*!
+ Returns the type (if any) that corresponds to the \a metaObject. Returns null if no
+ type is registered.
+*/
+QDeclarativeType *QDeclarativeMetaType::qmlType(const QMetaObject *metaObject)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+
+ return data->metaObjectToType.value(metaObject);
+}
+
+/*!
+ Returns the type (if any) that corresponds to the QVariant::Type \a userType.
+ Returns null if no type is registered.
+*/
+QDeclarativeType *QDeclarativeMetaType::qmlType(int userType)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+
+ QDeclarativeType *type = data->idToType.value(userType);
+ if (type && type->typeId() == userType)
+ return type;
+ else
+ return 0;
+}
+
+/*!
+ Returns the list of registered QML type names.
+*/
+QList<QByteArray> QDeclarativeMetaType::qmlTypeNames()
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+
+ return data->nameToType.keys();
+}
+
+/*!
+ Returns the list of registered QML types.
+*/
+QList<QDeclarativeType*> QDeclarativeMetaType::qmlTypes()
+{
+ QReadLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+
+ return data->nameToType.values();
+}
+
+QT_END_NAMESPACE
+
+#include <QtGui/qfont.h>
+#include <QtGui/qpixmap.h>
+#include <QtGui/qbrush.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qpalette.h>
+#include <QtGui/qicon.h>
+#include <QtGui/qimage.h>
+#include <QtGui/qpolygon.h>
+#include <QtGui/qregion.h>
+#include <QtGui/qbitmap.h>
+#include <QtGui/qcursor.h>
+#include <QtGui/qsizepolicy.h>
+#include <QtGui/qkeysequence.h>
+#include <QtGui/qpen.h>
+
+//#include <QtGui/qtextlength.h>
+#include <QtGui/qtextformat.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qtransform.h>
+#include <QtGui/qmatrix4x4.h>
+#include <QtGui/qvector2d.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
+#include <QtGui/qquaternion.h>
+
+Q_DECLARE_METATYPE(QScriptValue);
+
+QT_BEGIN_NAMESPACE
+/*!
+ Copies \a copy into \a data, assuming they both are of type \a type. If
+ \a copy is zero, a default type is copied. Returns true if the copy was
+ successful and false if not.
+
+ \note This should move into QMetaType once complete
+
+*/
+bool QDeclarativeMetaType::copy(int type, void *data, const void *copy)
+{
+ if (copy) {
+ switch(type) {
+ case QMetaType::VoidStar:
+ case QMetaType::QObjectStar:
+ case QMetaType::QWidgetStar:
+ *static_cast<void **>(data) = *static_cast<void* const *>(copy);
+ return true;
+ case QMetaType::Long:
+ *static_cast<long *>(data) = *static_cast<const long*>(copy);
+ return true;
+ case QMetaType::Int:
+ *static_cast<int *>(data) = *static_cast<const int*>(copy);
+ return true;
+ case QMetaType::Short:
+ *static_cast<short *>(data) = *static_cast<const short*>(copy);
+ return true;
+ case QMetaType::Char:
+ *static_cast<char *>(data) = *static_cast<const char*>(copy);
+ return true;
+ case QMetaType::ULong:
+ *static_cast<ulong *>(data) = *static_cast<const ulong*>(copy);
+ return true;
+ case QMetaType::UInt:
+ *static_cast<uint *>(data) = *static_cast<const uint*>(copy);
+ return true;
+ case QMetaType::LongLong:
+ *static_cast<qlonglong *>(data) = *static_cast<const qlonglong*>(copy);
+ return true;
+ case QMetaType::ULongLong:
+ *static_cast<qulonglong *>(data) = *static_cast<const qulonglong*>(copy);
+ return true;
+ case QMetaType::UShort:
+ *static_cast<ushort *>(data) = *static_cast<const ushort*>(copy);
+ return true;
+ case QMetaType::UChar:
+ *static_cast<uchar *>(data) = *static_cast<const uchar*>(copy);
+ return true;
+ case QMetaType::Bool:
+ *static_cast<bool *>(data) = *static_cast<const bool*>(copy);
+ return true;
+ case QMetaType::Float:
+ *static_cast<float *>(data) = *static_cast<const float*>(copy);
+ return true;
+ case QMetaType::Double:
+ *static_cast<double *>(data) = *static_cast<const double*>(copy);
+ return true;
+ case QMetaType::QChar:
+ *static_cast<NS(QChar) *>(data) = *static_cast<const NS(QChar)*>(copy);
+ return true;
+ case QMetaType::QVariantMap:
+ *static_cast<NS(QVariantMap) *>(data) = *static_cast<const NS(QVariantMap)*>(copy);
+ return true;
+ case QMetaType::QVariantHash:
+ *static_cast<NS(QVariantHash) *>(data) = *static_cast<const NS(QVariantHash)*>(copy);
+ return true;
+ case QMetaType::QVariantList:
+ *static_cast<NS(QVariantList) *>(data) = *static_cast<const NS(QVariantList)*>(copy);
+ return true;
+ case QMetaType::QByteArray:
+ *static_cast<NS(QByteArray) *>(data) = *static_cast<const NS(QByteArray)*>(copy);
+ return true;
+ case QMetaType::QString:
+ *static_cast<NS(QString) *>(data) = *static_cast<const NS(QString)*>(copy);
+ return true;
+ case QMetaType::QStringList:
+ *static_cast<NS(QStringList) *>(data) = *static_cast<const NS(QStringList)*>(copy);
+ return true;
+ case QMetaType::QBitArray:
+ *static_cast<NS(QBitArray) *>(data) = *static_cast<const NS(QBitArray)*>(copy);
+ return true;
+ case QMetaType::QDate:
+ *static_cast<NS(QDate) *>(data) = *static_cast<const NS(QDate)*>(copy);
+ return true;
+ case QMetaType::QTime:
+ *static_cast<NS(QTime) *>(data) = *static_cast<const NS(QTime)*>(copy);
+ return true;
+ case QMetaType::QDateTime:
+ *static_cast<NS(QDateTime) *>(data) = *static_cast<const NS(QDateTime)*>(copy);
+ return true;
+ case QMetaType::QUrl:
+ *static_cast<NS(QUrl) *>(data) = *static_cast<const NS(QUrl)*>(copy);
+ return true;
+ case QMetaType::QLocale:
+ *static_cast<NS(QLocale) *>(data) = *static_cast<const NS(QLocale)*>(copy);
+ return true;
+ case QMetaType::QRect:
+ *static_cast<NS(QRect) *>(data) = *static_cast<const NS(QRect)*>(copy);
+ return true;
+ case QMetaType::QRectF:
+ *static_cast<NS(QRectF) *>(data) = *static_cast<const NS(QRectF)*>(copy);
+ return true;
+ case QMetaType::QSize:
+ *static_cast<NS(QSize) *>(data) = *static_cast<const NS(QSize)*>(copy);
+ return true;
+ case QMetaType::QSizeF:
+ *static_cast<NS(QSizeF) *>(data) = *static_cast<const NS(QSizeF)*>(copy);
+ return true;
+ case QMetaType::QLine:
+ *static_cast<NS(QLine) *>(data) = *static_cast<const NS(QLine)*>(copy);
+ return true;
+ case QMetaType::QLineF:
+ *static_cast<NS(QLineF) *>(data) = *static_cast<const NS(QLineF)*>(copy);
+ return true;
+ case QMetaType::QPoint:
+ *static_cast<NS(QPoint) *>(data) = *static_cast<const NS(QPoint)*>(copy);
+ return true;
+ case QMetaType::QPointF:
+ *static_cast<NS(QPointF) *>(data) = *static_cast<const NS(QPointF)*>(copy);
+ return true;
+ case QMetaType::QVector3D:
+ *static_cast<NS(QVector3D) *>(data) = *static_cast<const NS(QVector3D)*>(copy);
+ return true;
+#ifndef QT_NO_REGEXP
+ case QMetaType::QRegExp:
+ *static_cast<NS(QRegExp) *>(data) = *static_cast<const NS(QRegExp)*>(copy);
+ return true;
+#endif
+ case QMetaType::Void:
+ return true;
+
+
+#ifdef QT3_SUPPORT
+ case QMetaType::QColorGroup:
+ *static_cast<NS(QColorGroup) *>(data) = *static_cast<const NS(QColorGroup)*>(copy);
+ return true;
+#endif
+
+ case QMetaType::QFont:
+ *static_cast<NS(QFont) *>(data) = *static_cast<const NS(QFont)*>(copy);
+ return true;
+ case QMetaType::QPixmap:
+ *static_cast<NS(QPixmap) *>(data) = *static_cast<const NS(QPixmap)*>(copy);
+ return true;
+ case QMetaType::QBrush:
+ *static_cast<NS(QBrush) *>(data) = *static_cast<const NS(QBrush)*>(copy);
+ return true;
+ case QMetaType::QColor:
+ *static_cast<NS(QColor) *>(data) = *static_cast<const NS(QColor)*>(copy);
+ return true;
+ case QMetaType::QPalette:
+ *static_cast<NS(QPalette) *>(data) = *static_cast<const NS(QPalette)*>(copy);
+ return true;
+ case QMetaType::QIcon:
+ *static_cast<NS(QIcon) *>(data) = *static_cast<const NS(QIcon)*>(copy);
+ return true;
+ case QMetaType::QImage:
+ *static_cast<NS(QImage) *>(data) = *static_cast<const NS(QImage)*>(copy);
+ return true;
+ case QMetaType::QPolygon:
+ *static_cast<NS(QPolygon) *>(data) = *static_cast<const NS(QPolygon)*>(copy);
+ return true;
+ case QMetaType::QRegion:
+ *static_cast<NS(QRegion) *>(data) = *static_cast<const NS(QRegion)*>(copy);
+ return true;
+ case QMetaType::QBitmap:
+ *static_cast<NS(QBitmap) *>(data) = *static_cast<const NS(QBitmap)*>(copy);
+ return true;
+#ifndef QT_NO_CURSOR
+ case QMetaType::QCursor:
+ *static_cast<NS(QCursor) *>(data) = *static_cast<const NS(QCursor)*>(copy);
+ return true;
+#endif
+ case QMetaType::QSizePolicy:
+ *static_cast<NS(QSizePolicy) *>(data) = *static_cast<const NS(QSizePolicy)*>(copy);
+ return true;
+ case QMetaType::QKeySequence:
+ *static_cast<NS(QKeySequence) *>(data) = *static_cast<const NS(QKeySequence)*>(copy);
+ return true;
+ case QMetaType::QPen:
+ *static_cast<NS(QPen) *>(data) = *static_cast<const NS(QPen)*>(copy);
+ return true;
+ case QMetaType::QTextLength:
+ *static_cast<NS(QTextLength) *>(data) = *static_cast<const NS(QTextLength)*>(copy);
+ return true;
+ case QMetaType::QTextFormat:
+ *static_cast<NS(QTextFormat) *>(data) = *static_cast<const NS(QTextFormat)*>(copy);
+ return true;
+ case QMetaType::QMatrix:
+ *static_cast<NS(QMatrix) *>(data) = *static_cast<const NS(QMatrix)*>(copy);
+ return true;
+ case QMetaType::QTransform:
+ *static_cast<NS(QTransform) *>(data) = *static_cast<const NS(QTransform)*>(copy);
+ return true;
+ case QMetaType::QMatrix4x4:
+ *static_cast<NS(QMatrix4x4) *>(data) = *static_cast<const NS(QMatrix4x4)*>(copy);
+ return true;
+ case QMetaType::QVector2D:
+ *static_cast<NS(QVector2D) *>(data) = *static_cast<const NS(QVector2D)*>(copy);
+ return true;
+ case QMetaType::QVector4D:
+ *static_cast<NS(QVector4D) *>(data) = *static_cast<const NS(QVector4D)*>(copy);
+ return true;
+ case QMetaType::QQuaternion:
+ *static_cast<NS(QQuaternion) *>(data) = *static_cast<const NS(QQuaternion)*>(copy);
+ return true;
+
+ default:
+ if (type == qMetaTypeId<QVariant>()) {
+ *static_cast<NS(QVariant) *>(data) = *static_cast<const NS(QVariant)*>(copy);
+ return true;
+ } else if (type == qMetaTypeId<QScriptValue>()) {
+ *static_cast<NS(QScriptValue) *>(data) = *static_cast<const NS(QScriptValue)*>(copy);
+ return true;
+ } else if (typeCategory(type) != Unknown) {
+ *static_cast<void **>(data) = *static_cast<void* const *>(copy);
+ return true;
+ }
+ break;
+ }
+ } else {
+ switch(type) {
+ case QMetaType::VoidStar:
+ case QMetaType::QObjectStar:
+ case QMetaType::QWidgetStar:
+ *static_cast<void **>(data) = 0;
+ return true;
+ case QMetaType::Long:
+ *static_cast<long *>(data) = long(0);
+ return true;
+ case QMetaType::Int:
+ *static_cast<int *>(data) = int(0);
+ return true;
+ case QMetaType::Short:
+ *static_cast<short *>(data) = short(0);
+ return true;
+ case QMetaType::Char:
+ *static_cast<char *>(data) = char(0);
+ return true;
+ case QMetaType::ULong:
+ *static_cast<ulong *>(data) = ulong(0);
+ return true;
+ case QMetaType::UInt:
+ *static_cast<uint *>(data) = uint(0);
+ return true;
+ case QMetaType::LongLong:
+ *static_cast<qlonglong *>(data) = qlonglong(0);
+ return true;
+ case QMetaType::ULongLong:
+ *static_cast<qulonglong *>(data) = qulonglong(0);
+ return true;
+ case QMetaType::UShort:
+ *static_cast<ushort *>(data) = ushort(0);
+ return true;
+ case QMetaType::UChar:
+ *static_cast<uchar *>(data) = uchar(0);
+ return true;
+ case QMetaType::Bool:
+ *static_cast<bool *>(data) = bool(false);
+ return true;
+ case QMetaType::Float:
+ *static_cast<float *>(data) = float(0);
+ return true;
+ case QMetaType::Double:
+ *static_cast<double *>(data) = double();
+ return true;
+ case QMetaType::QChar:
+ *static_cast<NS(QChar) *>(data) = NS(QChar)();
+ return true;
+ case QMetaType::QVariantMap:
+ *static_cast<NS(QVariantMap) *>(data) = NS(QVariantMap)();
+ return true;
+ case QMetaType::QVariantHash:
+ *static_cast<NS(QVariantHash) *>(data) = NS(QVariantHash)();
+ return true;
+ case QMetaType::QVariantList:
+ *static_cast<NS(QVariantList) *>(data) = NS(QVariantList)();
+ return true;
+ case QMetaType::QByteArray:
+ *static_cast<NS(QByteArray) *>(data) = NS(QByteArray)();
+ return true;
+ case QMetaType::QString:
+ *static_cast<NS(QString) *>(data) = NS(QString)();
+ return true;
+ case QMetaType::QStringList:
+ *static_cast<NS(QStringList) *>(data) = NS(QStringList)();
+ return true;
+ case QMetaType::QBitArray:
+ *static_cast<NS(QBitArray) *>(data) = NS(QBitArray)();
+ return true;
+ case QMetaType::QDate:
+ *static_cast<NS(QDate) *>(data) = NS(QDate)();
+ return true;
+ case QMetaType::QTime:
+ *static_cast<NS(QTime) *>(data) = NS(QTime)();
+ return true;
+ case QMetaType::QDateTime:
+ *static_cast<NS(QDateTime) *>(data) = NS(QDateTime)();
+ return true;
+ case QMetaType::QUrl:
+ *static_cast<NS(QUrl) *>(data) = NS(QUrl)();
+ return true;
+ case QMetaType::QLocale:
+ *static_cast<NS(QLocale) *>(data) = NS(QLocale)();
+ return true;
+ case QMetaType::QRect:
+ *static_cast<NS(QRect) *>(data) = NS(QRect)();
+ return true;
+ case QMetaType::QRectF:
+ *static_cast<NS(QRectF) *>(data) = NS(QRectF)();
+ return true;
+ case QMetaType::QSize:
+ *static_cast<NS(QSize) *>(data) = NS(QSize)();
+ return true;
+ case QMetaType::QSizeF:
+ *static_cast<NS(QSizeF) *>(data) = NS(QSizeF)();
+ return true;
+ case QMetaType::QLine:
+ *static_cast<NS(QLine) *>(data) = NS(QLine)();
+ return true;
+ case QMetaType::QLineF:
+ *static_cast<NS(QLineF) *>(data) = NS(QLineF)();
+ return true;
+ case QMetaType::QPoint:
+ *static_cast<NS(QPoint) *>(data) = NS(QPoint)();
+ return true;
+ case QMetaType::QPointF:
+ *static_cast<NS(QPointF) *>(data) = NS(QPointF)();
+ return true;
+ case QMetaType::QVector3D:
+ *static_cast<NS(QVector3D) *>(data) = NS(QVector3D)();
+ return true;
+#ifndef QT_NO_REGEXP
+ case QMetaType::QRegExp:
+ *static_cast<NS(QRegExp) *>(data) = NS(QRegExp)();
+ return true;
+#endif
+ case QMetaType::Void:
+ return true;
+
+#ifdef QT3_SUPPORT
+ case QMetaType::QColorGroup:
+ *static_cast<NS(QColorGroup) *>(data) = NS(QColorGroup)();
+ return true;
+#endif
+
+ case QMetaType::QFont:
+ *static_cast<NS(QFont) *>(data) = NS(QFont)();
+ return true;
+ case QMetaType::QPixmap:
+ *static_cast<NS(QPixmap) *>(data) = NS(QPixmap)();
+ return true;
+ case QMetaType::QBrush:
+ *static_cast<NS(QBrush) *>(data) = NS(QBrush)();
+ return true;
+ case QMetaType::QColor:
+ *static_cast<NS(QColor) *>(data) = NS(QColor)();
+ return true;
+ case QMetaType::QPalette:
+ *static_cast<NS(QPalette) *>(data) = NS(QPalette)();
+ return true;
+ case QMetaType::QIcon:
+ *static_cast<NS(QIcon) *>(data) = NS(QIcon)();
+ return true;
+ case QMetaType::QImage:
+ *static_cast<NS(QImage) *>(data) = NS(QImage)();
+ return true;
+ case QMetaType::QPolygon:
+ *static_cast<NS(QPolygon) *>(data) = NS(QPolygon)();
+ return true;
+ case QMetaType::QRegion:
+ *static_cast<NS(QRegion) *>(data) = NS(QRegion)();
+ return true;
+ case QMetaType::QBitmap:
+ *static_cast<NS(QBitmap) *>(data) = NS(QBitmap)();
+ return true;
+#ifndef QT_NO_CURSOR
+ case QMetaType::QCursor:
+ *static_cast<NS(QCursor) *>(data) = NS(QCursor)();
+ return true;
+#endif
+ case QMetaType::QSizePolicy:
+ *static_cast<NS(QSizePolicy) *>(data) = NS(QSizePolicy)();
+ return true;
+ case QMetaType::QKeySequence:
+ *static_cast<NS(QKeySequence) *>(data) = NS(QKeySequence)();
+ return true;
+ case QMetaType::QPen:
+ *static_cast<NS(QPen) *>(data) = NS(QPen)();
+ return true;
+ case QMetaType::QTextLength:
+ *static_cast<NS(QTextLength) *>(data) = NS(QTextLength)();
+ return true;
+ case QMetaType::QTextFormat:
+ *static_cast<NS(QTextFormat) *>(data) = NS(QTextFormat)();
+ return true;
+ case QMetaType::QMatrix:
+ *static_cast<NS(QMatrix) *>(data) = NS(QMatrix)();
+ return true;
+ case QMetaType::QTransform:
+ *static_cast<NS(QTransform) *>(data) = NS(QTransform)();
+ return true;
+ case QMetaType::QMatrix4x4:
+ *static_cast<NS(QMatrix4x4) *>(data) = NS(QMatrix4x4)();
+ return true;
+ case QMetaType::QVector2D:
+ *static_cast<NS(QVector2D) *>(data) = NS(QVector2D)();
+ return true;
+ case QMetaType::QVector4D:
+ *static_cast<NS(QVector4D) *>(data) = NS(QVector4D)();
+ return true;
+ case QMetaType::QQuaternion:
+ *static_cast<NS(QQuaternion) *>(data) = NS(QQuaternion)();
+ return true;
+ default:
+ if (type == qMetaTypeId<QVariant>()) {
+ *static_cast<NS(QVariant) *>(data) = NS(QVariant)();
+ return true;
+ } else if (type == qMetaTypeId<QScriptValue>()) {
+ *static_cast<NS(QScriptValue) *>(data) = NS(QScriptValue)();
+ return true;
+ } else if (typeCategory(type) != Unknown) {
+ *static_cast<void **>(data) = 0;
+ return true;
+ }
+ break;
+ }
+ }
+
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativemetatype.h b/src/declarative/qml/qdeclarativemetatype.h
new file mode 100644
index 0000000..0634939
--- /dev/null
+++ b/src/declarative/qml/qdeclarativemetatype.h
@@ -0,0 +1,281 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEMETATYPE_H
+#define QDECLARATIVEMETATYPE_H
+
+#include "qdeclarativeprivate.h"
+#include "qdeclarativeparserstatus.h"
+#include "qdeclarativepropertyvaluesource.h"
+#include "qdeclarativepropertyvalueinterceptor.h"
+#include "qdeclarativelist.h"
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qbitarray.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeType;
+class QDeclarativeCustomParser;
+class Q_DECLARATIVE_EXPORT QDeclarativeMetaType
+{
+public:
+ static int registerType(const QDeclarativePrivate::MetaTypeIds &, QObject *(*)(), const char *, int vmaj, int vmin, const char *qmlName, const QMetaObject *, QDeclarativeAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, int valueSource, int valueInterceptor, QDeclarativePrivate::CreateFunc extFunc, const QMetaObject *extmo, QDeclarativeCustomParser *);
+ static int registerInterface(const QDeclarativePrivate::MetaTypeIds &, const char *);
+
+ static bool copy(int type, void *data, const void *copy = 0);
+
+ static QList<QByteArray> qmlTypeNames();
+ static QList<QDeclarativeType*> qmlTypes();
+
+ static QDeclarativeType *qmlType(const QByteArray &, int, int);
+ static QDeclarativeType *qmlType(const QMetaObject *);
+ static QDeclarativeType *qmlType(int);
+
+ static QMetaProperty defaultProperty(const QMetaObject *);
+ static QMetaProperty defaultProperty(QObject *);
+ static QMetaMethod defaultMethod(const QMetaObject *);
+ static QMetaMethod defaultMethod(QObject *);
+
+ static bool isQObject(int);
+ static QObject *toQObject(const QVariant &, bool *ok = 0);
+
+ static int listType(int);
+ static int attachedPropertiesFuncId(const QMetaObject *);
+ static QDeclarativeAttachedPropertiesFunc attachedPropertiesFuncById(int);
+
+ enum TypeCategory { Unknown, Object, List };
+ static TypeCategory typeCategory(int);
+
+ static bool isInterface(int);
+ static const char *interfaceIId(int);
+ static bool isList(int);
+
+ typedef QVariant (*StringConverter)(const QString &);
+ static void registerCustomStringConverter(int, StringConverter);
+ static StringConverter customStringConverter(int);
+};
+
+class QDeclarativeTypePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeType
+{
+public:
+ QByteArray typeName() const;
+ QByteArray qmlTypeName() const;
+
+ int majorVersion() const;
+ int minorVersion() const;
+ bool availableInVersion(int vmajor, int vminor) const;
+
+ QObject *create() const;
+
+ QDeclarativeCustomParser *customParser() const;
+
+ bool isInterface() const;
+ int typeId() const;
+ int qListTypeId() const;
+
+ const QMetaObject *metaObject() const;
+ const QMetaObject *baseMetaObject() const;
+
+ QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction() const;
+ const QMetaObject *attachedPropertiesType() const;
+
+ int parserStatusCast() const;
+ QVariant fromObject(QObject *) const;
+ const char *interfaceIId() const;
+ int propertyValueSourceCast() const;
+ int propertyValueInterceptorCast() const;
+
+ int index() const;
+private:
+ friend class QDeclarativeMetaType;
+ friend class QDeclarativeTypePrivate;
+ friend struct QDeclarativeMetaTypeData;
+ QDeclarativeType(int, int, const char *, int);
+ QDeclarativeType(int, int, QObject *(*)(), const char *, int, int, const QMetaObject *, QDeclarativeAttachedPropertiesFunc, const QMetaObject *, int, int, int, QDeclarativePrivate::CreateFunc, const QMetaObject *, int, QDeclarativeCustomParser *);
+ ~QDeclarativeType();
+
+ QDeclarativeTypePrivate *d;
+};
+
+template<typename T>
+int qmlRegisterType(const char *typeName)
+{
+ QByteArray name(typeName);
+ QDeclarativePrivate::MetaTypeIds ids = {
+ qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
+ };
+
+ return QDeclarativeMetaType::registerType(ids, 0, 0, 0, 0, 0,
+ &T::staticMetaObject,
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QObject>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+ 0, 0, 0);
+}
+
+template<typename T>
+int qmlRegisterType(const char *uri, int version_maj, int version_min, const char *qmlName, const char *typeName)
+{
+ QByteArray name(typeName);
+ QDeclarativePrivate::MetaTypeIds ids = {
+ qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
+ };
+
+ return QDeclarativeMetaType::registerType(ids, QDeclarativePrivate::create<T>,
+ uri, version_maj, version_min, qmlName,
+ &T::staticMetaObject,
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QObject>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+ 0, 0, 0);
+}
+
+template<typename T, typename E>
+int qmlRegisterExtendedType(const char *typeName)
+{
+ QByteArray name(typeName);
+ QDeclarativePrivate::MetaTypeIds ids = {
+ qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
+ };
+
+ QDeclarativeAttachedPropertiesFunc attached =
+ QDeclarativePrivate::attachedPropertiesFunc<E>();
+ const QMetaObject * attachedMo =
+ QDeclarativePrivate::attachedPropertiesMetaObject<E>();
+ if (!attached) {
+ attached = QDeclarativePrivate::attachedPropertiesFunc<T>();
+ attachedMo = QDeclarativePrivate::attachedPropertiesMetaObject<T>();
+ }
+
+ return QDeclarativeMetaType::registerType(ids, 0, 0, 0, 0, 0,
+ &T::staticMetaObject, attached, attachedMo,
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QObject>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+ &QDeclarativePrivate::CreateParent<E>::create, &E::staticMetaObject, 0);
+}
+
+template<typename T, typename E>
+int qmlRegisterExtendedType(const char *uri, int version_maj, int version_min, const char *qmlName, const char *typeName)
+{
+ QByteArray name(typeName);
+ QDeclarativePrivate::MetaTypeIds ids = {
+ qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
+ };
+
+ QDeclarativeAttachedPropertiesFunc attached =
+ QDeclarativePrivate::attachedPropertiesFunc<E>();
+ const QMetaObject * attachedMo =
+ QDeclarativePrivate::attachedPropertiesMetaObject<E>();
+ if (!attached) {
+ attached = QDeclarativePrivate::attachedPropertiesFunc<T>();
+ attachedMo = QDeclarativePrivate::attachedPropertiesMetaObject<T>();
+ }
+
+ return QDeclarativeMetaType::registerType(ids, QDeclarativePrivate::create<T>,
+ uri, version_maj, version_min, qmlName,
+ &T::staticMetaObject,
+ attached, attachedMo,
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QObject>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+ &QDeclarativePrivate::CreateParent<E>::create,
+ &E::staticMetaObject, 0);
+}
+
+template<typename T>
+int qmlRegisterInterface(const char *typeName)
+{
+ QByteArray name(typeName);
+ QDeclarativePrivate::MetaTypeIds ids = {
+ qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
+ };
+
+ return QDeclarativeMetaType::registerInterface(ids, qobject_interface_iid<T *>());
+}
+
+template<typename T>
+int qmlRegisterCustomType(const char *uri, int version_maj, int version_min, const char *qmlName, const char *typeName, QDeclarativeCustomParser *parser)
+{
+ QByteArray name(typeName);
+ QDeclarativePrivate::MetaTypeIds ids = {
+ qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(QByteArray("QDeclarativeListProperty<" + name + ">").constData()),
+ };
+
+ return QDeclarativeMetaType::registerType(ids, QDeclarativePrivate::create<T>,
+ uri, version_maj, version_min, qmlName,
+ &T::staticMetaObject,
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QObject>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+ 0, 0, parser);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEMETATYPE_H
+
diff --git a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
new file mode 100644
index 0000000..9dd7d39
--- /dev/null
+++ b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativenetworkaccessmanagerfactory.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QDeclarativeNetworkAccessManagerFactory
+ \since 4.7
+ \brief The QDeclarativeNetworkAccessManagerFactory class provides a factory for QNetworkAccessManager
+
+ QNetworkAccessManager is used for all network access by QML.
+ By implementing a factory it is possible to create custom
+ QNetworkAccessManager with specialized caching, proxy and
+ cookie support.
+
+ To implement a factory, subclass QDeclarativeNetworkAccessManagerFactory and implement
+ the create() method.
+
+ If the created QNetworkAccessManager becomes invalid, due to a
+ change in proxy settings, for example, call the invalidate() method.
+ This will cause all QNetworkAccessManagers to be recreated.
+
+ Note: the create() method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+*/
+
+/*!
+ The destructor is empty.
+ */
+QDeclarativeNetworkAccessManagerFactory::~QDeclarativeNetworkAccessManagerFactory()
+{
+}
+
+/*!
+ \fn QNetworkAccessManager *QDeclarativeNetworkAccessManagerFactory::create(QObject *parent)
+
+ Implement this method to create a QNetworkAccessManager with \a parent.
+ This allows proxies, caching and cookie support to be setup appropriately.
+
+ Note: this method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.h b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.h
new file mode 100644
index 0000000..8c76013
--- /dev/null
+++ b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVENETWORKACCESSMANAGERFACTORY_H
+#define QDECLARATIVENETWORKACCESSMANAGERFACTORY_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QNetworkAccessManager;
+class Q_DECLARATIVE_EXPORT QDeclarativeNetworkAccessManagerFactory
+{
+public:
+ virtual ~QDeclarativeNetworkAccessManagerFactory();
+ virtual QNetworkAccessManager *create(QObject *parent) = 0;
+
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVENETWORKACCESSMANAGERFACTORY_H
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
new file mode 100644
index 0000000..50fe5c0
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -0,0 +1,673 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeobjectscriptclass_p.h"
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativedeclarativedata_p.h"
+#include "qdeclarativetypenamescriptclass_p.h"
+#include "qdeclarativelistscriptclass_p.h"
+#include "qdeclarativebinding_p.h"
+#include "qdeclarativeguard_p.h"
+#include "qdeclarativevmemetaobject_p.h"
+
+#include <QtCore/qtimer.h>
+#include <QtCore/qvarlengtharray.h>
+
+Q_DECLARE_METATYPE(QScriptValue);
+
+QT_BEGIN_NAMESPACE
+
+struct ObjectData : public QScriptDeclarativeClass::Object {
+ ObjectData(QObject *o, int t) : object(o), type(t) {}
+ QDeclarativeGuard<QObject> object;
+ int type;
+};
+
+/*
+ The QDeclarativeObjectScriptClass handles property access for QObjects
+ via QtScript. It is also used to provide a more useful API in
+ QtScript for QML.
+ */
+QDeclarativeObjectScriptClass::QDeclarativeObjectScriptClass(QDeclarativeEngine *bindEngine)
+: QDeclarativeScriptClass(QDeclarativeEnginePrivate::getScriptEngine(bindEngine)),
+#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
+ methods(bindEngine),
+#endif
+ lastData(0), engine(bindEngine)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ m_destroy = scriptEngine->newFunction(destroy);
+ m_destroyId = createPersistentIdentifier(QLatin1String("destroy"));
+ m_toString = scriptEngine->newFunction(tostring);
+ m_toStringId = createPersistentIdentifier(QLatin1String("toString"));
+}
+
+QDeclarativeObjectScriptClass::~QDeclarativeObjectScriptClass()
+{
+}
+
+QScriptValue QDeclarativeObjectScriptClass::newQObject(QObject *object, int type)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ if (!object)
+ return newObject(scriptEngine, this, new ObjectData(object, type));
+
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, true);
+
+ if (!ddata->scriptValue.isValid()) {
+ ddata->scriptValue = newObject(scriptEngine, this, new ObjectData(object, type));
+ return ddata->scriptValue;
+ } else if (ddata->scriptValue.engine() == QDeclarativeEnginePrivate::getScriptEngine(engine)) {
+ return ddata->scriptValue;
+ } else {
+ return newObject(scriptEngine, this, new ObjectData(object, type));
+ }
+}
+
+QObject *QDeclarativeObjectScriptClass::toQObject(const QScriptValue &value) const
+{
+ return value.toQObject();
+}
+
+int QDeclarativeObjectScriptClass::objectType(const QScriptValue &value) const
+{
+ if (scriptClass(value) != this)
+ return QVariant::Invalid;
+
+ Object *o = object(value);
+ return ((ObjectData*)(o))->type;
+}
+
+QScriptClass::QueryFlags
+QDeclarativeObjectScriptClass::queryProperty(Object *object, const Identifier &name,
+ QScriptClass::QueryFlags flags)
+{
+ return queryProperty(toQObject(object), name, flags, 0);
+}
+
+QScriptClass::QueryFlags
+QDeclarativeObjectScriptClass::queryProperty(QObject *obj, const Identifier &name,
+ QScriptClass::QueryFlags flags, QDeclarativeContext *evalContext,
+ QueryHints hints)
+{
+ Q_UNUSED(flags);
+ lastData = 0;
+ lastTNData = 0;
+
+ if (name == m_destroyId.identifier ||
+ name == m_toStringId.identifier)
+ return QScriptClass::HandlesReadAccess;
+
+ if (!obj)
+ return 0;
+
+ QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine);
+ lastData = QDeclarativePropertyCache::property(engine, obj, name, local);
+
+ if (lastData)
+ return QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess;
+
+ if (!(hints & SkipAttachedProperties)) {
+ if (!evalContext && context()) {
+ // Global object, QScriptContext activation object, QDeclarativeContext object
+ QScriptValue scopeNode = scopeChainValue(context(), -3);
+ if (scopeNode.isValid()) {
+ Q_ASSERT(scriptClass(scopeNode) == enginePrivate->contextClass);
+
+ evalContext = enginePrivate->contextClass->contextFromValue(scopeNode);
+ }
+ }
+
+ if (evalContext) {
+ QDeclarativeContextPrivate *cp = QDeclarativeContextPrivate::get(evalContext);
+
+ if (cp->imports) {
+ QDeclarativeTypeNameCache::Data *data = cp->imports->data(name);
+ if (data) {
+ lastTNData = data;
+ return QScriptClass::HandlesReadAccess;
+ }
+ }
+ }
+ }
+
+ if (!(hints & ImplicitObject)) {
+ local.coreIndex = -1;
+ lastData = &local;
+ return QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess;
+ }
+
+ return 0;
+}
+
+QDeclarativeObjectScriptClass::ScriptValue
+QDeclarativeObjectScriptClass::property(Object *object, const Identifier &name)
+{
+ return property(toQObject(object), name);
+}
+
+QDeclarativeObjectScriptClass::ScriptValue
+QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ if (name == m_destroyId.identifier)
+ return Value(scriptEngine, m_destroy);
+ else if (name == m_toStringId.identifier)
+ return Value(scriptEngine, m_toString);
+
+ if (lastData && !lastData->isValid())
+ return Value();
+
+ Q_ASSERT(obj);
+
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+
+ if (lastTNData) {
+
+ if (lastTNData->type)
+ return Value(scriptEngine, enginePriv->typeNameClass->newObject(obj, lastTNData->type));
+ else
+ return Value(scriptEngine, enginePriv->typeNameClass->newObject(obj, lastTNData->typeNamespace));
+
+ } else if (lastData->flags & QDeclarativePropertyCache::Data::IsFunction) {
+ if (lastData->flags & QDeclarativePropertyCache::Data::IsVMEFunction) {
+ return Value(scriptEngine, ((QDeclarativeVMEMetaObject *)(obj->metaObject()))->vmeMethod(lastData->coreIndex));
+ } else {
+#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
+ // Uncomment to use QtScript method call logic
+ // QScriptValue sobj = scriptEngine->newQObject(obj);
+ // return Value(scriptEngine, sobj.property(toString(name)));
+ return Value(scriptEngine, methods.newMethod(obj, lastData));
+#else
+ QScriptValue sobj = scriptEngine->newQObject(obj);
+ return Value(scriptEngine, sobj.property(toString(name)));
+#endif
+ }
+ } else {
+ if (enginePriv->captureProperties && !(lastData->flags & QDeclarativePropertyCache::Data::IsConstant)) {
+ enginePriv->capturedProperties <<
+ QDeclarativeEnginePrivate::CapturedProperty(obj, lastData->coreIndex, lastData->notifyIndex);
+ }
+
+ if ((uint)lastData->propType < QVariant::UserType) {
+ QDeclarativeValueType *valueType = enginePriv->valueTypes[lastData->propType];
+ if (valueType)
+ return Value(scriptEngine, enginePriv->valueTypeClass->newObject(obj, lastData->coreIndex, valueType));
+ }
+
+ if (lastData->flags & QDeclarativePropertyCache::Data::IsQList) {
+ return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, lastData->propType));
+ } else if (lastData->flags & QDeclarativePropertyCache::Data::IsQObjectDerived) {
+ QObject *rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
+ return Value(scriptEngine, newQObject(rv, lastData->propType));
+ } else if (lastData->flags & QDeclarativePropertyCache::Data::IsQScriptValue) {
+ QScriptValue rv = scriptEngine->nullValue();
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
+ return Value(scriptEngine, rv);
+ } else if (lastData->propType == QMetaType::QReal) {
+ qreal rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
+ return Value(scriptEngine, rv);
+ } else if (lastData->propType == QMetaType::Int) {
+ int rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
+ return Value(scriptEngine, rv);
+ } else if (lastData->propType == QMetaType::Bool) {
+ bool rv = false;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
+ return Value(scriptEngine, rv);
+ } else if (lastData->propType == QMetaType::QString) {
+ QString rv;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
+ return Value(scriptEngine, rv);
+ } else if (lastData->propType == QMetaType::UInt) {
+ uint rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
+ return Value(scriptEngine, rv);
+ } else if (lastData->propType == QMetaType::Float) {
+ float rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
+ return Value(scriptEngine, rv);
+ } else if (lastData->propType == QMetaType::Double) {
+ double rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
+ return Value(scriptEngine, rv);
+ } else {
+ QVariant var = obj->metaObject()->property(lastData->coreIndex).read(obj);
+ return Value(scriptEngine, enginePriv->scriptValueFromVariant(var));
+ }
+
+ }
+}
+
+void QDeclarativeObjectScriptClass::setProperty(Object *object,
+ const Identifier &name,
+ const QScriptValue &value)
+{
+ return setProperty(toQObject(object), name, value);
+}
+
+void QDeclarativeObjectScriptClass::setProperty(QObject *obj,
+ const Identifier &name,
+ const QScriptValue &value,
+ QDeclarativeContext *evalContext)
+{
+ Q_UNUSED(name);
+
+ Q_ASSERT(obj);
+ Q_ASSERT(lastData);
+
+ if (!lastData->isValid()) {
+ QString error = QLatin1String("Cannot assign to non-existent property \"") +
+ toString(name) + QLatin1Char('\"');
+ if (context())
+ context()->throwError(error);
+ return;
+ }
+
+ if (!(lastData->flags & QDeclarativePropertyCache::Data::IsWritable)) {
+ QString error = QLatin1String("Cannot assign to read-only property \"") +
+ toString(name) + QLatin1Char('\"');
+ if (context())
+ context()->throwError(error);
+ return;
+ }
+
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+
+ if (!evalContext && context()) {
+ // Global object, QScriptContext activation object, QDeclarativeContext object
+ QScriptValue scopeNode = scopeChainValue(context(), -3);
+ if (scopeNode.isValid()) {
+ Q_ASSERT(scriptClass(scopeNode) == enginePriv->contextClass);
+
+ evalContext = enginePriv->contextClass->contextFromValue(scopeNode);
+ }
+ }
+
+ QDeclarativeAbstractBinding *delBinding = QDeclarativeMetaPropertyPrivate::setBinding(obj, *lastData, 0);
+ if (delBinding)
+ delBinding->destroy();
+
+ if (value.isUndefined() && lastData->flags & QDeclarativePropertyCache::Data::IsResettable) {
+ void *a[] = { 0 };
+ QMetaObject::metacall(obj, QMetaObject::ResetProperty, lastData->coreIndex, a);
+ } else {
+ // ### Can well known types be optimized?
+ QVariant v = QDeclarativeScriptClass::toVariant(engine, value);
+ QDeclarativeMetaPropertyPrivate::write(obj, *lastData, v, evalContext);
+ }
+}
+
+bool QDeclarativeObjectScriptClass::isQObject() const
+{
+ return true;
+}
+
+QObject *QDeclarativeObjectScriptClass::toQObject(Object *object, bool *ok)
+{
+ if (ok) *ok = true;
+
+ ObjectData *data = (ObjectData*)object;
+ return data->object.data();
+}
+
+QScriptValue QDeclarativeObjectScriptClass::tostring(QScriptContext *context, QScriptEngine *)
+{
+ QObject* obj = context->thisObject().toQObject();
+
+ QString ret;
+ if(obj){
+ QString objectName = obj->objectName();
+
+ ret += QString::fromUtf8(obj->metaObject()->className());
+ ret += QLatin1String("(0x");
+ ret += QString::number((intptr_t)obj,16);
+
+ if (!objectName.isEmpty()) {
+ ret += QLatin1String(", \"");
+ ret += objectName;
+ ret += QLatin1Char('\"');
+ }
+
+ ret += QLatin1Char(')');
+ }else{
+ ret += QLatin1String("null");
+ }
+ return QScriptValue(ret);
+}
+
+QScriptValue QDeclarativeObjectScriptClass::destroy(QScriptContext *context, QScriptEngine *engine)
+{
+ QObject* obj = context->thisObject().toQObject();
+ if(obj){
+ int delay = 0;
+ if(context->argumentCount() > 0)
+ delay = context->argument(0).toInt32();
+ if (delay > 0)
+ QTimer::singleShot(delay, obj, SLOT(deleteLater()));
+ else
+ obj->deleteLater();
+ }
+ return engine->nullValue();
+}
+
+QStringList QDeclarativeObjectScriptClass::propertyNames(Object *object)
+{
+ QObject *obj = toQObject(object);
+ if (!obj)
+ return QStringList();
+
+ QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine);
+
+ QDeclarativePropertyCache *cache = 0;
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(obj);
+ if (ddata)
+ cache = ddata->propertyCache;
+ if (!cache) {
+ cache = enginePrivate->cache(obj);
+ if (cache && ddata) { cache->addref(); ddata->propertyCache = cache; }
+ }
+
+ if (!cache)
+ return QStringList();
+
+ return cache->propertyNames();
+}
+
+#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
+
+struct MethodData : public QScriptDeclarativeClass::Object {
+ MethodData(QObject *o, const QDeclarativePropertyCache::Data &d) : object(o), data(d) {}
+
+ QDeclarativeGuard<QObject> object;
+ QDeclarativePropertyCache::Data data;
+};
+
+QDeclarativeObjectMethodScriptClass::QDeclarativeObjectMethodScriptClass(QDeclarativeEngine *bindEngine)
+: QScriptDeclarativeClass(QDeclarativeEnginePrivate::getScriptEngine(bindEngine)),
+ engine(bindEngine)
+{
+ setSupportsCall(true);
+}
+
+QDeclarativeObjectMethodScriptClass::~QDeclarativeObjectMethodScriptClass()
+{
+}
+
+QScriptValue QDeclarativeObjectMethodScriptClass::newMethod(QObject *object, const QDeclarativePropertyCache::Data *method)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ return newObject(scriptEngine, this, new MethodData(object, *method));
+}
+
+namespace {
+struct MetaCallArgument {
+ inline MetaCallArgument();
+ inline ~MetaCallArgument();
+ inline void *dataPtr();
+
+ inline void initAsType(int type, QDeclarativeEngine *);
+ void fromScriptValue(int type, QDeclarativeEngine *, const QScriptValue &);
+ inline QScriptDeclarativeClass::Value toValue(QDeclarativeEngine *);
+
+private:
+ MetaCallArgument(const MetaCallArgument &);
+
+ inline void cleanup();
+
+ char *data[16];
+ int type;
+};
+}
+
+MetaCallArgument::MetaCallArgument()
+: type(QVariant::Invalid)
+{
+}
+
+MetaCallArgument::~MetaCallArgument()
+{
+ cleanup();
+}
+
+void MetaCallArgument::cleanup()
+{
+ if (type == QMetaType::QString) {
+ ((QString *)data)->~QString();
+ } else if (type == -1 || type == qMetaTypeId<QVariant>()) {
+ ((QVariant *)data)->~QVariant();
+ } else if (type == qMetaTypeId<QScriptValue>()) {
+ ((QScriptValue *)data)->~QScriptValue();
+ }
+}
+
+void *MetaCallArgument::dataPtr()
+{
+ if (type == -1)
+ return ((QVariant *)data)->data();
+ else
+ return (void *)data;
+}
+
+void MetaCallArgument::initAsType(int callType, QDeclarativeEngine *e)
+{
+ if (type != 0) { cleanup(); type = 0; }
+ if (callType == 0) return;
+
+ QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(e);
+
+ if (callType == qMetaTypeId<QScriptValue>()) {
+ new (data) QScriptValue(engine->undefinedValue());
+ type = callType;
+ } else if (callType == QMetaType::Int ||
+ callType == QMetaType::UInt ||
+ callType == QMetaType::Bool ||
+ callType == QMetaType::Double ||
+ callType == QMetaType::Float) {
+ type = callType;
+ } else if (callType == QMetaType::QObjectStar) {
+ *((QObject **)data) = 0;
+ type = callType;
+ } else if (callType == QMetaType::QString) {
+ new (data) QString();
+ type = callType;
+ } else if (callType == qMetaTypeId<QVariant>()) {
+ type = qMetaTypeId<QVariant>();
+ new (data) QVariant();
+ } else {
+ type = -1;
+ new (data) QVariant(callType, (void *)0);
+ }
+}
+
+void MetaCallArgument::fromScriptValue(int callType, QDeclarativeEngine *engine, const QScriptValue &value)
+{
+ if (type != 0) { cleanup(); type = 0; }
+
+ if (callType == qMetaTypeId<QScriptValue>()) {
+ new (data) QScriptValue(value);
+ type = qMetaTypeId<QScriptValue>();
+ } else if (callType == QMetaType::Int) {
+ *((int *)data) = int(value.toInt32());
+ type = callType;
+ } else if (callType == QMetaType::UInt) {
+ *((uint *)data) = uint(value.toUInt32());
+ type = callType;
+ } else if (callType == QMetaType::Bool) {
+ *((bool *)data) = value.toBool();
+ type = callType;
+ } else if (callType == QMetaType::Double) {
+ *((double *)data) = double(value.toNumber());
+ type = callType;
+ } else if (callType == QMetaType::Float) {
+ *((float *)data) = float(value.toNumber());
+ type = callType;
+ } else if (callType == QMetaType::QString) {
+ if (value.isNull() || value.isUndefined())
+ new (data) QString();
+ else
+ new (data) QString(value.toString());
+ type = callType;
+ } else if (callType == QMetaType::QObjectStar) {
+ *((QObject **)data) = value.toQObject();
+ type = callType;
+ } else if (callType == qMetaTypeId<QVariant>()) {
+ new (data) QVariant(QDeclarativeScriptClass::toVariant(engine, value));
+ type = callType;
+ } else {
+ new (data) QVariant();
+ type = -1;
+
+ QVariant v = QDeclarativeScriptClass::toVariant(engine, value);
+ if (v.userType() == callType) {
+ *((QVariant *)data) = v;
+ } else if (v.canConvert((QVariant::Type)callType)) {
+ *((QVariant *)data) = v;
+ ((QVariant *)data)->convert((QVariant::Type)callType);
+ } else {
+ *((QVariant *)data) = QVariant(callType, (void *)0);
+ }
+ }
+}
+
+QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e)
+{
+ QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(e);
+
+ if (type == qMetaTypeId<QScriptValue>()) {
+ return QScriptDeclarativeClass::Value(engine, *((QScriptValue *)data));
+ } else if (type == QMetaType::Int) {
+ return QScriptDeclarativeClass::Value(engine, *((int *)data));
+ } else if (type == QMetaType::UInt) {
+ return QScriptDeclarativeClass::Value(engine, *((uint *)data));
+ } else if (type == QMetaType::Bool) {
+ return QScriptDeclarativeClass::Value(engine, *((bool *)data));
+ } else if (type == QMetaType::Double) {
+ return QScriptDeclarativeClass::Value(engine, *((double *)data));
+ } else if (type == QMetaType::Float) {
+ return QScriptDeclarativeClass::Value(engine, *((float *)data));
+ } else if (type == QMetaType::QString) {
+ return QScriptDeclarativeClass::Value(engine, *((QString *)data));
+ } else if (type == QMetaType::QObjectStar) {
+ return QScriptDeclarativeClass::Value(engine, QDeclarativeEnginePrivate::get(e)->objectClass->newQObject(*((QObject **)data)));
+ } else if (type == -1 || type == qMetaTypeId<QVariant>()) {
+ return QScriptDeclarativeClass::Value(engine, QDeclarativeEnginePrivate::get(e)->scriptValueFromVariant(*((QVariant *)data)));
+ } else {
+ return QScriptDeclarativeClass::Value();
+ }
+}
+
+QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass::call(Object *o, QScriptContext *ctxt)
+{
+ MethodData *method = static_cast<MethodData *>(o);
+
+ if (method->data.flags & QDeclarativePropertyCache::Data::HasArguments) {
+
+ QMetaMethod m = method->object->metaObject()->method(method->data.coreIndex);
+ QList<QByteArray> argTypeNames = m.parameterTypes();
+ QVarLengthArray<int, 9> argTypes(argTypeNames.count());
+
+ // ### Cache
+ for (int ii = 0; ii < argTypeNames.count(); ++ii) {
+ argTypes[ii] = QMetaType::type(argTypeNames.at(ii));
+ if (argTypes[ii] == QVariant::Invalid)
+ return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii)))));
+ }
+
+ if (argTypes.count() > ctxt->argumentCount())
+ return Value(ctxt, ctxt->throwError(QLatin1String("Insufficient arguments")));
+
+ QVarLengthArray<MetaCallArgument, 9> args(argTypes.count() + 1);
+ args[0].initAsType(method->data.propType, engine);
+
+ for (int ii = 0; ii < argTypes.count(); ++ii)
+ args[ii + 1].fromScriptValue(argTypes[ii], engine, ctxt->argument(ii));
+
+ QVarLengthArray<void *, 9> argData(args.count());
+ for (int ii = 0; ii < args.count(); ++ii)
+ argData[ii] = args[ii].dataPtr();
+
+ QMetaObject::metacall(method->object, QMetaObject::InvokeMetaMethod, method->data.coreIndex, argData.data());
+
+ return args[0].toValue(engine);
+
+ } else if (method->data.propType != 0) {
+
+ MetaCallArgument arg;
+ arg.initAsType(method->data.propType, engine);
+
+ void *args[] = { arg.dataPtr() };
+
+ QMetaObject::metacall(method->object, QMetaObject::InvokeMetaMethod, method->data.coreIndex, args);
+
+ return arg.toValue(engine);
+
+ } else {
+
+ void *args[] = { 0 };
+ QMetaObject::metacall(method->object, QMetaObject::InvokeMetaMethod, method->data.coreIndex, args);
+ return Value();
+
+ }
+ return Value();
+}
+
+#endif
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
new file mode 100644
index 0000000..8023756
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEOBJECTSCRIPTCLASS_P_H
+#define QDECLARATIVEOBJECTSCRIPTCLASS_P_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 "qdeclarativepropertycache_p.h"
+#include "qdeclarativetypenamecache_p.h"
+
+#include <private/qdeclarativescriptclass_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QScriptContext;
+class QScriptEngine;
+class QDeclarativeContext;
+
+#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
+class Q_AUTOTEST_EXPORT QDeclarativeObjectMethodScriptClass : public QScriptDeclarativeClass
+{
+public:
+ QDeclarativeObjectMethodScriptClass(QDeclarativeEngine *);
+ ~QDeclarativeObjectMethodScriptClass();
+
+ QScriptValue newMethod(QObject *, const QDeclarativePropertyCache::Data *);
+protected:
+ virtual Value call(Object *, QScriptContext *);
+
+private:
+ QDeclarativeEngine *engine;
+};
+#endif
+
+class Q_AUTOTEST_EXPORT QDeclarativeObjectScriptClass : public QDeclarativeScriptClass
+{
+public:
+ QDeclarativeObjectScriptClass(QDeclarativeEngine *);
+ ~QDeclarativeObjectScriptClass();
+
+ QScriptValue newQObject(QObject *, int type = QMetaType::QObjectStar);
+ QObject *toQObject(const QScriptValue &) const;
+ int objectType(const QScriptValue &) const;
+
+ enum QueryHint {
+ ImplicitObject = 0x01,
+ SkipAttachedProperties = 0x02
+ };
+ Q_DECLARE_FLAGS(QueryHints, QueryHint)
+
+ QScriptClass::QueryFlags queryProperty(QObject *, const Identifier &,
+ QScriptClass::QueryFlags flags,
+ QDeclarativeContext *evalContext,
+ QueryHints hints = 0);
+
+ ScriptValue property(QObject *, const Identifier &);
+
+ void setProperty(QObject *, const Identifier &name, const QScriptValue &,
+ QDeclarativeContext *evalContext = 0);
+ virtual QStringList propertyNames(Object *);
+
+protected:
+ virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
+ QScriptClass::QueryFlags flags);
+
+ virtual ScriptValue property(Object *, const Identifier &);
+ virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
+ virtual bool isQObject() const;
+ virtual QObject *toQObject(Object *, bool *ok = 0);
+
+private:
+#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
+ QDeclarativeObjectMethodScriptClass methods;
+#endif
+
+ QDeclarativeTypeNameCache::Data *lastTNData;
+ QDeclarativePropertyCache::Data *lastData;
+ QDeclarativePropertyCache::Data local;
+
+ PersistentIdentifier m_destroyId;
+ PersistentIdentifier m_toStringId;
+ QScriptValue m_destroy;
+ QScriptValue m_toString;
+
+ static QScriptValue tostring(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue destroy(QScriptContext *context, QScriptEngine *engine);
+
+ QDeclarativeEngine *engine;
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeObjectScriptClass::QueryHints);
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEOBJECTSCRIPTCLASS_P_H
+
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
new file mode 100644
index 0000000..5ac49d5
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeparser.cpp
@@ -0,0 +1,387 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeparser_p.h"
+
+#include "qdeclarativepropertyvaluesource.h"
+#include "qdeclarativevme_p.h"
+#include "qdeclarative.h"
+#include "qdeclarativecomponent_p.h"
+#include "qdeclarativecomponent.h"
+#include "qmetaobjectbuilder_p.h"
+#include "qdeclarativevmemetaobject_p.h"
+#include "qdeclarativecompiler_p.h"
+#include "parser/qdeclarativejsast_p.h"
+#include "parser/qdeclarativejsengine_p.h"
+
+#include <qfxperf_p_p.h>
+
+#include <QStack>
+#include <QColor>
+#include <QPointF>
+#include <QSizeF>
+#include <QRectF>
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QDeclarativeJS;
+using namespace QDeclarativeParser;
+
+QDeclarativeParser::Object::Object()
+: type(-1), majorVersion(-1), minorVersion(-1), idIndex(-1), metatype(0), defaultProperty(0), parserStatusCast(-1)
+{
+}
+
+QDeclarativeParser::Object::~Object()
+{
+ if (defaultProperty) defaultProperty->release();
+ foreach(Property *prop, properties)
+ prop->release();
+ foreach(Property *prop, valueProperties)
+ prop->release();
+ foreach(Property *prop, signalProperties)
+ prop->release();
+ foreach(Property *prop, attachedProperties)
+ prop->release();
+ foreach(Property *prop, groupedProperties)
+ prop->release();
+ foreach(Property *prop, valueTypeProperties)
+ prop->release();
+ typedef QPair<Property *, int> PropPair;
+ foreach(const PropPair &prop, scriptStringProperties)
+ prop.first->release();
+ foreach(const DynamicProperty &prop, dynamicProperties)
+ if (prop.defaultValue) prop.defaultValue->release();
+ foreach(Object *obj, scriptBlockObjects)
+ obj->release();
+}
+
+void Object::setBindingBit(int b)
+{
+ while (bindingBitmask.size() < 4 * (1 + b / 32))
+ bindingBitmask.append(char(0));
+
+ quint32 *bits = (quint32 *)bindingBitmask.data();
+ bits[b / 32] |= (1 << (b % 32));
+}
+
+const QMetaObject *Object::metaObject() const
+{
+ if (!metadata.isEmpty() && metatype)
+ return &extObject;
+ else
+ return metatype;
+}
+
+QDeclarativeParser::Property *Object::getDefaultProperty()
+{
+ if (!defaultProperty) {
+ defaultProperty = new Property;
+ defaultProperty->parent = this;
+ }
+ return defaultProperty;
+}
+
+void QDeclarativeParser::Object::addValueProperty(Property *p)
+{
+ p->addref();
+ valueProperties << p;
+}
+
+void QDeclarativeParser::Object::addSignalProperty(Property *p)
+{
+ p->addref();
+ signalProperties << p;
+}
+
+void QDeclarativeParser::Object::addAttachedProperty(Property *p)
+{
+ p->addref();
+ attachedProperties << p;
+}
+
+void QDeclarativeParser::Object::addGroupedProperty(Property *p)
+{
+ p->addref();
+ groupedProperties << p;
+}
+
+void QDeclarativeParser::Object::addValueTypeProperty(Property *p)
+{
+ p->addref();
+ valueTypeProperties << p;
+}
+
+void QDeclarativeParser::Object::addScriptStringProperty(Property *p, int stack)
+{
+ p->addref();
+ scriptStringProperties << qMakePair(p, stack);
+}
+
+
+Property *QDeclarativeParser::Object::getProperty(const QByteArray &name, bool create)
+{
+ if (!properties.contains(name)) {
+ if (create) {
+ Property *property = new Property(name);
+ property->parent = this;
+ properties.insert(name, property);
+ } else {
+ return 0;
+ }
+ }
+ return properties[name];
+}
+
+QDeclarativeParser::Object::DynamicProperty::DynamicProperty()
+: isDefaultProperty(false), type(Variant), defaultValue(0)
+{
+}
+
+QDeclarativeParser::Object::DynamicProperty::DynamicProperty(const DynamicProperty &o)
+: isDefaultProperty(o.isDefaultProperty),
+ type(o.type),
+ customType(o.customType),
+ name(o.name),
+ defaultValue(o.defaultValue),
+ location(o.location)
+{
+}
+
+QDeclarativeParser::Object::DynamicSignal::DynamicSignal()
+{
+}
+
+QDeclarativeParser::Object::DynamicSignal::DynamicSignal(const DynamicSignal &o)
+: name(o.name), parameterTypes(o.parameterTypes),
+ parameterNames(o.parameterNames)
+{
+}
+
+QDeclarativeParser::Object::DynamicSlot::DynamicSlot()
+{
+}
+
+QDeclarativeParser::Object::DynamicSlot::DynamicSlot(const DynamicSlot &o)
+: name(o.name), body(o.body), parameterNames(o.parameterNames)
+{
+}
+
+QDeclarativeParser::Property::Property()
+: parent(0), type(0), index(-1), value(0), isDefault(true), isDeferred(false)
+{
+}
+
+QDeclarativeParser::Property::Property(const QByteArray &n)
+: parent(0), type(0), index(-1), value(0), name(n), isDefault(false),
+ isDeferred(false)
+{
+}
+
+QDeclarativeParser::Property::~Property()
+{
+ foreach(Value *value, values)
+ value->release();
+ if (value) value->release();
+}
+
+Object *QDeclarativeParser::Property::getValue()
+{
+ if (!value) value = new Object;
+ return value;
+}
+
+void QDeclarativeParser::Property::addValue(Value *v)
+{
+ values << v;
+}
+
+bool QDeclarativeParser::Property::isEmpty() const
+{
+ return !value && values.isEmpty();
+}
+
+QDeclarativeParser::Value::Value()
+: type(Unknown), object(0)
+{
+}
+
+QDeclarativeParser::Value::~Value()
+{
+ if (object) object->release();
+}
+
+QDeclarativeParser::Variant::Variant()
+: t(Invalid) {}
+
+QDeclarativeParser::Variant::Variant(const Variant &o)
+: t(o.t), d(o.d), s(o.s)
+{
+}
+
+QDeclarativeParser::Variant::Variant(bool v)
+: t(Boolean), b(v)
+{
+}
+
+QDeclarativeParser::Variant::Variant(double v, const QString &asWritten)
+: t(Number), d(v), s(asWritten)
+{
+}
+
+QDeclarativeParser::Variant::Variant(const QString &v)
+: t(String), s(v)
+{
+}
+
+QDeclarativeParser::Variant::Variant(const QString &v, QDeclarativeJS::AST::Node *n)
+: t(Script), n(n), s(v)
+{
+}
+
+QDeclarativeParser::Variant &QDeclarativeParser::Variant::operator=(const Variant &o)
+{
+ t = o.t;
+ d = o.d;
+ s = o.s;
+ return *this;
+}
+
+QDeclarativeParser::Variant::Type QDeclarativeParser::Variant::type() const
+{
+ return t;
+}
+
+bool QDeclarativeParser::Variant::asBoolean() const
+{
+ return b;
+}
+
+QString QDeclarativeParser::Variant::asString() const
+{
+ return s;
+}
+
+double QDeclarativeParser::Variant::asNumber() const
+{
+ return d;
+}
+
+QString QDeclarativeParser::Variant::asScript() const
+{
+ switch(type()) {
+ default:
+ case Invalid:
+ return QString();
+ case Boolean:
+ return b?QLatin1String("true"):QLatin1String("false");
+ case Number:
+ if (s.isEmpty())
+ return QString::number(d);
+ else
+ return s;
+ case String:
+ case Script:
+ return s;
+ }
+}
+
+QDeclarativeJS::AST::Node *QDeclarativeParser::Variant::asAST() const
+{
+ if (type() == Script)
+ return n;
+ else
+ return 0;
+}
+
+bool QDeclarativeParser::Variant::isStringList() const
+{
+ if (isString())
+ return true;
+
+ if (type() != Script || !n)
+ return false;
+
+ AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
+ if (!array)
+ return false;
+
+ AST::ElementList *elements = array->elements;
+
+ while (elements) {
+
+ if (!AST::cast<AST::StringLiteral *>(elements->expression))
+ return false;
+
+ elements = elements->next;
+ }
+
+ return true;
+}
+
+QStringList QDeclarativeParser::Variant::asStringList() const
+{
+ QStringList rv;
+ if (isString()) {
+ rv << asString();
+ return rv;
+ }
+
+ AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
+ if (!array)
+ return rv;
+
+ AST::ElementList *elements = array->elements;
+ while (elements) {
+
+ AST::StringLiteral *string = AST::cast<AST::StringLiteral *>(elements->expression);
+ if (!string)
+ return QStringList();
+ rv.append(string->value->asString());
+
+ elements = elements->next;
+ }
+
+ return rv;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
new file mode 100644
index 0000000..cfd0b87
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -0,0 +1,357 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPARSER_P_H
+#define QDECLARATIVEPARSER_P_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 "qdeclarative.h"
+#include "qdeclarativerefcount_p.h"
+
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/qstring.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+namespace QDeclarativeJS { namespace AST { class Node; } }
+
+/*
+ XXX
+
+ These types are created (and owned) by the QDeclarativeXmlParser and consumed by the
+ QDeclarativeCompiler. During the compilation phase the compiler will update some of
+ the fields for both its own use and for the use of the upcoming QDeclarativeDom API.
+
+ The types are part of the generic sounding "QDeclarativeParser" namespace for legacy
+ reasons (there used to be more in this namespace) and will be cleaned up and
+ migrated into a more appropriate location shortly.
+*/
+namespace QDeclarativeParser
+{
+ struct Location
+ {
+ Location() : line(-1), column(-1) {}
+ int line;
+ int column;
+ };
+
+ struct LocationRange
+ {
+ LocationRange() : offset(0), length(0) {}
+ quint32 offset;
+ quint32 length;
+ };
+
+ struct LocationSpan
+ {
+ Location start;
+ Location end;
+ LocationRange range;
+ };
+
+ class Property;
+ class Object : public QDeclarativeRefCount
+ {
+ public:
+ Object();
+ virtual ~Object();
+
+ // Type of the object. The integer is an index into the
+ // QDeclarativeCompiledData::types array, or -1 if the object is a property
+ // group.
+ int type;
+ // The url of this object if it is an external type. Used by the DOM
+ QUrl url;
+
+ // version information if type is defined in library or C++
+ int majorVersion;
+ int minorVersion;
+
+ // The fully-qualified name of this type
+ QByteArray typeName;
+ // The class name
+ QByteArray className;
+ // The id assigned to the object (if any). Set by the QDeclarativeCompiler
+ QString id;
+ // The id index assigned to the object (if any). Set by the QDeclarativeCompiler
+ int idIndex;
+ // Custom parsed data
+ QByteArray custom;
+ // Bit mask of the properties assigned bindings
+ QByteArray bindingBitmask;
+ void setBindingBit(int);
+ // Returns the metaobject for this type, or 0 if not available.
+ // Internally selectd between the metatype and extObject variables
+ const QMetaObject *metaObject() const;
+
+ // The compile time metaobject for this type
+ const QMetaObject *metatype;
+ // The synthesized metaobject, if QML added signals or properties to
+ // this type. Otherwise null
+ QAbstractDynamicMetaObject extObject;
+ QByteArray metadata; // Generated by compiler
+ QByteArray synthdata; // Generated by compiler
+
+ Property *getDefaultProperty();
+ Property *getProperty(const QByteArray &name, bool create=true);
+
+ Property *defaultProperty;
+ QHash<QByteArray, Property *> properties;
+
+ QList<Object *> scriptBlockObjects;
+
+ // Output of the compilation phase (these properties continue to exist
+ // in either the defaultProperty or properties members too)
+ void addValueProperty(Property *);
+ void addSignalProperty(Property *);
+ void addAttachedProperty(Property *);
+ void addGroupedProperty(Property *);
+ void addValueTypeProperty(Property *);
+ void addScriptStringProperty(Property *, int = 0);
+ QList<Property *> valueProperties;
+ QList<Property *> signalProperties;
+ QList<Property *> attachedProperties;
+ QList<Property *> groupedProperties;
+ QList<Property *> valueTypeProperties;
+ QList<QPair<Property *, int> > scriptStringProperties;
+
+ // Script blocks that were nested under this object
+ struct ScriptBlock {
+ QStringList codes;
+ QStringList files;
+ QList<int> lineNumbers;
+ };
+ QList<ScriptBlock> scripts;
+
+ // The bytes to cast instances by to get to the QDeclarativeParserStatus
+ // interface. -1 indicates the type doesn't support this interface.
+ // Set by the QDeclarativeCompiler.
+ int parserStatusCast;
+
+ LocationSpan location;
+
+ struct DynamicProperty {
+ DynamicProperty();
+ DynamicProperty(const DynamicProperty &);
+
+ enum Type { Variant, Int, Bool, Real, String, Url, Color, Date, Alias, Custom, CustomList };
+
+ bool isDefaultProperty;
+ Type type;
+ QByteArray customType;
+ QByteArray name;
+ QDeclarativeParser::Property *defaultValue;
+ LocationSpan location;
+ };
+ struct DynamicSignal {
+ DynamicSignal();
+ DynamicSignal(const DynamicSignal &);
+
+ QByteArray name;
+ QList<QByteArray> parameterTypes;
+ QList<QByteArray> parameterNames;
+ };
+ struct DynamicSlot {
+ DynamicSlot();
+ DynamicSlot(const DynamicSlot &);
+
+ QByteArray name;
+ QString body;
+ QList<QByteArray> parameterNames;
+ };
+
+ // The list of dynamic properties
+ QList<DynamicProperty> dynamicProperties;
+ // The list of dynamic signals
+ QList<DynamicSignal> dynamicSignals;
+ // The list of dynamic slots
+ QList<DynamicSlot> dynamicSlots;
+ };
+
+ class Variant
+ {
+ public:
+ enum Type {
+ Invalid,
+ Boolean,
+ Number,
+ String,
+ Script
+ };
+
+ Variant();
+ Variant(const Variant &);
+ Variant(bool);
+ Variant(double, const QString &asWritten=QString());
+ Variant(const QString &);
+ Variant(const QString &, QDeclarativeJS::AST::Node *);
+ Variant &operator=(const Variant &);
+
+ Type type() const;
+
+ bool isBoolean() const { return type() == Boolean; }
+ bool isNumber() const { return type() == Number; }
+ bool isString() const { return type() == String; }
+ bool isScript() const { return type() == Script; }
+ bool isStringList() const;
+
+ bool asBoolean() const;
+ QString asString() const;
+ double asNumber() const;
+ QString asScript() const;
+ QDeclarativeJS::AST::Node *asAST() const;
+ QStringList asStringList() const;
+
+ private:
+ Type t;
+ union {
+ bool b;
+ double d;
+ QDeclarativeJS::AST::Node *n;
+ };
+ QString s;
+ };
+
+ class Value : public QDeclarativeRefCount
+ {
+ public:
+ Value();
+ virtual ~Value();
+
+ enum Type {
+ // The type of this value assignment is not yet known
+ Unknown,
+ // This is used as a literal property assignment
+ Literal,
+ // This is used as a property binding assignment
+ PropertyBinding,
+ // This is used as a QDeclarativePropertyValueSource assignment
+ ValueSource,
+ // This is used as a QDeclarativePropertyValueInterceptor assignment
+ ValueInterceptor,
+ // This is used as a property QObject assignment
+ CreatedObject,
+ // This is used as a signal object assignment
+ SignalObject,
+ // This is used as a signal expression assignment
+ SignalExpression,
+ // This is used as an id assignment only
+ Id
+ };
+ Type type;
+
+ // ### Temporary
+ QString primitive() const { return value.asScript(); }
+
+ // Primitive value
+ Variant value;
+ // Object value
+ Object *object;
+
+ LocationSpan location;
+ };
+
+ class Property : public QDeclarativeRefCount
+ {
+ public:
+ Property();
+ Property(const QByteArray &n);
+ virtual ~Property();
+
+ // The Object to which this property is attached
+ Object *parent;
+
+ Object *getValue();
+ void addValue(Value *v);
+
+ // The QVariant::Type of the property, or 0 (QVariant::Invalid) if
+ // unknown.
+ int type;
+ // The metaobject index of this property, or -1 if unknown.
+ int index;
+
+ // Returns true if this is an empty property - both value and values
+ // are unset.
+ bool isEmpty() const;
+ // The list of values assigned to this property. Content in values
+ // and value are mutually exclusive
+ QList<Value *> values;
+ // The accessed property. This is used to represent dot properties.
+ // Content in value and values are mutually exclusive.
+ Object *value;
+ // The property name
+ QByteArray name;
+ // True if this property was accessed as the default property.
+ bool isDefault;
+ // True if the setting of this property will be deferred. Set by the
+ // QDeclarativeCompiler
+ bool isDeferred;
+
+ LocationSpan location;
+ LocationRange listValueRange;
+ QList<int> listCommaPositions;
+ };
+}
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeclarativeParser::Variant)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPARSER_P_H
diff --git a/src/declarative/qml/qdeclarativeparserstatus.cpp b/src/declarative/qml/qdeclarativeparserstatus.cpp
new file mode 100644
index 0000000..ec6260e
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeparserstatus.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeparserstatus.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QDeclarativeParserStatus
+ \since 4.7
+ \brief The QDeclarativeParserStatus class provides updates on the parser state.
+*/
+
+/*! \internal */
+QDeclarativeParserStatus::QDeclarativeParserStatus()
+: d(0)
+{
+}
+
+/*! \internal */
+QDeclarativeParserStatus::~QDeclarativeParserStatus()
+{
+ if(d)
+ (*d) = 0;
+}
+
+/*!
+ Invoked after class creation, but before any properties have been set.
+*/
+void QDeclarativeParserStatus::classBegin()
+{
+}
+
+/*!
+ Invoked after the root component that caused this instantiation has
+ completed construction. At this point all static values and binding values
+ have been assigned to the class.
+*/
+void QDeclarativeParserStatus::componentComplete()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeparserstatus.h b/src/declarative/qml/qdeclarativeparserstatus.h
new file mode 100644
index 0000000..34528c1
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeparserstatus.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPARSERSTATUS_H
+#define QDECLARATIVEPARSERSTATUS_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QDeclarativeParserStatus
+{
+public:
+ QDeclarativeParserStatus();
+ virtual ~QDeclarativeParserStatus();
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+private:
+ friend class QDeclarativeVME;
+ friend class QDeclarativeComponent;
+ friend class QDeclarativeComponentPrivate;
+ friend class QDeclarativeEnginePrivate;
+ QDeclarativeParserStatus **d;
+};
+Q_DECLARE_INTERFACE(QDeclarativeParserStatus, "com.trolltech.qml.QDeclarativeParserStatus")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPARSERSTATUS_H
diff --git a/src/declarative/qml/qdeclarativeprivate.cpp b/src/declarative/qml/qdeclarativeprivate.cpp
new file mode 100644
index 0000000..444fe56
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeprivate.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeprivate.h"
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativePrivate::InstanceType::InstanceType(int) {}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
new file mode 100644
index 0000000..c8a8c74
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeprivate.h
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPRIVATE_H
+#define QDECLARATIVEPRIVATE_H
+
+#include <QtCore/qglobal.h>
+
+#ifndef Q_OS_WIN
+#include <stdint.h>
+#endif
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+typedef QObject *(*QDeclarativeAttachedPropertiesFunc)(QObject *);
+
+//template<typename T>
+//struct qml_hasAttached { static bool const value = false; };
+
+template <typename TYPE>
+class QDeclarativeTypeInfo
+{
+public:
+ enum {
+ hasAttachedProperties = 0
+ };
+};
+
+
+namespace QDeclarativePrivate
+{
+ template<typename T>
+ QObject *create() { return new T; }
+
+ template<class From, class To, int N>
+ struct StaticCastSelectorClass
+ {
+ static inline int cast() { return -1; }
+ };
+
+ template<class From, class To>
+ struct StaticCastSelectorClass<From, To, sizeof(int)>
+ {
+ static inline int cast() { return (int)((intptr_t)static_cast<To *>((From *)0x10000000)) - 0x10000000; }
+ };
+
+ template<class From, class To>
+ struct StaticCastSelector
+ {
+ typedef int yes_type;
+ typedef char no_type;
+
+ static yes_type check(To *);
+ static no_type check(...);
+
+ static inline int cast()
+ {
+ return StaticCastSelectorClass<From, To, sizeof(check((From *)0))>::cast();
+ }
+ };
+
+ template <typename T>
+ struct has_attachedPropertiesMember
+ {
+ static bool const value = QDeclarativeTypeInfo<T>::hasAttachedProperties;
+ };
+
+ template <typename T, bool hasMember>
+ class has_attachedPropertiesMethod
+ {
+ typedef int yes_type;
+ typedef char no_type;
+
+ template<typename ReturnType>
+ static yes_type check(ReturnType *(*)(QObject *));
+ static no_type check(...);
+
+ public:
+ static bool const value = sizeof(check(&T::qmlAttachedProperties)) == sizeof(yes_type);
+ };
+
+ template <typename T>
+ class has_attachedPropertiesMethod<T, false>
+ {
+ public:
+ static bool const value = false;
+ };
+
+ template<typename T, int N>
+ class AttachedPropertySelector
+ {
+ public:
+ static inline QDeclarativeAttachedPropertiesFunc func() { return 0; }
+ static inline const QMetaObject *metaObject() { return 0; }
+ };
+ template<typename T>
+ class AttachedPropertySelector<T, 1>
+ {
+ static inline QObject *attachedProperties(QObject *obj) {
+ return T::qmlAttachedProperties(obj);
+ }
+ template<typename ReturnType>
+ static inline const QMetaObject *attachedPropertiesMetaObject(ReturnType *(*)(QObject *)) {
+ return &ReturnType::staticMetaObject;
+ }
+ public:
+ static inline QDeclarativeAttachedPropertiesFunc func() {
+ return &attachedProperties;
+ }
+ static inline const QMetaObject *metaObject() {
+ return attachedPropertiesMetaObject(&T::qmlAttachedProperties);
+ }
+ };
+
+ template<typename T>
+ inline QDeclarativeAttachedPropertiesFunc attachedPropertiesFunc()
+ {
+ return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::func();
+ }
+
+ template<typename T>
+ inline const QMetaObject *attachedPropertiesMetaObject()
+ {
+ return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::metaObject();
+ }
+
+ struct MetaTypeIds {
+ int typeId;
+ int listId;
+ };
+ typedef QObject *(*CreateFunc)(QObject *);
+
+ template<typename T>
+ struct CreateParent {
+ static QObject *create(QObject *other) {
+ return new T(other);
+ }
+ };
+
+ template<typename T>
+ struct CreateNoParent {
+ static QObject *create() {
+ return new T;
+ }
+ };
+
+ struct Q_DECLARATIVE_EXPORT InstanceType {
+ InstanceType(int);
+ };
+
+ template<typename T, int VMAJ, int VMIN>
+ struct Define {
+ static InstanceType instance;
+ };
+
+ template<typename T>
+ struct ExtCreate {
+ static QObject *create(QObject *other) {
+ return new T(other);
+ }
+ };
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPRIVATE_H
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp
new file mode 100644
index 0000000..08b47b7
--- /dev/null
+++ b/src/declarative/qml/qdeclarativepropertycache.cpp
@@ -0,0 +1,423 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativepropertycache_p.h"
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativebinding_p.h"
+#include <QtCore/qdebug.h>
+
+Q_DECLARE_METATYPE(QScriptValue);
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativePropertyCache::Data::Flags QDeclarativePropertyCache::Data::flagsForProperty(const QMetaProperty &p, QDeclarativeEngine *engine)
+{
+ int propType = p.userType();
+
+ Flags flags;
+
+ if (p.isConstant())
+ flags |= Data::IsConstant;
+ if (p.isWritable())
+ flags |= Data::IsWritable;
+ if (p.isResettable())
+ flags |= Data::IsResettable;
+
+ if (propType == qMetaTypeId<QDeclarativeBinding *>()) {
+ flags |= Data::IsQmlBinding;
+ } else if (propType == qMetaTypeId<QScriptValue>()) {
+ flags |= Data::IsQScriptValue;
+ } else if (p.isEnumType()) {
+ flags |= Data::IsEnumType;
+ } else {
+ QDeclarativeMetaType::TypeCategory cat = engine ? QDeclarativeEnginePrivate::get(engine)->typeCategory(propType)
+ : QDeclarativeMetaType::typeCategory(propType);
+ if (cat == QDeclarativeMetaType::Object)
+ flags |= Data::IsQObjectDerived;
+ else if (cat == QDeclarativeMetaType::List)
+ flags |= Data::IsQList;
+ }
+
+ return flags;
+}
+
+void QDeclarativePropertyCache::Data::load(const QMetaProperty &p, QDeclarativeEngine *engine)
+{
+ propType = p.userType();
+ if (QVariant::Type(propType) == QVariant::LastType)
+ propType = qMetaTypeId<QVariant>();
+ coreIndex = p.propertyIndex();
+ notifyIndex = p.notifySignalIndex();
+ flags = flagsForProperty(p, engine);
+}
+
+void QDeclarativePropertyCache::Data::load(const QMetaMethod &m)
+{
+ coreIndex = m.methodIndex();
+ flags |= Data::IsFunction;
+ propType = QVariant::Invalid;
+
+ const char *returnType = m.typeName();
+ if (returnType)
+ propType = QMetaType::type(returnType);
+
+ QList<QByteArray> params = m.parameterTypes();
+ if (!params.isEmpty())
+ flags |= Data::HasArguments;
+}
+
+
+QDeclarativePropertyCache::QDeclarativePropertyCache(QDeclarativeEngine *e)
+: QDeclarativeCleanup(e), engine(e)
+{
+}
+
+QDeclarativePropertyCache::~QDeclarativePropertyCache()
+{
+ clear();
+}
+
+void QDeclarativePropertyCache::clear()
+{
+ for (int ii = 0; ii < indexCache.count(); ++ii)
+ indexCache.at(ii)->release();
+
+ for (StringCache::ConstIterator iter = stringCache.begin();
+ iter != stringCache.end(); ++iter)
+ (*iter)->release();
+
+ for (IdentifierCache::ConstIterator iter = identifierCache.begin();
+ iter != identifierCache.end(); ++iter)
+ (*iter)->release();
+
+ indexCache.clear();
+ stringCache.clear();
+ identifierCache.clear();
+}
+
+QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObject *metaObject,
+ const QString &property)
+{
+ Q_ASSERT(metaObject);
+
+ QDeclarativePropertyCache::Data rv;
+ int idx = metaObject->indexOfProperty(property.toUtf8());
+ if (idx != -1) {
+ rv.load(metaObject->property(idx));
+ return rv;
+ }
+
+ int methodCount = metaObject->methodCount();
+ for (int ii = methodCount - 1; ii >= 0; --ii) {
+ QMetaMethod m = metaObject->method(ii);
+ if (m.access() == QMetaMethod::Private)
+ continue;
+ QString methodName = QString::fromUtf8(m.signature());
+
+ int parenIdx = methodName.indexOf(QLatin1Char('('));
+ Q_ASSERT(parenIdx != -1);
+ methodName = methodName.left(parenIdx);
+
+ if (methodName == property) {
+ rv.load(m);
+ return rv;
+ }
+ }
+
+ return rv;
+}
+
+QDeclarativePropertyCache *QDeclarativePropertyCache::copy() const
+{
+ QDeclarativePropertyCache *cache = new QDeclarativePropertyCache(engine);
+ cache->indexCache = indexCache;
+ cache->stringCache = stringCache;
+ cache->identifierCache = identifierCache;
+
+ for (int ii = 0; ii < indexCache.count(); ++ii)
+ indexCache.at(ii)->addref();
+ for (StringCache::ConstIterator iter = stringCache.begin(); iter != stringCache.end(); ++iter)
+ (*iter)->addref();
+ for (IdentifierCache::ConstIterator iter = identifierCache.begin(); iter != identifierCache.end(); ++iter)
+ (*iter)->addref();
+
+ return cache;
+}
+
+void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaObject *metaObject,
+ Data::Flag propertyFlags, Data::Flag methodFlags)
+{
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+
+ int propCount = metaObject->propertyCount();
+ int propOffset = metaObject->propertyOffset();
+
+ indexCache.resize(propCount);
+ for (int ii = propOffset; ii < propCount; ++ii) {
+ QMetaProperty p = metaObject->property(ii);
+ QString propName = QString::fromUtf8(p.name());
+
+ RData *data = new RData;
+ data->identifier = enginePriv->objectClass->createPersistentIdentifier(propName);
+
+ data->load(p, engine);
+ data->flags |= propertyFlags;
+
+ indexCache[ii] = data;
+
+ if (stringCache.contains(propName)) {
+ stringCache[propName]->release();
+ identifierCache[data->identifier.identifier]->release();
+ }
+
+ stringCache.insert(propName, data);
+ identifierCache.insert(data->identifier.identifier, data);
+ data->addref();
+ data->addref();
+ }
+
+ int methodCount = metaObject->methodCount();
+ int methodOffset = metaObject->methodOffset();
+ for (int ii = methodOffset; ii < methodCount; ++ii) {
+ QMetaMethod m = metaObject->method(ii);
+ if (m.access() == QMetaMethod::Private)
+ continue;
+ QString methodName = QString::fromUtf8(m.signature());
+
+ int parenIdx = methodName.indexOf(QLatin1Char('('));
+ Q_ASSERT(parenIdx != -1);
+ methodName = methodName.left(parenIdx);
+
+ RData *data = new RData;
+ data->identifier = enginePriv->objectClass->createPersistentIdentifier(methodName);
+
+ if (stringCache.contains(methodName)) {
+ stringCache[methodName]->release();
+ identifierCache[data->identifier.identifier]->release();
+ }
+
+ data->load(m);
+ if (m.methodType() == QMetaMethod::Slot || m.methodType() == QMetaMethod::Method)
+ data->flags |= methodFlags;
+
+ stringCache.insert(methodName, data);
+ identifierCache.insert(data->identifier.identifier, data);
+ data->addref();
+ }
+}
+
+// ### Optimize - check engine for the parent meta object etc.
+QDeclarativePropertyCache *QDeclarativePropertyCache::create(QDeclarativeEngine *engine, const QMetaObject *metaObject)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(metaObject);
+
+ QDeclarativePropertyCache *cache = new QDeclarativePropertyCache(engine);
+ cache->update(engine, metaObject);
+ return cache;
+}
+
+void QDeclarativePropertyCache::update(QDeclarativeEngine *engine, const QMetaObject *metaObject)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(metaObject);
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+
+ clear();
+
+ // ### The properties/methods should probably be spliced on a per-metaobject basis
+ int propCount = metaObject->propertyCount();
+
+ indexCache.resize(propCount);
+ for (int ii = propCount - 1; ii >= 0; --ii) {
+ QMetaProperty p = metaObject->property(ii);
+ QString propName = QString::fromUtf8(p.name());
+
+ RData *data = new RData;
+ data->identifier = enginePriv->objectClass->createPersistentIdentifier(propName);
+
+ data->load(p, engine);
+
+ indexCache[ii] = data;
+
+ if (stringCache.contains(propName))
+ continue;
+
+ stringCache.insert(propName, data);
+ identifierCache.insert(data->identifier.identifier, data);
+ data->addref();
+ data->addref();
+ }
+
+ int methodCount = metaObject->methodCount();
+ for (int ii = methodCount - 1; ii >= 0; --ii) {
+ QMetaMethod m = metaObject->method(ii);
+ if (m.access() == QMetaMethod::Private)
+ continue;
+ QString methodName = QString::fromUtf8(m.signature());
+
+ int parenIdx = methodName.indexOf(QLatin1Char('('));
+ Q_ASSERT(parenIdx != -1);
+ methodName = methodName.left(parenIdx);
+
+ if (stringCache.contains(methodName))
+ continue;
+
+ RData *data = new RData;
+ data->identifier = enginePriv->objectClass->createPersistentIdentifier(methodName);
+
+ data->load(m);
+
+ stringCache.insert(methodName, data);
+ identifierCache.insert(data->identifier.identifier, data);
+ data->addref();
+ }
+}
+
+QDeclarativePropertyCache::Data *
+QDeclarativePropertyCache::property(int index) const
+{
+ if (index < 0 || index >= indexCache.count())
+ return 0;
+
+ return indexCache.at(index);
+}
+
+QDeclarativePropertyCache::Data *
+QDeclarativePropertyCache::property(const QString &str) const
+{
+ return stringCache.value(str);
+}
+
+QString QDeclarativePropertyCache::Data::name(QObject *object)
+{
+ if (!object)
+ return QString();
+
+ return name(object->metaObject());
+}
+
+QString QDeclarativePropertyCache::Data::name(const QMetaObject *metaObject)
+{
+ if (!metaObject || coreIndex == -1)
+ return QString();
+
+ if (flags & IsFunction) {
+ QMetaMethod m = metaObject->method(coreIndex);
+
+ QString name = QString::fromUtf8(m.signature());
+ int parenIdx = name.indexOf(QLatin1Char('('));
+ if (parenIdx != -1)
+ name = name.left(parenIdx);
+ return name;
+ } else {
+ QMetaProperty p = metaObject->property(coreIndex);
+ return QString::fromUtf8(p.name());
+ }
+}
+
+QStringList QDeclarativePropertyCache::propertyNames() const
+{
+ return stringCache.keys();
+}
+
+QDeclarativePropertyCache::Data *QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj,
+ const QScriptDeclarativeClass::Identifier &name, Data &local)
+{
+ QDeclarativePropertyCache::Data *rv = 0;
+
+ QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine);
+
+ QDeclarativePropertyCache *cache = 0;
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(obj);
+ if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine)
+ cache = ddata->propertyCache;
+ if (!cache) {
+ cache = enginePrivate->cache(obj);
+ if (cache && ddata && !ddata->propertyCache) { cache->addref(); ddata->propertyCache = cache; }
+ }
+
+ if (cache) {
+ rv = cache->property(name);
+ } else {
+ local = QDeclarativePropertyCache::create(obj->metaObject(), enginePrivate->objectClass->toString(name));
+ if (local.isValid())
+ rv = &local;
+ }
+
+ return rv;
+}
+
+QDeclarativePropertyCache::Data *QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj,
+ const QString &name, Data &local)
+{
+ QDeclarativePropertyCache::Data *rv = 0;
+
+ if (!engine) {
+ local = QDeclarativePropertyCache::create(obj->metaObject(), name);
+ if (local.isValid())
+ rv = &local;
+ } else {
+ QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine);
+
+ QDeclarativePropertyCache *cache = 0;
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(obj);
+ if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine)
+ cache = ddata->propertyCache;
+ if (!cache) {
+ cache = enginePrivate->cache(obj);
+ if (cache && ddata && !ddata->propertyCache) { cache->addref(); ddata->propertyCache = cache; }
+ }
+
+ if (cache) {
+ rv = cache->property(name);
+ } else {
+ local = QDeclarativePropertyCache::create(obj->metaObject(), name);
+ if (local.isValid())
+ rv = &local;
+ }
+ }
+
+ return rv;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h
new file mode 100644
index 0000000..7f4b174
--- /dev/null
+++ b/src/declarative/qml/qdeclarativepropertycache_p.h
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPROPERTYCACHE_P_H
+#define QDECLARATIVEPROPERTYCACHE_P_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 "qdeclarativerefcount_p.h"
+#include "qdeclarativecleanup_p.h"
+
+#include <QtCore/qvector.h>
+
+#include <private/qscriptdeclarativeclass_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QMetaProperty;
+class QDeclarativePropertyCache : public QDeclarativeRefCount, public QDeclarativeCleanup
+{
+public:
+ QDeclarativePropertyCache(QDeclarativeEngine *);
+ virtual ~QDeclarativePropertyCache();
+
+ struct Data {
+ inline Data();
+ inline bool operator==(const Data &);
+
+ enum Flag {
+ NoFlags = 0x00000000,
+
+ // Can apply to all properties, except IsFunction
+ IsConstant = 0x00000001,
+ IsWritable = 0x00000002,
+ IsResettable = 0x00000004,
+
+ // These are mutualy exclusive
+ IsFunction = 0x00000008,
+ IsQObjectDerived = 0x00000010,
+ IsEnumType = 0x00000020,
+ IsQList = 0x00000080,
+ IsQmlBinding = 0x00000100,
+ IsQScriptValue = 0x00000200,
+
+ // Apply only to IsFunctions
+ IsVMEFunction = 0x00000400,
+ HasArguments = 0x00000800
+
+ };
+ Q_DECLARE_FLAGS(Flags, Flag)
+
+ bool isValid() const { return coreIndex != -1; }
+
+ Flags flags;
+ int propType;
+ int coreIndex;
+ int notifyIndex;
+
+ static Flags flagsForProperty(const QMetaProperty &, QDeclarativeEngine *engine = 0);
+ void load(const QMetaProperty &, QDeclarativeEngine *engine = 0);
+ void load(const QMetaMethod &);
+ QString name(QObject *);
+ QString name(const QMetaObject *);
+ };
+
+ struct ValueTypeData {
+ inline ValueTypeData();
+ inline bool operator==(const ValueTypeData &);
+ Data::Flags flags; // flags on the value type wrapper
+ int valueTypeCoreIdx; // The prop index of the access property on the value type wrapper
+ int valueTypePropType; // The QVariant::Type of access property on the value type wrapper
+ };
+
+ void update(QDeclarativeEngine *, const QMetaObject *);
+
+ QDeclarativePropertyCache *copy() const;
+ void append(QDeclarativeEngine *, const QMetaObject *, Data::Flag propertyFlags = Data::NoFlags,
+ Data::Flag methodFlags = Data::NoFlags);
+
+ static QDeclarativePropertyCache *create(QDeclarativeEngine *, const QMetaObject *);
+ static Data create(const QMetaObject *, const QString &);
+
+ inline Data *property(const QScriptDeclarativeClass::Identifier &id) const;
+ Data *property(const QString &) const;
+ Data *property(int) const;
+ QStringList propertyNames() const;
+
+ inline QDeclarativeEngine *qmlEngine() const;
+ static Data *property(QDeclarativeEngine *, QObject *, const QScriptDeclarativeClass::Identifier &, Data &);
+ static Data *property(QDeclarativeEngine *, QObject *, const QString &, Data &);
+protected:
+ virtual void clear();
+
+private:
+ struct RData : public Data, public QDeclarativeRefCount {
+ QScriptDeclarativeClass::PersistentIdentifier identifier;
+ };
+
+ typedef QVector<RData *> IndexCache;
+ typedef QHash<QString, RData *> StringCache;
+ typedef QHash<QScriptDeclarativeClass::Identifier, RData *> IdentifierCache;
+
+ QDeclarativeEngine *engine;
+ IndexCache indexCache;
+ StringCache stringCache;
+ IdentifierCache identifierCache;
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyCache::Data::Flags);
+
+QDeclarativePropertyCache::Data::Data()
+: flags(0), propType(0), coreIndex(-1), notifyIndex(-1)
+{
+}
+
+bool QDeclarativePropertyCache::Data::operator==(const QDeclarativePropertyCache::Data &other)
+{
+ return flags == other.flags &&
+ propType == other.propType &&
+ coreIndex == other.coreIndex &&
+ notifyIndex == other.notifyIndex;
+}
+
+QDeclarativePropertyCache::Data *
+QDeclarativePropertyCache::property(const QScriptDeclarativeClass::Identifier &id) const
+{
+ return identifierCache.value(id);
+}
+
+QDeclarativePropertyCache::ValueTypeData::ValueTypeData()
+: flags(QDeclarativePropertyCache::Data::NoFlags), valueTypeCoreIdx(-1), valueTypePropType(0)
+{
+}
+
+bool QDeclarativePropertyCache::ValueTypeData::operator==(const ValueTypeData &o)
+{
+ return flags == o.flags &&
+ valueTypeCoreIdx == o.valueTypeCoreIdx &&
+ valueTypePropType == o.valueTypePropType;
+}
+
+QDeclarativeEngine *QDeclarativePropertyCache::qmlEngine() const
+{
+ return engine;
+}
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEPROPERTYCACHE_P_H
diff --git a/src/declarative/qml/qdeclarativepropertyvalueinterceptor.cpp b/src/declarative/qml/qdeclarativepropertyvalueinterceptor.cpp
new file mode 100644
index 0000000..7626d56
--- /dev/null
+++ b/src/declarative/qml/qdeclarativepropertyvalueinterceptor.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativepropertyvalueinterceptor.h"
+
+#include "qdeclarative.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QDeclarativePropertyValueInterceptor
+ \brief The QDeclarativePropertyValueInterceptor class is inherited by property interceptors such as Behavior.
+ \internal
+
+ This class intercepts property writes, allowing for custom handling. For example, Behavior uses this
+ interception to provide a default animation for all changes to a property's value.
+ */
+
+/*!
+ Constructs a QDeclarativePropertyValueInterceptor.
+*/
+QDeclarativePropertyValueInterceptor::QDeclarativePropertyValueInterceptor()
+{
+}
+
+QDeclarativePropertyValueInterceptor::~QDeclarativePropertyValueInterceptor()
+{
+}
+
+/*!
+ \fn void QDeclarativePropertyValueInterceptor::setTarget(const QDeclarativeMetaProperty &property)
+ Set the target \a property for the value interceptor. This method will
+ be called by the QML engine when assigning a value interceptor.
+*/
+
+/*!
+ \fn void QDeclarativePropertyValueInterceptor::write(const QVariant &value)
+ This method will be called when a new \a value is assigned to the property being intercepted.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativepropertyvalueinterceptor.h b/src/declarative/qml/qdeclarativepropertyvalueinterceptor.h
new file mode 100644
index 0000000..2a29d5b
--- /dev/null
+++ b/src/declarative/qml/qdeclarativepropertyvalueinterceptor.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPROPERTYVALUEINTERCEPTOR_H
+#define QDECLARATIVEPROPERTYVALUEINTERCEPTOR_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeMetaProperty;
+class Q_DECLARATIVE_EXPORT QDeclarativePropertyValueInterceptor
+{
+public:
+ QDeclarativePropertyValueInterceptor();
+ virtual ~QDeclarativePropertyValueInterceptor();
+ virtual void setTarget(const QDeclarativeMetaProperty &property) = 0;
+ virtual void write(const QVariant &value) = 0;
+};
+Q_DECLARE_INTERFACE(QDeclarativePropertyValueInterceptor, "com.trolltech.qml.QDeclarativePropertyValueInterceptor")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPROPERTYVALUEINTERCEPTOR_H
diff --git a/src/declarative/qml/qdeclarativepropertyvaluesource.cpp b/src/declarative/qml/qdeclarativepropertyvaluesource.cpp
new file mode 100644
index 0000000..626e391
--- /dev/null
+++ b/src/declarative/qml/qdeclarativepropertyvaluesource.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativepropertyvaluesource.h"
+
+#include "qdeclarative.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QDeclarativePropertyValueSource
+ \brief The QDeclarativePropertyValueSource class is inherited by property value sources such as animations and bindings.
+ \internal
+ */
+
+/*!
+ Constructs a QDeclarativePropertyValueSource.
+*/
+QDeclarativePropertyValueSource::QDeclarativePropertyValueSource()
+{
+}
+
+QDeclarativePropertyValueSource::~QDeclarativePropertyValueSource()
+{
+}
+
+/*!
+ \fn void QDeclarativePropertyValueSource::setTarget(const QDeclarativeMetaProperty &property)
+ Set the target \a property for the value source. This method will
+ be called by the QML engine when assigning a value source.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativepropertyvaluesource.h b/src/declarative/qml/qdeclarativepropertyvaluesource.h
new file mode 100644
index 0000000..99c80af
--- /dev/null
+++ b/src/declarative/qml/qdeclarativepropertyvaluesource.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPROPERTYVALUESOURCE_H
+#define QDECLARATIVEPROPERTYVALUESOURCE_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeMetaProperty;
+class Q_DECLARATIVE_EXPORT QDeclarativePropertyValueSource
+{
+public:
+ QDeclarativePropertyValueSource();
+ virtual ~QDeclarativePropertyValueSource();
+ virtual void setTarget(const QDeclarativeMetaProperty &) = 0;
+};
+Q_DECLARE_INTERFACE(QDeclarativePropertyValueSource, "com.trolltech.qml.QDeclarativePropertyValueSource")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPROPERTYVALUESOURCE_H
diff --git a/src/declarative/qml/qdeclarativeproxymetaobject.cpp b/src/declarative/qml/qdeclarativeproxymetaobject.cpp
new file mode 100644
index 0000000..1decea1
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeproxymetaobject.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeproxymetaobject_p.h"
+
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeProxyMetaObject::QDeclarativeProxyMetaObject(QObject *obj, QList<ProxyData> *mList)
+: metaObjects(mList), proxies(0), parent(0), object(obj)
+{
+#ifdef QDECLARATIVEPROXYMETAOBJECT_DEBUG
+ qWarning() << "QDeclarativeProxyMetaObject" << obj->metaObject()->className();
+#endif
+
+ *static_cast<QMetaObject *>(this) = *metaObjects->first().metaObject;
+
+ QObjectPrivate *op = QObjectPrivate::get(obj);
+ if (op->metaObject)
+ parent = static_cast<QAbstractDynamicMetaObject*>(op->metaObject);
+
+ op->metaObject = this;
+
+#ifdef QDECLARATIVEPROXYMETAOBJECT_DEBUG
+ const QMetaObject *mo = obj->metaObject();
+ while(mo) {
+ qWarning() << " " << mo->className();
+ mo = mo->superClass();
+ }
+#endif
+}
+
+QDeclarativeProxyMetaObject::~QDeclarativeProxyMetaObject()
+{
+ if (parent)
+ delete parent;
+ parent = 0;
+
+ if (proxies)
+ delete [] proxies;
+ proxies = 0;
+}
+
+int QDeclarativeProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
+{
+ if ((c == QMetaObject::ReadProperty ||
+ c == QMetaObject::WriteProperty) &&
+ id >= metaObjects->last().propertyOffset) {
+
+ for (int ii = 0; ii < metaObjects->count(); ++ii) {
+ const ProxyData &data = metaObjects->at(ii);
+ if (id >= data.propertyOffset) {
+ if (!proxies) {
+ proxies = new QObject*[metaObjects->count()];
+ ::memset(proxies, 0,
+ sizeof(QObject *) * metaObjects->count());
+ }
+
+ if (!proxies[ii]) {
+ QObject *proxy = data.createFunc(object);
+ const QMetaObject *metaObject = proxy->metaObject();
+ proxies[ii] = proxy;
+
+ int localOffset = data.metaObject->methodOffset();
+ int methodOffset = metaObject->methodOffset();
+ int methods = metaObject->methodCount() - methodOffset;
+
+ // ### - Can this be done more optimally?
+ for (int jj = 0; jj < methods; ++jj) {
+ QMetaMethod method =
+ metaObject->method(jj + methodOffset);
+ if (method.methodType() == QMetaMethod::Signal)
+ QMetaObject::connect(proxy, methodOffset + jj,
+ object, localOffset + jj);
+ }
+ }
+
+ int proxyOffset = proxies[ii]->metaObject()->propertyOffset();
+ int proxyId = id - data.propertyOffset + proxyOffset;
+
+ return proxies[ii]->qt_metacall(c, proxyId, a);
+ }
+ }
+ } else if (c == QMetaObject::InvokeMetaMethod &&
+ id >= metaObjects->last().methodOffset) {
+ QMetaMethod m = object->metaObject()->method(id);
+ if (m.methodType() == QMetaMethod::Signal) {
+ QMetaObject::activate(object, id, a);
+ return -1;
+ }
+ }
+
+ if (parent)
+ return parent->metaCall(c, id, a);
+ else
+ return object->qt_metacall(c, id, a);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeproxymetaobject_p.h b/src/declarative/qml/qdeclarativeproxymetaobject_p.h
new file mode 100644
index 0000000..3f103b6
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeproxymetaobject_p.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPROXYMETAOBJECT_P_H
+#define QDECLARATIVEPROXYMETAOBJECT_P_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 "qmetaobjectbuilder_p.h"
+#include "qdeclarative.h"
+
+#include <QtCore/QMetaObject>
+#include <QtCore/QObject>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeProxyMetaObject : public QAbstractDynamicMetaObject
+{
+public:
+ struct ProxyData {
+ typedef QObject *(*CreateFunc)(QObject *);
+ QMetaObject *metaObject;
+ CreateFunc createFunc;
+ int propertyOffset;
+ int methodOffset;
+ };
+
+ QDeclarativeProxyMetaObject(QObject *, QList<ProxyData> *);
+ virtual ~QDeclarativeProxyMetaObject();
+
+protected:
+ virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
+
+private:
+ QList<ProxyData> *metaObjects;
+ QObject **proxies;
+
+ QAbstractDynamicMetaObject *parent;
+ QObject *object;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPROXYMETAOBJECT_P_H
+
diff --git a/src/declarative/qml/qdeclarativerefcount.cpp b/src/declarative/qml/qdeclarativerefcount.cpp
new file mode 100644
index 0000000..943e35c
--- /dev/null
+++ b/src/declarative/qml/qdeclarativerefcount.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativerefcount_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeRefCount::QDeclarativeRefCount()
+: refCount(1)
+{
+}
+
+QDeclarativeRefCount::~QDeclarativeRefCount()
+{
+}
+
+void QDeclarativeRefCount::addref()
+{
+ Q_ASSERT(refCount > 0);
+ ++refCount;
+}
+
+void QDeclarativeRefCount::release()
+{
+ Q_ASSERT(refCount > 0);
+ --refCount;
+ if (refCount == 0)
+ delete this;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qdeclarativerefcount_p.h b/src/declarative/qml/qdeclarativerefcount_p.h
new file mode 100644
index 0000000..1170b86
--- /dev/null
+++ b/src/declarative/qml/qdeclarativerefcount_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEREFCOUNT_P_H
+#define QDECLARATIVEREFCOUNT_P_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>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_AUTOTEST_EXPORT QDeclarativeRefCount
+{
+public:
+ QDeclarativeRefCount();
+ virtual ~QDeclarativeRefCount();
+ void addref();
+ void release();
+
+private:
+ int refCount;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEREFCOUNT_P_H
diff --git a/src/declarative/qml/qdeclarativerewrite.cpp b/src/declarative/qml/qdeclarativerewrite.cpp
new file mode 100644
index 0000000..afc6e63
--- /dev/null
+++ b/src/declarative/qml/qdeclarativerewrite.cpp
@@ -0,0 +1,215 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativerewrite_p.h"
+
+#include "qdeclarativeglobal_p.h"
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(rewriteDump, QML_REWRITE_DUMP);
+
+namespace QDeclarativeRewrite {
+
+bool SharedBindingTester::isSharable(const QString &code)
+{
+ Engine engine;
+ NodePool pool(QString(), &engine);
+ Lexer lexer(&engine);
+ Parser parser(&engine);
+ lexer.setCode(code, 0);
+ parser.parseStatement();
+ if (!parser.statement())
+ return false;
+
+ _sharable = true;
+ AST::Node::acceptChild(parser.statement(), this);
+ return _sharable;
+}
+
+QString RewriteBinding::operator()(const QString &code, bool *ok)
+{
+ Engine engine;
+ NodePool pool(QString(), &engine);
+ Lexer lexer(&engine);
+ Parser parser(&engine);
+ lexer.setCode(code, 0);
+ parser.parseStatement();
+ if (!parser.statement()) {
+ if (ok) *ok = false;
+ return QString();
+ } else {
+ if (ok) *ok = true;
+ }
+ return rewrite(code, 0, parser.statement());
+}
+
+void RewriteBinding::accept(AST::Node *node)
+{
+ AST::Node::acceptChild(node, this);
+}
+
+QString RewriteBinding::rewrite(QString code, unsigned position,
+ AST::Statement *node)
+{
+ TextWriter w;
+ _writer = &w;
+ _position = position;
+ _inLoop = 0;
+
+ accept(node);
+
+ unsigned startOfStatement = node->firstSourceLocation().begin() - _position;
+ unsigned endOfStatement = node->lastSourceLocation().end() - _position;
+
+ _writer->replace(startOfStatement, 0, QLatin1String("(function() { "));
+ _writer->replace(endOfStatement, 0, QLatin1String(" })"));
+
+ if (rewriteDump()) {
+ qWarning() << "=============================================================";
+ qWarning() << "Rewrote:";
+ qWarning() << qPrintable(code);
+ }
+
+ w.write(&code);
+
+ if (rewriteDump()) {
+ qWarning() << "To:";
+ qWarning() << qPrintable(code);
+ qWarning() << "=============================================================";
+ }
+
+ return code;
+}
+
+bool RewriteBinding::visit(AST::Block *ast)
+{
+ for (AST::StatementList *it = ast->statements; it; it = it->next) {
+ if (! it->next) {
+ // we need to rewrite only the last statement of a block.
+ accept(it->statement);
+ }
+ }
+
+ return false;
+}
+
+bool RewriteBinding::visit(AST::ExpressionStatement *ast)
+{
+ if (! _inLoop) {
+ unsigned startOfExpressionStatement = ast->firstSourceLocation().begin() - _position;
+ _writer->replace(startOfExpressionStatement, 0, QLatin1String("return "));
+ }
+
+ return false;
+}
+
+bool RewriteBinding::visit(AST::DoWhileStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::DoWhileStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::WhileStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::WhileStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::ForStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::ForStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::LocalForStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::LocalForStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::ForEachStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::ForEachStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::LocalForEachStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::LocalForEachStatement *)
+{
+ --_inLoop;
+}
+
+} // namespace QDeclarativeRewrite
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativerewrite_p.h b/src/declarative/qml/qdeclarativerewrite_p.h
new file mode 100644
index 0000000..33b168c
--- /dev/null
+++ b/src/declarative/qml/qdeclarativerewrite_p.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEREWRITE_P_H
+#define QDECLARATIVEREWRITE_P_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 "rewriter/textwriter_p.h"
+#include "parser/qdeclarativejslexer_p.h"
+#include "parser/qdeclarativejsparser_p.h"
+#include "parser/qdeclarativejsnodepool_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QDeclarativeRewrite {
+using namespace QDeclarativeJS;
+
+class SharedBindingTester : protected AST::Visitor
+{
+ bool _sharable;
+public:
+ bool isSharable(const QString &code);
+
+ virtual bool visit(AST::FunctionDeclaration *) { _sharable = false; return false; }
+ virtual bool visit(AST::FunctionExpression *) { _sharable = false; return false; }
+ virtual bool visit(AST::CallExpression *) { _sharable = false; return false; }
+};
+
+class RewriteBinding: protected AST::Visitor
+{
+ unsigned _position;
+ TextWriter *_writer;
+
+public:
+ QString operator()(const QString &code, bool *ok = 0);
+
+protected:
+ using AST::Visitor::visit;
+
+ void accept(AST::Node *node);
+ QString rewrite(QString code, unsigned position, AST::Statement *node);
+
+ virtual bool visit(AST::Block *ast);
+ virtual bool visit(AST::ExpressionStatement *ast);
+
+ virtual bool visit(AST::DoWhileStatement *ast);
+ virtual void endVisit(AST::DoWhileStatement *ast);
+
+ virtual bool visit(AST::WhileStatement *ast);
+ virtual void endVisit(AST::WhileStatement *ast);
+
+ virtual bool visit(AST::ForStatement *ast);
+ virtual void endVisit(AST::ForStatement *ast);
+
+ virtual bool visit(AST::LocalForStatement *ast);
+ virtual void endVisit(AST::LocalForStatement *ast);
+
+ virtual bool visit(AST::ForEachStatement *ast);
+ virtual void endVisit(AST::ForEachStatement *ast);
+
+ virtual bool visit(AST::LocalForEachStatement *ast);
+ virtual void endVisit(AST::LocalForEachStatement *ast);
+
+private:
+ int _inLoop;
+};
+
+} // namespace QDeclarativeRewrite
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEREWRITE_P_H
+
diff --git a/src/declarative/qml/qdeclarativescript.cpp b/src/declarative/qml/qdeclarativescript.cpp
new file mode 100644
index 0000000..acfb9e1
--- /dev/null
+++ b/src/declarative/qml/qdeclarativescript.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This is just a dummy file to include the documentation
+
+/*!
+ \qmlclass Script QDeclarativeScript
+ \brief The Script element provides a way to add JavaScript code snippets in QML.
+ \ingroup group_utility
+
+ The Script element is used to add convenient JavaScript "glue" methods to
+ your Qt Declarative application or component.
+
+ An example:
+
+ \qml
+ Script {
+ function debugMyComponent() {
+ console.log(text.text);
+ console.log(otherinterestingitem.property);
+ }
+ }
+ MouseArea { onClicked: debugMyComponent() }
+ \endqml
+
+ \note While it is possible to use any JavaScript code within a Script element,
+ it is recommended that the code be limited to defining functions. The Script
+ element executes JavaScript as soon as it is specified, so
+ when defining a component, this may be done before the execution context is
+ fully specified. As a result, some properties or items may not be
+ accessible. You can avoid this problem by limiting your JavaScript to
+ defining functions that are only executed later once the context is fully
+ defined.
+
+ \sa {JavaScript Blocks}
+*/
+
+/*!
+ \qmlproperty string Script::script
+ \default
+ The JavaScript code to be executed.
+*/
+
+/*!
+ \qmlproperty url Script::source
+
+ Specifies a source file containing JavaScript code. This can be used instead
+ of providing inline JavaScript code in the Script element.
+*/
diff --git a/src/declarative/qml/qdeclarativescriptclass_p.h b/src/declarative/qml/qdeclarativescriptclass_p.h
new file mode 100644
index 0000000..d8733db
--- /dev/null
+++ b/src/declarative/qml/qdeclarativescriptclass_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVESCRIPTCLASS_P_H
+#define QDECLARATIVESCRIPTCLASS_P_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 <QtScript/qscriptclass.h>
+#include <private/qscriptdeclarativeclass_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QDeclarativeScriptClass : public QScriptDeclarativeClass
+{
+public:
+ QDeclarativeScriptClass(QScriptEngine *);
+
+ static QVariant toVariant(QDeclarativeEngine *, const QScriptValue &);
+
+#if (QT_VERSION <= QT_VERSION_CHECK(4, 6, 2)) && !defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
+ struct Value : public QScriptValue {
+ Value() : QScriptValue() {}
+ Value(QScriptEngine *engine, int v) : QScriptValue(engine, v) {}
+ Value(QScriptEngine *engine, uint v) : QScriptValue(engine, v) {}
+ Value(QScriptEngine *engine, bool v) : QScriptValue(engine, v) {}
+ Value(QScriptEngine *engine, double v) : QScriptValue(engine, v) {}
+ Value(QScriptEngine *engine, float v) : QScriptValue(engine, v) {}
+ Value(QScriptEngine *engine, const QString &v) : QScriptValue(engine, v) {}
+ Value(QScriptEngine *, const QScriptValue &v) : QScriptValue(v) {}
+ };
+
+ typedef QScriptValue ScriptValue;
+#else
+ typedef Value ScriptValue;
+#endif
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVESCRIPTCLASS_P_H
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
new file mode 100644
index 0000000..9636350
--- /dev/null
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -0,0 +1,952 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativescriptparser_p.h"
+
+#include "qdeclarativeparser_p.h"
+#include "parser/qdeclarativejsengine_p.h"
+#include "parser/qdeclarativejsparser_p.h"
+#include "parser/qdeclarativejslexer_p.h"
+#include "parser/qdeclarativejsnodepool_p.h"
+#include "parser/qdeclarativejsastvisitor_p.h"
+#include "parser/qdeclarativejsast_p.h"
+#include "qdeclarativerewrite_p.h"
+
+#include <qfxperf_p_p.h>
+
+#include <QStack>
+#include <QCoreApplication>
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QDeclarativeJS;
+using namespace QDeclarativeParser;
+
+namespace {
+
+class ProcessAST: protected AST::Visitor
+{
+ struct State {
+ State() : object(0), property(0) {}
+ State(Object *o) : object(o), property(0) {}
+ State(Object *o, Property *p) : object(o), property(p) {}
+
+ Object *object;
+ Property *property;
+ };
+
+ struct StateStack : public QStack<State>
+ {
+ void pushObject(Object *obj)
+ {
+ push(State(obj));
+ }
+
+ void pushProperty(const QString &name, const LocationSpan &location)
+ {
+ const State &state = top();
+ if (state.property) {
+ State s(state.property->getValue(),
+ state.property->getValue()->getProperty(name.toUtf8()));
+ s.property->location = location;
+ push(s);
+ } else {
+ State s(state.object,
+ state.object->getProperty(name.toUtf8()));
+
+ s.property->location = location;
+ push(s);
+ }
+ }
+ };
+
+public:
+ ProcessAST(QDeclarativeScriptParser *parser);
+ virtual ~ProcessAST();
+
+ void operator()(const QString &code, AST::Node *node);
+
+protected:
+ Object *defineObjectBinding(AST::UiQualifiedId *propertyName,
+ AST::UiQualifiedId *objectTypeName,
+ LocationSpan location,
+ AST::UiObjectInitializer *initializer = 0);
+
+ Object *defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
+ const QString &objectType,
+ AST::SourceLocation typeLocation,
+ LocationSpan location,
+ AST::UiObjectInitializer *initializer = 0);
+
+ QDeclarativeParser::Variant getVariant(AST::ExpressionNode *expr);
+
+ LocationSpan location(AST::SourceLocation start, AST::SourceLocation end);
+ LocationSpan location(AST::UiQualifiedId *);
+
+ using AST::Visitor::visit;
+ using AST::Visitor::endVisit;
+
+ virtual bool visit(AST::UiProgram *node);
+ virtual bool visit(AST::UiImport *node);
+ virtual bool visit(AST::UiObjectDefinition *node);
+ virtual bool visit(AST::UiPublicMember *node);
+ virtual bool visit(AST::UiObjectBinding *node);
+
+ virtual bool visit(AST::UiScriptBinding *node);
+ virtual bool visit(AST::UiArrayBinding *node);
+ virtual bool visit(AST::UiSourceElement *node);
+
+ void accept(AST::Node *node);
+
+ QString asString(AST::UiQualifiedId *node) const;
+
+ const State state() const;
+ Object *currentObject() const;
+ Property *currentProperty() const;
+
+ QString qualifiedNameId() const;
+
+ QString textAt(const AST::SourceLocation &loc) const
+ { return _contents.mid(loc.offset, loc.length); }
+
+
+ QString textAt(const AST::SourceLocation &first,
+ const AST::SourceLocation &last) const
+ { return _contents.mid(first.offset, last.offset + last.length - first.offset); }
+
+ QString asString(AST::ExpressionNode *expr)
+ {
+ if (! expr)
+ return QString();
+
+ return textAt(expr->firstSourceLocation(), expr->lastSourceLocation());
+ }
+
+ QString asString(AST::Statement *stmt)
+ {
+ if (! stmt)
+ return QString();
+
+ QString s = textAt(stmt->firstSourceLocation(), stmt->lastSourceLocation());
+ s += QLatin1Char('\n');
+ return s;
+ }
+
+private:
+ QDeclarativeScriptParser *_parser;
+ StateStack _stateStack;
+ QStringList _scope;
+ QString _contents;
+
+ inline bool isSignalProperty(const QByteArray &propertyName) const {
+ return (propertyName.length() >= 3 && propertyName.startsWith("on") &&
+ ('A' <= propertyName.at(2) && 'Z' >= propertyName.at(2)));
+ }
+
+};
+
+ProcessAST::ProcessAST(QDeclarativeScriptParser *parser)
+ : _parser(parser)
+{
+}
+
+ProcessAST::~ProcessAST()
+{
+}
+
+void ProcessAST::operator()(const QString &code, AST::Node *node)
+{
+ _contents = code;
+ accept(node);
+}
+
+void ProcessAST::accept(AST::Node *node)
+{
+ AST::Node::acceptChild(node, this);
+}
+
+const ProcessAST::State ProcessAST::state() const
+{
+ if (_stateStack.isEmpty())
+ return State();
+
+ return _stateStack.back();
+}
+
+Object *ProcessAST::currentObject() const
+{
+ return state().object;
+}
+
+Property *ProcessAST::currentProperty() const
+{
+ return state().property;
+}
+
+QString ProcessAST::qualifiedNameId() const
+{
+ return _scope.join(QLatin1String("/"));
+}
+
+QString ProcessAST::asString(AST::UiQualifiedId *node) const
+{
+ QString s;
+
+ for (AST::UiQualifiedId *it = node; it; it = it->next) {
+ s.append(it->name->asString());
+
+ if (it->next)
+ s.append(QLatin1Char('.'));
+ }
+
+ return s;
+}
+
+Object *
+ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
+ const QString &objectType,
+ AST::SourceLocation typeLocation,
+ LocationSpan location,
+ AST::UiObjectInitializer *initializer)
+{
+ int lastTypeDot = objectType.lastIndexOf(QLatin1Char('.'));
+ bool isType = !objectType.isEmpty() &&
+ (objectType.at(0).isUpper() ||
+ (lastTypeDot >= 0 && objectType.at(lastTypeDot+1).isUpper()));
+
+ int propertyCount = 0;
+ for (; propertyName; propertyName = propertyName->next){
+ ++propertyCount;
+ _stateStack.pushProperty(propertyName->name->asString(),
+ this->location(propertyName));
+ }
+
+ if (!isType) {
+
+ if(propertyCount || !currentObject()) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Expected type name"));
+ error.setLine(typeLocation.startLine);
+ error.setColumn(typeLocation.startColumn);
+ _parser->_errors << error;
+ return 0;
+ }
+
+ LocationSpan loc = ProcessAST::location(typeLocation, typeLocation);
+ if (propertyName)
+ loc = ProcessAST::location(propertyName);
+
+ _stateStack.pushProperty(objectType, loc);
+ accept(initializer);
+ _stateStack.pop();
+
+ return 0;
+
+ } else {
+ // Class
+
+ QString resolvableObjectType = objectType;
+ if (lastTypeDot >= 0)
+ resolvableObjectType.replace(QLatin1Char('.'),QLatin1Char('/'));
+
+ bool isScript = resolvableObjectType == QLatin1String("Script");
+
+ if (isScript) {
+ if (_stateStack.isEmpty() || _stateStack.top().property) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Invalid use of Script block"));
+ error.setLine(typeLocation.startLine);
+ error.setColumn(typeLocation.startColumn);
+ _parser->_errors << error;
+ return 0;
+ }
+ }
+
+ Object *obj = new Object;
+
+ if (!isScript) {
+ QDeclarativeScriptParser::TypeReference *typeRef = _parser->findOrCreateType(resolvableObjectType);
+ obj->type = typeRef->id;
+
+ typeRef->refObjects.append(obj);
+ }
+
+ // XXX this doesn't do anything (_scope never builds up)
+ _scope.append(resolvableObjectType);
+ obj->typeName = qualifiedNameId().toUtf8();
+ _scope.removeLast();
+
+ obj->location = location;
+
+ if (isScript) {
+
+ _stateStack.top().object->scriptBlockObjects.append(obj);
+
+ } else if (propertyCount) {
+
+ Property *prop = currentProperty();
+ Value *v = new Value;
+ v->object = obj;
+ v->location = obj->location;
+ prop->addValue(v);
+
+ while (propertyCount--)
+ _stateStack.pop();
+
+ } else {
+
+ if (! _parser->tree()) {
+ _parser->setTree(obj);
+ } else {
+ const State state = _stateStack.top();
+ Value *v = new Value;
+ v->object = obj;
+ v->location = obj->location;
+ if (state.property) {
+ state.property->addValue(v);
+ } else {
+ Property *defaultProp = state.object->getDefaultProperty();
+ if (defaultProp->location.start.line == -1) {
+ defaultProp->location = v->location;
+ defaultProp->location.end = defaultProp->location.start;
+ defaultProp->location.range.length = 0;
+ }
+ defaultProp->addValue(v);
+ }
+ }
+ }
+
+ _stateStack.pushObject(obj);
+ accept(initializer);
+ _stateStack.pop();
+
+ return obj;
+ }
+}
+
+Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId,
+ AST::UiQualifiedId *objectTypeName,
+ LocationSpan location,
+ AST::UiObjectInitializer *initializer)
+{
+ const QString objectType = asString(objectTypeName);
+ const AST::SourceLocation typeLocation = objectTypeName->identifierToken;
+
+ if (objectType == QLatin1String("Script")) {
+
+ AST::UiObjectMemberList *it = initializer->members;
+ for (; it; it = it->next) {
+ AST::UiScriptBinding *scriptBinding = AST::cast<AST::UiScriptBinding *>(it->member);
+ if (! scriptBinding)
+ continue;
+
+ QString propertyName = asString(scriptBinding->qualifiedId);
+ if (propertyName == QLatin1String("source")) {
+ if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(scriptBinding->statement)) {
+ QDeclarativeParser::Variant string = getVariant(stmt->expression);
+ if (string.isStringList()) {
+ QStringList urls = string.asStringList();
+ // We need to add this as a resource
+ for (int ii = 0; ii < urls.count(); ++ii)
+ _parser->_refUrls << QUrl(urls.at(ii));
+ }
+ }
+ }
+ }
+
+ }
+
+ return defineObjectBinding_helper(qualifiedId, objectType, typeLocation, location, initializer);
+}
+
+LocationSpan ProcessAST::location(AST::UiQualifiedId *id)
+{
+ return location(id->identifierToken, id->identifierToken);
+}
+
+LocationSpan ProcessAST::location(AST::SourceLocation start, AST::SourceLocation end)
+{
+ LocationSpan rv;
+ rv.start.line = start.startLine;
+ rv.start.column = start.startColumn;
+ rv.end.line = end.startLine;
+ rv.end.column = end.startColumn + end.length - 1;
+ rv.range.offset = start.offset;
+ rv.range.length = end.offset + end.length - start.offset;
+ return rv;
+}
+
+// UiProgram: UiImportListOpt UiObjectMemberList ;
+bool ProcessAST::visit(AST::UiProgram *node)
+{
+ accept(node->imports);
+ accept(node->members->member);
+ return false;
+}
+
+// UiImport: T_IMPORT T_STRING_LITERAL ;
+bool ProcessAST::visit(AST::UiImport *node)
+{
+ QString uri;
+ QDeclarativeScriptParser::Import import;
+
+ if (node->fileName) {
+ import.type = QDeclarativeScriptParser::Import::File;
+ uri = node->fileName->asString();
+ } else {
+ import.type = QDeclarativeScriptParser::Import::Library;
+ uri = asString(node->importUri);
+ }
+
+ AST::SourceLocation startLoc = node->importToken;
+ AST::SourceLocation endLoc = node->semicolonToken;
+
+ if (node->importId) {
+ import.qualifier = node->importId->asString();
+ if (!import.qualifier.at(0).isUpper()) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Invalid import qualifier ID"));
+ error.setLine(node->importIdToken.startLine);
+ error.setColumn(node->importIdToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+ }
+ if (node->versionToken.isValid())
+ import.version = textAt(node->versionToken);
+ else if (import.type == QDeclarativeScriptParser::Import::Library) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Library import requires a version"));
+ error.setLine(node->importIdToken.startLine);
+ error.setColumn(node->importIdToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ import.location = location(startLoc, endLoc);
+ import.uri = uri;
+
+ _parser->_imports << import;
+
+ return false;
+}
+
+bool ProcessAST::visit(AST::UiPublicMember *node)
+{
+ const struct TypeNameToType {
+ const char *name;
+ Object::DynamicProperty::Type type;
+ const char *qtName;
+ } propTypeNameToTypes[] = {
+ { "int", Object::DynamicProperty::Int, "int" },
+ { "bool", Object::DynamicProperty::Bool, "bool" },
+ { "double", Object::DynamicProperty::Real, "double" },
+ { "real", Object::DynamicProperty::Real, "qreal" },
+ { "string", Object::DynamicProperty::String, "QString" },
+ { "url", Object::DynamicProperty::Url, "QUrl" },
+ { "color", Object::DynamicProperty::Color, "QColor" },
+ { "date", Object::DynamicProperty::Date, "QDate" },
+ { "var", Object::DynamicProperty::Variant, "QVariant" },
+ { "variant", Object::DynamicProperty::Variant, "QVariant" }
+ };
+ const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) /
+ sizeof(propTypeNameToTypes[0]);
+
+ if(node->type == AST::UiPublicMember::Signal) {
+ const QString name = node->name->asString();
+
+ Object::DynamicSignal signal;
+ signal.name = name.toUtf8();
+
+ AST::UiParameterList *p = node->parameters;
+ while (p) {
+ const QString memberType = p->type->asString();
+ const char *qtType = 0;
+ for(int ii = 0; !qtType && ii < propTypeNameToTypesCount; ++ii) {
+ if(QLatin1String(propTypeNameToTypes[ii].name) == memberType)
+ qtType = propTypeNameToTypes[ii].qtName;
+ }
+
+ if (!qtType) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Expected parameter type"));
+ error.setLine(node->typeToken.startLine);
+ error.setColumn(node->typeToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ signal.parameterTypes << qtType;
+ signal.parameterNames << p->name->asString().toUtf8();
+ p = p->finish();
+ }
+
+ _stateStack.top().object->dynamicSignals << signal;
+ } else {
+ const QString memberType = node->memberType->asString();
+ const QString name = node->name->asString();
+
+ bool typeFound = false;
+ Object::DynamicProperty::Type type;
+
+ if (memberType == QLatin1String("alias")) {
+ type = Object::DynamicProperty::Alias;
+ typeFound = true;
+ }
+
+ for(int ii = 0; !typeFound && ii < propTypeNameToTypesCount; ++ii) {
+ if(QLatin1String(propTypeNameToTypes[ii].name) == memberType) {
+ type = propTypeNameToTypes[ii].type;
+ typeFound = true;
+ }
+ }
+
+ if (!typeFound && memberType.at(0).isUpper()) {
+ QString typemodifier;
+ if(node->typeModifier)
+ typemodifier = node->typeModifier->asString();
+ if (typemodifier == QString()) {
+ type = Object::DynamicProperty::Custom;
+ } else if(typemodifier == QLatin1String("list")) {
+ type = Object::DynamicProperty::CustomList;
+ } else {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Invalid property type modifier"));
+ error.setLine(node->typeModifierToken.startLine);
+ error.setColumn(node->typeModifierToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+ typeFound = true;
+ } else if (node->typeModifier) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Unexpected property type modifier"));
+ error.setLine(node->typeModifierToken.startLine);
+ error.setColumn(node->typeModifierToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ if(!typeFound) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Expected property type"));
+ error.setLine(node->typeToken.startLine);
+ error.setColumn(node->typeToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ if (node->isReadonlyMember) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Readonly not yet supported"));
+ error.setLine(node->readonlyToken.startLine);
+ error.setColumn(node->readonlyToken.startColumn);
+ _parser->_errors << error;
+ return false;
+
+ }
+ Object::DynamicProperty property;
+ property.isDefaultProperty = node->isDefaultMember;
+ property.type = type;
+ if (type >= Object::DynamicProperty::Custom) {
+ QDeclarativeScriptParser::TypeReference *typeRef =
+ _parser->findOrCreateType(memberType);
+ typeRef->refObjects.append(_stateStack.top().object);
+ }
+ property.customType = memberType.toUtf8();
+ property.name = name.toUtf8();
+ property.location = location(node->firstSourceLocation(),
+ node->lastSourceLocation());
+
+ if (node->expression) { // default value
+ property.defaultValue = new Property;
+ property.defaultValue->parent = _stateStack.top().object;
+ property.defaultValue->location =
+ location(node->expression->firstSourceLocation(),
+ node->expression->lastSourceLocation());
+ Value *value = new Value;
+ value->location = location(node->expression->firstSourceLocation(),
+ node->expression->lastSourceLocation());
+ value->value = getVariant(node->expression);
+ property.defaultValue->values << value;
+ }
+
+ _stateStack.top().object->dynamicProperties << property;
+ }
+
+ return true;
+}
+
+
+// UiObjectMember: UiQualifiedId UiObjectInitializer ;
+bool ProcessAST::visit(AST::UiObjectDefinition *node)
+{
+ LocationSpan l = location(node->firstSourceLocation(),
+ node->lastSourceLocation());
+
+ defineObjectBinding(/*propertyName = */ 0,
+ node->qualifiedTypeNameId,
+ l,
+ node->initializer);
+
+ return false;
+}
+
+
+// UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ;
+bool ProcessAST::visit(AST::UiObjectBinding *node)
+{
+ LocationSpan l = location(node->qualifiedTypeNameId->identifierToken,
+ node->initializer->rbraceToken);
+
+ defineObjectBinding(node->qualifiedId,
+ node->qualifiedTypeNameId,
+ l,
+ node->initializer);
+
+ return false;
+}
+
+QDeclarativeParser::Variant ProcessAST::getVariant(AST::ExpressionNode *expr)
+{
+ if (AST::StringLiteral *lit = AST::cast<AST::StringLiteral *>(expr)) {
+ return QDeclarativeParser::Variant(lit->value->asString());
+ } else if (expr->kind == AST::Node::Kind_TrueLiteral) {
+ return QDeclarativeParser::Variant(true);
+ } else if (expr->kind == AST::Node::Kind_FalseLiteral) {
+ return QDeclarativeParser::Variant(false);
+ } else if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(expr)) {
+ return QDeclarativeParser::Variant(lit->value, asString(expr));
+ } else {
+
+ if (AST::UnaryMinusExpression *unaryMinus = AST::cast<AST::UnaryMinusExpression *>(expr)) {
+ if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(unaryMinus->expression)) {
+ return QDeclarativeParser::Variant(-lit->value, asString(expr));
+ }
+ }
+
+ return QDeclarativeParser::Variant(asString(expr), expr);
+ }
+}
+
+
+// UiObjectMember: UiQualifiedId T_COLON Statement ;
+bool ProcessAST::visit(AST::UiScriptBinding *node)
+{
+ int propertyCount = 0;
+ AST::UiQualifiedId *propertyName = node->qualifiedId;
+ for (; propertyName; propertyName = propertyName->next){
+ ++propertyCount;
+ _stateStack.pushProperty(propertyName->name->asString(),
+ location(propertyName));
+ }
+
+ Property *prop = currentProperty();
+
+ QDeclarativeParser::Variant primitive;
+
+ if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(node->statement)) {
+ primitive = getVariant(stmt->expression);
+ } else { // do binding
+ primitive = QDeclarativeParser::Variant(asString(node->statement),
+ node->statement);
+ }
+
+ prop->location.range.length = prop->location.range.offset + prop->location.range.length - node->qualifiedId->identifierToken.offset;
+ prop->location.range.offset = node->qualifiedId->identifierToken.offset;
+ Value *v = new Value;
+ v->value = primitive;
+ v->location = location(node->statement->firstSourceLocation(),
+ node->statement->lastSourceLocation());
+
+ prop->addValue(v);
+
+ while (propertyCount--)
+ _stateStack.pop();
+
+ return true;
+}
+
+static QList<int> collectCommas(AST::UiArrayMemberList *members)
+{
+ QList<int> commas;
+
+ if (members) {
+ for (AST::UiArrayMemberList *it = members->next; it; it = it->next) {
+ commas.append(it->commaToken.offset);
+ }
+ }
+
+ return commas;
+}
+
+// UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
+bool ProcessAST::visit(AST::UiArrayBinding *node)
+{
+ int propertyCount = 0;
+ AST::UiQualifiedId *propertyName = node->qualifiedId;
+ for (; propertyName; propertyName = propertyName->next){
+ ++propertyCount;
+ _stateStack.pushProperty(propertyName->name->asString(),
+ location(propertyName));
+ }
+
+ accept(node->members);
+
+ // For the DOM, store the position of the T_LBRACKET upto the T_RBRACKET as the range:
+ Property* prop = currentProperty();
+ prop->listValueRange.offset = node->lbracketToken.offset;
+ prop->listValueRange.length = node->rbracketToken.offset + node->rbracketToken.length - node->lbracketToken.offset;
+
+ // Store the positions of the comma token too, again for the DOM to be able to retreive it.
+ prop->listCommaPositions = collectCommas(node->members);
+
+ while (propertyCount--)
+ _stateStack.pop();
+
+ return false;
+}
+
+bool ProcessAST::visit(AST::UiSourceElement *node)
+{
+ QDeclarativeParser::Object *obj = currentObject();
+
+ bool isScript = (obj && obj->typeName == "Script");
+
+ if (!isScript) {
+
+ if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) {
+
+ Object::DynamicSlot slot;
+
+ AST::FormalParameterList *f = funDecl->formals;
+ while (f) {
+ slot.parameterNames << f->name->asString().toUtf8();
+ f = f->finish();
+ }
+
+ QString body = textAt(funDecl->lbraceToken, funDecl->rbraceToken);
+ slot.name = funDecl->name->asString().toUtf8();
+ slot.body = body;
+ obj->dynamicSlots << slot;
+
+ } else {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","QDeclarativeJS declaration outside Script element"));
+ error.setLine(node->firstSourceLocation().startLine);
+ error.setColumn(node->firstSourceLocation().startColumn);
+ _parser->_errors << error;
+ }
+ return false;
+
+ } else {
+ QString source;
+
+ int line = 0;
+ if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) {
+ line = funDecl->functionToken.startLine;
+ source = asString(funDecl);
+ } else if (AST::VariableStatement *varStmt = AST::cast<AST::VariableStatement *>(node->sourceElement)) {
+ // ignore variable declarations
+ line = varStmt->declarationKindToken.startLine;
+
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser", "Variable declarations not allow in inline Script blocks"));
+ error.setLine(node->firstSourceLocation().startLine);
+ error.setColumn(node->firstSourceLocation().startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ Value *value = new Value;
+ value->location = location(node->firstSourceLocation(),
+ node->lastSourceLocation());
+ value->value = QDeclarativeParser::Variant(source);
+
+ obj->getDefaultProperty()->addValue(value);
+ }
+
+ return false;
+}
+
+} // end of anonymous namespace
+
+
+QDeclarativeScriptParser::QDeclarativeScriptParser()
+: root(0), data(0)
+{
+
+}
+
+QDeclarativeScriptParser::~QDeclarativeScriptParser()
+{
+ clear();
+}
+
+class QDeclarativeScriptParserJsASTData
+{
+public:
+ QDeclarativeScriptParserJsASTData(const QString &filename)
+ : nodePool(filename, &engine) {}
+
+ Engine engine;
+ NodePool nodePool;
+};
+
+bool QDeclarativeScriptParser::parse(const QByteArray &qmldata, const QUrl &url)
+{
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QDeclarativePerfTimer<QDeclarativePerf::QDeclarativeParsing> pt;
+#endif
+ clear();
+
+ const QString fileName = url.toString();
+
+ QTextStream stream(qmldata, QIODevice::ReadOnly);
+ stream.setCodec("UTF-8");
+ const QString code = stream.readAll();
+
+ data = new QDeclarativeScriptParserJsASTData(fileName);
+
+ Lexer lexer(&data->engine);
+ lexer.setCode(code, /*line = */ 1);
+
+ Parser parser(&data->engine);
+
+ if (! parser.parse() || !_errors.isEmpty()) {
+
+ // Extract errors from the parser
+ foreach (const DiagnosticMessage &m, parser.diagnosticMessages()) {
+
+ if (m.isWarning())
+ continue;
+
+ QDeclarativeError error;
+ error.setUrl(url);
+ error.setDescription(m.message);
+ error.setLine(m.loc.startLine);
+ error.setColumn(m.loc.startColumn);
+ _errors << error;
+
+ }
+ }
+
+ if (_errors.isEmpty()) {
+ ProcessAST process(this);
+ process(code, parser.ast());
+
+ // Set the url for process errors
+ for(int ii = 0; ii < _errors.count(); ++ii)
+ _errors[ii].setUrl(url);
+ }
+
+ return _errors.isEmpty();
+}
+
+QList<QDeclarativeScriptParser::TypeReference*> QDeclarativeScriptParser::referencedTypes() const
+{
+ return _refTypes;
+}
+
+QList<QUrl> QDeclarativeScriptParser::referencedResources() const
+{
+ return _refUrls;
+}
+
+Object *QDeclarativeScriptParser::tree() const
+{
+ return root;
+}
+
+QList<QDeclarativeScriptParser::Import> QDeclarativeScriptParser::imports() const
+{
+ return _imports;
+}
+
+QList<QDeclarativeError> QDeclarativeScriptParser::errors() const
+{
+ return _errors;
+}
+
+void QDeclarativeScriptParser::clear()
+{
+ if (root) {
+ root->release();
+ root = 0;
+ }
+ _imports.clear();
+ qDeleteAll(_refTypes);
+ _refTypes.clear();
+ _errors.clear();
+
+ if (data) {
+ delete data;
+ data = 0;
+ }
+}
+
+QDeclarativeScriptParser::TypeReference *QDeclarativeScriptParser::findOrCreateType(const QString &name)
+{
+ TypeReference *type = 0;
+ int i = 0;
+ for (; i < _refTypes.size(); ++i) {
+ if (_refTypes.at(i)->name == name) {
+ type = _refTypes.at(i);
+ break;
+ }
+ }
+ if (!type) {
+ type = new TypeReference(i, name);
+ _refTypes.append(type);
+ }
+
+ return type;
+}
+
+void QDeclarativeScriptParser::setTree(Object *tree)
+{
+ Q_ASSERT(! root);
+
+ root = tree;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativescriptparser_p.h b/src/declarative/qml/qdeclarativescriptparser_p.h
new file mode 100644
index 0000000..b8f77d1
--- /dev/null
+++ b/src/declarative/qml/qdeclarativescriptparser_p.h
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QDECLARATIVESCRIPTPARSER_P_H
+#define QDECLARATIVESCRIPTPARSER_P_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 "qdeclarativeerror.h"
+#include "qdeclarativeparser_p.h"
+
+#include <QtCore/QList>
+#include <QtCore/QUrl>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QByteArray;
+
+class QDeclarativeScriptParserJsASTData;
+class QDeclarativeScriptParser
+{
+public:
+ class Import
+ {
+ public:
+ Import() : type(Library) {}
+
+ enum Type { Library, File };
+ Type type;
+
+ QString uri;
+ QString qualifier;
+ QString version;
+
+ QDeclarativeParser::LocationSpan location;
+ };
+
+ class TypeReference
+ {
+ public:
+ TypeReference(int typeId, const QString &typeName) : id(typeId), name(typeName) {}
+
+ int id;
+ // type as it has been referenced in Qml
+ QString name;
+ // objects in parse tree referencing the type
+ QList<QDeclarativeParser::Object*> refObjects;
+ };
+
+ QDeclarativeScriptParser();
+ ~QDeclarativeScriptParser();
+
+ bool parse(const QByteArray &data, const QUrl &url = QUrl());
+
+ QList<TypeReference*> referencedTypes() const;
+ QList<QUrl> referencedResources() const;
+
+ QDeclarativeParser::Object *tree() const;
+ QList<Import> imports() const;
+
+ void clear();
+
+ QList<QDeclarativeError> errors() const;
+
+// ### private:
+ TypeReference *findOrCreateType(const QString &name);
+ void setTree(QDeclarativeParser::Object *tree);
+
+ void setScriptFile(const QString &filename) {_scriptFile = filename; }
+ QString scriptFile() const { return _scriptFile; }
+
+// ### private:
+ QList<QDeclarativeError> _errors;
+
+ QDeclarativeParser::Object *root;
+ QList<Import> _imports;
+ QList<TypeReference*> _refTypes;
+ QList<QUrl> _refUrls;
+ QString _scriptFile;
+ QDeclarativeScriptParserJsASTData *data;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVESCRIPTPARSER_P_H
diff --git a/src/declarative/qml/qdeclarativescriptstring.cpp b/src/declarative/qml/qdeclarativescriptstring.cpp
new file mode 100644
index 0000000..5b9afe9
--- /dev/null
+++ b/src/declarative/qml/qdeclarativescriptstring.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativescriptstring.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeScriptStringPrivate : public QSharedData
+{
+public:
+ QDeclarativeScriptStringPrivate() : context(0), scope(0) {}
+
+ QDeclarativeContext *context;
+ QObject *scope;
+ QString script;
+};
+
+/*!
+\class QDeclarativeScriptString
+ \since 4.7
+\brief The QDeclarativeScriptString class encapsulates a script and its context.
+
+The QDeclarativeScriptString is used by properties that want to accept a script "assignment" from QML.
+
+Normally, the following code would result in a binding being established for the \c script
+property. If the property had a type of QDeclarativeScriptString, the script - \e {console.log(1921)} - itself
+would be passed to the property and it could choose how to handle it.
+
+\code
+MyType {
+ script: console.log(1921)
+}
+\endcode
+*/
+
+/*!
+Construct an empty instance.
+*/
+QDeclarativeScriptString::QDeclarativeScriptString()
+: d(new QDeclarativeScriptStringPrivate)
+{
+}
+
+/*!
+Copy \a other.
+*/
+QDeclarativeScriptString::QDeclarativeScriptString(const QDeclarativeScriptString &other)
+: d(other.d)
+{
+}
+
+/*!
+\internal
+*/
+QDeclarativeScriptString::~QDeclarativeScriptString()
+{
+}
+
+/*!
+Assign \a other to this.
+*/
+QDeclarativeScriptString &QDeclarativeScriptString::operator=(const QDeclarativeScriptString &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+Return the context for the script.
+*/
+QDeclarativeContext *QDeclarativeScriptString::context() const
+{
+ return d->context;
+}
+
+/*!
+Sets the \a context for the script.
+*/
+void QDeclarativeScriptString::setContext(QDeclarativeContext *context)
+{
+ d->context = context;
+}
+
+/*!
+Returns the scope object for the script.
+*/
+QObject *QDeclarativeScriptString::scopeObject() const
+{
+ return d->scope;
+}
+
+/*!
+Sets the scope \a object for the script.
+*/
+void QDeclarativeScriptString::setScopeObject(QObject *object)
+{
+ d->scope = object;
+}
+
+/*!
+Returns the script text.
+*/
+QString QDeclarativeScriptString::script() const
+{
+ return d->script;
+}
+
+/*!
+Sets the \a script text.
+*/
+void QDeclarativeScriptString::setScript(const QString &script)
+{
+ d->script = script;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qdeclarativescriptstring.h b/src/declarative/qml/qdeclarativescriptstring.h
new file mode 100644
index 0000000..43bef44
--- /dev/null
+++ b/src/declarative/qml/qdeclarativescriptstring.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVESCRIPTSTRING_H
+#define QDECLARATIVESCRIPTSTRING_H
+
+#include <QtCore/qstring.h>
+#include <QtCore/qshareddata.h>
+#include <QtCore/qmetatype.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QObject;
+class QDeclarativeContext;
+class QDeclarativeScriptStringPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeScriptString
+{
+public:
+ QDeclarativeScriptString();
+ QDeclarativeScriptString(const QDeclarativeScriptString &);
+ ~QDeclarativeScriptString();
+
+ QDeclarativeScriptString &operator=(const QDeclarativeScriptString &);
+
+ QDeclarativeContext *context() const;
+ void setContext(QDeclarativeContext *);
+
+ QObject *scopeObject() const;
+ void setScopeObject(QObject *);
+
+ QString script() const;
+ void setScript(const QString &);
+
+private:
+ QSharedDataPointer<QDeclarativeScriptStringPrivate> d;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeclarativeScriptString);
+
+QT_END_HEADER
+
+#endif // QDECLARATIVESCRIPTSTRING_H
+
diff --git a/src/declarative/qml/qdeclarativesqldatabase.cpp b/src/declarative/qml/qdeclarativesqldatabase.cpp
new file mode 100644
index 0000000..855d623
--- /dev/null
+++ b/src/declarative/qml/qdeclarativesqldatabase.cpp
@@ -0,0 +1,428 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativesqldatabase_p.h"
+
+#include "qdeclarativeengine.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativerefcount_p.h"
+#include "qdeclarativeengine_p.h"
+
+#include <QtCore/qobject.h>
+#include <QtScript/qscriptvalue.h>
+#include <QtScript/qscriptvalueiterator.h>
+#include <QtScript/qscriptcontext.h>
+#include <QtScript/qscriptengine.h>
+#include <QtScript/qscriptclasspropertyiterator.h>
+#include <QtSql/qsqldatabase.h>
+#include <QtSql/qsqlquery.h>
+#include <QtSql/qsqlerror.h>
+#include <QtSql/qsqlrecord.h>
+#include <QtCore/qstack.h>
+#include <QtCore/qcryptographichash.h>
+#include <QtCore/qsettings.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qdebug.h>
+
+Q_DECLARE_METATYPE(QSqlDatabase)
+Q_DECLARE_METATYPE(QSqlQuery)
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeSqlQueryScriptClass: public QScriptClass {
+public:
+ QDeclarativeSqlQueryScriptClass(QScriptEngine *engine) : QScriptClass(engine)
+ {
+ str_length = engine->toStringHandle(QLatin1String("length"));
+ str_forwardOnly = engine->toStringHandle(QLatin1String("forwardOnly")); // not in HTML5 (an optimization)
+ }
+
+ QueryFlags queryProperty(const QScriptValue &,
+ const QScriptString &name,
+ QueryFlags flags, uint *)
+ {
+ if (flags & HandlesReadAccess) {
+ if (name == str_length) {
+ return HandlesReadAccess;
+ } else if (name == str_forwardOnly) {
+ return flags;
+ }
+ }
+ if (flags & HandlesWriteAccess)
+ if (name == str_forwardOnly)
+ return flags;
+ return 0;
+ }
+
+ QScriptValue property(const QScriptValue &object,
+ const QScriptString &name, uint)
+ {
+ QSqlQuery query = qscriptvalue_cast<QSqlQuery>(object.data());
+ if (name == str_length) {
+ int s = query.size();
+ if (s<0) {
+ // Inefficient.
+ if (query.last()) {
+ return query.at()+1;
+ } else {
+ return 0;
+ }
+ } else {
+ return s;
+ }
+ } else if (name == str_forwardOnly) {
+ return query.isForwardOnly();
+ }
+ return engine()->undefinedValue();
+ }
+
+ void setProperty(QScriptValue &object,
+ const QScriptString &name, uint, const QScriptValue & value)
+ {
+ if (name == str_forwardOnly) {
+ QSqlQuery query = qscriptvalue_cast<QSqlQuery>(object.data());
+ query.setForwardOnly(value.toBool());
+ }
+ }
+
+ QScriptValue::PropertyFlags propertyFlags(const QScriptValue &/*object*/, const QScriptString &name, uint /*id*/)
+ {
+ if (name == str_length) {
+ return QScriptValue::Undeletable
+ | QScriptValue::SkipInEnumeration;
+ }
+ return QScriptValue::Undeletable;
+ }
+
+private:
+ QScriptString str_length;
+ QScriptString str_forwardOnly;
+};
+
+// If the spec changes to allow iteration, check git history...
+// class QDeclarativeSqlQueryScriptClassPropertyIterator : public QScriptClassPropertyIterator
+
+
+
+enum SqlException {
+ UNKNOWN_ERR,
+ DATABASE_ERR,
+ VERSION_ERR,
+ TOO_LARGE_ERR,
+ QUOTA_ERR,
+ SYNTAX_ERR,
+ CONSTRAINT_ERR,
+ TIMEOUT_ERR
+};
+
+static const char* sqlerror[] = {
+ "UNKNOWN_ERR",
+ "DATABASE_ERR",
+ "VERSION_ERR",
+ "TOO_LARGE_ERR",
+ "QUOTA_ERR",
+ "SYNTAX_ERR",
+ "CONSTRAINT_ERR",
+ "TIMEOUT_ERR",
+ 0
+};
+
+#define THROW_SQL(error, desc) \
+{ \
+ QScriptValue errorValue = context->throwError(desc); \
+ errorValue.setProperty(QLatin1String("code"), error); \
+ return errorValue; \
+}
+
+
+static QString databaseFile(const QString& connectionName, QScriptEngine *engine)
+{
+ QDeclarativeScriptEngine *qmlengine = static_cast<QDeclarativeScriptEngine*>(engine);
+ QString basename = qmlengine->offlineStoragePath
+ + QDir::separator() + QLatin1String("Databases") + QDir::separator();
+ basename += connectionName;
+ return basename;
+}
+
+
+
+static QScriptValue qmlsqldatabase_item(QScriptContext *context, QScriptEngine *engine)
+{
+ QSqlQuery query = qscriptvalue_cast<QSqlQuery>(context->thisObject().data());
+ int i = context->argument(0).toNumber();
+ if (query.at() == i || query.seek(i)) { // Qt 4.6 doesn't optimize seek(at())
+ QSqlRecord r = query.record();
+ QScriptValue row = engine->newObject();
+ for (int j=0; j<r.count(); ++j) {
+ row.setProperty(r.fieldName(j), QScriptValue(engine,r.value(j).toString()));
+ }
+ return row;
+ }
+ return engine->undefinedValue();
+}
+
+static QScriptValue qmlsqldatabase_executeSql_outsidetransaction(QScriptContext *context, QScriptEngine * /*engine*/)
+{
+ THROW_SQL(DATABASE_ERR,QDeclarativeEngine::tr("executeSql called outside transaction()"));
+}
+
+static QScriptValue qmlsqldatabase_executeSql(QScriptContext *context, QScriptEngine *engine)
+{
+ QSqlDatabase db = qscriptvalue_cast<QSqlDatabase>(context->thisObject());
+ QString sql = context->argument(0).toString();
+ QSqlQuery query(db);
+ bool err = false;
+
+ QScriptValue result;
+
+ if (query.prepare(sql)) {
+ if (context->argumentCount() > 1) {
+ QScriptValue values = context->argument(1);
+ if (values.isObject()) {
+ for (QScriptValueIterator it(values); it.hasNext();) {
+ it.next();
+ query.bindValue(it.name(),it.value().toVariant());
+ }
+ } else {
+ query.bindValue(0,values.toVariant());
+ }
+ }
+ if (query.exec()) {
+ result = engine->newObject();
+ QDeclarativeScriptEngine *qmlengine = static_cast<QDeclarativeScriptEngine*>(engine);
+ if (!qmlengine->sqlQueryClass)
+ qmlengine->sqlQueryClass = new QDeclarativeSqlQueryScriptClass(engine);
+ QScriptValue rows = engine->newObject(qmlengine->sqlQueryClass);
+ rows.setData(engine->newVariant(qVariantFromValue(query)));
+ rows.setProperty(QLatin1String("item"), engine->newFunction(qmlsqldatabase_item,1), QScriptValue::SkipInEnumeration);
+ result.setProperty(QLatin1String("rows"),rows);
+ result.setProperty(QLatin1String("rowsAffected"),query.numRowsAffected());
+ result.setProperty(QLatin1String("insertId"),query.lastInsertId().toString());
+ } else {
+ err = true;
+ }
+ } else {
+ err = true;
+ }
+ if (err)
+ THROW_SQL(DATABASE_ERR,query.lastError().text());
+ return result;
+}
+
+static QScriptValue qmlsqldatabase_executeSql_readonly(QScriptContext *context, QScriptEngine *engine)
+{
+ QString sql = context->argument(0).toString();
+ if (sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) {
+ return qmlsqldatabase_executeSql(context,engine);
+ } else {
+ THROW_SQL(SYNTAX_ERR,QDeclarativeEngine::tr("Read-only Transaction"))
+ }
+}
+
+static QScriptValue qmlsqldatabase_change_version(QScriptContext *context, QScriptEngine *engine)
+{
+ if (context->argumentCount() < 2)
+ return engine->undefinedValue();
+
+ QSqlDatabase db = qscriptvalue_cast<QSqlDatabase>(context->thisObject());
+ QString from_version = context->argument(0).toString();
+ QString to_version = context->argument(1).toString();
+ QScriptValue callback = context->argument(2);
+
+ QScriptValue instance = engine->newObject();
+ instance.setProperty(QLatin1String("executeSql"), engine->newFunction(qmlsqldatabase_executeSql,1));
+ QScriptValue tx = engine->newVariant(instance,qVariantFromValue(db));
+
+ QString foundvers = context->thisObject().property(QLatin1String("version")).toString();
+ if (from_version!=foundvers) {
+ THROW_SQL(2,QDeclarativeEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(foundvers));
+ return engine->undefinedValue();
+ }
+
+ bool ok = true;
+ if (callback.isFunction()) {
+ ok = false;
+ db.transaction();
+ callback.call(QScriptValue(), QScriptValueList() << tx);
+ if (engine->hasUncaughtException()) {
+ db.rollback();
+ } else {
+ if (!db.commit()) {
+ db.rollback();
+ THROW_SQL(0,QDeclarativeEngine::tr("SQL transaction failed"));
+ } else {
+ ok = true;
+ }
+ }
+ }
+
+ if (ok) {
+ context->thisObject().setProperty(QLatin1String("version"), to_version, QScriptValue::ReadOnly);
+ QSettings ini(databaseFile(db.connectionName(),engine)+QLatin1String(".ini"),QSettings::IniFormat);
+ ini.setValue(QLatin1String("Version"), to_version);
+ }
+
+ return engine->undefinedValue();
+}
+
+static QScriptValue qmlsqldatabase_transaction_shared(QScriptContext *context, QScriptEngine *engine, bool readOnly)
+{
+ QSqlDatabase db = qscriptvalue_cast<QSqlDatabase>(context->thisObject());
+ QScriptValue callback = context->argument(0);
+ if (!callback.isFunction())
+ THROW_SQL(UNKNOWN_ERR,QDeclarativeEngine::tr("transaction: missing callback"));
+
+ QScriptValue instance = engine->newObject();
+ instance.setProperty(QLatin1String("executeSql"),
+ engine->newFunction(readOnly ? qmlsqldatabase_executeSql_readonly : qmlsqldatabase_executeSql,1));
+ QScriptValue tx = engine->newVariant(instance,qVariantFromValue(db));
+
+ db.transaction();
+ callback.call(QScriptValue(), QScriptValueList() << tx);
+ instance.setProperty(QLatin1String("executeSql"),
+ engine->newFunction(qmlsqldatabase_executeSql_outsidetransaction));
+ if (engine->hasUncaughtException()) {
+ db.rollback();
+ } else {
+ if (!db.commit())
+ db.rollback();
+ }
+ return engine->undefinedValue();
+}
+
+static QScriptValue qmlsqldatabase_transaction(QScriptContext *context, QScriptEngine *engine)
+{
+ return qmlsqldatabase_transaction_shared(context,engine,false);
+}
+static QScriptValue qmlsqldatabase_read_transaction(QScriptContext *context, QScriptEngine *engine)
+{
+ return qmlsqldatabase_transaction_shared(context,engine,true);
+}
+
+/*
+ Currently documented in doc/src/declarastive/globalobject.qdoc
+*/
+static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEngine *engine)
+{
+ QSqlDatabase database;
+
+ QString dbname = context->argument(0).toString();
+ QString dbversion = context->argument(1).toString();
+ QString dbdescription = context->argument(2).toString();
+ int dbestimatedsize = context->argument(3).toNumber();
+ QScriptValue dbcreationCallback = context->argument(4);
+
+ QCryptographicHash md5(QCryptographicHash::Md5);
+ md5.addData(dbname.toUtf8());
+ QString dbid(QLatin1String(md5.result().toHex()));
+
+ QString basename = databaseFile(dbid,engine);
+ bool created = false;
+ QString version = dbversion;
+
+ {
+ QSettings ini(basename+QLatin1String(".ini"),QSettings::IniFormat);
+
+ if (QSqlDatabase::connectionNames().contains(dbid)) {
+ database = QSqlDatabase::database(dbid);
+ version = ini.value(QLatin1String("Version")).toString();
+ if (version != dbversion && !dbversion.isEmpty() && !version.isEmpty())
+ THROW_SQL(VERSION_ERR,QDeclarativeEngine::tr("SQL: database version mismatch"));
+ } else {
+ created = !QFile::exists(basename+QLatin1String(".sqlite"));
+ database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid);
+ QDir().mkpath(basename);
+ if (created) {
+ ini.setValue(QLatin1String("Name"), dbname);
+ if (dbcreationCallback.isFunction())
+ version = QString();
+ ini.setValue(QLatin1String("Version"), version);
+ ini.setValue(QLatin1String("Description"), dbdescription);
+ ini.setValue(QLatin1String("EstimatedSize"), dbestimatedsize);
+ ini.setValue(QLatin1String("Driver"), QLatin1String("QSQLITE"));
+ } else {
+ if (!dbversion.isEmpty() && ini.value(QLatin1String("Version")) != dbversion) {
+ // Incompatible
+ THROW_SQL(VERSION_ERR,QDeclarativeEngine::tr("SQL: database version mismatch"));
+ }
+ version = ini.value(QLatin1String("Version")).toString();
+ }
+ database.setDatabaseName(basename+QLatin1String(".sqlite"));
+ }
+ if (!database.isOpen())
+ database.open();
+ }
+
+ QScriptValue instance = engine->newObject();
+ instance.setProperty(QLatin1String("transaction"), engine->newFunction(qmlsqldatabase_transaction,1));
+ instance.setProperty(QLatin1String("readTransaction"), engine->newFunction(qmlsqldatabase_read_transaction,1));
+ instance.setProperty(QLatin1String("version"), version, QScriptValue::ReadOnly);
+ instance.setProperty(QLatin1String("changeVersion"), engine->newFunction(qmlsqldatabase_change_version,3));
+
+ QScriptValue result = engine->newVariant(instance,qVariantFromValue(database));
+
+ if (created && dbcreationCallback.isFunction()) {
+ dbcreationCallback.call(QScriptValue(), QScriptValueList() << result);
+ }
+
+ return result;
+}
+
+void qt_add_qmlsqldatabase(QScriptEngine *engine)
+{
+ QScriptValue openDatabase = engine->newFunction(qmlsqldatabase_open_sync, 4);
+ engine->globalObject().setProperty(QLatin1String("openDatabaseSync"), openDatabase);
+
+ QScriptValue sqlExceptionPrototype = engine->newObject();
+ for (int i=0; sqlerror[i]; ++i)
+ sqlExceptionPrototype.setProperty(QLatin1String(sqlerror[i]),
+ i,QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+
+ engine->globalObject().setProperty(QLatin1String("SQLException"), sqlExceptionPrototype);
+}
+
+/*
+HTML5 "spec" says "rs.rows[n]", but WebKit only impelments "rs.rows.item(n)". We do both (and property iterator).
+We add a "forwardOnly" property that stops Qt caching results (code promises to only go forward
+through the data.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativesqldatabase_p.h b/src/declarative/qml/qdeclarativesqldatabase_p.h
new file mode 100644
index 0000000..d0b6c0b
--- /dev/null
+++ b/src/declarative/qml/qdeclarativesqldatabase_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVESQLDATABASE_P_H
+#define QDECLARATIVESQLDATABASE_P_H
+
+#include <QtScript/qscriptengine.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>
+
+QT_BEGIN_NAMESPACE
+
+class QScriptEngine;
+void qt_add_qmlsqldatabase(QScriptEngine *engine);
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVESQLDATABASE_P_H
+
diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp
new file mode 100644
index 0000000..f3497e5
--- /dev/null
+++ b/src/declarative/qml/qdeclarativestringconverters.cpp
@@ -0,0 +1,276 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativestringconverters_p.h"
+
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qdatetime.h>
+
+QT_BEGIN_NAMESPACE
+
+static uchar fromHex(const uchar c, const uchar c2)
+{
+ uchar rv = 0;
+ if (c >= '0' && c <= '9')
+ rv += (c - '0') * 16;
+ else if (c >= 'A' && c <= 'F')
+ rv += (c - 'A' + 10) * 16;
+ else if (c >= 'a' && c <= 'f')
+ rv += (c - 'a' + 10) * 16;
+
+ if (c2 >= '0' && c2 <= '9')
+ rv += (c2 - '0');
+ else if (c2 >= 'A' && c2 <= 'F')
+ rv += (c2 - 'A' + 10);
+ else if (c2 >= 'a' && c2 <= 'f')
+ rv += (c2 - 'a' + 10);
+
+ return rv;
+}
+
+static uchar fromHex(const QString &s, int idx)
+{
+ uchar c = s.at(idx).toAscii();
+ uchar c2 = s.at(idx + 1).toAscii();
+ return fromHex(c, c2);
+}
+
+QVariant QDeclarativeStringConverters::variantFromString(const QString &s)
+{
+ if (s.isEmpty())
+ return QVariant(s);
+ if (s.startsWith(QLatin1Char('\'')) && s.endsWith(QLatin1Char('\''))) {
+ QString data = s.mid(1, s.length() - 2);
+ return QVariant(data);
+ }
+ bool ok = false;
+ QRectF r = rectFFromString(s, &ok);
+ if (ok) return QVariant(r);
+ QColor c = colorFromString(s, &ok);
+ if (ok) return QVariant(c);
+ QPointF p = pointFFromString(s, &ok);
+ if (ok) return QVariant(p);
+ QSizeF sz = sizeFFromString(s, &ok);
+ if (ok) return QVariant(sz);
+ QVector3D v = vector3DFromString(s, &ok);
+ if (ok) return qVariantFromValue(v);
+
+ return QVariant(s);
+}
+
+QVariant QDeclarativeStringConverters::variantFromString(const QString &s, int preferredType, bool *ok)
+{
+ switch (preferredType) {
+ case QMetaType::QColor:
+ return QVariant::fromValue(colorFromString(s, ok));
+ 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));
+ case QMetaType::QPointF:
+ return QVariant::fromValue(pointFFromString(s, ok));
+ case QMetaType::QPoint:
+ return QVariant::fromValue(pointFFromString(s, ok).toPoint());
+ case QMetaType::QSizeF:
+ return QVariant::fromValue(sizeFFromString(s, ok));
+ case QMetaType::QSize:
+ return QVariant::fromValue(sizeFFromString(s, ok).toSize());
+ case QMetaType::QRectF:
+ return QVariant::fromValue(rectFFromString(s, ok));
+ case QMetaType::QRect:
+ return QVariant::fromValue(rectFFromString(s, ok).toRect());
+ case QMetaType::QVector3D:
+ return QVariant::fromValue(vector3DFromString(s, ok));
+ default:
+ if (ok) *ok = false;
+ return QVariant();
+ }
+}
+
+QColor QDeclarativeStringConverters::colorFromString(const QString &s, bool *ok)
+{
+ if (s.startsWith(QLatin1Char('#')) && s.length() == 9) {
+ uchar a = fromHex(s, 1);
+ uchar r = fromHex(s, 3);
+ uchar g = fromHex(s, 5);
+ uchar b = fromHex(s, 7);
+ if (ok) *ok = true;
+ return QColor(r, g, b, a);
+ } else {
+ QColor rv;
+ if (s.startsWith(QLatin1Char('#')) || QColor::colorNames().contains(s.toLower()))
+ rv = QColor(s);
+ if (ok) *ok = rv.isValid();
+ return rv;
+ }
+}
+
+QDate QDeclarativeStringConverters::dateFromString(const QString &s, bool *ok)
+{
+ QDate d = QDate::fromString(s, Qt::ISODate);
+ if (ok) *ok = d.isValid();
+ return d;
+}
+
+QTime QDeclarativeStringConverters::timeFromString(const QString &s, bool *ok)
+{
+ QTime t = QTime::fromString(s, Qt::ISODate);
+ if (ok) *ok = t.isValid();
+ return t;
+}
+
+QDateTime QDeclarativeStringConverters::dateTimeFromString(const QString &s, bool *ok)
+{
+ QDateTime d = QDateTime::fromString(s, Qt::ISODate);
+ if (ok) *ok = d.isValid();
+ return d;
+}
+
+//expects input of "x,y"
+QPointF QDeclarativeStringConverters::pointFFromString(const QString &s, bool *ok)
+{
+ if (s.count(QLatin1Char(',')) != 1) {
+ if (ok)
+ *ok = false;
+ return QPointF();
+ }
+
+ bool xGood, yGood;
+ int index = s.indexOf(QLatin1Char(','));
+ qreal xCoord = s.left(index).toDouble(&xGood);
+ qreal yCoord = s.mid(index+1).toDouble(&yGood);
+ if (!xGood || !yGood) {
+ if (ok)
+ *ok = false;
+ return QPointF();
+ }
+
+ if (ok)
+ *ok = true;
+ return QPointF(xCoord, yCoord);
+}
+
+//expects input of "widthxheight"
+QSizeF QDeclarativeStringConverters::sizeFFromString(const QString &s, bool *ok)
+{
+ if (s.count(QLatin1Char('x')) != 1) {
+ if (ok)
+ *ok = false;
+ return QSizeF();
+ }
+
+ bool wGood, hGood;
+ int index = s.indexOf(QLatin1Char('x'));
+ qreal width = s.left(index).toDouble(&wGood);
+ qreal height = s.mid(index+1).toDouble(&hGood);
+ if (!wGood || !hGood) {
+ if (ok)
+ *ok = false;
+ return QSizeF();
+ }
+
+ if (ok)
+ *ok = true;
+ return QSizeF(width, height);
+}
+
+//expects input of "x,y,widthxheight" //### use space instead of second comma?
+QRectF QDeclarativeStringConverters::rectFFromString(const QString &s, bool *ok)
+{
+ if (s.count(QLatin1Char(',')) != 2 || s.count(QLatin1Char('x')) != 1) {
+ if (ok)
+ *ok = false;
+ return QRectF();
+ }
+
+ bool xGood, yGood, wGood, hGood;
+ int index = s.indexOf(QLatin1Char(','));
+ qreal x = s.left(index).toDouble(&xGood);
+ int index2 = s.indexOf(QLatin1Char(','), index+1);
+ qreal y = s.mid(index+1, index2-index-1).toDouble(&yGood);
+ index = s.indexOf(QLatin1Char('x'), index2+1);
+ qreal width = s.mid(index2+1, index-index2-1).toDouble(&wGood);
+ qreal height = s.mid(index+1).toDouble(&hGood);
+ if (!xGood || !yGood || !wGood || !hGood) {
+ if (ok)
+ *ok = false;
+ return QRectF();
+ }
+
+ if (ok)
+ *ok = true;
+ return QRectF(x, y, width, height);
+}
+
+//expects input of "x,y,z"
+QVector3D QDeclarativeStringConverters::vector3DFromString(const QString &s, bool *ok)
+{
+ if (s.count(QLatin1Char(',')) != 2) {
+ if (ok)
+ *ok = false;
+ return QVector3D();
+ }
+
+ bool xGood, yGood, zGood;
+ int index = s.indexOf(QLatin1Char(','));
+ int index2 = s.indexOf(QLatin1Char(','), index+1);
+ qreal xCoord = s.left(index).toDouble(&xGood);
+ qreal yCoord = s.mid(index+1, index2-index-1).toDouble(&yGood);
+ qreal zCoord = s.mid(index2+1).toDouble(&zGood);
+ if (!xGood || !yGood || !zGood) {
+ if (ok)
+ *ok = false;
+ return QVector3D();
+ }
+
+ if (ok)
+ *ok = true;
+ return QVector3D(xCoord, yCoord, zCoord);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativestringconverters_p.h b/src/declarative/qml/qdeclarativestringconverters_p.h
new file mode 100644
index 0000000..7afdfd3
--- /dev/null
+++ b/src/declarative/qml/qdeclarativestringconverters_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVESTRINGCONVERTERS_P_H
+#define QDECLARATIVESTRINGCONVERTERS_P_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>
+
+QT_BEGIN_NAMESPACE
+
+class QColor;
+class QPointF;
+class QSizeF;
+class QRectF;
+class QString;
+class QByteArray;
+class QVector3D;
+
+// XXX - Bauhaus currently uses these methods which is why they're exported
+namespace QDeclarativeStringConverters
+{
+ QVariant Q_DECLARATIVE_EXPORT variantFromString(const QString &);
+ QVariant Q_DECLARATIVE_EXPORT variantFromString(const QString &, int preferredType, bool *ok = 0);
+
+ QColor Q_DECLARATIVE_EXPORT colorFromString(const QString &, bool *ok = 0);
+ 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);
+ QPointF Q_DECLARATIVE_EXPORT pointFFromString(const QString &, bool *ok = 0);
+ QSizeF Q_DECLARATIVE_EXPORT sizeFFromString(const QString &, bool *ok = 0);
+ QRectF Q_DECLARATIVE_EXPORT rectFFromString(const QString &, bool *ok = 0);
+ QVector3D Q_DECLARATIVE_EXPORT vector3DFromString(const QString &, bool *ok = 0);
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVESTRINGCONVERTERS_P_H
diff --git a/src/declarative/qml/qdeclarativetypenamecache.cpp b/src/declarative/qml/qdeclarativetypenamecache.cpp
new file mode 100644
index 0000000..f94f944
--- /dev/null
+++ b/src/declarative/qml/qdeclarativetypenamecache.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativetypenamecache_p.h"
+
+#include "qdeclarativeengine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeTypeNameCache::QDeclarativeTypeNameCache(QDeclarativeEngine *e)
+: QDeclarativeCleanup(e), engine(e)
+{
+}
+
+QDeclarativeTypeNameCache::~QDeclarativeTypeNameCache()
+{
+ clear();
+}
+
+void QDeclarativeTypeNameCache::clear()
+{
+ qDeleteAll(stringCache);
+ stringCache.clear();
+ identifierCache.clear();
+ engine = 0;
+}
+
+void QDeclarativeTypeNameCache::add(const QString &name, QDeclarativeType *type)
+{
+ if (stringCache.contains(name))
+ return;
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+
+ RData *data = new RData;
+ // ### Use typename class
+ data->identifier = ep->objectClass->createPersistentIdentifier(name);
+ data->type = type;
+ stringCache.insert(name, data);
+ identifierCache.insert(data->identifier.identifier, data);
+}
+
+void QDeclarativeTypeNameCache::add(const QString &name, QDeclarativeTypeNameCache *typeNamespace)
+{
+ if (stringCache.contains(name))
+ return;
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+
+ RData *data = new RData;
+ // ### Use typename class
+ data->identifier = ep->objectClass->createPersistentIdentifier(name);
+ data->typeNamespace = typeNamespace;
+ stringCache.insert(name, data);
+ identifierCache.insert(data->identifier.identifier, data);
+ typeNamespace->addref();
+}
+
+QDeclarativeTypeNameCache::Data *QDeclarativeTypeNameCache::data(const QString &id) const
+{
+ return stringCache.value(id);
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qdeclarativetypenamecache_p.h b/src/declarative/qml/qdeclarativetypenamecache_p.h
new file mode 100644
index 0000000..eee5b77
--- /dev/null
+++ b/src/declarative/qml/qdeclarativetypenamecache_p.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVETYPENAMECACHE_P_H
+#define QDECLARATIVETYPENAMECACHE_P_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 "qdeclarativerefcount_p.h"
+#include "qdeclarativecleanup_p.h"
+
+#include <private/qscriptdeclarativeclass_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeType;
+class QDeclarativeEngine;
+class QDeclarativeTypeNameCache : public QDeclarativeRefCount, public QDeclarativeCleanup
+{
+public:
+ QDeclarativeTypeNameCache(QDeclarativeEngine *);
+ virtual ~QDeclarativeTypeNameCache();
+
+ struct Data {
+ inline Data();
+ inline ~Data();
+ QDeclarativeType *type;
+ QDeclarativeTypeNameCache *typeNamespace;
+ };
+
+ void add(const QString &, QDeclarativeType *);
+ void add(const QString &, QDeclarativeTypeNameCache *);
+
+ Data *data(const QString &) const;
+ inline Data *data(const QScriptDeclarativeClass::Identifier &id) const;
+
+protected:
+ virtual void clear();
+
+private:
+ struct RData : public Data {
+ QScriptDeclarativeClass::PersistentIdentifier identifier;
+ };
+ typedef QHash<QString, RData *> StringCache;
+ typedef QHash<QScriptDeclarativeClass::Identifier, RData *> IdentifierCache;
+
+ StringCache stringCache;
+ IdentifierCache identifierCache;
+ QDeclarativeEngine *engine;
+};
+
+QDeclarativeTypeNameCache::Data::Data()
+: type(0), typeNamespace(0)
+{
+}
+
+QDeclarativeTypeNameCache::Data::~Data()
+{
+ if (typeNamespace) typeNamespace->release();
+}
+
+QDeclarativeTypeNameCache::Data *QDeclarativeTypeNameCache::data(const QScriptDeclarativeClass::Identifier &id) const
+{
+ return identifierCache.value(id);
+}
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVETYPENAMECACHE_P_H
+
diff --git a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
new file mode 100644
index 0000000..02370e0
--- /dev/null
+++ b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativetypenamescriptclass_p.h"
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativetypenamecache_p.h"
+
+QT_BEGIN_NAMESPACE
+
+struct TypeNameData : public QScriptDeclarativeClass::Object {
+ TypeNameData(QObject *o, QDeclarativeType *t, QDeclarativeTypeNameScriptClass::TypeNameMode m) : object(o), type(t), typeNamespace(0), mode(m) {}
+ TypeNameData(QObject *o, QDeclarativeTypeNameCache *n, QDeclarativeTypeNameScriptClass::TypeNameMode m) : object(o), type(0), typeNamespace(n), mode(m) {
+ if (typeNamespace) typeNamespace->addref();
+ }
+ ~TypeNameData() {
+ if (typeNamespace) typeNamespace->release();
+ }
+
+ QObject *object;
+ QDeclarativeType *type;
+ QDeclarativeTypeNameCache *typeNamespace;
+ QDeclarativeTypeNameScriptClass::TypeNameMode mode;
+};
+
+QDeclarativeTypeNameScriptClass::QDeclarativeTypeNameScriptClass(QDeclarativeEngine *bindEngine)
+: QDeclarativeScriptClass(QDeclarativeEnginePrivate::getScriptEngine(bindEngine)),
+ engine(bindEngine), object(0), type(0)
+{
+}
+
+QDeclarativeTypeNameScriptClass::~QDeclarativeTypeNameScriptClass()
+{
+}
+
+QScriptValue QDeclarativeTypeNameScriptClass::newObject(QObject *object, QDeclarativeType *type, TypeNameMode mode)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ return QScriptDeclarativeClass::newObject(scriptEngine, this, new TypeNameData(object, type, mode));
+}
+
+QScriptValue QDeclarativeTypeNameScriptClass::newObject(QObject *object, QDeclarativeTypeNameCache *ns, TypeNameMode mode)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ return QScriptDeclarativeClass::newObject(scriptEngine, this, new TypeNameData(object, ns, mode));
+}
+
+QScriptClass::QueryFlags
+QDeclarativeTypeNameScriptClass::queryProperty(Object *obj, const Identifier &name,
+ QScriptClass::QueryFlags flags)
+{
+ Q_UNUSED(flags);
+
+ TypeNameData *data = (TypeNameData *)obj;
+
+ object = 0;
+ type = 0;
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+
+ if (data->typeNamespace) {
+
+ QDeclarativeTypeNameCache::Data *d = data->typeNamespace->data(name);
+ if (d && d->type) {
+ type = d->type;
+ return QScriptClass::HandlesReadAccess;
+ } else {
+ return 0;
+ }
+
+ } else {
+ Q_ASSERT(data->type);
+
+ QString strName = toString(name);
+
+ if (strName.at(0).isUpper()) {
+ // Must be an enum
+ if (data->mode == IncludeEnums) {
+ // ### Optimize
+ QByteArray enumName = strName.toUtf8();
+ const QMetaObject *metaObject = data->type->baseMetaObject();
+ for (int ii = metaObject->enumeratorCount() - 1; ii >= 0; --ii) {
+ QMetaEnum e = metaObject->enumerator(ii);
+ int value = e.keyToValue(enumName.constData());
+ if (value != -1) {
+ enumValue = value;
+ return QScriptClass::HandlesReadAccess;
+ }
+ }
+ }
+ return 0;
+ } else if (data->object) {
+ // Must be an attached property
+ object = qmlAttachedPropertiesObjectById(data->type->index(), data->object);
+ if (!object) return 0;
+ return ep->objectClass->queryProperty(object, name, flags, 0);
+ }
+ }
+
+ return 0;
+}
+
+QDeclarativeTypeNameScriptClass::ScriptValue
+QDeclarativeTypeNameScriptClass::property(Object *obj, const Identifier &name)
+{
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+ if (type) {
+ return Value(scriptEngine, newObject(((TypeNameData *)obj)->object, type, ((TypeNameData *)obj)->mode));
+ } else if (object) {
+ return ep->objectClass->property(object, name);
+ } else {
+ return Value(scriptEngine, enumValue);
+ }
+}
+
+void QDeclarativeTypeNameScriptClass::setProperty(Object *o, const Identifier &n, const QScriptValue &v)
+{
+ Q_ASSERT(object);
+ Q_ASSERT(!type);
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ ep->objectClass->setProperty(((TypeNameData *)o)->object, n, v);
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qdeclarativetypenamescriptclass_p.h b/src/declarative/qml/qdeclarativetypenamescriptclass_p.h
new file mode 100644
index 0000000..b6e3f51
--- /dev/null
+++ b/src/declarative/qml/qdeclarativetypenamescriptclass_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVETYPENAMESCRIPTCLASS_P_H
+#define QDECLARATIVETYPENAMESCRIPTCLASS_P_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 "qdeclarativeengine_p.h"
+
+#include <QtScript/qscriptclass.h>
+
+#include <private/qdeclarativescriptclass_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QDeclarativeType;
+class QDeclarativeTypeNameCache;
+class QDeclarativeTypeNameScriptClass : public QDeclarativeScriptClass
+{
+public:
+ QDeclarativeTypeNameScriptClass(QDeclarativeEngine *);
+ ~QDeclarativeTypeNameScriptClass();
+
+ enum TypeNameMode { IncludeEnums, ExcludeEnums };
+ QScriptValue newObject(QObject *, QDeclarativeType *, TypeNameMode = IncludeEnums);
+ QScriptValue newObject(QObject *, QDeclarativeTypeNameCache *, TypeNameMode = IncludeEnums);
+
+protected:
+ virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
+ QScriptClass::QueryFlags flags);
+
+ virtual ScriptValue property(Object *, const Identifier &);
+ virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
+
+private:
+ QDeclarativeEngine *engine;
+ QObject *object;
+ QDeclarativeType *type;
+ quint32 enumValue;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVETYPENAMESCRIPTCLASS_P_H
+
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
new file mode 100644
index 0000000..df83fa4
--- /dev/null
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -0,0 +1,706 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativevaluetype_p.h"
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory()
+{
+ // ### Optimize
+ for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
+ valueTypes[ii] = valueType(ii);
+}
+
+QDeclarativeValueTypeFactory::~QDeclarativeValueTypeFactory()
+{
+ for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
+ delete valueTypes[ii];
+}
+
+QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
+{
+ switch (t) {
+ case QVariant::Point:
+ return new QDeclarativePointValueType;
+ case QVariant::PointF:
+ return new QDeclarativePointFValueType;
+ case QVariant::Size:
+ return new QDeclarativeSizeValueType;
+ case QVariant::SizeF:
+ return new QDeclarativeSizeFValueType;
+ case QVariant::Rect:
+ return new QDeclarativeRectValueType;
+ case QVariant::RectF:
+ return new QDeclarativeRectFValueType;
+ case QVariant::Vector3D:
+ return new QDeclarativeVector3DValueType;
+ case QVariant::EasingCurve:
+ return new QDeclarativeEasingValueType;
+ case QVariant::Font:
+ return new QDeclarativeFontValueType;
+ default:
+ return 0;
+ }
+}
+
+QDeclarativeValueType::QDeclarativeValueType(QObject *parent)
+: QObject(parent)
+{
+}
+
+QDeclarativePointFValueType::QDeclarativePointFValueType(QObject *parent)
+: QDeclarativeValueType(parent)
+{
+}
+
+void QDeclarativePointFValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &point, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QDeclarativePointFValueType::write(QObject *obj, int idx, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &point, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QDeclarativePointFValueType::value()
+{
+ return QVariant(point);
+}
+
+void QDeclarativePointFValueType::setValue(QVariant value)
+{
+ point = qvariant_cast<QPointF>(value);
+}
+
+qreal QDeclarativePointFValueType::x() const
+{
+ return point.x();
+}
+
+qreal QDeclarativePointFValueType::y() const
+{
+ return point.y();
+}
+
+void QDeclarativePointFValueType::setX(qreal x)
+{
+ point.setX(x);
+}
+
+void QDeclarativePointFValueType::setY(qreal y)
+{
+ point.setY(y);
+}
+
+QDeclarativePointValueType::QDeclarativePointValueType(QObject *parent)
+: QDeclarativeValueType(parent)
+{
+}
+
+void QDeclarativePointValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &point, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QDeclarativePointValueType::write(QObject *obj, int idx, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &point, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QDeclarativePointValueType::value()
+{
+ return QVariant(point);
+}
+
+void QDeclarativePointValueType::setValue(QVariant value)
+{
+ point = qvariant_cast<QPoint>(value);
+}
+
+int QDeclarativePointValueType::x() const
+{
+ return point.x();
+}
+
+int QDeclarativePointValueType::y() const
+{
+ return point.y();
+}
+
+void QDeclarativePointValueType::setX(int x)
+{
+ point.setX(x);
+}
+
+void QDeclarativePointValueType::setY(int y)
+{
+ point.setY(y);
+}
+
+QDeclarativeSizeFValueType::QDeclarativeSizeFValueType(QObject *parent)
+: QDeclarativeValueType(parent)
+{
+}
+
+void QDeclarativeSizeFValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &size, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QDeclarativeSizeFValueType::write(QObject *obj, int idx, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &size, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QDeclarativeSizeFValueType::value()
+{
+ return QVariant(size);
+}
+
+void QDeclarativeSizeFValueType::setValue(QVariant value)
+{
+ size = qvariant_cast<QSizeF>(value);
+}
+
+qreal QDeclarativeSizeFValueType::width() const
+{
+ return size.width();
+}
+
+qreal QDeclarativeSizeFValueType::height() const
+{
+ return size.height();
+}
+
+void QDeclarativeSizeFValueType::setWidth(qreal w)
+{
+ size.setWidth(w);
+}
+
+void QDeclarativeSizeFValueType::setHeight(qreal h)
+{
+ size.setHeight(h);
+}
+
+QDeclarativeSizeValueType::QDeclarativeSizeValueType(QObject *parent)
+: QDeclarativeValueType(parent)
+{
+}
+
+void QDeclarativeSizeValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &size, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QDeclarativeSizeValueType::write(QObject *obj, int idx, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &size, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QDeclarativeSizeValueType::value()
+{
+ return QVariant(size);
+}
+
+void QDeclarativeSizeValueType::setValue(QVariant value)
+{
+ size = qvariant_cast<QSize>(value);
+}
+
+int QDeclarativeSizeValueType::width() const
+{
+ return size.width();
+}
+
+int QDeclarativeSizeValueType::height() const
+{
+ return size.height();
+}
+
+void QDeclarativeSizeValueType::setWidth(int w)
+{
+ size.setWidth(w);
+}
+
+void QDeclarativeSizeValueType::setHeight(int h)
+{
+ size.setHeight(h);
+}
+
+QDeclarativeRectFValueType::QDeclarativeRectFValueType(QObject *parent)
+: QDeclarativeValueType(parent)
+{
+}
+
+void QDeclarativeRectFValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &rect, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QDeclarativeRectFValueType::write(QObject *obj, int idx, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &rect, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QDeclarativeRectFValueType::value()
+{
+ return QVariant(rect);
+}
+
+void QDeclarativeRectFValueType::setValue(QVariant value)
+{
+ rect = qvariant_cast<QRectF>(value);
+}
+
+qreal QDeclarativeRectFValueType::x() const
+{
+ return rect.x();
+}
+
+qreal QDeclarativeRectFValueType::y() const
+{
+ return rect.y();
+}
+
+void QDeclarativeRectFValueType::setX(qreal x)
+{
+ rect.moveLeft(x);
+}
+
+void QDeclarativeRectFValueType::setY(qreal y)
+{
+ rect.moveTop(y);
+}
+
+qreal QDeclarativeRectFValueType::width() const
+{
+ return rect.width();
+}
+
+qreal QDeclarativeRectFValueType::height() const
+{
+ return rect.height();
+}
+
+void QDeclarativeRectFValueType::setWidth(qreal w)
+{
+ rect.setWidth(w);
+}
+
+void QDeclarativeRectFValueType::setHeight(qreal h)
+{
+ rect.setHeight(h);
+}
+
+QDeclarativeRectValueType::QDeclarativeRectValueType(QObject *parent)
+: QDeclarativeValueType(parent)
+{
+}
+
+void QDeclarativeRectValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &rect, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QDeclarativeRectValueType::write(QObject *obj, int idx, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &rect, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QDeclarativeRectValueType::value()
+{
+ return QVariant(rect);
+}
+
+void QDeclarativeRectValueType::setValue(QVariant value)
+{
+ rect = qvariant_cast<QRect>(value);
+}
+
+int QDeclarativeRectValueType::x() const
+{
+ return rect.x();
+}
+
+int QDeclarativeRectValueType::y() const
+{
+ return rect.y();
+}
+
+void QDeclarativeRectValueType::setX(int x)
+{
+ rect.moveLeft(x);
+}
+
+void QDeclarativeRectValueType::setY(int y)
+{
+ rect.moveTop(y);
+}
+
+int QDeclarativeRectValueType::width() const
+{
+ return rect.width();
+}
+
+int QDeclarativeRectValueType::height() const
+{
+ return rect.height();
+}
+
+void QDeclarativeRectValueType::setWidth(int w)
+{
+ rect.setWidth(w);
+}
+
+void QDeclarativeRectValueType::setHeight(int h)
+{
+ rect.setHeight(h);
+}
+
+QDeclarativeVector3DValueType::QDeclarativeVector3DValueType(QObject *parent)
+: QDeclarativeValueType(parent)
+{
+}
+
+void QDeclarativeVector3DValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &vector, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QDeclarativeVector3DValueType::write(QObject *obj, int idx, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &vector, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QDeclarativeVector3DValueType::value()
+{
+ return QVariant(vector);
+}
+
+void QDeclarativeVector3DValueType::setValue(QVariant value)
+{
+ vector = qvariant_cast<QVector3D>(value);
+}
+
+qreal QDeclarativeVector3DValueType::x() const
+{
+ return vector.x();
+}
+
+qreal QDeclarativeVector3DValueType::y() const
+{
+ return vector.y();
+}
+
+qreal QDeclarativeVector3DValueType::z() const
+{
+ return vector.z();
+}
+
+void QDeclarativeVector3DValueType::setX(qreal x)
+{
+ vector.setX(x);
+}
+
+void QDeclarativeVector3DValueType::setY(qreal y)
+{
+ vector.setY(y);
+}
+
+void QDeclarativeVector3DValueType::setZ(qreal z)
+{
+ vector.setZ(z);
+}
+
+QDeclarativeEasingValueType::QDeclarativeEasingValueType(QObject *parent)
+: QDeclarativeValueType(parent)
+{
+}
+
+void QDeclarativeEasingValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &easing, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QDeclarativeEasingValueType::write(QObject *obj, int idx, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &easing, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QDeclarativeEasingValueType::value()
+{
+ return QVariant(easing);
+}
+
+void QDeclarativeEasingValueType::setValue(QVariant value)
+{
+ easing = qvariant_cast<QEasingCurve>(value);
+}
+
+QDeclarativeEasingValueType::Type QDeclarativeEasingValueType::type() const
+{
+ return (QDeclarativeEasingValueType::Type)easing.type();
+}
+
+qreal QDeclarativeEasingValueType::amplitude() const
+{
+ return easing.amplitude();
+}
+
+qreal QDeclarativeEasingValueType::overshoot() const
+{
+ return easing.overshoot();
+}
+
+qreal QDeclarativeEasingValueType::period() const
+{
+ return easing.period();
+}
+
+void QDeclarativeEasingValueType::setType(QDeclarativeEasingValueType::Type type)
+{
+ easing.setType((QEasingCurve::Type)type);
+}
+
+void QDeclarativeEasingValueType::setAmplitude(qreal amplitude)
+{
+ easing.setAmplitude(amplitude);
+}
+
+void QDeclarativeEasingValueType::setOvershoot(qreal overshoot)
+{
+ easing.setOvershoot(overshoot);
+}
+
+void QDeclarativeEasingValueType::setPeriod(qreal period)
+{
+ easing.setPeriod(period);
+}
+
+QDeclarativeFontValueType::QDeclarativeFontValueType(QObject *parent)
+: QDeclarativeValueType(parent), hasPixelSize(false)
+{
+}
+
+void QDeclarativeFontValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &font, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QDeclarativeFontValueType::write(QObject *obj, int idx, QDeclarativeMetaProperty::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &font, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QDeclarativeFontValueType::value()
+{
+ return QVariant(font);
+}
+
+void QDeclarativeFontValueType::setValue(QVariant value)
+{
+ font = qvariant_cast<QFont>(value);
+}
+
+
+QString QDeclarativeFontValueType::family() const
+{
+ return font.family();
+}
+
+void QDeclarativeFontValueType::setFamily(const QString &family)
+{
+ font.setFamily(family);
+}
+
+bool QDeclarativeFontValueType::bold() const
+{
+ return font.bold();
+}
+
+void QDeclarativeFontValueType::setBold(bool b)
+{
+ font.setBold(b);
+}
+
+QDeclarativeFontValueType::FontWeight QDeclarativeFontValueType::weight() const
+{
+ return (QDeclarativeFontValueType::FontWeight)font.weight();
+}
+
+void QDeclarativeFontValueType::setWeight(QDeclarativeFontValueType::FontWeight w)
+{
+ font.setWeight((QFont::Weight)w);
+}
+
+bool QDeclarativeFontValueType::italic() const
+{
+ return font.italic();
+}
+
+void QDeclarativeFontValueType::setItalic(bool b)
+{
+ font.setItalic(b);
+}
+
+bool QDeclarativeFontValueType::underline() const
+{
+ return font.underline();
+}
+
+void QDeclarativeFontValueType::setUnderline(bool b)
+{
+ font.setUnderline(b);
+}
+
+bool QDeclarativeFontValueType::overline() const
+{
+ return font.overline();
+}
+
+void QDeclarativeFontValueType::setOverline(bool b)
+{
+ font.setOverline(b);
+}
+
+bool QDeclarativeFontValueType::strikeout() const
+{
+ return font.strikeOut();
+}
+
+void QDeclarativeFontValueType::setStrikeout(bool b)
+{
+ font.setStrikeOut(b);
+}
+
+qreal QDeclarativeFontValueType::pointSize() const
+{
+ return font.pointSizeF();
+}
+
+void QDeclarativeFontValueType::setPointSize(qreal size)
+{
+ if (hasPixelSize) {
+ qWarning() << "Both point size and pixel size set. Using pixel size.";
+ return;
+ }
+
+ if (size >= 0.0)
+ font.setPointSizeF(size);
+}
+
+int QDeclarativeFontValueType::pixelSize() const
+{
+ return font.pixelSize();
+}
+
+void QDeclarativeFontValueType::setPixelSize(int size)
+{
+ if (size >=0) {
+ font.setPixelSize(size);
+ hasPixelSize = true;
+ } else {
+ hasPixelSize = false;
+ }
+}
+
+QDeclarativeFontValueType::Capitalization QDeclarativeFontValueType::capitalization() const
+{
+ return (QDeclarativeFontValueType::Capitalization)font.capitalization();
+}
+
+void QDeclarativeFontValueType::setCapitalization(QDeclarativeFontValueType::Capitalization c)
+{
+ font.setCapitalization((QFont::Capitalization)c);
+}
+
+qreal QDeclarativeFontValueType::letterSpacing() const
+{
+ return font.letterSpacing();
+}
+
+void QDeclarativeFontValueType::setLetterSpacing(qreal size)
+{
+ font.setLetterSpacing(QFont::PercentageSpacing, size);
+}
+
+qreal QDeclarativeFontValueType::wordSpacing() const
+{
+ return font.wordSpacing();
+}
+
+void QDeclarativeFontValueType::setWordSpacing(qreal size)
+{
+ font.setWordSpacing(size);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h
new file mode 100644
index 0000000..995433b
--- /dev/null
+++ b/src/declarative/qml/qdeclarativevaluetype_p.h
@@ -0,0 +1,397 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEVALUETYPE_P_H
+#define QDECLARATIVEVALUETYPE_P_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 "qdeclarativemetaproperty.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qeasingcurve.h>
+#include <QtCore/qvariant.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/qfont.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_DECLARATIVE_EXPORT QDeclarativeValueType : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeValueType(QObject *parent = 0);
+ virtual void read(QObject *, int) = 0;
+ virtual void write(QObject *, int, QDeclarativeMetaProperty::WriteFlags flags) = 0;
+ virtual QVariant value() = 0;
+ virtual void setValue(QVariant) = 0;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeValueTypeFactory
+{
+public:
+ QDeclarativeValueTypeFactory();
+ ~QDeclarativeValueTypeFactory();
+ static QDeclarativeValueType *valueType(int);
+
+ QDeclarativeValueType *valueTypes[QVariant::UserType - 1];
+ QDeclarativeValueType *operator[](int idx) const { return valueTypes[idx]; }
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativePointFValueType : public QDeclarativeValueType
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_OBJECT
+public:
+ QDeclarativePointFValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QDeclarativeMetaProperty::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+
+ qreal x() const;
+ qreal y() const;
+ void setX(qreal);
+ void setY(qreal);
+
+private:
+ QPointF point;
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativePointValueType : public QDeclarativeValueType
+{
+ Q_PROPERTY(int x READ x WRITE setX)
+ Q_PROPERTY(int y READ y WRITE setY)
+ Q_OBJECT
+public:
+ QDeclarativePointValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QDeclarativeMetaProperty::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+
+ int x() const;
+ int y() const;
+ void setX(int);
+ void setY(int);
+
+private:
+ QPoint point;
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeSizeFValueType : public QDeclarativeValueType
+{
+ Q_PROPERTY(qreal width READ width WRITE setWidth)
+ Q_PROPERTY(qreal height READ height WRITE setHeight)
+ Q_OBJECT
+public:
+ QDeclarativeSizeFValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QDeclarativeMetaProperty::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+
+ qreal width() const;
+ qreal height() const;
+ void setWidth(qreal);
+ void setHeight(qreal);
+
+private:
+ QSizeF size;
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeSizeValueType : public QDeclarativeValueType
+{
+ Q_PROPERTY(int width READ width WRITE setWidth)
+ Q_PROPERTY(int height READ height WRITE setHeight)
+ Q_OBJECT
+public:
+ QDeclarativeSizeValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QDeclarativeMetaProperty::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+
+ int width() const;
+ int height() const;
+ void setWidth(int);
+ void setHeight(int);
+
+private:
+ QSize size;
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeRectFValueType : public QDeclarativeValueType
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_PROPERTY(qreal width READ width WRITE setWidth)
+ Q_PROPERTY(qreal height READ height WRITE setHeight)
+ Q_OBJECT
+public:
+ QDeclarativeRectFValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QDeclarativeMetaProperty::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+
+ qreal x() const;
+ qreal y() const;
+ void setX(qreal);
+ void setY(qreal);
+
+ qreal width() const;
+ qreal height() const;
+ void setWidth(qreal);
+ void setHeight(qreal);
+
+private:
+ QRectF rect;
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeRectValueType : public QDeclarativeValueType
+{
+ Q_PROPERTY(int x READ x WRITE setX)
+ Q_PROPERTY(int y READ y WRITE setY)
+ Q_PROPERTY(int width READ width WRITE setWidth)
+ Q_PROPERTY(int height READ height WRITE setHeight)
+ Q_OBJECT
+public:
+ QDeclarativeRectValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QDeclarativeMetaProperty::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+
+ int x() const;
+ int y() const;
+ void setX(int);
+ void setY(int);
+
+ int width() const;
+ int height() const;
+ void setWidth(int);
+ void setHeight(int);
+
+private:
+ QRect rect;
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeVector3DValueType : public QDeclarativeValueType
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_PROPERTY(qreal z READ z WRITE setZ)
+ Q_OBJECT
+public:
+ QDeclarativeVector3DValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QDeclarativeMetaProperty::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+ void setX(qreal);
+ void setY(qreal);
+ void setZ(qreal);
+
+private:
+ QVector3D vector;
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeEasingValueType : public QDeclarativeValueType
+{
+ Q_OBJECT
+ Q_ENUMS(Type)
+
+ Q_PROPERTY(QDeclarativeEasingValueType::Type type READ type WRITE setType)
+ Q_PROPERTY(qreal amplitude READ amplitude WRITE setAmplitude)
+ Q_PROPERTY(qreal overshoot READ overshoot WRITE setOvershoot)
+ Q_PROPERTY(qreal period READ period WRITE setPeriod)
+public:
+ enum Type {
+ Linear = QEasingCurve::Linear,
+ InQuad = QEasingCurve::InQuad, OutQuad = QEasingCurve::OutQuad,
+ InOutQuad = QEasingCurve::InOutQuad, OutInQuad = QEasingCurve::OutInQuad,
+ InCubic = QEasingCurve::InCubic, OutCubic = QEasingCurve::OutCubic,
+ InOutCubic = QEasingCurve::InOutCubic, OutInCubic = QEasingCurve::OutInCubic,
+ InQuart = QEasingCurve::InQuart, OutQuart = QEasingCurve::OutQuart,
+ InOutQuart = QEasingCurve::InOutQuart, OutInQuart = QEasingCurve::OutInQuart,
+ InQuint = QEasingCurve::InQuint, OutQuint = QEasingCurve::OutQuint,
+ InOutQuint = QEasingCurve::InOutQuint, OutInQuint = QEasingCurve::OutInQuint,
+ InSine = QEasingCurve::InSine, OutSine = QEasingCurve::OutSine,
+ InOutSine = QEasingCurve::InOutSine, OutInSine = QEasingCurve::OutInSine,
+ InExpo = QEasingCurve::InExpo, OutExpo = QEasingCurve::OutExpo,
+ InOutExpo = QEasingCurve::InOutExpo, OutInExpo = QEasingCurve::OutInExpo,
+ InCirc = QEasingCurve::InCirc, OutCirc = QEasingCurve::OutCirc,
+ InOutCirc = QEasingCurve::InOutCirc, OutInCirc = QEasingCurve::OutInCirc,
+ InElastic = QEasingCurve::InElastic, OutElastic = QEasingCurve::OutElastic,
+ InOutElastic = QEasingCurve::InOutElastic, OutInElastic = QEasingCurve::OutInElastic,
+ InBack = QEasingCurve::InBack, OutBack = QEasingCurve::OutBack,
+ InOutBack = QEasingCurve::InOutBack, OutInBack = QEasingCurve::OutInBack,
+ InBounce = QEasingCurve::InBounce, OutBounce = QEasingCurve::OutBounce,
+ InOutBounce = QEasingCurve::InOutBounce, OutInBounce = QEasingCurve::OutInBounce,
+ InCurve = QEasingCurve::InCurve, OutCurve = QEasingCurve::OutCurve,
+ SineCurve = QEasingCurve::SineCurve, CosineCurve = QEasingCurve::CosineCurve,
+ };
+
+ QDeclarativeEasingValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QDeclarativeMetaProperty::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+
+ Type type() const;
+ qreal amplitude() const;
+ qreal overshoot() const;
+ qreal period() const;
+ void setType(Type);
+ void setAmplitude(qreal);
+ void setOvershoot(qreal);
+ void setPeriod(qreal);
+
+private:
+ QEasingCurve easing;
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeFontValueType : public QDeclarativeValueType
+{
+ Q_OBJECT
+ Q_ENUMS(FontWeight)
+ Q_ENUMS(Capitalization)
+
+ Q_PROPERTY(QString family READ family WRITE setFamily)
+ Q_PROPERTY(bool bold READ bold WRITE setBold)
+ Q_PROPERTY(FontWeight weight READ weight WRITE setWeight)
+ Q_PROPERTY(bool italic READ italic WRITE setItalic)
+ Q_PROPERTY(bool underline READ underline WRITE setUnderline)
+ Q_PROPERTY(bool overline READ overline WRITE setOverline)
+ Q_PROPERTY(bool strikeout READ strikeout WRITE setStrikeout)
+ Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize)
+ Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize)
+ Q_PROPERTY(Capitalization capitalization READ capitalization WRITE setCapitalization)
+ Q_PROPERTY(qreal letterSpacing READ letterSpacing WRITE setLetterSpacing)
+ Q_PROPERTY(qreal wordSpacing READ wordSpacing WRITE setWordSpacing)
+
+public:
+ enum FontWeight { Light = QFont::Light,
+ Normal = QFont::Normal,
+ DemiBold = QFont::DemiBold,
+ Bold = QFont::Bold,
+ Black = QFont::Black };
+ enum Capitalization { MixedCase = QFont::MixedCase,
+ AllUppercase = QFont::AllUppercase,
+ AllLowercase = QFont::AllLowercase,
+ SmallCaps = QFont::SmallCaps,
+ Capitalize = QFont::Capitalize };
+
+ QDeclarativeFontValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QDeclarativeMetaProperty::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+
+ QString family() const;
+ void setFamily(const QString &);
+
+ bool bold() const;
+ void setBold(bool b);
+
+ FontWeight weight() const;
+ void setWeight(FontWeight);
+
+ bool italic() const;
+ void setItalic(bool b);
+
+ bool underline() const;
+ void setUnderline(bool b);
+
+ bool overline() const;
+ void setOverline(bool b);
+
+ bool strikeout() const;
+ void setStrikeout(bool b);
+
+ qreal pointSize() const;
+ void setPointSize(qreal size);
+
+ int pixelSize() const;
+ void setPixelSize(int size);
+
+ Capitalization capitalization() const;
+ void setCapitalization(Capitalization);
+
+ qreal letterSpacing() const;
+ void setLetterSpacing(qreal spacing);
+
+ qreal wordSpacing() const;
+ void setWordSpacing(qreal spacing);
+
+private:
+ QFont font;
+ bool hasPixelSize;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEVALUETYPE_P_H
diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
new file mode 100644
index 0000000..9cb65f8
--- /dev/null
+++ b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativevaluetypescriptclass_p.h"
+
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativeguard_p.h"
+
+QT_BEGIN_NAMESPACE
+
+struct QDeclarativeValueTypeReference : public QScriptDeclarativeClass::Object {
+ QDeclarativeValueType *type;
+ QDeclarativeGuard<QObject> object;
+ int property;
+};
+
+QDeclarativeValueTypeScriptClass::QDeclarativeValueTypeScriptClass(QDeclarativeEngine *bindEngine)
+: QDeclarativeScriptClass(QDeclarativeEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine)
+{
+}
+
+QDeclarativeValueTypeScriptClass::~QDeclarativeValueTypeScriptClass()
+{
+}
+
+QScriptValue QDeclarativeValueTypeScriptClass::newObject(QObject *object, int coreIndex, QDeclarativeValueType *type)
+{
+ QDeclarativeValueTypeReference *ref = new QDeclarativeValueTypeReference;
+ ref->type = type;
+ ref->object = object;
+ ref->property = coreIndex;
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+ return QScriptDeclarativeClass::newObject(scriptEngine, this, ref);
+}
+
+QScriptClass::QueryFlags
+QDeclarativeValueTypeScriptClass::queryProperty(Object *obj, const Identifier &name,
+ QScriptClass::QueryFlags)
+{
+ QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
+
+ m_lastIndex = -1;
+
+ if (!ref->object)
+ return 0;
+
+ QByteArray propName = toString(name).toUtf8();
+
+ m_lastIndex = ref->type->metaObject()->indexOfProperty(propName.constData());
+ if (m_lastIndex == -1)
+ return 0;
+
+ QMetaProperty prop = ref->object->metaObject()->property(m_lastIndex);
+
+ QScriptClass::QueryFlags rv =
+ QScriptClass::HandlesReadAccess;
+ if (prop.isWritable())
+ rv |= QScriptClass::HandlesWriteAccess;
+
+ return rv;
+}
+
+QDeclarativeValueTypeScriptClass::ScriptValue QDeclarativeValueTypeScriptClass::property(Object *obj, const Identifier &)
+{
+ QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
+
+ QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
+ ref->type->read(ref->object, ref->property);
+ QVariant rv = p.read(ref->type);
+
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+ return Value(scriptEngine, static_cast<QDeclarativeEnginePrivate *>(QObjectPrivate::get(engine))->scriptValueFromVariant(rv));
+}
+
+void QDeclarativeValueTypeScriptClass::setProperty(Object *obj, const Identifier &,
+ const QScriptValue &value)
+{
+ QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
+
+ QVariant v = QDeclarativeScriptClass::toVariant(engine, value);
+
+ ref->type->read(ref->object, ref->property);
+ QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
+ p.write(ref->type, v);
+ ref->type->write(ref->object, ref->property, 0);
+}
+
+QVariant QDeclarativeValueTypeScriptClass::toVariant(Object *obj, bool *ok)
+{
+ QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
+
+ if (ok) *ok = true;
+
+ if (ref->object) {
+ ref->type->read(ref->object, ref->property);
+ return ref->type->value();
+ } else {
+ return QVariant();
+ }
+}
+
+QVariant QDeclarativeValueTypeScriptClass::toVariant(const QScriptValue &value)
+{
+ Q_ASSERT(scriptClass(value) == this);
+
+ return toVariant(object(value), 0);
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h b/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h
new file mode 100644
index 0000000..31bd415
--- /dev/null
+++ b/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEVALUETYPESCRIPTCLASS_P_H
+#define QDECLARATIVEVALUETYPESCRIPTCLASS_P_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 <private/qdeclarativescriptclass_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QDeclarativeValueType;
+class QDeclarativeValueTypeScriptClass : public QDeclarativeScriptClass
+{
+public:
+ QDeclarativeValueTypeScriptClass(QDeclarativeEngine *);
+ ~QDeclarativeValueTypeScriptClass();
+
+ QScriptValue newObject(QObject *object, int coreIndex, QDeclarativeValueType *);
+
+ virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
+ QScriptClass::QueryFlags flags);
+ virtual ScriptValue property(Object *, const Identifier &);
+ virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
+
+ virtual QVariant toVariant(Object *, bool *ok = 0);
+ QVariant toVariant(const QScriptValue &);
+private:
+ QDeclarativeEngine *engine;
+ int m_lastIndex;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEVALUETYPESCRIPTCLASS_P_H
+
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
new file mode 100644
index 0000000..d1140a6
--- /dev/null
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -0,0 +1,851 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativevme_p.h"
+
+#include "qdeclarativecompiler_p.h"
+#include "qdeclarativeboundsignal_p.h"
+#include "qdeclarativestringconverters_p.h"
+#include "qmetaobjectbuilder_p.h"
+#include "qdeclarativedeclarativedata_p.h"
+#include "qdeclarative.h"
+#include "qdeclarativecustomparser_p.h"
+#include "qdeclarativeengine.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarativecomponent.h"
+#include "qdeclarativebinding_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativecomponent_p.h"
+#include "qdeclarativevmemetaobject_p.h"
+#include "qdeclarativebinding_p_p.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativecompiledbindings_p.h"
+#include "qdeclarativeglobal_p.h"
+#include "qdeclarativescriptstring.h"
+
+#include <qfxperf_p_p.h>
+
+#include <QStack>
+#include <QWidget>
+#include <QColor>
+#include <QPointF>
+#include <QSizeF>
+#include <QRectF>
+#include <QtCore/qdebug.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qcoreapplication.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeVME::QDeclarativeVME()
+{
+}
+
+#define VME_EXCEPTION(desc) \
+ { \
+ QDeclarativeError error; \
+ error.setDescription(desc.trimmed()); \
+ error.setLine(instr.line); \
+ error.setUrl(comp->url); \
+ vmeErrors << error; \
+ break; \
+ }
+
+struct ListInstance
+{
+ ListInstance()
+ : type(0) {}
+ ListInstance(int t)
+ : type(t) {}
+
+ int type;
+ QDeclarativeListProperty<void> qListProperty;
+};
+
+QObject *QDeclarativeVME::run(QDeclarativeContext *ctxt, QDeclarativeCompiledData *comp,
+ int start, int count,
+ const QBitField &bindingSkipList)
+{
+ QDeclarativeVMEStack<QObject *> stack;
+
+ if (start == -1) start = 0;
+ if (count == -1) count = comp->bytecode.count();
+
+ return run(stack, ctxt, comp, start, count, bindingSkipList);
+}
+
+void QDeclarativeVME::runDeferred(QObject *object)
+{
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object);
+
+ if (!data || !data->context || !data->deferredComponent)
+ return;
+
+ QDeclarativeContext *ctxt = data->context;
+ QDeclarativeCompiledData *comp = data->deferredComponent;
+ int start = data->deferredIdx + 1;
+ int count = data->deferredComponent->bytecode.at(data->deferredIdx).defer.deferCount;
+ QDeclarativeVMEStack<QObject *> stack;
+ stack.push(object);
+
+ run(stack, ctxt, comp, start, count, QBitField());
+}
+
+QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarativeContext *ctxt,
+ QDeclarativeCompiledData *comp,
+ int start, int count,
+ const QBitField &bindingSkipList)
+{
+ Q_ASSERT(comp);
+ Q_ASSERT(ctxt);
+ const QList<QDeclarativeCompiledData::TypeReference> &types = comp->types;
+ const QList<QString> &primitives = comp->primitives;
+ const QList<QByteArray> &datas = comp->datas;
+ const QList<QDeclarativeCompiledData::CustomTypeData> &customTypeData = comp->customTypeData;
+ const QList<int> &intData = comp->intData;
+ const QList<float> &floatData = comp->floatData;
+ const QList<QDeclarativePropertyCache *> &propertyCaches = comp->propertyCaches;
+ const QList<QDeclarativeParser::Object::ScriptBlock> &scripts = comp->scripts;
+ const QList<QUrl> &urls = comp->urls;
+
+ QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding> bindValues;
+ QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus> parserStatus;
+
+ QDeclarativeVMEStack<ListInstance> qliststack;
+
+ vmeErrors.clear();
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(ctxt->engine());
+ QDeclarativeContextPrivate *cp = (QDeclarativeContextPrivate *)QObjectPrivate::get(ctxt);
+
+ int status = -1; //for dbus
+ QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::BypassInterceptor;
+
+ for (int ii = start; !isError() && ii < (start + count); ++ii) {
+ const QDeclarativeInstruction &instr = comp->bytecode.at(ii);
+
+ switch(instr.type) {
+ case QDeclarativeInstruction::Init:
+ {
+ if (instr.init.bindingsSize)
+ bindValues = QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding>(instr.init.bindingsSize);
+ if (instr.init.parserStatusSize)
+ parserStatus = QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus>(instr.init.parserStatusSize);
+ if (instr.init.contextCache != -1)
+ cp->setIdPropertyData(comp->contextCaches.at(instr.init.contextCache));
+ if (instr.init.compiledBinding != -1)
+ cp->optimizedBindings = new QDeclarativeCompiledBindings(datas.at(instr.init.compiledBinding).constData(), ctxt);
+ }
+ break;
+
+ case QDeclarativeInstruction::CreateObject:
+ {
+ QBitField bindings;
+ if (instr.create.bindingBits != -1) {
+ const QByteArray &bits = datas.at(instr.create.bindingBits);
+ bindings = QBitField((const quint32*)bits.constData(),
+ bits.size() * 8);
+ }
+ if (stack.isEmpty())
+ bindings = bindings.united(bindingSkipList);
+
+ QObject *o =
+ types.at(instr.create.type).createInstance(ctxt, bindings);
+ if (!o) {
+ if(types.at(instr.create.type).component)
+ vmeErrors << types.at(instr.create.type).component->errors();
+
+ VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create object of type %1").arg(QString::fromLatin1(types.at(instr.create.type).className)));
+ }
+
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(o);
+ Q_ASSERT(ddata);
+ ddata->outerContext = ctxt;
+ ddata->lineNumber = instr.line;
+ ddata->columnNumber = instr.create.column;
+
+ if (instr.create.data != -1) {
+ QDeclarativeCustomParser *customParser =
+ types.at(instr.create.type).type->customParser();
+ customParser->setCustomData(o, datas.at(instr.create.data));
+ }
+ if (!stack.isEmpty()) {
+ QObject *parent = stack.top();
+ if (o->isWidgetType()) {
+ QWidget *widget = static_cast<QWidget*>(o);
+ if (parent->isWidgetType()) {
+ QWidget *parentWidget = static_cast<QWidget*>(parent);
+ widget->setParent(parentWidget);
+ } else {
+ // TODO: parent might be a layout
+ }
+ } else {
+ QDeclarativeGraphics_setParent_noEvent(o, parent);
+ // o->setParent(parent);
+ }
+ }
+ stack.push(o);
+ }
+ break;
+
+ case QDeclarativeInstruction::SetId:
+ {
+ QObject *target = stack.top();
+ cp->setIdProperty(instr.setId.index, target);
+ }
+ break;
+
+
+ case QDeclarativeInstruction::SetDefault:
+ {
+ QObject *target = stack.top();
+ ctxt->addDefaultObject(target);
+ }
+ break;
+
+ case QDeclarativeInstruction::CreateComponent:
+ {
+ QObject *qcomp = new QDeclarativeComponent(ctxt->engine(), comp, ii + 1, instr.createComponent.count, stack.isEmpty() ? 0 : stack.top());
+
+ QDeclarativeEngine::setContextForObject(qcomp, ctxt);
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(qcomp);
+ Q_ASSERT(ddata);
+ ddata->outerContext = ctxt;
+ ddata->lineNumber = instr.line;
+ ddata->columnNumber = instr.create.column;
+
+ stack.push(qcomp);
+ ii += instr.createComponent.count;
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreMetaObject:
+ {
+ QObject *target = stack.top();
+
+ QMetaObject mo;
+ const QByteArray &metadata = datas.at(instr.storeMeta.data);
+ QMetaObjectBuilder::fromRelocatableData(&mo, 0, metadata);
+
+ const QDeclarativeVMEMetaData *data =
+ (const QDeclarativeVMEMetaData *)datas.at(instr.storeMeta.aliasData).constData();
+
+ (void)new QDeclarativeVMEMetaObject(target, &mo, data, comp);
+
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(target, true);
+ if (ddata->propertyCache) ddata->propertyCache->release();
+ ddata->propertyCache = propertyCaches.at(instr.storeMeta.propertyCache);
+ ddata->propertyCache->addref();
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreVariant:
+ {
+ QObject *target = stack.top();
+ // XXX - can be more efficient
+ QVariant v = QDeclarativeStringConverters::variantFromString(primitives.at(instr.storeString.value));
+ void *a[] = { &v, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeString.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreString:
+ {
+ QObject *target = stack.top();
+ void *a[] = { (void *)&primitives.at(instr.storeString.value), 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeString.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreUrl:
+ {
+ QObject *target = stack.top();
+ void *a[] = { (void *)&urls.at(instr.storeUrl.value), 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeUrl.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreFloat:
+ {
+ QObject *target = stack.top();
+ float f = instr.storeFloat.value;
+ void *a[] = { &f, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeFloat.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreDouble:
+ {
+ QObject *target = stack.top();
+ double d = instr.storeDouble.value;
+ void *a[] = { &d, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeDouble.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreBool:
+ {
+ QObject *target = stack.top();
+ void *a[] = { (void *)&instr.storeBool.value, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeBool.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreInteger:
+ {
+ QObject *target = stack.top();
+ void *a[] = { (void *)&instr.storeInteger.value, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeInteger.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreColor:
+ {
+ QObject *target = stack.top();
+ QColor c = QColor::fromRgba(instr.storeColor.value);
+ void *a[] = { &c, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeColor.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreDate:
+ {
+ QObject *target = stack.top();
+ QDate d = QDate::fromJulianDay(instr.storeDate.value);
+ void *a[] = { &d, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeDate.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreTime:
+ {
+ QObject *target = stack.top();
+ QTime t;
+ t.setHMS(intData.at(instr.storeTime.valueIndex),
+ intData.at(instr.storeTime.valueIndex+1),
+ intData.at(instr.storeTime.valueIndex+2),
+ intData.at(instr.storeTime.valueIndex+3));
+ void *a[] = { &t, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeTime.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreDateTime:
+ {
+ QObject *target = stack.top();
+ QTime t;
+ t.setHMS(intData.at(instr.storeDateTime.valueIndex+1),
+ intData.at(instr.storeDateTime.valueIndex+2),
+ intData.at(instr.storeDateTime.valueIndex+3),
+ intData.at(instr.storeDateTime.valueIndex+4));
+ QDateTime dt(QDate::fromJulianDay(intData.at(instr.storeDateTime.valueIndex)), t);
+ void *a[] = { &dt, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeDateTime.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StorePoint:
+ {
+ QObject *target = stack.top();
+ QPoint p = QPointF(floatData.at(instr.storeRealPair.valueIndex),
+ floatData.at(instr.storeRealPair.valueIndex+1)).toPoint();
+ void *a[] = { &p, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRealPair.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StorePointF:
+ {
+ QObject *target = stack.top();
+ QPointF p(floatData.at(instr.storeRealPair.valueIndex),
+ floatData.at(instr.storeRealPair.valueIndex+1));
+ void *a[] = { &p, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRealPair.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreSize:
+ {
+ QObject *target = stack.top();
+ QSize p = QSizeF(floatData.at(instr.storeRealPair.valueIndex),
+ floatData.at(instr.storeRealPair.valueIndex+1)).toSize();
+ void *a[] = { &p, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRealPair.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreSizeF:
+ {
+ QObject *target = stack.top();
+ QSizeF s(floatData.at(instr.storeRealPair.valueIndex),
+ floatData.at(instr.storeRealPair.valueIndex+1));
+ void *a[] = { &s, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRealPair.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreRect:
+ {
+ QObject *target = stack.top();
+ QRect r = QRectF(floatData.at(instr.storeRect.valueIndex),
+ floatData.at(instr.storeRect.valueIndex+1),
+ floatData.at(instr.storeRect.valueIndex+2),
+ floatData.at(instr.storeRect.valueIndex+3)).toRect();
+ void *a[] = { &r, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRect.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreRectF:
+ {
+ QObject *target = stack.top();
+ QRectF r(floatData.at(instr.storeRect.valueIndex),
+ floatData.at(instr.storeRect.valueIndex+1),
+ floatData.at(instr.storeRect.valueIndex+2),
+ floatData.at(instr.storeRect.valueIndex+3));
+ void *a[] = { &r, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRect.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreVector3D:
+ {
+ QObject *target = stack.top();
+ QVector3D p(floatData.at(instr.storeVector3D.valueIndex),
+ floatData.at(instr.storeVector3D.valueIndex+1),
+ floatData.at(instr.storeVector3D.valueIndex+2));
+ void *a[] = { &p, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeVector3D.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreObject:
+ {
+ QObject *assignObj = stack.pop();
+ QObject *target = stack.top();
+
+ void *a[] = { (void *)&assignObj, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeObject.propertyIndex, a);
+ }
+ break;
+
+
+ case QDeclarativeInstruction::AssignCustomType:
+ {
+ QObject *target = stack.top();
+ QDeclarativeCompiledData::CustomTypeData data = customTypeData.at(instr.assignCustomType.valueIndex);
+ const QString &primitive = primitives.at(data.index);
+ QDeclarativeMetaType::StringConverter converter =
+ QDeclarativeMetaType::customStringConverter(data.type);
+ QVariant v = (*converter)(primitive);
+
+ QMetaProperty prop =
+ target->metaObject()->property(instr.assignCustomType.propertyIndex);
+ if (v.isNull() || ((int)prop.type() != data.type && prop.userType() != data.type))
+ VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign value %1 to property %2").arg(primitive).arg(QString::fromUtf8(prop.name())));
+
+ void *a[] = { (void *)v.data(), 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.assignCustomType.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::AssignSignalObject:
+ {
+ // XXX optimize
+
+ QObject *assign = stack.pop();
+ QObject *target = stack.top();
+ int sigIdx = instr.assignSignalObject.signal;
+ const QByteArray &pr = datas.at(sigIdx);
+
+ QDeclarativeMetaProperty prop(target, QString::fromUtf8(pr));
+ if (prop.type() & QDeclarativeMetaProperty::SignalProperty) {
+
+ QMetaMethod method = QDeclarativeMetaType::defaultMethod(assign);
+ if (method.signature() == 0)
+ VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object type %1 with no default method").arg(QString::fromLatin1(assign->metaObject()->className())));
+
+ if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature()))
+ VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature())));
+
+ QMetaObject::connect(target, prop.coreIndex(), assign, method.methodIndex());
+
+ } else {
+ VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign an object to signal property %1").arg(QString::fromUtf8(pr)));
+ }
+
+
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreSignal:
+ {
+ QObject *target = stack.top();
+ // XXX scope
+ QMetaMethod signal =
+ target->metaObject()->method(instr.storeSignal.signalIndex);
+
+ QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
+ QDeclarativeExpression *expr =
+ new QDeclarativeExpression(ctxt, primitives.at(instr.storeSignal.value), target);
+ expr->setSourceLocation(comp->name, instr.line);
+ bs->setExpression(expr);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreScript:
+ {
+ QObject *target = stack.top();
+ cp->addScript(scripts.at(instr.storeScript.value), target);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreScriptString:
+ {
+ QObject *target = stack.top();
+ QObject *scope = stack.at(stack.count() - 1 - instr.storeScriptString.scope);
+ QDeclarativeScriptString ss;
+ ss.setContext(ctxt);
+ ss.setScopeObject(scope);
+ ss.setScript(primitives.at(instr.storeScriptString.value));
+
+ void *a[] = { &ss, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeScriptString.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::BeginObject:
+ {
+ QObject *target = stack.top();
+ QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>(target) + instr.begin.castValue);
+ parserStatus.append(status);
+ status->d = &parserStatus.values[parserStatus.count - 1];
+
+ status->classBegin();
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreBinding:
+ {
+ QObject *target =
+ stack.at(stack.count() - 1 - instr.assignBinding.owner);
+ QObject *context =
+ stack.at(stack.count() - 1 - instr.assignBinding.context);
+
+ QDeclarativeMetaProperty mp =
+ QDeclarativeMetaPropertyPrivate::restore(datas.at(instr.assignBinding.property), target, ctxt);
+
+ int coreIndex = mp.coreIndex();
+
+ if (stack.count() == 1 && bindingSkipList.testBit(coreIndex))
+ break;
+
+ QDeclarativeBinding *bind = new QDeclarativeBinding((void *)datas.at(instr.assignBinding.value).constData(), comp, context, ctxt, comp->name, instr.line, 0);
+ bindValues.append(bind);
+ bind->m_mePtr = &bindValues.values[bindValues.count - 1];
+ bind->setTarget(mp);
+ bind->addToObject(target);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreCompiledBinding:
+ {
+ QObject *target =
+ stack.at(stack.count() - 1 - instr.assignBinding.owner);
+ QObject *scope =
+ stack.at(stack.count() - 1 - instr.assignBinding.context);
+
+ int property = instr.assignBinding.property;
+ if (stack.count() == 1 && bindingSkipList.testBit(property & 0xFFFF))
+ break;
+
+ QDeclarativeAbstractBinding *binding =
+ cp->optimizedBindings->configBinding(instr.assignBinding.value, target, scope, property);
+ bindValues.append(binding);
+ binding->m_mePtr = &bindValues.values[bindValues.count - 1];
+ binding->addToObject(target);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreValueSource:
+ {
+ QObject *obj = stack.pop();
+ QDeclarativePropertyValueSource *vs = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.assignValueSource.castValue);
+ QObject *target = stack.at(stack.count() - 1 - instr.assignValueSource.owner);
+
+ QDeclarativeMetaProperty prop =
+ QDeclarativeMetaPropertyPrivate::restore(datas.at(instr.assignValueSource.property), target, ctxt);
+ obj->setParent(target);
+ vs->setTarget(prop);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreValueInterceptor:
+ {
+ QObject *obj = stack.pop();
+ QDeclarativePropertyValueInterceptor *vi = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.assignValueInterceptor.castValue);
+ QObject *target = stack.at(stack.count() - 1 - instr.assignValueInterceptor.owner);
+ QDeclarativeMetaProperty prop =
+ QDeclarativeMetaPropertyPrivate::restore(datas.at(instr.assignValueInterceptor.property), target, ctxt);
+ obj->setParent(target);
+ vi->setTarget(prop);
+ QDeclarativeVMEMetaObject *mo = static_cast<QDeclarativeVMEMetaObject *>((QMetaObject*)target->metaObject());
+ mo->registerInterceptor(prop.coreIndex(), prop.valueTypeCoreIndex(), vi);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreObjectQList:
+ {
+ QObject *assign = stack.pop();
+
+ const ListInstance &list = qliststack.top();
+ list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, assign);
+ }
+ break;
+
+ case QDeclarativeInstruction::AssignObjectList:
+ {
+ // This is only used for assigning interfaces
+ QObject *assign = stack.pop();
+ const ListInstance &list = qliststack.top();
+
+ int type = list.type;
+
+ void *ptr = 0;
+
+ const char *iid = QDeclarativeMetaType::interfaceIId(type);
+ if (iid)
+ ptr = assign->qt_metacast(iid);
+ if (!ptr)
+ VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object to list"));
+
+
+ list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, ptr);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreVariantObject:
+ {
+ QObject *assign = stack.pop();
+ QObject *target = stack.top();
+
+ QVariant v = QVariant::fromValue(assign);
+ void *a[] = { &v, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeObject.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreInterface:
+ {
+ QObject *assign = stack.pop();
+ QObject *target = stack.top();
+
+ int coreIdx = instr.storeObject.propertyIndex;
+ QMetaProperty prop = target->metaObject()->property(coreIdx);
+ int t = prop.userType();
+ const char *iid = QDeclarativeMetaType::interfaceIId(t);
+ bool ok = false;
+ if (iid) {
+ void *ptr = assign->qt_metacast(iid);
+ if (ptr) {
+ void *a[] = { &ptr, 0, &status, &flags };
+ QMetaObject::metacall(target,
+ QMetaObject::WriteProperty,
+ coreIdx, a);
+ ok = true;
+ }
+ }
+
+ if (!ok)
+ VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object to interface property"));
+ }
+ break;
+
+ case QDeclarativeInstruction::FetchAttached:
+ {
+ QObject *target = stack.top();
+
+ QObject *qmlObject = qmlAttachedPropertiesObjectById(instr.fetchAttached.id, target);
+
+ if (!qmlObject)
+ VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create attached object"));
+
+ stack.push(qmlObject);
+ }
+ break;
+
+ case QDeclarativeInstruction::FetchQList:
+ {
+ QObject *target = stack.top();
+
+ qliststack.push(ListInstance(instr.fetchQmlList.type));
+
+ void *a[1];
+ a[0] = (void *)&(qliststack.top().qListProperty);
+ QMetaObject::metacall(target, QMetaObject::ReadProperty,
+ instr.fetchQmlList.property, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::FetchObject:
+ {
+ QObject *target = stack.top();
+
+ QObject *obj = 0;
+ // NOTE: This assumes a cast to QObject does not alter the
+ // object pointer
+ void *a[1];
+ a[0] = &obj;
+ QMetaObject::metacall(target, QMetaObject::ReadProperty,
+ instr.fetch.property, a);
+
+ if (!obj)
+ VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.fetch.property).name())));
+
+ stack.push(obj);
+ }
+ break;
+
+ case QDeclarativeInstruction::PopQList:
+ {
+ qliststack.pop();
+ }
+ break;
+
+ case QDeclarativeInstruction::Defer:
+ {
+ if (instr.defer.deferCount) {
+ QObject *target = stack.top();
+ QDeclarativeDeclarativeData *data =
+ QDeclarativeDeclarativeData::get(target, true);
+ comp->addref();
+ data->deferredComponent = comp;
+ data->deferredIdx = ii;
+ ii += instr.defer.deferCount;
+ }
+ }
+ break;
+
+ case QDeclarativeInstruction::PopFetchedObject:
+ {
+ stack.pop();
+ }
+ break;
+
+ case QDeclarativeInstruction::FetchValueType:
+ {
+ QObject *target = stack.top();
+ QDeclarativeValueType *valueHandler =
+ ep->valueTypes[instr.fetchValue.type];
+ valueHandler->read(target, instr.fetchValue.property);
+ stack.push(valueHandler);
+ }
+ break;
+
+ case QDeclarativeInstruction::PopValueType:
+ {
+ QDeclarativeValueType *valueHandler =
+ static_cast<QDeclarativeValueType *>(stack.pop());
+ QObject *target = stack.top();
+ valueHandler->write(target, instr.fetchValue.property, QDeclarativeMetaProperty::BypassInterceptor);
+ }
+ break;
+
+ default:
+ qFatal("QDeclarativeCompiledData: Internal error - unknown instruction %d", instr.type);
+ break;
+ }
+ }
+
+ if (isError()) {
+ if (!stack.isEmpty()) {
+ delete stack.at(0);
+ }
+
+ QDeclarativeEnginePrivate::clear(bindValues);
+ QDeclarativeEnginePrivate::clear(parserStatus);
+ return 0;
+ }
+
+ if (bindValues.count)
+ ep->bindValues << bindValues;
+ if (parserStatus.count)
+ ep->parserStatus << parserStatus;
+
+ if (stack.isEmpty())
+ return 0;
+ else
+ return stack.top();
+ return 0;
+}
+
+bool QDeclarativeVME::isError() const
+{
+ return !vmeErrors.isEmpty();
+}
+
+QList<QDeclarativeError> QDeclarativeVME::errors() const
+{
+ return vmeErrors;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativevme_p.h b/src/declarative/qml/qdeclarativevme_p.h
new file mode 100644
index 0000000..951f6a7
--- /dev/null
+++ b/src/declarative/qml/qdeclarativevme_p.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEVME_P_H
+#define QDECLARATIVEVME_P_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 "qdeclarativeerror.h"
+#include "qbitfield_p.h"
+
+#include <QtCore/QString>
+#include <QtCore/QStack>
+
+QT_BEGIN_NAMESPACE
+
+class QObject;
+class QDeclarativeInstruction;
+class QDeclarativeCompiledData;
+class QDeclarativeCompiledData;
+class QDeclarativeContext;
+
+template<typename T, int N = 128>
+class QDeclarativeVMEStack {
+public:
+ QDeclarativeVMEStack() : index(-1), maxSize(N), data(fixedData) {}
+ ~QDeclarativeVMEStack() { if (data != fixedData) qFree(fixedData); }
+
+ bool isEmpty() const { return index == -1; }
+ const T &top() const { return data[index]; }
+ void push(const T &i) { ++index; if (index == maxSize) realloc(); data[index] = i; }
+ const T &pop() { --index; return data[index + 1]; }
+ int count() const { return index + 1; }
+ const T &at(int idx) { return data[idx]; }
+
+private:
+ void realloc() {
+ maxSize += N;
+ if (data != fixedData) {
+ data = (T*)qRealloc(data, maxSize * sizeof(T));
+ } else {
+ data = (T*)qMalloc(maxSize * sizeof(T));
+ }
+ }
+ int index;
+ int maxSize;
+ T *data;
+ T fixedData[N];
+};
+
+class QDeclarativeVME
+{
+public:
+ QDeclarativeVME();
+
+ QObject *run(QDeclarativeContext *, QDeclarativeCompiledData *,
+ int start = -1, int count = -1,
+ const QBitField & = QBitField());
+ void runDeferred(QObject *);
+
+ bool isError() const;
+ QList<QDeclarativeError> errors() const;
+
+private:
+ QObject *run(QDeclarativeVMEStack<QObject *> &, QDeclarativeContext *, QDeclarativeCompiledData *,
+ int start, int count, const QBitField &);
+ QList<QDeclarativeError> vmeErrors;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEVME_P_H
diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp
new file mode 100644
index 0000000..6811e13
--- /dev/null
+++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp
@@ -0,0 +1,366 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativevmemetaobject_p.h"
+
+#include "qdeclarative.h"
+#include "qdeclarativerefcount_p.h"
+#include "qdeclarativeexpression.h"
+#include "qdeclarativeexpression_p.h"
+#include "qdeclarativecontext_p.h"
+
+#include <QColor>
+#include <QDate>
+#include <QtCore/qlist.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(QObject *obj,
+ const QMetaObject *other,
+ const QDeclarativeVMEMetaData *meta,
+ QDeclarativeCompiledData *cdata)
+: object(obj), compiledData(cdata), ctxt(qmlContext(obj)), metaData(meta), methods(0),
+ parent(0)
+{
+ compiledData->addref();
+
+ *static_cast<QMetaObject *>(this) = *other;
+ this->d.superdata = obj->metaObject();
+
+ QObjectPrivate *op = QObjectPrivate::get(obj);
+ if (op->metaObject)
+ parent = static_cast<QAbstractDynamicMetaObject*>(op->metaObject);
+ op->metaObject = this;
+
+ propOffset = QAbstractDynamicMetaObject::propertyOffset();
+ methodOffset = QAbstractDynamicMetaObject::methodOffset();
+
+ data = new QVariant[metaData->propertyCount];
+ aConnected.resize(metaData->aliasCount);
+
+ int list_type = qMetaTypeId<QDeclarativeListProperty<QObject> >();
+ // ### Optimize
+ for (int ii = 0; ii < metaData->propertyCount; ++ii) {
+ int t = (metaData->propertyData() + ii)->propertyType;
+ if (t == list_type) {
+ listProperties.append(new List(methodOffset + ii));
+ data[ii] = QVariant::fromValue(QDeclarativeListProperty<QObject>(obj, listProperties.last(), list_append,
+ list_count, list_at, list_clear));
+ } else if (t != -1) {
+ data[ii] = QVariant((QVariant::Type)t);
+ }
+ }
+}
+
+QDeclarativeVMEMetaObject::~QDeclarativeVMEMetaObject()
+{
+ compiledData->release();
+ delete parent;
+ qDeleteAll(listProperties);
+ delete [] data;
+ delete [] methods;
+}
+
+int QDeclarativeVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
+{
+ int id = _id;
+ if(c == QMetaObject::WriteProperty) {
+ int flags = *reinterpret_cast<int*>(a[3]);
+ if (!(flags & QDeclarativeMetaProperty::BypassInterceptor)
+ && !aInterceptors.isEmpty()
+ && aInterceptors.testBit(id)) {
+ QPair<int, QDeclarativePropertyValueInterceptor*> pair = interceptors.value(id);
+ int valueIndex = pair.first;
+ QDeclarativePropertyValueInterceptor *vi = pair.second;
+ int type = property(id).userType();
+
+ if (type != QVariant::Invalid) {
+ if (valueIndex != -1) {
+ QDeclarativeEnginePrivate *ep = ctxt?QDeclarativeEnginePrivate::get(ctxt->engine()):0;
+ QDeclarativeValueType *valueType = 0;
+ if (ep) valueType = ep->valueTypes[type];
+ else valueType = QDeclarativeValueTypeFactory::valueType(type);
+ Q_ASSERT(valueType);
+
+ valueType->setValue(QVariant(type, a[0]));
+ QMetaProperty valueProp = valueType->metaObject()->property(valueIndex);
+ vi->write(valueProp.read(valueType));
+
+ if (!ep) delete valueType;
+ return -1;
+ } else {
+ vi->write(QVariant(type, a[0]));
+ return -1;
+ }
+ }
+ }
+ }
+ if(c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty) {
+ if (id >= propOffset) {
+ id -= propOffset;
+
+ if (id < metaData->propertyCount) {
+ int t = (metaData->propertyData() + id)->propertyType;
+ bool needActivate = false;
+
+ if (t == -1) {
+
+ if (c == QMetaObject::ReadProperty) {
+ *reinterpret_cast<QVariant *>(a[0]) = data[id];
+ } else if (c == QMetaObject::WriteProperty) {
+ needActivate =
+ (data[id] != *reinterpret_cast<QVariant *>(a[0]));
+ data[id] = *reinterpret_cast<QVariant *>(a[0]);
+ }
+
+ } else {
+
+ if (c == QMetaObject::ReadProperty) {
+ switch(t) {
+ case QVariant::Int:
+ *reinterpret_cast<int *>(a[0]) = data[id].toInt();
+ break;
+ case QVariant::Bool:
+ *reinterpret_cast<bool *>(a[0]) = data[id].toBool();
+ break;
+ case QVariant::Double:
+ *reinterpret_cast<double *>(a[0]) = data[id].toDouble();
+ break;
+ case QVariant::String:
+ *reinterpret_cast<QString *>(a[0]) = data[id].toString();
+ break;
+ case QVariant::Url:
+ *reinterpret_cast<QUrl *>(a[0]) = data[id].toUrl();
+ break;
+ case QVariant::Color:
+ *reinterpret_cast<QColor *>(a[0]) = data[id].value<QColor>();
+ break;
+ case QVariant::Date:
+ *reinterpret_cast<QDate *>(a[0]) = data[id].toDate();
+ break;
+ case QMetaType::QObjectStar:
+ *reinterpret_cast<QObject **>(a[0]) = data[id].value<QObject*>();
+ break;
+ default:
+ break;
+ }
+ if (t == qMetaTypeId<QDeclarativeListProperty<QObject> >()) {
+ *reinterpret_cast<QDeclarativeListProperty<QObject> *>(a[0]) =
+ data[id].value<QDeclarativeListProperty<QObject> >();
+ }
+
+ } else if (c == QMetaObject::WriteProperty) {
+
+ QVariant value = QVariant((QVariant::Type)data[id].type(), a[0]);
+ needActivate = (data[id] != value);
+ data[id] = value;
+ }
+
+ }
+
+ if (c == QMetaObject::WriteProperty && needActivate) {
+ activate(object, methodOffset + id, 0);
+ }
+
+ return -1;
+ }
+
+ id -= metaData->propertyCount;
+
+ if (id < metaData->aliasCount) {
+
+ QDeclarativeVMEMetaData::AliasData *d = metaData->aliasData() + id;
+
+ if (d->flags & QML_ALIAS_FLAG_PTR && c == QMetaObject::ReadProperty)
+ *reinterpret_cast<void **>(a[0]) = 0;
+
+ if (!ctxt) return -1;
+ QDeclarativeContextPrivate *ctxtPriv =
+ (QDeclarativeContextPrivate *)QObjectPrivate::get(ctxt);
+
+ QObject *target = ctxtPriv->idValues[d->contextIdx].data();
+ if (!target)
+ return -1;
+
+ if (c == QMetaObject::ReadProperty && !aConnected.testBit(id)) {
+ int sigIdx = methodOffset + id + metaData->propertyCount;
+ QMetaObject::connect(ctxt, d->contextIdx + ctxtPriv->notifyIndex, object, sigIdx);
+
+ if (d->propertyIdx != -1) {
+ QMetaProperty prop =
+ target->metaObject()->property(d->propertyIdx);
+ if (prop.hasNotifySignal())
+ QMetaObject::connect(target, prop.notifySignalIndex(),
+ object, sigIdx);
+ }
+ aConnected.setBit(id);
+ }
+
+ if (d->propertyIdx == -1) {
+ *reinterpret_cast<QObject **>(a[0]) = target;
+ return -1;
+ } else {
+ return QMetaObject::metacall(target, c, d->propertyIdx, a);
+ }
+
+ }
+ return -1;
+
+ }
+
+ } else if(c == QMetaObject::InvokeMetaMethod) {
+
+ if (id >= methodOffset) {
+
+ id -= methodOffset;
+ int plainSignals = metaData->signalCount + metaData->propertyCount +
+ metaData->aliasCount;
+ if (id < plainSignals) {
+ QMetaObject::activate(object, _id, a);
+ return -1;
+ }
+
+ id -= plainSignals;
+
+ if (id < metaData->methodCount) {
+ if (!ctxt->engine())
+ return -1; // We can't run the method
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(ctxt->engine());
+
+ QScriptValue function = method(id);
+
+ QScriptValueList args;
+ QDeclarativeVMEMetaData::MethodData *data = metaData->methodData() + id;
+ if (data->parameterCount) {
+ for (int ii = 0; ii < data->parameterCount; ++ii) {
+ args << ep->scriptValueFromVariant(*(QVariant *)a[ii + 1]);
+ }
+ }
+ QScriptValue rv = function.call(ep->objectClass->newQObject(object), args);
+
+ if (a[0]) *reinterpret_cast<QVariant *>(a[0]) = ep->scriptValueToVariant(rv);
+
+ return -1;
+ }
+ return -1;
+ }
+ }
+
+ if (parent)
+ return parent->metaCall(c, _id, a);
+ else
+ return object->qt_metacall(c, _id, a);
+}
+
+QScriptValue QDeclarativeVMEMetaObject::method(int index)
+{
+ if (!methods)
+ methods = new QScriptValue[metaData->methodCount];
+
+ if (!methods[index].isValid()) {
+ QDeclarativeVMEMetaData::MethodData *data = metaData->methodData() + index;
+
+ const QChar *body =
+ (const QChar *)(((const char*)metaData) + data->bodyOffset);
+
+ QString code = QString::fromRawData(body, data->bodyLength);
+
+ // XXX Use QScriptProgram
+ // XXX We should evaluate all methods in a single big script block to
+ // improve the call time between dynamic methods defined on the same
+ // object
+ methods[index] = QDeclarativeExpressionPrivate::evalInObjectScope(ctxt, object, code);
+ }
+
+ return methods[index];
+}
+
+void QDeclarativeVMEMetaObject::listChanged(int id)
+{
+ activate(object, methodOffset + id, 0);
+}
+
+void QDeclarativeVMEMetaObject::list_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
+{
+ List *list = static_cast<List *>(prop->data);
+ list->append(o);
+ QMetaObject::activate(prop->object, list->notifyIndex, 0);
+}
+
+int QDeclarativeVMEMetaObject::list_count(QDeclarativeListProperty<QObject> *prop)
+{
+ return static_cast<List *>(prop->data)->count();
+}
+
+QObject *QDeclarativeVMEMetaObject::list_at(QDeclarativeListProperty<QObject> *prop, int index)
+{
+ return static_cast<List *>(prop->data)->at(index);
+}
+
+void QDeclarativeVMEMetaObject::list_clear(QDeclarativeListProperty<QObject> *prop)
+{
+ List *list = static_cast<List *>(prop->data);
+ list->clear();
+ QMetaObject::activate(prop->object, list->notifyIndex, 0);
+}
+
+void QDeclarativeVMEMetaObject::registerInterceptor(int index, int valueIndex, QDeclarativePropertyValueInterceptor *interceptor)
+{
+ if (aInterceptors.isEmpty())
+ aInterceptors.resize(propertyCount() + metaData->propertyCount);
+ aInterceptors.setBit(index);
+ interceptors.insert(index, qMakePair(valueIndex, interceptor));
+}
+
+QScriptValue QDeclarativeVMEMetaObject::vmeMethod(int index)
+{
+ if (index < methodOffset) {
+ Q_ASSERT(parent);
+ return static_cast<QDeclarativeVMEMetaObject *>(parent)->vmeMethod(index);
+ }
+ int plainSignals = metaData->signalCount + metaData->propertyCount + metaData->aliasCount;
+ Q_ASSERT(index >= (methodOffset + plainSignals) && index < (methodOffset + plainSignals + metaData->methodCount));
+ return method(index - methodOffset - plainSignals);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativevmemetaobject_p.h b/src/declarative/qml/qdeclarativevmemetaobject_p.h
new file mode 100644
index 0000000..37c0b7a
--- /dev/null
+++ b/src/declarative/qml/qdeclarativevmemetaobject_p.h
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEVMEMETAOBJECT_P_H
+#define QDECLARATIVEVMEMETAOBJECT_P_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 "qdeclarative.h"
+
+#include <QtCore/QMetaObject>
+#include <QtCore/QBitArray>
+#include <QtCore/QPair>
+
+#include <private/qobject_p.h>
+
+#include "qdeclarativeguard_p.h"
+#include "qdeclarativecompiler_p.h"
+
+QT_BEGIN_NAMESPACE
+
+#define QML_ALIAS_FLAG_PTR 0x00000001
+
+struct QDeclarativeVMEMetaData
+{
+ short propertyCount;
+ short aliasCount;
+ short signalCount;
+ short methodCount;
+
+ struct AliasData {
+ int contextIdx;
+ int propertyIdx;
+ int flags;
+ };
+
+ struct PropertyData {
+ int propertyType;
+ };
+
+ struct MethodData {
+ int parameterCount;
+ int bodyOffset;
+ int bodyLength;
+ int scriptProgram;
+ };
+
+ PropertyData *propertyData() const {
+ return (PropertyData *)(((const char *)this) + sizeof(QDeclarativeVMEMetaData));
+ }
+
+ AliasData *aliasData() const {
+ return (AliasData *)(propertyData() + propertyCount);
+ }
+
+ MethodData *methodData() const {
+ return (MethodData *)(aliasData() + aliasCount);
+ }
+};
+
+class QDeclarativeRefCount;
+class QDeclarativeVMEMetaObject : public QAbstractDynamicMetaObject
+{
+public:
+ QDeclarativeVMEMetaObject(QObject *obj, const QMetaObject *other, const QDeclarativeVMEMetaData *data,
+ QDeclarativeCompiledData *compiledData);
+ ~QDeclarativeVMEMetaObject();
+
+ void registerInterceptor(int index, int valueIndex, QDeclarativePropertyValueInterceptor *interceptor);
+ QScriptValue vmeMethod(int index);
+protected:
+ virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
+
+private:
+ QObject *object;
+ QDeclarativeCompiledData *compiledData;
+ QDeclarativeGuard<QDeclarativeContext> ctxt;
+
+ const QDeclarativeVMEMetaData *metaData;
+ int propOffset;
+ int methodOffset;
+
+ QVariant *data;
+ QBitArray aConnected;
+ QBitArray aInterceptors;
+ QHash<int, QPair<int, QDeclarativePropertyValueInterceptor*> > interceptors;
+
+ QScriptValue *methods;
+ QScriptValue method(int);
+
+ QAbstractDynamicMetaObject *parent;
+
+ void listChanged(int);
+ class List : public QList<QObject*>
+ {
+ public:
+ List(int lpi) : notifyIndex(lpi) {}
+ int notifyIndex;
+ };
+ QList<List *> listProperties;
+
+ static void list_append(QDeclarativeListProperty<QObject> *, QObject *);
+ static int list_count(QDeclarativeListProperty<QObject> *);
+ static QObject *list_at(QDeclarativeListProperty<QObject> *, int);
+ static void list_clear(QDeclarativeListProperty<QObject> *);
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEVMEMETAOBJECT_P_H
diff --git a/src/declarative/qml/qdeclarativewatcher.cpp b/src/declarative/qml/qdeclarativewatcher.cpp
new file mode 100644
index 0000000..2f61195
--- /dev/null
+++ b/src/declarative/qml/qdeclarativewatcher.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativewatcher_p.h"
+
+#include "qdeclarativeexpression.h"
+#include "qdeclarativecontext.h"
+#include "qdeclarative.h"
+
+#include <qdeclarativedebugservice_p.h>
+
+#include <QtCore/qmetaobject.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+
+class QDeclarativeWatchProxy : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeWatchProxy(int id,
+ QObject *object,
+ int debugId,
+ const QMetaProperty &prop,
+ QDeclarativeWatcher *parent = 0);
+
+ QDeclarativeWatchProxy(int id,
+ QDeclarativeExpression *exp,
+ int debugId,
+ QDeclarativeWatcher *parent = 0);
+
+public slots:
+ void notifyValueChanged();
+
+private:
+ friend class QDeclarativeWatcher;
+ int m_id;
+ QDeclarativeWatcher *m_watch;
+ QObject *m_object;
+ int m_debugId;
+ QMetaProperty m_property;
+
+ QDeclarativeExpression *m_expr;
+};
+
+QDeclarativeWatchProxy::QDeclarativeWatchProxy(int id,
+ QDeclarativeExpression *exp,
+ int debugId,
+ QDeclarativeWatcher *parent)
+: QObject(parent), m_id(id), m_watch(parent), m_object(0), m_debugId(debugId), m_expr(exp)
+{
+ QObject::connect(m_expr, SIGNAL(valueChanged()), this, SLOT(notifyValueChanged()));
+}
+
+QDeclarativeWatchProxy::QDeclarativeWatchProxy(int id,
+ QObject *object,
+ int debugId,
+ const QMetaProperty &prop,
+ QDeclarativeWatcher *parent)
+: QObject(parent), m_id(id), m_watch(parent), m_object(object), m_debugId(debugId), m_property(prop), m_expr(0)
+{
+ static int refreshIdx = -1;
+ if(refreshIdx == -1)
+ refreshIdx = QDeclarativeWatchProxy::staticMetaObject.indexOfMethod("notifyValueChanged()");
+
+ if (prop.hasNotifySignal())
+ QMetaObject::connect(m_object, prop.notifySignalIndex(), this, refreshIdx);
+}
+
+void QDeclarativeWatchProxy::notifyValueChanged()
+{
+ QVariant v;
+ if (m_expr)
+ v = m_expr->value();
+ else
+ v = m_property.read(m_object);
+
+ emit m_watch->propertyChanged(m_id, m_debugId, m_property, v);
+}
+
+
+QDeclarativeWatcher::QDeclarativeWatcher(QObject *parent)
+ : QObject(parent)
+{
+}
+
+bool QDeclarativeWatcher::addWatch(int id, quint32 debugId)
+{
+ QObject *object = QDeclarativeDebugService::objectForId(debugId);
+ if (object) {
+ int propCount = object->metaObject()->propertyCount();
+ for (int ii=0; ii<propCount; ii++)
+ addPropertyWatch(id, object, debugId, object->metaObject()->property(ii));
+ return true;
+ }
+ return false;
+}
+
+bool QDeclarativeWatcher::addWatch(int id, quint32 debugId, const QByteArray &property)
+{
+ QObject *object = QDeclarativeDebugService::objectForId(debugId);
+ if (object) {
+ int index = object->metaObject()->indexOfProperty(property.constData());
+ if (index >= 0) {
+ addPropertyWatch(id, object, debugId, object->metaObject()->property(index));
+ return true;
+ }
+ }
+ return false;
+}
+
+bool QDeclarativeWatcher::addWatch(int id, quint32 objectId, const QString &expr)
+{
+ QObject *object = QDeclarativeDebugService::objectForId(objectId);
+ QDeclarativeContext *context = qmlContext(object);
+ if (context) {
+ QDeclarativeExpression *exprObj = new QDeclarativeExpression(context, expr, object);
+ exprObj->setNotifyOnValueChanged(true);
+ QDeclarativeWatchProxy *proxy = new QDeclarativeWatchProxy(id, exprObj, objectId, this);
+ exprObj->setParent(proxy);
+ m_proxies[id].append(proxy);
+ proxy->notifyValueChanged();
+ return true;
+ }
+ return false;
+}
+
+void QDeclarativeWatcher::removeWatch(int id)
+{
+ if (!m_proxies.contains(id))
+ return;
+
+ QList<QPointer<QDeclarativeWatchProxy> > proxies = m_proxies.take(id);
+ qDeleteAll(proxies);
+}
+
+void QDeclarativeWatcher::addPropertyWatch(int id, QObject *object, quint32 debugId, const QMetaProperty &property)
+{
+ QDeclarativeWatchProxy *proxy = new QDeclarativeWatchProxy(id, object, debugId, property, this);
+ m_proxies[id].append(proxy);
+
+ proxy->notifyValueChanged();
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativewatcher.moc>
diff --git a/src/declarative/qml/qdeclarativewatcher_p.h b/src/declarative/qml/qdeclarativewatcher_p.h
new file mode 100644
index 0000000..4e3352f
--- /dev/null
+++ b/src/declarative/qml/qdeclarativewatcher_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEWATCHER_P_H
+#define QDECLARATIVEWATCHER_P_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/qobject.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qpair.h>
+#include <QtCore/qhash.h>
+#include <QtCore/qset.h>
+#include <QtCore/qpointer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeWatchProxy;
+class QDeclarativeExpression;
+class QDeclarativeContext;
+class QMetaProperty;
+
+class QDeclarativeWatcher : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeWatcher(QObject * = 0);
+
+ bool addWatch(int id, quint32 objectId);
+ bool addWatch(int id, quint32 objectId, const QByteArray &property);
+ bool addWatch(int id, quint32 objectId, const QString &expr);
+
+ void removeWatch(int id);
+
+Q_SIGNALS:
+ void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value);
+
+private:
+ friend class QDeclarativeWatchProxy;
+ void addPropertyWatch(int id, QObject *object, quint32 objectId, const QMetaProperty &property);
+
+ QHash<int, QList<QPointer<QDeclarativeWatchProxy> > > m_proxies;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEWATCHER_P_H
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
new file mode 100644
index 0000000..03151e4
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -0,0 +1,1041 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeworkerscript_p.h"
+
+#include "qdeclarativeengine_p.h"
+
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qdebug.h>
+#include <QtScript/qscriptengine.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qwaitcondition.h>
+#include <QtScript/qscriptvalueiterator.h>
+#include <QtCore/qfile.h>
+#include <QtNetwork/qnetworkaccessmanager.h>
+#include <QtDeclarative/qdeclarativeinfo.h>
+#include "qdeclarativenetworkaccessmanagerfactory.h"
+
+
+QT_BEGIN_NAMESPACE
+
+class WorkerDataEvent : public QEvent
+{
+public:
+ enum Type { WorkerData = QEvent::User };
+
+ WorkerDataEvent(int workerId, const QVariant &data);
+ virtual ~WorkerDataEvent();
+
+ int workerId() const;
+ QVariant data() const;
+
+private:
+ int m_id;
+ QVariant m_data;
+};
+
+class WorkerLoadEvent : public QEvent
+{
+public:
+ enum Type { WorkerLoad = WorkerDataEvent::WorkerData + 1 };
+
+ WorkerLoadEvent(int workerId, const QUrl &url);
+
+ int workerId() const;
+ QUrl url() const;
+
+private:
+ int m_id;
+ QUrl m_url;
+};
+
+class WorkerRemoveEvent : public QEvent
+{
+public:
+ enum Type { WorkerRemove = WorkerLoadEvent::WorkerLoad + 1 };
+
+ WorkerRemoveEvent(int workerId);
+
+ int workerId() const;
+
+private:
+ int m_id;
+};
+
+class QDeclarativeWorkerScriptEnginePrivate : public QObject
+{
+public:
+ QDeclarativeWorkerScriptEnginePrivate(QDeclarativeEngine *eng);
+
+ struct ScriptEngine : public QDeclarativeScriptEngine
+ {
+ ScriptEngine(QDeclarativeWorkerScriptEnginePrivate *parent) : QDeclarativeScriptEngine(0), p(parent), accessManager(0) {}
+ ~ScriptEngine() { delete accessManager; }
+ QDeclarativeWorkerScriptEnginePrivate *p;
+ QNetworkAccessManager *accessManager;
+
+ virtual QNetworkAccessManager *networkAccessManager() {
+ if (!accessManager) {
+ if (p->qmlengine && p->qmlengine->networkAccessManagerFactory()) {
+ accessManager = p->qmlengine->networkAccessManagerFactory()->create(this);
+ } else {
+ accessManager = new QNetworkAccessManager(this);
+ }
+ }
+ return accessManager;
+ }
+ };
+ ScriptEngine *workerEngine;
+ static QDeclarativeWorkerScriptEnginePrivate *get(QScriptEngine *e) {
+ return static_cast<ScriptEngine *>(e)->p;
+ }
+
+ QDeclarativeEngine *qmlengine;
+
+ QMutex m_lock;
+ QWaitCondition m_wait;
+
+ struct WorkerScript {
+ WorkerScript();
+
+ int id;
+ bool initialized;
+ QDeclarativeWorkerScript *owner;
+ QScriptValue object;
+
+ QScriptValue callback;
+ };
+
+ QHash<int, WorkerScript *> workers;
+ QScriptValue getWorker(int);
+
+ int m_nextId;
+
+ static QVariant scriptValueToVariant(const QScriptValue &);
+ static QScriptValue variantToScriptValue(const QVariant &, QScriptEngine *);
+
+ static QScriptValue onMessage(QScriptContext *ctxt, QScriptEngine *engine);
+ static QScriptValue sendMessage(QScriptContext *ctxt, QScriptEngine *engine);
+
+protected:
+ virtual bool event(QEvent *);
+
+private:
+ void processMessage(int, const QVariant &);
+ void processLoad(int, const QUrl &);
+};
+
+// Currently this will leak as no-one releases it in the worker thread
+class QDeclarativeWorkerListModelAgent : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ count)
+
+public:
+ QDeclarativeWorkerListModelAgent(QDeclarativeWorkerListModel *);
+ ~QDeclarativeWorkerListModelAgent();
+
+ void addref();
+ void release();
+
+ int count() const;
+
+ Q_INVOKABLE void clear();
+ Q_INVOKABLE void remove(int index);
+ Q_INVOKABLE void append(const QScriptValue &);
+ Q_INVOKABLE void insert(int index, const QScriptValue&);
+ Q_INVOKABLE QScriptValue get(int index) const;
+ Q_INVOKABLE void set(int index, const QScriptValue &);
+ Q_INVOKABLE void sync();
+
+ struct VariantRef
+ {
+ VariantRef() : a(0) {}
+ VariantRef(const VariantRef &r) : a(r.a) { if (a) a->addref(); }
+ VariantRef(QDeclarativeWorkerListModelAgent *_a) : a(_a) { if (a) a->addref(); }
+ ~VariantRef() { if (a) a->release(); }
+
+ VariantRef &operator=(const VariantRef &o) {
+ if (o.a) o.a->addref();
+ if (a) a->release(); a = o.a;
+ return *this;
+ }
+
+ QDeclarativeWorkerListModelAgent *a;
+ };
+protected:
+ virtual bool event(QEvent *);
+
+private:
+ friend class QDeclarativeWorkerScriptEnginePrivate;
+ friend class QDeclarativeWorkerListModel;
+ QScriptEngine *m_engine;
+
+ struct Change {
+ enum { Inserted, Removed, Moved, Changed } type;
+ int index; // Inserted/Removed/Moved/Changed
+ int count; // Inserted/Removed/Moved/Changed
+ int to; // Moved
+ };
+
+ struct Data {
+ QHash<int, QString> roles;
+ QHash<QString, int> strings;
+ QList<QHash<int, QVariant> > values;
+ QList<Change> changes;
+
+ void clearChange();
+ void insertChange(int index, int count);
+ void removeChange(int index, int count);
+ void changedChange(int index, int count);
+ };
+ Data data;
+
+ struct Sync : public QEvent {
+ Sync() : QEvent(QEvent::User) {}
+ Data data;
+ };
+
+ QAtomicInt m_ref;
+ QDeclarativeWorkerListModel *m_model;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeclarativeWorkerListModelAgent::VariantRef);
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeWorkerScriptEnginePrivate::QDeclarativeWorkerScriptEnginePrivate(QDeclarativeEngine *engine)
+: workerEngine(0), qmlengine(engine), m_nextId(0)
+{
+}
+
+QScriptValue QDeclarativeWorkerScriptEnginePrivate::onMessage(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ QDeclarativeWorkerScriptEnginePrivate *p = QDeclarativeWorkerScriptEnginePrivate::get(engine);
+
+ int id = ctxt->thisObject().data().toVariant().toInt();
+
+ WorkerScript *script = p->workers.value(id);
+ if (!script)
+ return engine->undefinedValue();
+
+ if (ctxt->argumentCount() >= 1)
+ script->callback = ctxt->argument(0);
+
+ return script->callback;
+}
+
+QScriptValue QDeclarativeWorkerScriptEnginePrivate::sendMessage(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if (!ctxt->argumentCount())
+ return engine->undefinedValue();
+
+ QDeclarativeWorkerScriptEnginePrivate *p = QDeclarativeWorkerScriptEnginePrivate::get(engine);
+
+ int id = ctxt->thisObject().data().toVariant().toInt();
+
+ WorkerScript *script = p->workers.value(id);
+ if (!script)
+ return engine->undefinedValue();
+
+ p->m_lock.lock();
+ if (script->owner)
+ QCoreApplication::postEvent(script->owner,
+ new WorkerDataEvent(0, scriptValueToVariant(ctxt->argument(0))));
+ p->m_lock.unlock();
+
+ return engine->undefinedValue();
+}
+
+QScriptValue QDeclarativeWorkerScriptEnginePrivate::getWorker(int id)
+{
+ QHash<int, WorkerScript *>::ConstIterator iter = workers.find(id);
+
+ if (iter == workers.end())
+ return workerEngine->nullValue();
+
+ WorkerScript *script = *iter;
+ if (!script->initialized) {
+
+ script->initialized = true;
+ script->object = workerEngine->newObject();
+
+ QScriptValue api = workerEngine->newObject();
+ api.setData(script->id);
+
+ api.setProperty(QLatin1String("onMessage"), workerEngine->newFunction(onMessage),
+ QScriptValue::PropertyGetter | QScriptValue::PropertySetter);
+ api.setProperty(QLatin1String("sendMessage"), workerEngine->newFunction(sendMessage));
+
+ script->object.setProperty(QLatin1String("WorkerScript"), api);
+ }
+
+ return script->object;
+}
+
+bool QDeclarativeWorkerScriptEnginePrivate::event(QEvent *event)
+{
+ if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
+ WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event);
+ processMessage(workerEvent->workerId(), workerEvent->data());
+ return true;
+ } else if (event->type() == (QEvent::Type)WorkerLoadEvent::WorkerLoad) {
+ WorkerLoadEvent *workerEvent = static_cast<WorkerLoadEvent *>(event);
+ processLoad(workerEvent->workerId(), workerEvent->url());
+ return true;
+ } else {
+ return QObject::event(event);
+ }
+}
+
+void QDeclarativeWorkerScriptEnginePrivate::processMessage(int id, const QVariant &data)
+{
+ WorkerScript *script = workers.value(id);
+ if (!script)
+ return;
+
+ if (script->callback.isFunction()) {
+ QScriptValue args = workerEngine->newArray(1);
+ args.setProperty(0, variantToScriptValue(data, workerEngine));
+
+ script->callback.call(script->object, args);
+ }
+}
+
+void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
+{
+ if (url.isRelative() || url.scheme() != QLatin1String("file"))
+ return;
+
+ QString fileName = url.toLocalFile();
+
+ QFile f(fileName);
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray data = f.readAll();
+ QString script = QString::fromUtf8(data);
+
+ QScriptValue activation = getWorker(id);
+
+ QScriptContext *ctxt = workerEngine->pushContext();
+ ctxt->setActivationObject(activation);
+
+ workerEngine->baseUrl = url;
+ workerEngine->evaluate(script);
+
+ workerEngine->popContext();
+ }
+}
+
+QVariant QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(const QScriptValue &value)
+{
+ if (value.isBool()) {
+ return QVariant(value.toBool());
+ } else if (value.isString()) {
+ return QVariant(value.toString());
+ } else if (value.isNumber()) {
+ return QVariant((qreal)value.toNumber());
+ } else if (value.isArray()) {
+ QVariantList list;
+
+ quint32 length = (quint32)value.property(QLatin1String("length")).toNumber();
+
+ for (quint32 ii = 0; ii < length; ++ii) {
+ QVariant v = scriptValueToVariant(ii);
+ list << v;
+ }
+
+ return QVariant(list);
+ } else if (value.isQObject()) {
+ QDeclarativeWorkerListModel *lm = qobject_cast<QDeclarativeWorkerListModel *>(value.toQObject());
+ if (lm) {
+ QDeclarativeWorkerListModelAgent::VariantRef v(lm->agent());
+ return qVariantFromValue(v);
+ } else {
+ // No other QObject's are allowed to be sent
+ return QVariant();
+ }
+ } else if (value.isObject()) {
+ QVariantHash hash;
+
+ QScriptValueIterator iter(value);
+
+ while (iter.hasNext()) {
+ iter.next();
+ hash.insert(iter.name(), scriptValueToVariant(iter.value()));
+ }
+
+ return QVariant(hash);
+ }
+
+ return QVariant();
+
+}
+
+QScriptValue QDeclarativeWorkerScriptEnginePrivate::variantToScriptValue(const QVariant &value, QScriptEngine *engine)
+{
+ if (value.userType() == QVariant::Bool) {
+ return QScriptValue(value.toBool());
+ } else if (value.userType() == QVariant::String) {
+ return QScriptValue(value.toString());
+ } else if (value.userType() == QMetaType::QReal) {
+ return QScriptValue(value.toReal());
+ } else if (value.userType() == qMetaTypeId<QDeclarativeWorkerListModelAgent::VariantRef>()) {
+ QDeclarativeWorkerListModelAgent::VariantRef vr = qvariant_cast<QDeclarativeWorkerListModelAgent::VariantRef>(value);
+ if (vr.a->m_engine == 0)
+ vr.a->m_engine = engine;
+ else if (vr.a->m_engine != engine)
+ return engine->nullValue();
+ QScriptValue o = engine->newQObject(vr.a);
+ o.setData(engine->newVariant(value)); // Keeps the agent ref so that it is cleaned up on gc
+ return o;
+ } else if (value.userType() == QMetaType::QVariantList) {
+ QVariantList list = qvariant_cast<QVariantList>(value);
+ QScriptValue rv = engine->newArray(list.count());
+
+ for (quint32 ii = 0; ii < quint32(list.count()); ++ii)
+ rv.setProperty(ii, variantToScriptValue(list.at(ii), engine));
+
+ return rv;
+ } else if (value.userType() == QMetaType::QVariantHash) {
+
+ QVariantHash hash = qvariant_cast<QVariantHash>(value);
+
+ QScriptValue rv = engine->newObject();
+
+ for (QVariantHash::ConstIterator iter = hash.begin(); iter != hash.end(); ++iter)
+ rv.setProperty(iter.key(), variantToScriptValue(iter.value(), engine));
+
+ return rv;
+ } else {
+ return engine->nullValue();
+ }
+}
+
+WorkerDataEvent::WorkerDataEvent(int workerId, const QVariant &data)
+: QEvent((QEvent::Type)WorkerData), m_id(workerId), m_data(data)
+{
+}
+
+WorkerDataEvent::~WorkerDataEvent()
+{
+}
+
+int WorkerDataEvent::workerId() const
+{
+ return m_id;
+}
+
+QVariant WorkerDataEvent::data() const
+{
+ return m_data;
+}
+
+WorkerLoadEvent::WorkerLoadEvent(int workerId, const QUrl &url)
+: QEvent((QEvent::Type)WorkerLoad), m_id(workerId), m_url(url)
+{
+}
+
+int WorkerLoadEvent::workerId() const
+{
+ return m_id;
+}
+
+QUrl WorkerLoadEvent::url() const
+{
+ return m_url;
+}
+
+WorkerRemoveEvent::WorkerRemoveEvent(int workerId)
+: QEvent((QEvent::Type)WorkerRemove), m_id(workerId)
+{
+}
+
+int WorkerRemoveEvent::workerId() const
+{
+ return m_id;
+}
+
+QDeclarativeWorkerScriptEngine::QDeclarativeWorkerScriptEngine(QDeclarativeEngine *parent)
+: QThread(parent), d(new QDeclarativeWorkerScriptEnginePrivate(parent))
+{
+ d->m_lock.lock();
+ start(QThread::LowPriority);
+ d->m_wait.wait(&d->m_lock);
+ d->moveToThread(this);
+ d->m_lock.unlock();
+}
+
+QDeclarativeWorkerScriptEngine::~QDeclarativeWorkerScriptEngine()
+{
+ qDeleteAll(d->workers);
+ delete d; d = 0;
+}
+
+QDeclarativeWorkerScriptEnginePrivate::WorkerScript::WorkerScript()
+: id(-1), initialized(false), owner(0)
+{
+}
+
+int QDeclarativeWorkerScriptEngine::registerWorkerScript(QDeclarativeWorkerScript *owner)
+{
+ QDeclarativeWorkerScriptEnginePrivate::WorkerScript *script = new QDeclarativeWorkerScriptEnginePrivate::WorkerScript;
+ script->id = d->m_nextId++;
+ script->owner = owner;
+
+ d->m_lock.lock();
+ d->workers.insert(script->id, script);
+ d->m_lock.unlock();
+
+ return script->id;
+}
+
+void QDeclarativeWorkerScriptEngine::removeWorkerScript(int id)
+{
+ QCoreApplication::postEvent(d, new WorkerRemoveEvent(id));
+}
+
+void QDeclarativeWorkerScriptEngine::executeUrl(int id, const QUrl &url)
+{
+ QCoreApplication::postEvent(d, new WorkerLoadEvent(id, url));
+}
+
+void QDeclarativeWorkerScriptEngine::sendMessage(int id, const QVariant &data)
+{
+ QCoreApplication::postEvent(d, new WorkerDataEvent(id, data));
+}
+
+void QDeclarativeWorkerScriptEngine::run()
+{
+ d->m_lock.lock();
+
+ d->workerEngine = new QDeclarativeWorkerScriptEnginePrivate::ScriptEngine(d);
+
+ d->m_wait.wakeAll();
+
+ d->m_lock.unlock();
+
+ exec();
+
+ delete d->workerEngine; d->workerEngine = 0;
+}
+
+QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent)
+: QObject(parent), m_engine(0), m_scriptId(-1)
+{
+}
+
+QDeclarativeWorkerScript::~QDeclarativeWorkerScript()
+{
+ if (m_scriptId != -1) m_engine->removeWorkerScript(m_scriptId);
+}
+
+QUrl QDeclarativeWorkerScript::source() const
+{
+ return m_source;
+}
+
+void QDeclarativeWorkerScript::setSource(const QUrl &source)
+{
+ if (m_source == source)
+ return;
+
+ m_source = source;
+
+ if (m_engine)
+ m_engine->executeUrl(m_scriptId, m_source);
+
+ emit sourceChanged();
+}
+
+void QDeclarativeWorkerScript::sendMessage(const QScriptValue &message)
+{
+ if (!m_engine) {
+ qWarning("QDeclarativeWorkerScript: Attempt to send message before WorkerScript establishment");
+ return;
+ }
+
+ m_engine->sendMessage(m_scriptId, QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(message));
+}
+
+void QDeclarativeWorkerScript::componentComplete()
+{
+ if (!m_engine) {
+ QDeclarativeEngine *engine = qmlEngine(this);
+ if (!engine) {
+ qWarning("QDeclarativeWorkerScript: componentComplete() called without qmlEngine() set");
+ return;
+ }
+
+ m_engine = QDeclarativeEnginePrivate::get(engine)->getWorkerScriptEngine();
+ m_scriptId = m_engine->registerWorkerScript(this);
+
+ if (m_source.isValid())
+ m_engine->executeUrl(m_scriptId, m_source);
+ }
+}
+
+bool QDeclarativeWorkerScript::event(QEvent *event)
+{
+ if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
+ QDeclarativeEngine *engine = qmlEngine(this);
+ if (engine) {
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+ WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event);
+ QScriptValue value =
+ QDeclarativeWorkerScriptEnginePrivate::variantToScriptValue(workerEvent->data(), scriptEngine);
+ emit message(value);
+ }
+ return true;
+ } else {
+ return QObject::event(event);
+ }
+}
+
+void QDeclarativeWorkerListModelAgent::Data::clearChange()
+{
+ changes.clear();
+}
+
+void QDeclarativeWorkerListModelAgent::Data::insertChange(int index, int count)
+{
+ Change c = { Change::Inserted, index, count, 0 };
+ changes << c;
+}
+
+void QDeclarativeWorkerListModelAgent::Data::removeChange(int index, int count)
+{
+ Change c = { Change::Removed, index, count, 0 };
+ changes << c;
+}
+
+void QDeclarativeWorkerListModelAgent::Data::changedChange(int index, int count)
+{
+ Change c = { Change::Changed, index, count, 0 };
+ changes << c;
+}
+
+QDeclarativeWorkerListModelAgent::QDeclarativeWorkerListModelAgent(QDeclarativeWorkerListModel *m)
+: m_engine(0), m_ref(1), m_model(m)
+{
+ data.roles = m_model->m_roles;
+ data.strings = m_model->m_strings;
+ data.values = m_model->m_values;
+}
+
+QDeclarativeWorkerListModelAgent::~QDeclarativeWorkerListModelAgent()
+{
+}
+
+void QDeclarativeWorkerListModelAgent::addref()
+{
+ m_ref.ref();
+}
+
+void QDeclarativeWorkerListModelAgent::release()
+{
+ bool del = !m_ref.deref();
+
+ if (del)
+ delete this;
+}
+
+int QDeclarativeWorkerListModelAgent::count() const
+{
+ return data.values.count();
+}
+
+void QDeclarativeWorkerListModelAgent::clear()
+{
+ data.clearChange();
+ data.removeChange(0, data.values.count());
+ data.values.clear();
+}
+
+void QDeclarativeWorkerListModelAgent::remove(int index)
+{
+ if (data.values.count() <= index)
+ return;
+
+ data.values.removeAt(index);
+ data.removeChange(index, 1);
+}
+
+void QDeclarativeWorkerListModelAgent::append(const QScriptValue &value)
+{
+ QHash<int, QVariant> row;
+
+ QScriptValueIterator it(value);
+ while (it.hasNext()) {
+ it.next();
+ QString name = it.name();
+ QVariant v = it.value().toVariant();
+
+ QHash<QString, int>::Iterator iter = data.strings.find(name);
+ if (iter == data.strings.end()) {
+ int role = data.roles.count();
+ data.roles.insert(role, name);
+ iter = data.strings.insert(name, role);
+ }
+ row.insert(*iter, v);
+ }
+
+ data.values.append(row);
+ data.insertChange(data.values.count() - 1, 1);
+}
+
+void QDeclarativeWorkerListModelAgent::insert(int index, const QScriptValue &value)
+{
+ if (index > data.values.count())
+ return;
+
+ QHash<int, QVariant> row;
+
+ QScriptValueIterator it(value);
+ while (it.hasNext()) {
+ it.next();
+ QString name = it.name();
+ QVariant v = it.value().toVariant();
+
+ QHash<QString, int>::Iterator iter = data.strings.find(name);
+ if (iter == data.strings.end()) {
+ int role = data.roles.count();
+ data.roles.insert(role, name);
+ iter = data.strings.insert(name, role);
+ }
+ row.insert(*iter, v);
+ }
+
+ data.values.insert(index, row);
+ data.insertChange(index, 1);
+}
+
+void QDeclarativeWorkerListModelAgent::set(int index, const QScriptValue &value)
+{
+ if (data.values.count() <= index)
+ return;
+
+ QHash<int, QVariant> row;
+
+ QScriptValueIterator it(value);
+ while (it.hasNext()) {
+ it.next();
+ QString name = it.name();
+ QVariant v = it.value().toVariant();
+
+ QHash<QString, int>::Iterator iter = data.strings.find(name);
+ if (iter == data.strings.end()) {
+ int role = data.roles.count();
+ data.roles.insert(role, name);
+ iter = data.strings.insert(name, role);
+ }
+ row.insert(*iter, v);
+ }
+
+ if (data.values.at(index) != row) {
+ data.values[index] = row;
+ data.changedChange(index, 1);
+ }
+}
+
+QScriptValue QDeclarativeWorkerListModelAgent::get(int index) const
+{
+ if (data.values.count() <= index)
+ return m_engine->undefinedValue();
+
+ QScriptValue rv = m_engine->newObject();
+
+ QHash<int, QVariant> row = data.values.at(index);
+ for (QHash<int, QVariant>::ConstIterator iter = row.begin(); iter != row.end(); ++iter)
+ rv.setProperty(data.roles.value(iter.key()), qScriptValueFromValue(m_engine, iter.value()));
+
+ return rv;
+}
+
+void QDeclarativeWorkerListModelAgent::sync()
+{
+ Sync *s = new Sync;
+ s->data = data;
+ data.changes.clear();
+ QCoreApplication::postEvent(this, s);
+}
+
+bool QDeclarativeWorkerListModelAgent::event(QEvent *e)
+{
+ if (e->type() == QEvent::User) {
+ Sync *s = static_cast<Sync *>(e);
+
+ const QList<Change> &changes = s->data.changes;
+
+ if (m_model) {
+ bool cc = m_model->m_values.count() != s->data.values.count();
+
+ m_model->m_roles = s->data.roles;
+ m_model->m_strings = s->data.strings;
+ m_model->m_values = s->data.values;
+
+ for (int ii = 0; ii < changes.count(); ++ii) {
+ const Change &change = changes.at(ii);
+ switch (change.type) {
+ case Change::Inserted:
+ emit m_model->itemsInserted(change.index, change.count);
+ break;
+ case Change::Removed:
+ emit m_model->itemsRemoved(change.index, change.count);
+ break;
+ case Change::Moved:
+ emit m_model->itemsMoved(change.index, change.to, change.count);
+ break;
+ case Change::Changed:
+ emit m_model->itemsMoved(change.index, change.to, change.count);
+ break;
+ }
+ }
+
+ if (cc)
+ emit m_model->countChanged();
+ }
+ }
+
+ return QObject::event(e);
+}
+
+QDeclarativeWorkerListModel::QDeclarativeWorkerListModel(QObject *parent)
+: QListModelInterface(parent), m_agent(0)
+{
+}
+
+QDeclarativeWorkerListModel::~QDeclarativeWorkerListModel()
+{
+ if (m_agent) {
+ m_agent->m_model = 0;
+ m_agent->release();
+ }
+}
+
+void QDeclarativeWorkerListModel::clear()
+{
+ if (m_agent) {
+ qmlInfo(this) << "List can only be modified from a WorkerScript";
+ return;
+ }
+
+ int count = m_values.count();
+ m_values.clear();
+ if (count) {
+ emit itemsRemoved(0, count);
+ emit countChanged();
+ }
+}
+
+void QDeclarativeWorkerListModel::remove(int index)
+{
+ if (m_agent) {
+ qmlInfo(this) << "List can only be modified from a WorkerScript";
+ return;
+ }
+
+ if (m_values.count() <= index)
+ return;
+
+ m_values.removeAt(index);
+ emit itemsRemoved(index, 1);
+ emit countChanged();
+}
+
+void QDeclarativeWorkerListModel::append(const QScriptValue &value)
+{
+ if (m_agent) {
+ qmlInfo(this) << "List can only be modified from a WorkerScript";
+ return;
+ }
+
+ QHash<int, QVariant> data;
+
+ QScriptValueIterator it(value);
+ while (it.hasNext()) {
+ it.next();
+ QString name = it.name();
+ QVariant v = it.value().toVariant();
+
+ QHash<QString, int>::Iterator iter = m_strings.find(name);
+ if (iter == m_strings.end()) {
+ int role = m_roles.count();
+ m_roles.insert(role, name);
+ iter = m_strings.insert(name, role);
+ }
+ data.insert(*iter, v);
+ }
+
+ m_values.append(data);
+
+ emit itemsInserted(m_values.count() - 1, 1);
+ emit countChanged();
+}
+
+void QDeclarativeWorkerListModel::insert(int index, const QScriptValue &value)
+{
+ if (m_agent) {
+ qmlInfo(this) << "List can only be modified from a WorkerScript";
+ return;
+ }
+
+ if (index > m_values.count())
+ return;
+
+ QHash<int, QVariant> data;
+
+ QScriptValueIterator it(value);
+ while (it.hasNext()) {
+ it.next();
+ QString name = it.name();
+ QVariant v = it.value().toVariant();
+
+ QHash<QString, int>::Iterator iter = m_strings.find(name);
+ if (iter == m_strings.end()) {
+ int role = m_roles.count();
+ m_roles.insert(role, name);
+ iter = m_strings.insert(name, role);
+ }
+ data.insert(*iter, v);
+ }
+
+ m_values.insert(index, data);
+ emit itemsInserted(index, 1);
+ emit countChanged();
+}
+
+QScriptValue QDeclarativeWorkerListModel::get(int index) const
+{
+ QDeclarativeEngine *engine = qmlEngine(this);
+ if (!engine || m_values.count() <= index)
+ return QScriptValue();
+
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+ QScriptValue rv = scriptEngine->newObject();
+
+ QHash<int, QVariant> data = m_values.at(index);
+ for (QHash<int, QVariant>::ConstIterator iter = data.begin(); iter != data.end(); ++iter)
+ rv.setProperty(m_roles.value(iter.key()), qScriptValueFromValue(scriptEngine, iter.value()));
+
+ return rv;
+}
+
+void QDeclarativeWorkerListModel::set(int index, const QScriptValue &value)
+{
+ if (m_agent) {
+ qmlInfo(this) << "List can only be modified from a WorkerScript";
+ return;
+ }
+
+ if (m_values.count() <= index)
+ return;
+
+ QHash<int, QVariant> data;
+
+ QScriptValueIterator it(value);
+ while (it.hasNext()) {
+ it.next();
+ QString name = it.name();
+ QVariant v = it.value().toVariant();
+
+ QHash<QString, int>::Iterator iter = m_strings.find(name);
+ if (iter == m_strings.end()) {
+ int role = m_roles.count();
+ m_roles.insert(role, name);
+ iter = m_strings.insert(name, role);
+ }
+ data.insert(*iter, v);
+ }
+
+ if (m_values.at(index) != data) {
+ m_values[index] = data;
+ emit itemsChanged(index, 1, m_roles.keys());
+ }
+}
+
+QDeclarativeWorkerListModelAgent *QDeclarativeWorkerListModel::agent()
+{
+ if (!m_agent)
+ m_agent = new QDeclarativeWorkerListModelAgent(this);
+
+ return m_agent;
+}
+
+QList<int> QDeclarativeWorkerListModel::roles() const
+{
+ return m_roles.keys();
+}
+
+QString QDeclarativeWorkerListModel::toString(int role) const
+{
+ return m_roles.value(role);
+}
+
+int QDeclarativeWorkerListModel::count() const
+{
+ return m_values.count();
+}
+
+QHash<int,QVariant> QDeclarativeWorkerListModel::data(int index, const QList<int> &) const
+{
+ if (m_values.count() <= index)
+ return QHash<int, QVariant>();
+ else
+ return m_values.at(index);
+}
+
+QVariant QDeclarativeWorkerListModel::data(int index, int role) const
+{
+ if (m_values.count() <= index)
+ return QVariant();
+ else
+ return m_values.at(index).value(role);
+}
+
+QT_END_NAMESPACE
+
+#include "qdeclarativeworkerscript.moc"
+
+
diff --git a/src/declarative/qml/qdeclarativeworkerscript_p.h b/src/declarative/qml/qdeclarativeworkerscript_p.h
new file mode 100644
index 0000000..8ebd2c1
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeworkerscript_p.h
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEWORKERSCRIPT_P_H
+#define QDECLARATIVEWORKERSCRIPT_P_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 "qdeclarative.h"
+#include "qdeclarativeparserstatus.h"
+#include <private/qlistmodelinterface_p.h>
+
+#include <QtCore/qthread.h>
+#include <QtScript/qscriptvalue.h>
+#include <QtCore/qurl.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeWorkerScript;
+class QDeclarativeWorkerScriptEnginePrivate;
+class QDeclarativeWorkerScriptEngine : public QThread
+{
+Q_OBJECT
+public:
+ QDeclarativeWorkerScriptEngine(QDeclarativeEngine *parent = 0);
+ virtual ~QDeclarativeWorkerScriptEngine();
+
+ int registerWorkerScript(QDeclarativeWorkerScript *);
+ void removeWorkerScript(int);
+ void executeUrl(int, const QUrl &);
+ void sendMessage(int, const QVariant &);
+
+protected:
+ virtual void run();
+
+private:
+ QDeclarativeWorkerScriptEnginePrivate *d;
+};
+
+class QDeclarativeWorkerScript : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+
+ Q_INTERFACES(QDeclarativeParserStatus)
+public:
+ QDeclarativeWorkerScript(QObject *parent = 0);
+ virtual ~QDeclarativeWorkerScript();
+
+ QUrl source() const;
+ void setSource(const QUrl &);
+
+public slots:
+ void sendMessage(const QScriptValue &);
+
+signals:
+ void sourceChanged();
+ void message(const QScriptValue &messageObject);
+
+protected:
+ virtual void componentComplete();
+ virtual bool event(QEvent *);
+
+private:
+ QDeclarativeWorkerScriptEngine *m_engine;
+ int m_scriptId;
+ QUrl m_source;
+};
+
+class QDeclarativeWorkerListModelAgent;
+class QDeclarativeWorkerListModel : public QListModelInterface
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+
+public:
+ QDeclarativeWorkerListModel(QObject * = 0);
+ virtual ~QDeclarativeWorkerListModel();
+
+ Q_INVOKABLE void clear();
+ Q_INVOKABLE void remove(int index);
+ Q_INVOKABLE void append(const QScriptValue &);
+ Q_INVOKABLE void insert(int index, const QScriptValue&);
+ Q_INVOKABLE QScriptValue get(int index) const;
+ Q_INVOKABLE void set(int index, const QScriptValue &);
+
+ QDeclarativeWorkerListModelAgent *agent();
+
+ virtual QList<int> roles() const;
+ virtual QString toString(int role) const;
+ virtual int count() const;
+ virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
+ virtual QVariant data(int index, int role) const;
+
+Q_SIGNALS:
+ void countChanged();
+
+private:
+ friend class QDeclarativeWorkerListModelAgent;
+
+ QHash<int, QString> m_roles;
+ QHash<QString, int> m_strings;
+ QList<QHash<int, QVariant> > m_values;
+
+ QDeclarativeWorkerListModelAgent *m_agent;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeWorkerScript);
+QML_DECLARE_TYPE(QDeclarativeWorkerListModel);
+
+#endif // QDECLARATIVEWORKERSCRIPT_P_H
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
new file mode 100644
index 0000000..3ba53f0
--- /dev/null
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -0,0 +1,1631 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativexmlhttprequest_p.h"
+
+#include "qdeclarativeengine.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativerefcount_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativeexpression_p.h"
+
+#include <QtCore/qobject.h>
+#include <QtScript/qscriptvalue.h>
+#include <QtScript/qscriptcontext.h>
+#include <QtScript/qscriptengine.h>
+#include <QtNetwork/qnetworkreply.h>
+#include <QtCore/qxmlstream.h>
+#include <QtCore/qstack.h>
+#include <QtCore/qdebug.h>
+
+// From DOM-Level-3-Core spec
+// http://www.w3.org/TR/DOM-Level-3-Core/core.html
+#define INDEX_SIZE_ERR 1
+#define DOMSTRING_SIZE_ERR 2
+#define HIERARCHY_REQUEST_ERR 3
+#define WRONG_DOCUMENT_ERR 4
+#define INVALID_CHARACTER_ERR 5
+#define NO_DATA_ALLOWED_ERR 6
+#define NO_MODIFICATION_ALLOWED_ERR 7
+#define NOT_FOUND_ERR 8
+#define NOT_SUPPORTED_ERR 9
+#define INUSE_ATTRIBUTE_ERR 10
+#define INVALID_STATE_ERR 11
+#define SYNTAX_ERR 12
+#define INVALID_MODIFICATION_ERR 13
+#define NAMESPACE_ERR 14
+#define INVALID_ACCESS_ERR 15
+#define VALIDATION_ERR 16
+#define TYPE_MISMATCH_ERR 17
+
+#define THROW_DOM(error, desc) \
+{ \
+ QScriptValue errorValue = context->throwError(QLatin1String(desc)); \
+ errorValue.setProperty(QLatin1String("code"), error); \
+ return errorValue; \
+}
+
+#define THROW_SYNTAX(desc) \
+ return context->throwError(QScriptContext::SyntaxError, QLatin1String(desc));
+#define THROW_REFERENCE(desc) \
+ return context->throwError(QScriptContext::ReferenceError, QLatin1String(desc));
+
+#define D(arg) (arg)->release()
+#define A(arg) (arg)->addref()
+
+QT_BEGIN_NAMESPACE
+
+class DocumentImpl;
+class NodeImpl
+{
+public:
+ NodeImpl() : type(Element), document(0), parent(0) {}
+ virtual ~NodeImpl() {
+ for (int ii = 0; ii < children.count(); ++ii)
+ delete children.at(ii);
+ for (int ii = 0; ii < attributes.count(); ++ii)
+ delete attributes.at(ii);
+ }
+
+ // These numbers are copied from the Node IDL definition
+ enum Type {
+ Attr = 2,
+ CDATA = 4,
+ Comment = 8,
+ Document = 9,
+ DocumentFragment = 11,
+ DocumentType = 10,
+ Element = 1,
+ Entity = 6,
+ EntityReference = 5,
+ Notation = 12,
+ ProcessingInstruction = 7,
+ Text = 3
+ };
+ Type type;
+
+ QString namespaceUri;
+ QString name;
+
+ QString data;
+
+ void addref();
+ void release();
+
+ DocumentImpl *document;
+ NodeImpl *parent;
+
+ QList<NodeImpl *> children;
+ QList<NodeImpl *> attributes;
+};
+
+class DocumentImpl : public QDeclarativeRefCount, public NodeImpl
+{
+public:
+ DocumentImpl() : root(0) { type = Document; }
+ virtual ~DocumentImpl() {
+ if (root) delete root;
+ }
+
+ QString version;
+ QString encoding;
+ bool isStandalone;
+
+ NodeImpl *root;
+
+ void addref() { QDeclarativeRefCount::addref(); }
+ void release() { QDeclarativeRefCount::release(); }
+};
+
+class NamedNodeMap
+{
+public:
+ // JS API
+ static QScriptValue length(QScriptContext *context, QScriptEngine *engine);
+
+ // C++ API
+ static QScriptValue prototype(QScriptEngine *);
+ static QScriptValue create(QScriptEngine *, NodeImpl *, QList<NodeImpl *> *);
+
+ NamedNodeMap();
+ NamedNodeMap(const NamedNodeMap &);
+ ~NamedNodeMap();
+ bool isNull();
+
+ NodeImpl *d;
+ QList<NodeImpl *> *list;
+private:
+ NamedNodeMap &operator=(const NamedNodeMap &);
+};
+
+class NamedNodeMapClass : public QScriptClass
+{
+public:
+ NamedNodeMapClass(QScriptEngine *engine) : QScriptClass(engine) {}
+
+ virtual QueryFlags queryProperty(const QScriptValue &object, const QScriptString &name, QueryFlags flags, uint *id);
+ virtual QScriptValue property(const QScriptValue &object, const QScriptString &name, uint id);
+};
+
+class NodeList
+{
+public:
+ // JS API
+ static QScriptValue length(QScriptContext *context, QScriptEngine *engine);
+
+ // C++ API
+ static QScriptValue prototype(QScriptEngine *);
+ static QScriptValue create(QScriptEngine *, NodeImpl *);
+
+ NodeList();
+ NodeList(const NodeList &);
+ ~NodeList();
+ bool isNull();
+
+ NodeImpl *d;
+private:
+ NodeList &operator=(const NodeList &);
+};
+
+class NodeListClass : public QScriptClass
+{
+public:
+ NodeListClass(QScriptEngine *engine) : QScriptClass(engine) {}
+ virtual QueryFlags queryProperty(const QScriptValue &object, const QScriptString &name, QueryFlags flags, uint *id);
+ virtual QScriptValue property(const QScriptValue &object, const QScriptString &name, uint id);
+};
+
+class Node
+{
+public:
+ // JS API
+ static QScriptValue nodeName(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue nodeValue(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue nodeType(QScriptContext *context, QScriptEngine *engine);
+
+ static QScriptValue parentNode(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue childNodes(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue firstChild(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue lastChild(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue previousSibling(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue nextSibling(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue attributes(QScriptContext *context, QScriptEngine *engine);
+
+ //static QScriptValue ownerDocument(QScriptContext *context, QScriptEngine *engine);
+ //static QScriptValue namespaceURI(QScriptContext *context, QScriptEngine *engine);
+ //static QScriptValue prefix(QScriptContext *context, QScriptEngine *engine);
+ //static QScriptValue localName(QScriptContext *context, QScriptEngine *engine);
+ //static QScriptValue baseURI(QScriptContext *context, QScriptEngine *engine);
+ //static QScriptValue textContent(QScriptContext *context, QScriptEngine *engine);
+
+ // C++ API
+ static QScriptValue prototype(QScriptEngine *);
+ static QScriptValue create(QScriptEngine *, NodeImpl *);
+
+ Node();
+ Node(const Node &o);
+ ~Node();
+ bool isNull() const;
+
+ NodeImpl *d;
+
+private:
+ Node &operator=(const Node &);
+};
+
+class Element : public Node
+{
+public:
+ // C++ API
+ static QScriptValue prototype(QScriptEngine *);
+};
+
+class Attr : public Node
+{
+public:
+ // JS API
+ static QScriptValue name(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue specified(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue value(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue ownerElement(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue schemaTypeInfo(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue isId(QScriptContext *context, QScriptEngine *engine);
+
+ // C++ API
+ static QScriptValue prototype(QScriptEngine *);
+};
+
+class CharacterData : public Node
+{
+public:
+ // JS API
+ static QScriptValue length(QScriptContext *context, QScriptEngine *engine);
+
+ // C++ API
+ static QScriptValue prototype(QScriptEngine *);
+};
+
+class Text : public CharacterData
+{
+public:
+ // JS API
+ static QScriptValue isElementContentWhitespace(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue wholeText(QScriptContext *context, QScriptEngine *engine);
+
+ // C++ API
+ static QScriptValue prototype(QScriptEngine *);
+};
+
+class CDATA : public Text
+{
+public:
+ // C++ API
+ static QScriptValue prototype(QScriptEngine *);
+};
+
+class Document : public Node
+{
+public:
+ // JS API
+ static QScriptValue xmlVersion(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue xmlEncoding(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue xmlStandalone(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue documentElement(QScriptContext *context, QScriptEngine *engine);
+
+ // C++ API
+ static QScriptValue prototype(QScriptEngine *);
+ static QScriptValue load(QScriptEngine *engine, const QString &data);
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Node);
+Q_DECLARE_METATYPE(NodeList);
+Q_DECLARE_METATYPE(NamedNodeMap);
+
+QT_BEGIN_NAMESPACE
+
+void NodeImpl::addref()
+{
+ A(document);
+}
+
+void NodeImpl::release()
+{
+ D(document);
+}
+
+QScriptValue Node::nodeName(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ switch (node.d->type) {
+ case NodeImpl::Document:
+ return QScriptValue(QLatin1String("#document"));
+ case NodeImpl::CDATA:
+ return QScriptValue(QLatin1String("#cdata-section"));
+ case NodeImpl::Text:
+ return QScriptValue(QLatin1String("#text"));
+ default:
+ return QScriptValue(node.d->name);
+ }
+}
+
+QScriptValue Node::nodeValue(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ if (node.d->type == NodeImpl::Document ||
+ node.d->type == NodeImpl::DocumentFragment ||
+ node.d->type == NodeImpl::DocumentType ||
+ node.d->type == NodeImpl::Element ||
+ node.d->type == NodeImpl::Entity ||
+ node.d->type == NodeImpl::EntityReference ||
+ node.d->type == NodeImpl::Notation)
+ return engine->nullValue();
+
+ return QScriptValue(node.d->data);
+}
+
+QScriptValue Node::nodeType(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+ return QScriptValue(node.d->type);
+}
+
+QScriptValue Node::parentNode(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ if (node.d->parent) return Node::create(engine, node.d->parent);
+ else return engine->nullValue();
+}
+
+QScriptValue Node::childNodes(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ return NodeList::create(engine, node.d);
+}
+
+QScriptValue Node::firstChild(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ if (node.d->children.isEmpty()) return engine->nullValue();
+ else return Node::create(engine, node.d->children.first());
+}
+
+QScriptValue Node::lastChild(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ if (node.d->children.isEmpty()) return engine->nullValue();
+ else return Node::create(engine, node.d->children.last());
+}
+
+QScriptValue Node::previousSibling(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ if (!node.d->parent) return engine->nullValue();
+
+ for (int ii = 0; ii < node.d->parent->children.count(); ++ii) {
+ if (node.d->parent->children.at(ii) == node.d) {
+ if (ii == 0) return engine->nullValue();
+ else return Node::create(engine, node.d->parent->children.at(ii - 1));
+ }
+ }
+
+ return engine->nullValue();
+}
+
+QScriptValue Node::nextSibling(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ if (!node.d->parent) return engine->nullValue();
+
+ for (int ii = 0; ii < node.d->parent->children.count(); ++ii) {
+ if (node.d->parent->children.at(ii) == node.d) {
+ if ((ii + 1) == node.d->parent->children.count()) return engine->nullValue();
+ else return Node::create(engine, node.d->parent->children.at(ii + 1));
+ }
+ }
+
+ return engine->nullValue();
+}
+
+QScriptValue Node::attributes(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ if (node.d->type != NodeImpl::Element)
+ return engine->nullValue();
+ else
+ return NamedNodeMap::create(engine, node.d, &node.d->attributes);
+}
+
+QScriptValue Node::prototype(QScriptEngine *engine)
+{
+ QScriptValue proto = engine->newObject();
+
+ proto.setProperty(QLatin1String("nodeName"), engine->newFunction(nodeName), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("nodeValue"), engine->newFunction(nodeValue), QScriptValue::ReadOnly | QScriptValue::PropertyGetter | QScriptValue::PropertySetter);
+ proto.setProperty(QLatin1String("nodeType"), engine->newFunction(nodeType), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("parentNode"), engine->newFunction(parentNode), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("childNodes"), engine->newFunction(childNodes), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("firstChild"), engine->newFunction(firstChild), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("lastChild"), engine->newFunction(lastChild), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("previousSibling"), engine->newFunction(previousSibling), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("nextSibling"), engine->newFunction(nextSibling), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("attributes"), engine->newFunction(attributes), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+
+ return proto;
+}
+
+QScriptValue Node::create(QScriptEngine *engine, NodeImpl *data)
+{
+ QScriptValue instance = engine->newObject();
+
+ switch (data->type) {
+ case NodeImpl::Attr:
+ instance.setPrototype(Attr::prototype(engine));
+ break;
+ case NodeImpl::Comment:
+ case NodeImpl::Document:
+ case NodeImpl::DocumentFragment:
+ case NodeImpl::DocumentType:
+ case NodeImpl::Entity:
+ case NodeImpl::EntityReference:
+ case NodeImpl::Notation:
+ case NodeImpl::ProcessingInstruction:
+ return QScriptValue();
+ case NodeImpl::CDATA:
+ instance.setPrototype(CDATA::prototype(engine));
+ break;
+ case NodeImpl::Text:
+ instance.setPrototype(Text::prototype(engine));
+ break;
+ case NodeImpl::Element:
+ instance.setPrototype(Element::prototype(engine));
+ break;
+ }
+
+ Node node;
+ node.d = data;
+ if (data) A(data);
+
+ return engine->newVariant(instance, qVariantFromValue(node));
+}
+
+QScriptValue Element::prototype(QScriptEngine *engine)
+{
+ QScriptValue proto = engine->newObject();
+ proto.setPrototype(Node::prototype(engine));
+
+ proto.setProperty(QLatin1String("tagName"), engine->newFunction(nodeName), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+
+ return proto;
+}
+
+QScriptValue Attr::prototype(QScriptEngine *engine)
+{
+ QScriptValue proto = engine->newObject();
+ proto.setPrototype(Node::prototype(engine));
+
+ proto.setProperty(QLatin1String("name"), engine->newFunction(name), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("value"), engine->newFunction(value), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("ownerElement"), engine->newFunction(ownerElement), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+
+ return proto;
+}
+
+QScriptValue Attr::name(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ return QScriptValue(node.d->name);
+}
+
+QScriptValue Attr::value(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ return QScriptValue(node.d->data);
+}
+
+QScriptValue Attr::ownerElement(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ return Node::create(engine, node.d->parent);
+}
+
+QScriptValue CharacterData::length(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ return QScriptValue(node.d->data.length());
+}
+
+QScriptValue CharacterData::prototype(QScriptEngine *engine)
+{
+ QScriptValue proto = engine->newObject();
+ proto.setPrototype(Node::prototype(engine));
+
+ proto.setProperty(QLatin1String("data"), engine->newFunction(nodeValue), QScriptValue::ReadOnly | QScriptValue::PropertyGetter | QScriptValue::PropertySetter);
+ proto.setProperty(QLatin1String("length"), engine->newFunction(length), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+
+ return proto;
+}
+
+QScriptValue Text::isElementContentWhitespace(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ return node.d->data.trimmed().isEmpty();
+}
+
+QScriptValue Text::wholeText(QScriptContext *context, QScriptEngine *engine)
+{
+ Node node = qscriptvalue_cast<Node>(context->thisObject());
+ if (node.isNull()) return engine->undefinedValue();
+
+ return node.d->data;
+}
+
+QScriptValue Text::prototype(QScriptEngine *engine)
+{
+ QScriptValue proto = engine->newObject();
+ proto.setPrototype(CharacterData::prototype(engine));
+
+ proto.setProperty(QLatin1String("isElementContentWhitespace"), engine->newFunction(isElementContentWhitespace), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ proto.setProperty(QLatin1String("wholeText"), engine->newFunction(wholeText), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+
+ return proto;
+}
+
+QScriptValue CDATA::prototype(QScriptEngine *engine)
+{
+ QScriptValue proto = engine->newObject();
+ proto.setPrototype(Text::prototype(engine));
+ return proto;
+}
+
+QScriptValue Document::prototype(QScriptEngine *engine)
+{
+ QScriptValue proto = engine->newObject();
+ proto.setPrototype(Node::prototype(engine));
+
+ proto.setProperty(QLatin1String("xmlVersion"), engine->newFunction(xmlVersion), QScriptValue::ReadOnly | QScriptValue::PropertyGetter | QScriptValue::PropertySetter);
+ proto.setProperty(QLatin1String("xmlEncoding"), engine->newFunction(xmlEncoding), QScriptValue::ReadOnly | QScriptValue::PropertyGetter | QScriptValue::PropertySetter);
+ proto.setProperty(QLatin1String("xmlStandalone"), engine->newFunction(xmlStandalone), QScriptValue::ReadOnly | QScriptValue::PropertyGetter | QScriptValue::PropertySetter);
+ proto.setProperty(QLatin1String("documentElement"), engine->newFunction(documentElement), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+
+ return proto;
+}
+
+QScriptValue Document::load(QScriptEngine *engine, const QString &data)
+{
+ Q_ASSERT(engine);
+
+ DocumentImpl *document = 0;
+ QStack<NodeImpl *> nodeStack;
+
+ QXmlStreamReader reader(data);
+
+ while (!reader.atEnd()) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::NoToken:
+ break;
+ case QXmlStreamReader::Invalid:
+ break;
+ case QXmlStreamReader::StartDocument:
+ Q_ASSERT(!document);
+ document = new DocumentImpl;
+ document->document = document;
+ document->version = reader.documentVersion().toString();
+ document->encoding = reader.documentEncoding().toString();
+ document->isStandalone = reader.isStandaloneDocument();
+ break;
+ case QXmlStreamReader::EndDocument:
+ break;
+ case QXmlStreamReader::StartElement:
+ {
+ Q_ASSERT(document);
+ NodeImpl *node = new NodeImpl;
+ node->document = document;
+ node->namespaceUri = reader.namespaceUri().toString();
+ node->name = reader.name().toString();
+ if (nodeStack.isEmpty()) {
+ document->root = node;
+ } else {
+ node->parent = nodeStack.top();
+ node->parent->children.append(node);
+ }
+ nodeStack.append(node);
+
+ foreach (const QXmlStreamAttribute &a, reader.attributes()) {
+ NodeImpl *attr = new NodeImpl;
+ attr->document = document;
+ attr->type = NodeImpl::Attr;
+ attr->namespaceUri = a.namespaceUri().toString();
+ attr->name = a.name().toString();
+ attr->data = a.value().toString();
+ attr->parent = node;
+ node->attributes.append(attr);
+ }
+ }
+ break;
+ case QXmlStreamReader::EndElement:
+ nodeStack.pop();
+ break;
+ case QXmlStreamReader::Characters:
+ {
+ NodeImpl *node = new NodeImpl;
+ node->document = document;
+ node->type = reader.isCDATA()?NodeImpl::CDATA:NodeImpl::Text;
+ node->parent = nodeStack.top();
+ node->parent->children.append(node);
+ node->data = reader.text().toString();
+ }
+ break;
+ case QXmlStreamReader::Comment:
+ break;
+ case QXmlStreamReader::DTD:
+ break;
+ case QXmlStreamReader::EntityReference:
+ break;
+ case QXmlStreamReader::ProcessingInstruction:
+ break;
+ }
+ }
+
+ if (!document || reader.hasError()) {
+ if (document) D(document);
+ return engine->nullValue();
+ }
+
+ QScriptValue instance = engine->newObject();
+ instance.setPrototype(Document::prototype(engine));
+ Node documentNode;
+ documentNode.d = document;
+ return engine->newVariant(instance, qVariantFromValue(documentNode));
+}
+
+Node::Node()
+: d(0)
+{
+}
+
+Node::Node(const Node &o)
+: d(o.d)
+{
+ if (d) A(d);
+}
+
+Node::~Node()
+{
+ if (d) D(d);
+}
+
+bool Node::isNull() const
+{
+ return d == 0;
+}
+
+QScriptValue NamedNodeMap::length(QScriptContext *context, QScriptEngine *engine)
+{
+ NamedNodeMap map = qscriptvalue_cast<NamedNodeMap>(context->thisObject().data());
+ if (map.isNull()) return engine->undefinedValue();
+
+ return QScriptValue(map.list->count());
+}
+
+QScriptValue NamedNodeMap::prototype(QScriptEngine *engine)
+{
+ QScriptValue proto = engine->newObject();
+
+ proto.setProperty(QLatin1String("length"), engine->newFunction(length), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+
+ return proto;
+}
+
+QScriptValue NamedNodeMap::create(QScriptEngine *engine, NodeImpl *data, QList<NodeImpl *> *list)
+{
+ QScriptValue instance = engine->newObject();
+ instance.setPrototype(NamedNodeMap::prototype(engine));
+
+ NamedNodeMap map;
+ map.d = data;
+ map.list = list;
+ if (data) A(data);
+
+ instance.setData(engine->newVariant(qVariantFromValue(map)));
+
+ if (!QDeclarativeScriptEngine::get(engine)->namedNodeMapClass)
+ QDeclarativeScriptEngine::get(engine)->namedNodeMapClass= new NamedNodeMapClass(engine);
+
+ instance.setScriptClass(QDeclarativeScriptEngine::get(engine)->namedNodeMapClass);
+
+ return instance;
+}
+
+NamedNodeMap::NamedNodeMap()
+: d(0), list(0)
+{
+}
+
+NamedNodeMap::NamedNodeMap(const NamedNodeMap &o)
+: d(o.d), list(o.list)
+{
+ if (d) A(d);
+}
+
+NamedNodeMap::~NamedNodeMap()
+{
+ if (d) D(d);
+}
+
+bool NamedNodeMap::isNull()
+{
+ return d == 0;
+}
+
+QScriptValue NodeList::length(QScriptContext *context, QScriptEngine *engine)
+{
+ NodeList list = qscriptvalue_cast<NodeList>(context->thisObject().data());
+ if (list.isNull()) return engine->undefinedValue();
+
+ return QScriptValue(list.d->children.count());
+}
+
+QScriptValue NodeList::prototype(QScriptEngine *engine)
+{
+ QScriptValue proto = engine->newObject();
+
+ proto.setProperty(QLatin1String("length"), engine->newFunction(length), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+
+ return proto;
+}
+
+QScriptValue NodeList::create(QScriptEngine *engine, NodeImpl *data)
+{
+ QScriptValue instance = engine->newObject();
+ instance.setPrototype(NodeList::prototype(engine));
+
+ NodeList list;
+ list.d = data;
+ if (data) A(data);
+
+ instance.setData(engine->newVariant(qVariantFromValue(list)));
+
+ if (!QDeclarativeScriptEngine::get(engine)->nodeListClass)
+ QDeclarativeScriptEngine::get(engine)->nodeListClass= new NodeListClass(engine);
+
+ instance.setScriptClass(QDeclarativeScriptEngine::get(engine)->nodeListClass);
+
+ return instance;
+}
+
+NodeList::NodeList()
+: d(0)
+{
+}
+
+NodeList::NodeList(const NodeList &o)
+: d(o.d)
+{
+ if (d) A(d);
+}
+
+NodeList::~NodeList()
+{
+ if (d) D(d);
+}
+
+bool NodeList::isNull()
+{
+ return d == 0;
+}
+
+NamedNodeMapClass::QueryFlags NamedNodeMapClass::queryProperty(const QScriptValue &object, const QScriptString &name, QueryFlags flags, uint *id)
+{
+ if (!(flags & HandlesReadAccess))
+ return 0;
+
+ NamedNodeMap map = qscriptvalue_cast<NamedNodeMap>(object.data());
+ Q_ASSERT(!map.isNull());
+
+ bool ok = false;
+ QString nameString = name.toString();
+ uint index = nameString.toUInt(&ok);
+ if (ok) {
+ if ((uint)map.list->count() <= index)
+ return 0;
+
+ *id = index;
+ return HandlesReadAccess;
+ } else {
+ for (int ii = 0; ii < map.list->count(); ++ii) {
+ if (map.list->at(ii) && map.list->at(ii)->name == nameString) {
+ *id = ii;
+ return HandlesReadAccess;
+ }
+ }
+ }
+
+ return 0;
+}
+
+QScriptValue NamedNodeMapClass::property(const QScriptValue &object, const QScriptString &, uint id)
+{
+ NamedNodeMap map = qscriptvalue_cast<NamedNodeMap>(object.data());
+ return Node::create(engine(), map.list->at(id));
+}
+
+NodeListClass::QueryFlags NodeListClass::queryProperty(const QScriptValue &object, const QScriptString &name, QueryFlags flags, uint *id)
+{
+ if (!(flags & HandlesReadAccess))
+ return 0;
+
+ bool ok = false;
+ uint index = name.toString().toUInt(&ok);
+ if (!ok)
+ return 0;
+
+ NodeList list = qscriptvalue_cast<NodeList>(object.data());
+ if (list.isNull() || (uint)list.d->children.count() <= index)
+ return 0; // ### I think we're meant to raise an exception
+
+ *id = index;
+ return HandlesReadAccess;
+}
+
+QScriptValue NodeListClass::property(const QScriptValue &object, const QScriptString &, uint id)
+{
+ NodeList list = qscriptvalue_cast<NodeList>(object.data());
+ return Node::create(engine(), list.d->children.at(id));
+}
+
+QScriptValue Document::documentElement(QScriptContext *context, QScriptEngine *engine)
+{
+ Node document = qscriptvalue_cast<Node>(context->thisObject());
+ if (document.isNull() || document.d->type != NodeImpl::Document) return engine->undefinedValue();
+
+ return Node::create(engine, static_cast<DocumentImpl *>(document.d)->root);
+}
+
+QScriptValue Document::xmlStandalone(QScriptContext *context, QScriptEngine *engine)
+{
+ Node document = qscriptvalue_cast<Node>(context->thisObject());
+ if (document.isNull() || document.d->type != NodeImpl::Document) return engine->undefinedValue();
+
+ return QScriptValue(static_cast<DocumentImpl *>(document.d)->isStandalone);
+}
+
+QScriptValue Document::xmlVersion(QScriptContext *context, QScriptEngine *engine)
+{
+ Node document = qscriptvalue_cast<Node>(context->thisObject());
+ if (document.isNull() || document.d->type != NodeImpl::Document) return engine->undefinedValue();
+
+ return QScriptValue(static_cast<DocumentImpl *>(document.d)->version);
+}
+
+QScriptValue Document::xmlEncoding(QScriptContext *context, QScriptEngine *engine)
+{
+ Node document = qscriptvalue_cast<Node>(context->thisObject());
+ if (document.isNull() || document.d->type != NodeImpl::Document) return engine->undefinedValue();
+
+ return QScriptValue(static_cast<DocumentImpl *>(document.d)->encoding);
+}
+
+class QDeclarativeXMLHttpRequest : public QObject
+{
+Q_OBJECT
+public:
+ enum State { Unsent = 0,
+ Opened = 1, HeadersReceived = 2,
+ Loading = 3, Done = 4 };
+
+ QDeclarativeXMLHttpRequest(QNetworkAccessManager *manager);
+ virtual ~QDeclarativeXMLHttpRequest();
+
+ bool sendFlag() const;
+ bool errorFlag() const;
+ quint32 readyState() const;
+ int replyStatus() const;
+ QString replyStatusText() const;
+
+ QScriptValue open(QScriptValue *me, const QString &, const QUrl &);
+
+ void addHeader(const QString &, const QString &);
+ QString header(const QString &name);
+ QString headers();
+ QScriptValue send(QScriptValue *me, const QByteArray &);
+ QScriptValue abort(QScriptValue *me);
+
+ QString responseBody() const;
+private slots:
+ void downloadProgress(qint64);
+ void error(QNetworkReply::NetworkError);
+ void finished();
+
+private:
+ void requestFromUrl(const QUrl &url);
+
+ State m_state;
+ bool m_errorFlag;
+ bool m_sendFlag;
+ QString m_method;
+ QUrl m_url;
+ QByteArray m_responseEntityBody;
+ QByteArray m_data;
+ int m_redirectCount;
+
+ typedef QPair<QByteArray, QByteArray> HeaderPair;
+ typedef QList<HeaderPair> HeadersList;
+ HeadersList m_headersList;
+ void fillHeadersList();
+
+ QScriptValue m_me; // Set to the data object while a send() is ongoing (to access the callback)
+
+ QScriptValue dispatchCallback(QScriptValue *me);
+ void printError(const QScriptValue&);
+
+ int m_status;
+ QString m_statusText;
+ QNetworkRequest m_request;
+ QNetworkReply *m_network;
+ void destroyNetwork();
+
+ QNetworkAccessManager *m_nam;
+ QNetworkAccessManager *networkAccessManager() { return m_nam; }
+};
+
+QDeclarativeXMLHttpRequest::QDeclarativeXMLHttpRequest(QNetworkAccessManager *manager)
+: m_state(Unsent), m_errorFlag(false), m_sendFlag(false),
+ m_redirectCount(0), m_network(0), m_nam(manager)
+{
+}
+
+QDeclarativeXMLHttpRequest::~QDeclarativeXMLHttpRequest()
+{
+ destroyNetwork();
+}
+
+bool QDeclarativeXMLHttpRequest::sendFlag() const
+{
+ return m_sendFlag;
+}
+
+bool QDeclarativeXMLHttpRequest::errorFlag() const
+{
+ return m_errorFlag;
+}
+
+quint32 QDeclarativeXMLHttpRequest::readyState() const
+{
+ return m_state;
+}
+
+int QDeclarativeXMLHttpRequest::replyStatus() const
+{
+ return m_status;
+}
+
+QString QDeclarativeXMLHttpRequest::replyStatusText() const
+{
+ return m_statusText;
+}
+
+QScriptValue QDeclarativeXMLHttpRequest::open(QScriptValue *me, const QString &method, const QUrl &url)
+{
+ destroyNetwork();
+ m_sendFlag = false;
+ m_errorFlag = false;
+ m_responseEntityBody = QByteArray();
+ m_method = method;
+ m_url = url;
+ m_state = Opened;
+ return dispatchCallback(me);
+}
+
+void QDeclarativeXMLHttpRequest::addHeader(const QString &name, const QString &value)
+{
+ QByteArray utfname = name.toUtf8();
+
+ if (m_request.hasRawHeader(utfname)) {
+ m_request.setRawHeader(utfname, m_request.rawHeader(utfname) + ',' + value.toUtf8());
+ } else {
+ m_request.setRawHeader(utfname, value.toUtf8());
+ }
+}
+
+QString QDeclarativeXMLHttpRequest::header(const QString &name)
+{
+ QByteArray utfname = name.toLower().toUtf8();
+
+ foreach (const HeaderPair &header, m_headersList) {
+ if (header.first == utfname)
+ return QString::fromUtf8(header.second);
+ }
+ return QString();
+}
+
+QString QDeclarativeXMLHttpRequest::headers()
+{
+ QString ret;
+
+ foreach (const HeaderPair &header, m_headersList) {
+ if (ret.length())
+ ret.append(QString::fromUtf8("\r\n"));
+ ret.append(QString::fromUtf8(header.first));
+ ret.append(QString::fromUtf8(": "));
+ ret.append(QString::fromUtf8(header.second));
+ }
+ return ret;
+}
+
+void QDeclarativeXMLHttpRequest::fillHeadersList()
+{
+ QList<QByteArray> headerList = m_network->rawHeaderList();
+
+ m_headersList.clear();
+ foreach (const QByteArray &header, headerList) {
+ HeaderPair pair (header.toLower(), m_network->rawHeader(header));
+ if (pair.first == "set-cookie" ||
+ pair.first == "set-cookie2")
+ continue;
+
+ m_headersList << pair;
+ }
+}
+
+void QDeclarativeXMLHttpRequest::requestFromUrl(const QUrl &url)
+{
+ QNetworkRequest request = m_request;
+ request.setUrl(url);
+ if(m_method == QLatin1String("POST") ||
+ m_method == QLatin1String("PUT")) {
+ QVariant var = request.header(QNetworkRequest::ContentTypeHeader);
+ if (var.isValid()) {
+ QString str = var.toString();
+ int charsetIdx = str.indexOf(QLatin1String("charset="));
+ if (charsetIdx == -1) {
+ // No charset - append
+ if (!str.isEmpty()) str.append(QLatin1Char(';'));
+ str.append(QLatin1String("charset=UTF-8"));
+ } else {
+ charsetIdx += 8;
+ int n = 0;
+ int semiColon = str.indexOf(QLatin1Char(';'), charsetIdx);
+ if (semiColon == -1) {
+ n = str.length() - charsetIdx;
+ } else {
+ n = semiColon - charsetIdx;
+ }
+
+ str.replace(charsetIdx, n, QLatin1String("UTF-8"));
+ }
+ request.setHeader(QNetworkRequest::ContentTypeHeader, str);
+ } else {
+ request.setHeader(QNetworkRequest::ContentTypeHeader,
+ QLatin1String("text/plain;charset=UTF-8"));
+ }
+ }
+
+ if (m_method == QLatin1String("GET"))
+ m_network = networkAccessManager()->get(request);
+ else if (m_method == QLatin1String("HEAD"))
+ m_network = networkAccessManager()->head(request);
+ else if(m_method == QLatin1String("POST"))
+ m_network = networkAccessManager()->post(request, m_data);
+ else if(m_method == QLatin1String("PUT"))
+ m_network = networkAccessManager()->put(request, m_data);
+
+ QObject::connect(m_network, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(downloadProgress(qint64)));
+ QObject::connect(m_network, SIGNAL(error(QNetworkReply::NetworkError)),
+ this, SLOT(error(QNetworkReply::NetworkError)));
+ QObject::connect(m_network, SIGNAL(finished()),
+ this, SLOT(finished()));
+}
+
+QScriptValue QDeclarativeXMLHttpRequest::send(QScriptValue *me, const QByteArray &data)
+{
+ m_errorFlag = false;
+ m_sendFlag = true;
+ m_redirectCount = 0;
+ m_data = data;
+ m_me = *me;
+
+ requestFromUrl(m_url);
+
+ return QScriptValue();
+}
+
+QScriptValue QDeclarativeXMLHttpRequest::abort(QScriptValue *me)
+{
+ destroyNetwork();
+ m_responseEntityBody = QByteArray();
+ m_errorFlag = true;
+ m_request = QNetworkRequest();
+
+ if (!(m_state == Unsent ||
+ (m_state == Opened && !m_sendFlag) ||
+ m_state == Done)) {
+
+ m_state = Done;
+ m_sendFlag = false;
+ QScriptValue cbv = dispatchCallback(me);
+ if (cbv.isError()) return cbv;
+ }
+
+ m_state = Unsent;
+ return QScriptValue();
+}
+
+void QDeclarativeXMLHttpRequest::downloadProgress(qint64 bytes)
+{
+ Q_UNUSED(bytes)
+ m_status =
+ m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ m_statusText =
+ QString::fromUtf8(m_network->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray());
+
+ // ### We assume if this is called the headers are now available
+ if (m_state < HeadersReceived) {
+ m_state = HeadersReceived;
+ fillHeadersList ();
+ QScriptValue cbv = dispatchCallback(&m_me);
+ if (cbv.isError()) printError(cbv);
+ }
+
+ bool wasEmpty = m_responseEntityBody.isEmpty();
+ m_responseEntityBody.append(m_network->readAll());
+ if (wasEmpty && !m_responseEntityBody.isEmpty()) {
+ m_state = Loading;
+ QScriptValue cbv = dispatchCallback(&m_me);
+ if (cbv.isError()) printError(cbv);
+ }
+}
+
+void QDeclarativeXMLHttpRequest::error(QNetworkReply::NetworkError error)
+{
+ Q_UNUSED(error)
+ m_status =
+ m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ m_statusText =
+ QString::fromUtf8(m_network->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray());
+
+ m_responseEntityBody = QByteArray();
+
+ m_request = QNetworkRequest();
+ m_data.clear();
+ destroyNetwork();
+
+ if (error == QNetworkReply::ContentAccessDenied ||
+ error == QNetworkReply::ContentOperationNotPermittedError ||
+ error == QNetworkReply::ContentNotFoundError ||
+ error == QNetworkReply::AuthenticationRequiredError ||
+ error == QNetworkReply::ContentReSendError) {
+ m_state = Loading;
+ QScriptValue cbv = dispatchCallback(&m_me);
+ if (cbv.isError()) printError(cbv);
+ } else {
+ m_errorFlag = true;
+ }
+
+ m_state = Done;
+ QScriptValue cbv = dispatchCallback(&m_me);
+ if (cbv.isError()) printError(cbv);
+}
+
+#define XMLHTTPREQUEST_MAXIMUM_REDIRECT_RECURSION 15
+void QDeclarativeXMLHttpRequest::finished()
+{
+ m_redirectCount++;
+ if (m_redirectCount < XMLHTTPREQUEST_MAXIMUM_REDIRECT_RECURSION) {
+ QVariant redirect = m_network->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = redirect.toUrl();
+ destroyNetwork();
+ requestFromUrl(url);
+ return;
+ }
+ }
+
+ m_status =
+ m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ m_statusText =
+ QString::fromUtf8(m_network->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray());
+
+ if (m_state < HeadersReceived) {
+ m_state = HeadersReceived;
+ fillHeadersList ();
+ QScriptValue cbv = dispatchCallback(&m_me);
+ if (cbv.isError()) printError(cbv);
+ }
+ m_responseEntityBody.append(m_network->readAll());
+ m_data.clear();
+ destroyNetwork();
+ if (m_state < Loading) {
+ m_state = Loading;
+ QScriptValue cbv = dispatchCallback(&m_me);
+ if (cbv.isError()) printError(cbv);
+ }
+ m_state = Done;
+ QScriptValue cbv = dispatchCallback(&m_me);
+ if (cbv.isError()) printError(cbv);
+
+ m_me = QScriptValue();
+}
+
+
+QString QDeclarativeXMLHttpRequest::responseBody() const
+{
+ return QString::fromUtf8(m_responseEntityBody);
+}
+
+QScriptValue QDeclarativeXMLHttpRequest::dispatchCallback(QScriptValue *me)
+{
+ QScriptValue v = me->property(QLatin1String("callback"));
+ return v.call();
+}
+
+void QDeclarativeXMLHttpRequest::printError(const QScriptValue& sv)
+{
+ QDeclarativeError error;
+ QDeclarativeExpressionPrivate::exceptionToError(sv.engine(), error);
+ qWarning().nospace() << qPrintable(error.toString());
+}
+
+void QDeclarativeXMLHttpRequest::destroyNetwork()
+{
+ if (m_network) {
+ m_network->disconnect();
+ m_network->deleteLater();
+ m_network = 0;
+ }
+}
+
+// XMLHttpRequest methods
+static QScriptValue qmlxmlhttprequest_open(QScriptContext *context, QScriptEngine *engine)
+{
+ QScriptValue dataObject = context->thisObject().data();
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(dataObject.toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (context->argumentCount() < 2 || context->argumentCount() > 5)
+ THROW_DOM(SYNTAX_ERR, "Incorrect argument count");
+
+ // Argument 0 - Method
+ QString method = context->argument(0).toString().toUpper();
+ if (method != QLatin1String("GET") &&
+ method != QLatin1String("PUT") &&
+ method != QLatin1String("HEAD") &&
+ method != QLatin1String("POST"))
+ THROW_DOM(SYNTAX_ERR, "Unsupported HTTP method type");
+
+
+ // Argument 1 - URL
+ QUrl url = QUrl::fromEncoded(context->argument(1).toString().toUtf8());
+
+ if (url.isRelative()) {
+ url = QDeclarativeScriptEngine::get(engine)->resolvedUrl(context,url);
+ }
+
+ // Argument 2 - async (optional)
+ if (context->argumentCount() > 2 && !context->argument(2).toBoolean())
+ THROW_DOM(NOT_SUPPORTED_ERR, "Synchronous XMLHttpRequest calls are not supported");
+
+
+ // Argument 3/4 - user/pass (optional)
+ QString username, password;
+ if (context->argumentCount() > 3)
+ username = context->argument(3).toString();
+ if (context->argumentCount() > 4)
+ password = context->argument(4).toString();
+
+
+ // Clear the fragment (if any)
+ url.setFragment(QString());
+ // Set username/password
+ if (!username.isNull()) url.setUserName(username);
+ if (!password.isNull()) url.setPassword(password);
+
+ return request->open(&dataObject, method, url);
+}
+
+static QScriptValue qmlxmlhttprequest_setRequestHeader(QScriptContext *context, QScriptEngine *engine)
+{
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(context->thisObject().data().toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (context->argumentCount() != 2)
+ THROW_DOM(SYNTAX_ERR, "Incorrect argument count");
+
+
+ if (request->readyState() != QDeclarativeXMLHttpRequest::Opened ||
+ request->sendFlag())
+ THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+
+
+ QString name = context->argument(0).toString();
+ QString value = context->argument(1).toString();
+
+ // ### Check that name and value are well formed
+
+ QString nameUpper = name.toUpper();
+ if (nameUpper == QLatin1String("ACCEPT-CHARSET") ||
+ nameUpper == QLatin1String("ACCEPT-ENCODING") ||
+ nameUpper == QLatin1String("CONNECTION") ||
+ nameUpper == QLatin1String("CONTENT-LENGTH") ||
+ nameUpper == QLatin1String("COOKIE") ||
+ nameUpper == QLatin1String("COOKIE2") ||
+ nameUpper == QLatin1String("CONTENT-TRANSFER-ENCODING") ||
+ nameUpper == QLatin1String("DATE") ||
+ nameUpper == QLatin1String("EXPECT") ||
+ nameUpper == QLatin1String("HOST") ||
+ nameUpper == QLatin1String("KEEP-ALIVE") ||
+ nameUpper == QLatin1String("REFERER") ||
+ nameUpper == QLatin1String("TE") ||
+ nameUpper == QLatin1String("TRAILER") ||
+ nameUpper == QLatin1String("TRANSFER-ENCODING") ||
+ nameUpper == QLatin1String("UPGRADE") ||
+ nameUpper == QLatin1String("USER-AGENT") ||
+ nameUpper == QLatin1String("VIA") ||
+ nameUpper.startsWith(QLatin1String("PROXY-")) ||
+ nameUpper.startsWith(QLatin1String("SEC-")))
+ return engine->undefinedValue();
+
+ request->addHeader(nameUpper, value);
+
+ return engine->undefinedValue();
+}
+
+static QScriptValue qmlxmlhttprequest_send(QScriptContext *context, QScriptEngine *)
+{
+ QScriptValue dataObject = context->thisObject().data();
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(dataObject.toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (request->readyState() != QDeclarativeXMLHttpRequest::Opened)
+ THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+
+ if (request->sendFlag())
+ THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+
+ QByteArray data;
+ if (context->argumentCount() > 0)
+ data = context->argument(0).toString().toUtf8();
+
+ return request->send(&dataObject, data);
+}
+
+static QScriptValue qmlxmlhttprequest_abort(QScriptContext *context, QScriptEngine *)
+{
+ QScriptValue dataObject = context->thisObject().data();
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(dataObject.toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ return request->abort(&dataObject);
+}
+
+static QScriptValue qmlxmlhttprequest_getResponseHeader(QScriptContext *context, QScriptEngine *engine)
+{
+ Q_UNUSED(engine)
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(context->thisObject().data().toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (context->argumentCount() != 1)
+ THROW_DOM(SYNTAX_ERR, "Incorrect argument count");
+
+ if (request->readyState() != QDeclarativeXMLHttpRequest::Loading &&
+ request->readyState() != QDeclarativeXMLHttpRequest::Done &&
+ request->readyState() != QDeclarativeXMLHttpRequest::HeadersReceived)
+ THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+
+ QString headerName = context->argument(0).toString();
+
+ return QScriptValue(request->header(headerName));
+}
+
+static QScriptValue qmlxmlhttprequest_getAllResponseHeaders(QScriptContext *context, QScriptEngine *engine)
+{
+ Q_UNUSED(engine)
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(context->thisObject().data().toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (context->argumentCount() != 0)
+ THROW_DOM(SYNTAX_ERR, "Incorrect argument count");
+
+ if (request->readyState() != QDeclarativeXMLHttpRequest::Loading &&
+ request->readyState() != QDeclarativeXMLHttpRequest::Done &&
+ request->readyState() != QDeclarativeXMLHttpRequest::HeadersReceived)
+ THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+
+ return QScriptValue(request->headers());
+}
+
+// XMLHttpRequest properties
+static QScriptValue qmlxmlhttprequest_readyState(QScriptContext *context, QScriptEngine *engine)
+{
+ Q_UNUSED(engine)
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(context->thisObject().data().toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ return QScriptValue(request->readyState());
+}
+
+static QScriptValue qmlxmlhttprequest_status(QScriptContext *context, QScriptEngine *engine)
+{
+ Q_UNUSED(engine)
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(context->thisObject().data().toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (request->readyState() == QDeclarativeXMLHttpRequest::Unsent ||
+ request->readyState() == QDeclarativeXMLHttpRequest::Opened)
+ THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+
+ if (request->errorFlag())
+ return QScriptValue(0);
+ else
+ return QScriptValue(request->replyStatus());
+}
+
+static QScriptValue qmlxmlhttprequest_statusText(QScriptContext *context, QScriptEngine *engine)
+{
+ Q_UNUSED(engine)
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(context->thisObject().data().toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (request->readyState() == QDeclarativeXMLHttpRequest::Unsent ||
+ request->readyState() == QDeclarativeXMLHttpRequest::Opened)
+ THROW_DOM(INVALID_STATE_ERR, "Invalid state");
+
+ if (request->errorFlag())
+ return QScriptValue(0);
+ else
+ return QScriptValue(request->replyStatusText());
+}
+
+static QScriptValue qmlxmlhttprequest_responseText(QScriptContext *context, QScriptEngine *engine)
+{
+ Q_UNUSED(engine)
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(context->thisObject().data().toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (request->readyState() != QDeclarativeXMLHttpRequest::Loading &&
+ request->readyState() != QDeclarativeXMLHttpRequest::Done)
+ return QScriptValue(QString());
+ else
+ return QScriptValue(request->responseBody());
+}
+
+static QScriptValue qmlxmlhttprequest_responseXML(QScriptContext *context, QScriptEngine *engine)
+{
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(context->thisObject().data().toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (request->readyState() != QDeclarativeXMLHttpRequest::Loading &&
+ request->readyState() != QDeclarativeXMLHttpRequest::Done)
+ return engine->nullValue();
+ else
+ return Document::load(engine, request->responseBody());
+}
+
+static QScriptValue qmlxmlhttprequest_onreadystatechange(QScriptContext *context, QScriptEngine *engine)
+{
+ Q_UNUSED(engine);
+ QScriptValue dataObject = context->thisObject().data();
+ QDeclarativeXMLHttpRequest *request = qobject_cast<QDeclarativeXMLHttpRequest *>(dataObject.toQObject());
+ if (!request)
+ THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (context->argumentCount()) {
+ QScriptValue v = context->argument(0);
+ dataObject.setProperty(QLatin1String("callback"), v);
+ return v;
+ } else {
+ return dataObject.property(QLatin1String("callback"));
+ }
+}
+
+// Constructor
+static QScriptValue qmlxmlhttprequest_new(QScriptContext *context, QScriptEngine *engine)
+{
+ if (context->isCalledAsConstructor()) {
+ context->thisObject().setData(engine->newQObject(new QDeclarativeXMLHttpRequest(QDeclarativeScriptEngine::get(engine)->networkAccessManager()), QScriptEngine::ScriptOwnership));
+ }
+ return engine->undefinedValue();
+}
+
+void qt_add_qmlxmlhttprequest(QScriptEngine *engine)
+{
+ QScriptValue prototype = engine->newObject();
+
+ // Methods
+ prototype.setProperty(QLatin1String("open"), engine->newFunction(qmlxmlhttprequest_open, 2));
+ prototype.setProperty(QLatin1String("setRequestHeader"), engine->newFunction(qmlxmlhttprequest_setRequestHeader, 2));
+ prototype.setProperty(QLatin1String("send"), engine->newFunction(qmlxmlhttprequest_send));
+ prototype.setProperty(QLatin1String("abort"), engine->newFunction(qmlxmlhttprequest_abort));
+ prototype.setProperty(QLatin1String("getResponseHeader"), engine->newFunction(qmlxmlhttprequest_getResponseHeader, 1));
+ prototype.setProperty(QLatin1String("getAllResponseHeaders"), engine->newFunction(qmlxmlhttprequest_getAllResponseHeaders));
+
+ // Read-only properties
+ prototype.setProperty(QLatin1String("readyState"), engine->newFunction(qmlxmlhttprequest_readyState), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ prototype.setProperty(QLatin1String("status"), engine->newFunction(qmlxmlhttprequest_status), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ prototype.setProperty(QLatin1String("statusText"), engine->newFunction(qmlxmlhttprequest_statusText), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ prototype.setProperty(QLatin1String("responseText"), engine->newFunction(qmlxmlhttprequest_responseText), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ prototype.setProperty(QLatin1String("responseXML"), engine->newFunction(qmlxmlhttprequest_responseXML), QScriptValue::ReadOnly | QScriptValue::PropertyGetter);
+ prototype.setProperty(QLatin1String("onreadystatechange"), engine->newFunction(qmlxmlhttprequest_onreadystatechange), QScriptValue::PropertyGetter | QScriptValue::PropertySetter);
+
+ // State values
+ prototype.setProperty(QLatin1String("UNSENT"), 0, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ prototype.setProperty(QLatin1String("OPENED"), 1, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ prototype.setProperty(QLatin1String("HEADERS_RECEIVED"), 2, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ prototype.setProperty(QLatin1String("LOADING"), 3, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ prototype.setProperty(QLatin1String("DONE"), 4, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+
+ // Constructor
+ QScriptValue constructor = engine->newFunction(qmlxmlhttprequest_new, prototype);
+ constructor.setProperty(QLatin1String("UNSENT"), 0, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ constructor.setProperty(QLatin1String("OPENED"), 1, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ constructor.setProperty(QLatin1String("HEADERS_RECEIVED"), 2, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ constructor.setProperty(QLatin1String("LOADING"), 3, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ constructor.setProperty(QLatin1String("DONE"), 4, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ engine->globalObject().setProperty(QLatin1String("XMLHttpRequest"), constructor);
+
+ // DOM Exception
+ QScriptValue domExceptionPrototype = engine->newObject();
+ domExceptionPrototype.setProperty(QLatin1String("INDEX_SIZE_ERR"), INDEX_SIZE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("DOMSTRING_SIZE_ERR"), DOMSTRING_SIZE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("HIERARCHY_REQUEST_ERR"), HIERARCHY_REQUEST_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("WRONG_DOCUMENT_ERR"), WRONG_DOCUMENT_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("INVALID_CHARACTER_ERR"), INVALID_CHARACTER_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("NO_DATA_ALLOWED_ERR"), NO_DATA_ALLOWED_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("NO_MODIFICATION_ALLOWED_ERR"), NO_MODIFICATION_ALLOWED_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("NOT_FOUND_ERR"), NOT_FOUND_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("NOT_SUPPORTED_ERR"), NOT_SUPPORTED_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("INUSE_ATTRIBUTE_ERR"), INUSE_ATTRIBUTE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("INVALID_STATE_ERR"), INVALID_STATE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("SYNTAX_ERR"), SYNTAX_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("INVALID_MODIFICATION_ERR"), INVALID_MODIFICATION_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("NAMESPACE_ERR"), NAMESPACE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("INVALID_ACCESS_ERR"), INVALID_ACCESS_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("VALIDATION_ERR"), VALIDATION_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+ domExceptionPrototype.setProperty(QLatin1String("TYPE_MISMATCH_ERR"), TYPE_MISMATCH_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
+
+ engine->globalObject().setProperty(QLatin1String("DOMException"), domExceptionPrototype);
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativexmlhttprequest.moc>
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest_p.h b/src/declarative/qml/qdeclarativexmlhttprequest_p.h
new file mode 100644
index 0000000..068cd0f
--- /dev/null
+++ b/src/declarative/qml/qdeclarativexmlhttprequest_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEXMLHTTPREQUEST_P_H
+#define QDECLARATIVEXMLHTTPREQUEST_P_H
+
+#include <QtScript/qscriptengine.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>
+
+QT_BEGIN_NAMESPACE
+
+class QScriptEngine;
+void qt_add_qmlxmlhttprequest(QScriptEngine *engine);
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEXMLHTTPREQUEST_P_H
+
diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h
deleted file mode 100644
index 7cde731..0000000
--- a/src/declarative/qml/qml.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QML_H
-#define QML_H
-
-#include "qmlmetatype.h"
-#include "qmlmetaproperty.h"
-#include "qmlparserstatus.h"
-#include "qmlpropertyvaluesource.h"
-#include "qmllist.h"
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qmetaobject.h>
-
-QT_BEGIN_HEADER
-
-#define QML_DECLARE_TYPE(TYPE) \
- Q_DECLARE_METATYPE(TYPE *) \
- Q_DECLARE_METATYPE(QmlListProperty<TYPE>)
-
-#define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \
- Q_DECLARE_METATYPE(QmlListProperty<TYPE>)
-
-#define QML_DECLARE_INTERFACE(INTERFACE) \
- QML_DECLARE_TYPE(INTERFACE)
-
-#define QML_DECLARE_INTERFACE_HASMETATYPE(INTERFACE) \
- QML_DECLARE_TYPE_HASMETATYPE(INTERFACE)
-
-enum { /* TYPEINFO flags */
- QML_HAS_ATTACHED_PROPERTIES = 0x01,
-};
-
-#define QML_DECLARE_TYPEINFO(TYPE, FLAGS) \
-QT_BEGIN_NAMESPACE \
-template <> \
-class QmlTypeInfo<TYPE > \
-{ \
-public: \
- enum { \
- hasAttachedProperties = (((FLAGS) & QML_HAS_ATTACHED_PROPERTIES) == QML_HAS_ATTACHED_PROPERTIES) \
- }; \
-}; \
-QT_END_NAMESPACE
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-#define QML_REGISTER_INTERFACE(INTERFACE) \
- qmlRegisterInterface<INTERFACE>(#INTERFACE)
-
-#define QML_REGISTER_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \
- qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE)
-
-#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \
- qmlRegisterType<CLASS>(#URI, VMAJ, VMIN, #TYPE, #CLASS)
-
-#define QML_REGISTER_NOCREATE_TYPE(CLASS) \
- qmlRegisterType<CLASS>(#CLASS)
-
-class QmlContext;
-class QmlEngine;
-Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *);
-Q_DECLARATIVE_EXPORT QmlContext *qmlContext(const QObject *);
-Q_DECLARATIVE_EXPORT QmlEngine *qmlEngine(const QObject *);
-Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true);
-
-template<typename T>
-QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)
-{
- // ### is this threadsafe?
- static int idx = -1;
-
- if (idx == -1)
- idx = QmlMetaType::attachedPropertiesFuncId(&T::staticMetaObject);
-
- if (idx == -1 || !obj)
- return 0;
-
- return qmlAttachedPropertiesObjectById(idx, obj, create);
-}
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QObject)
-Q_DECLARE_METATYPE(QVariant)
-
-QT_END_HEADER
-
-#endif // QML_H
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index 1e4e234..0d5fcb0 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -1,131 +1,131 @@
INCLUDEPATH += $$PWD
SOURCES += \
- $$PWD/qmlparser.cpp \
- $$PWD/qmlinstruction.cpp \
- $$PWD/qmlvmemetaobject.cpp \
- $$PWD/qmlengine.cpp \
- $$PWD/qmlexpression.cpp \
- $$PWD/qmlbinding.cpp \
- $$PWD/qmlmetaproperty.cpp \
- $$PWD/qmlcomponent.cpp \
- $$PWD/qmlcontext.cpp \
- $$PWD/qmlcustomparser.cpp \
- $$PWD/qmlpropertyvaluesource.cpp \
- $$PWD/qmlpropertyvalueinterceptor.cpp \
- $$PWD/qmlproxymetaobject.cpp \
- $$PWD/qmlvme.cpp \
- $$PWD/qmlcompiler.cpp \
- $$PWD/qmlcompileddata.cpp \
- $$PWD/qmlboundsignal.cpp \
- $$PWD/qmldom.cpp \
- $$PWD/qmlrefcount.cpp \
- $$PWD/qmlprivate.cpp \
- $$PWD/qmlmetatype.cpp \
- $$PWD/qmlstringconverters.cpp \
- $$PWD/qmlclassfactory.cpp \
- $$PWD/qmlparserstatus.cpp \
- $$PWD/qmlcompositetypemanager.cpp \
- $$PWD/qmlinfo.cpp \
- $$PWD/qmlerror.cpp \
- $$PWD/qmlscriptparser.cpp \
- $$PWD/qmlenginedebug.cpp \
- $$PWD/qmlrewrite.cpp \
- $$PWD/qmlvaluetype.cpp \
- $$PWD/qmlcompiledbindings.cpp \
- $$PWD/qmlxmlhttprequest.cpp \
- $$PWD/qmlsqldatabase.cpp \
+ $$PWD/qdeclarativeparser.cpp \
+ $$PWD/qdeclarativeinstruction.cpp \
+ $$PWD/qdeclarativevmemetaobject.cpp \
+ $$PWD/qdeclarativeengine.cpp \
+ $$PWD/qdeclarativeexpression.cpp \
+ $$PWD/qdeclarativebinding.cpp \
+ $$PWD/qdeclarativemetaproperty.cpp \
+ $$PWD/qdeclarativecomponent.cpp \
+ $$PWD/qdeclarativecontext.cpp \
+ $$PWD/qdeclarativecustomparser.cpp \
+ $$PWD/qdeclarativepropertyvaluesource.cpp \
+ $$PWD/qdeclarativepropertyvalueinterceptor.cpp \
+ $$PWD/qdeclarativeproxymetaobject.cpp \
+ $$PWD/qdeclarativevme.cpp \
+ $$PWD/qdeclarativecompiler.cpp \
+ $$PWD/qdeclarativecompileddata.cpp \
+ $$PWD/qdeclarativeboundsignal.cpp \
+ $$PWD/qdeclarativedom.cpp \
+ $$PWD/qdeclarativerefcount.cpp \
+ $$PWD/qdeclarativeprivate.cpp \
+ $$PWD/qdeclarativemetatype.cpp \
+ $$PWD/qdeclarativestringconverters.cpp \
+ $$PWD/qdeclarativeclassfactory.cpp \
+ $$PWD/qdeclarativeparserstatus.cpp \
+ $$PWD/qdeclarativecompositetypemanager.cpp \
+ $$PWD/qdeclarativeinfo.cpp \
+ $$PWD/qdeclarativeerror.cpp \
+ $$PWD/qdeclarativescriptparser.cpp \
+ $$PWD/qdeclarativeenginedebug.cpp \
+ $$PWD/qdeclarativerewrite.cpp \
+ $$PWD/qdeclarativevaluetype.cpp \
+ $$PWD/qdeclarativecompiledbindings.cpp \
+ $$PWD/qdeclarativexmlhttprequest.cpp \
+ $$PWD/qdeclarativesqldatabase.cpp \
$$PWD/qmetaobjectbuilder.cpp \
- $$PWD/qmlwatcher.cpp \
- $$PWD/qmlscript.cpp \
- $$PWD/qmlcleanup.cpp \
- $$PWD/qmlpropertycache.cpp \
- $$PWD/qmlintegercache.cpp \
- $$PWD/qmltypenamecache.cpp \
- $$PWD/qmlscriptstring.cpp \
- $$PWD/qmlobjectscriptclass.cpp \
- $$PWD/qmlcontextscriptclass.cpp \
- $$PWD/qmlglobalscriptclass.cpp \
- $$PWD/qmlvaluetypescriptclass.cpp \
- $$PWD/qmltypenamescriptclass.cpp \
- $$PWD/qmllistscriptclass.cpp \
- $$PWD/qmlworkerscript.cpp \
- $$PWD/qmlimageprovider.cpp \
- $$PWD/qmlnetworkaccessmanagerfactory.cpp \
- $$PWD/qmldirparser.cpp \
- $$PWD/qmlextensionplugin.cpp \
- $$PWD/qmllist.cpp
+ $$PWD/qdeclarativewatcher.cpp \
+ $$PWD/qdeclarativescript.cpp \
+ $$PWD/qdeclarativecleanup.cpp \
+ $$PWD/qdeclarativepropertycache.cpp \
+ $$PWD/qdeclarativeintegercache.cpp \
+ $$PWD/qdeclarativetypenamecache.cpp \
+ $$PWD/qdeclarativescriptstring.cpp \
+ $$PWD/qdeclarativeobjectscriptclass.cpp \
+ $$PWD/qdeclarativecontextscriptclass.cpp \
+ $$PWD/qdeclarativeglobalscriptclass.cpp \
+ $$PWD/qdeclarativevaluetypescriptclass.cpp \
+ $$PWD/qdeclarativetypenamescriptclass.cpp \
+ $$PWD/qdeclarativelistscriptclass.cpp \
+ $$PWD/qdeclarativeworkerscript.cpp \
+ $$PWD/qdeclarativeimageprovider.cpp \
+ $$PWD/qdeclarativenetworkaccessmanagerfactory.cpp \
+ $$PWD/qdeclarativedirparser.cpp \
+ $$PWD/qdeclarativeextensionplugin.cpp \
+ $$PWD/qdeclarativelist.cpp
HEADERS += \
- $$PWD/qmlparser_p.h \
- $$PWD/qmlglobal_p.h \
- $$PWD/qmlinstruction_p.h \
- $$PWD/qmlvmemetaobject_p.h \
- $$PWD/qml.h \
- $$PWD/qmlbinding_p.h \
- $$PWD/qmlbinding_p_p.h \
- $$PWD/qmlmetaproperty.h \
- $$PWD/qmlcomponent.h \
- $$PWD/qmlcomponent_p.h \
- $$PWD/qmlcustomparser_p.h \
- $$PWD/qmlcustomparser_p_p.h \
- $$PWD/qmlpropertyvaluesource.h \
- $$PWD/qmlpropertyvalueinterceptor.h \
- $$PWD/qmlboundsignal_p.h \
- $$PWD/qmlparserstatus.h \
- $$PWD/qmlproxymetaobject_p.h \
- $$PWD/qmlvme_p.h \
- $$PWD/qmlcompiler_p.h \
- $$PWD/qmlengine_p.h \
- $$PWD/qmlexpression_p.h \
- $$PWD/qmlprivate.h \
- $$PWD/qmldom_p.h \
- $$PWD/qmldom_p_p.h \
- $$PWD/qmlrefcount_p.h \
- $$PWD/qmlmetatype.h \
- $$PWD/qmlengine.h \
- $$PWD/qmlcontext.h \
- $$PWD/qmlexpression.h \
- $$PWD/qmlstringconverters_p.h \
- $$PWD/qmlclassfactory_p.h \
- $$PWD/qmlinfo.h \
- $$PWD/qmlmetaproperty_p.h \
- $$PWD/qmlcontext_p.h \
- $$PWD/qmlcompositetypedata_p.h \
- $$PWD/qmlcompositetypemanager_p.h \
- $$PWD/qmllist.h \
- $$PWD/qmllist_p.h \
- $$PWD/qmldeclarativedata_p.h \
- $$PWD/qmlerror.h \
- $$PWD/qmlscriptparser_p.h \
- $$PWD/qmlenginedebug_p.h \
- $$PWD/qmlrewrite_p.h \
+ $$PWD/qdeclarativeparser_p.h \
+ $$PWD/qdeclarativeglobal_p.h \
+ $$PWD/qdeclarativeinstruction_p.h \
+ $$PWD/qdeclarativevmemetaobject_p.h \
+ $$PWD/qdeclarative.h \
+ $$PWD/qdeclarativebinding_p.h \
+ $$PWD/qdeclarativebinding_p_p.h \
+ $$PWD/qdeclarativemetaproperty.h \
+ $$PWD/qdeclarativecomponent.h \
+ $$PWD/qdeclarativecomponent_p.h \
+ $$PWD/qdeclarativecustomparser_p.h \
+ $$PWD/qdeclarativecustomparser_p_p.h \
+ $$PWD/qdeclarativepropertyvaluesource.h \
+ $$PWD/qdeclarativepropertyvalueinterceptor.h \
+ $$PWD/qdeclarativeboundsignal_p.h \
+ $$PWD/qdeclarativeparserstatus.h \
+ $$PWD/qdeclarativeproxymetaobject_p.h \
+ $$PWD/qdeclarativevme_p.h \
+ $$PWD/qdeclarativecompiler_p.h \
+ $$PWD/qdeclarativeengine_p.h \
+ $$PWD/qdeclarativeexpression_p.h \
+ $$PWD/qdeclarativeprivate.h \
+ $$PWD/qdeclarativedom_p.h \
+ $$PWD/qdeclarativedom_p_p.h \
+ $$PWD/qdeclarativerefcount_p.h \
+ $$PWD/qdeclarativemetatype.h \
+ $$PWD/qdeclarativeengine.h \
+ $$PWD/qdeclarativecontext.h \
+ $$PWD/qdeclarativeexpression.h \
+ $$PWD/qdeclarativestringconverters_p.h \
+ $$PWD/qdeclarativeclassfactory_p.h \
+ $$PWD/qdeclarativeinfo.h \
+ $$PWD/qdeclarativemetaproperty_p.h \
+ $$PWD/qdeclarativecontext_p.h \
+ $$PWD/qdeclarativecompositetypedata_p.h \
+ $$PWD/qdeclarativecompositetypemanager_p.h \
+ $$PWD/qdeclarativelist.h \
+ $$PWD/qdeclarativelist_p.h \
+ $$PWD/qdeclarativedeclarativedata_p.h \
+ $$PWD/qdeclarativeerror.h \
+ $$PWD/qdeclarativescriptparser_p.h \
+ $$PWD/qdeclarativeenginedebug_p.h \
+ $$PWD/qdeclarativerewrite_p.h \
$$PWD/qpodvector_p.h \
$$PWD/qbitfield_p.h \
- $$PWD/qmlvaluetype_p.h \
- $$PWD/qmlcompiledbindings_p.h \
- $$PWD/qmlxmlhttprequest_p.h \
- $$PWD/qmlsqldatabase_p.h \
+ $$PWD/qdeclarativevaluetype_p.h \
+ $$PWD/qdeclarativecompiledbindings_p.h \
+ $$PWD/qdeclarativexmlhttprequest_p.h \
+ $$PWD/qdeclarativesqldatabase_p.h \
$$PWD/qmetaobjectbuilder_p.h \
- $$PWD/qmlwatcher_p.h \
- $$PWD/qmlcleanup_p.h \
- $$PWD/qmlpropertycache_p.h \
- $$PWD/qmlintegercache_p.h \
- $$PWD/qmltypenamecache_p.h \
- $$PWD/qmlscriptstring.h \
- $$PWD/qmlobjectscriptclass_p.h \
- $$PWD/qmlcontextscriptclass_p.h \
- $$PWD/qmlglobalscriptclass_p.h \
- $$PWD/qmlvaluetypescriptclass_p.h \
- $$PWD/qmltypenamescriptclass_p.h \
- $$PWD/qmllistscriptclass_p.h \
- $$PWD/qmlworkerscript_p.h \
- $$PWD/qmlscriptclass_p.h \
- $$PWD/qmlguard_p.h \
- $$PWD/qmlimageprovider.h \
- $$PWD/qmlnetworkaccessmanagerfactory.h \
- $$PWD/qmldirparser_p.h \
- $$PWD/qmlextensioninterface.h \
- $$PWD/qmlextensionplugin.h
+ $$PWD/qdeclarativewatcher_p.h \
+ $$PWD/qdeclarativecleanup_p.h \
+ $$PWD/qdeclarativepropertycache_p.h \
+ $$PWD/qdeclarativeintegercache_p.h \
+ $$PWD/qdeclarativetypenamecache_p.h \
+ $$PWD/qdeclarativescriptstring.h \
+ $$PWD/qdeclarativeobjectscriptclass_p.h \
+ $$PWD/qdeclarativecontextscriptclass_p.h \
+ $$PWD/qdeclarativeglobalscriptclass_p.h \
+ $$PWD/qdeclarativevaluetypescriptclass_p.h \
+ $$PWD/qdeclarativetypenamescriptclass_p.h \
+ $$PWD/qdeclarativelistscriptclass_p.h \
+ $$PWD/qdeclarativeworkerscript_p.h \
+ $$PWD/qdeclarativescriptclass_p.h \
+ $$PWD/qdeclarativeguard_p.h \
+ $$PWD/qdeclarativeimageprovider.h \
+ $$PWD/qdeclarativenetworkaccessmanagerfactory.h \
+ $$PWD/qdeclarativedirparser_p.h \
+ $$PWD/qdeclarativeextensioninterface.h \
+ $$PWD/qdeclarativeextensionplugin.h
QT += sql
include(parser/parser.pri)
diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp
deleted file mode 100644
index 04801df..0000000
--- a/src/declarative/qml/qmlbinding.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlbinding_p.h"
-#include "qmlbinding_p_p.h"
-
-#include "qml.h"
-#include "qmlcontext.h"
-#include "qmlinfo.h"
-#include "qmlcontext_p.h"
-#include "qmldeclarativedata_p.h"
-#include "qmlstringconverters_p.h"
-
-#include <qfxperf_p_p.h>
-
-#include <QVariant>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-QmlBindingData::QmlBindingData()
-: updating(false), enabled(false)
-{
-}
-
-QmlBindingData::~QmlBindingData()
-{
- removeError();
-}
-
-void QmlBindingData::refresh()
-{
- if (enabled && !updating && q) {
- QmlBinding *b = static_cast<QmlBinding *>(QmlExpressionPrivate::get(q));
- b->update();
- }
-}
-
-QmlBindingPrivate::QmlBindingPrivate()
-: QmlExpressionPrivate(new QmlBindingData)
-{
-}
-
-QmlBinding::QmlBinding(void *data, QmlRefCount *rc, QObject *obj, QmlContext *ctxt, const QString &url, int lineNumber, QObject *parent)
-: QmlExpression(ctxt, data, rc, obj, url, lineNumber, *new QmlBindingPrivate)
-{
- setParent(parent);
- setNotifyOnValueChanged(true);
-}
-
-QmlBinding::QmlBinding(const QString &str, QObject *obj, QmlContext *ctxt, QObject *parent)
-: QmlExpression(ctxt, str, obj, *new QmlBindingPrivate)
-{
- setParent(parent);
- setNotifyOnValueChanged(true);
-}
-
-QmlBinding::~QmlBinding()
-{
-}
-
-void QmlBinding::setTarget(const QmlMetaProperty &prop)
-{
- Q_D(QmlBinding);
- d->bindingData()->property = prop;
-
- update();
-}
-
-QmlMetaProperty QmlBinding::property() const
-{
- Q_D(const QmlBinding);
- return d->bindingData()->property;
-}
-
-void QmlBinding::update(QmlMetaProperty::WriteFlags flags)
-{
- Q_D(QmlBinding);
-
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::BindableValueUpdate> bu;
-#endif
- QmlBindingData *data = d->bindingData();
-
- if (!data->enabled)
- return;
-
- data->addref();
-
- if (!data->updating) {
- data->updating = true;
-
- if (data->property.propertyCategory() == QmlMetaProperty::Bindable) {
-
- int idx = data->property.coreIndex();
- Q_ASSERT(idx != -1);
-
-
- QmlBinding *t = this;
- int status = -1;
- void *a[] = { &t, 0, &status, &flags };
- QMetaObject::metacall(data->property.object(),
- QMetaObject::WriteProperty,
- idx, a);
-
- } else {
- bool isUndefined = false;
- QVariant value = this->value(&isUndefined);
-
- if (isUndefined && !data->error.isValid() && data->property.isResettable()) {
-
- data->property.reset();
-
- } else if (isUndefined && !data->error.isValid()) {
-
- QUrl url = QUrl(data->url);
- int line = data->line;
- if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
-
- data->error.setUrl(url);
- data->error.setLine(line);
- data->error.setColumn(-1);
- data->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + QLatin1String(QMetaType::typeName(data->property.propertyType())));
-
- } else if (!isUndefined && data->property.object() &&
- !data->property.write(value, flags)) {
-
- QUrl url = QUrl(data->url);
- int line = data->line;
- if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
-
- const char *valueType = 0;
- if (value.userType() == QVariant::Invalid) valueType = "null";
- else valueType = QMetaType::typeName(value.userType());
-
- data->error.setUrl(url);
- data->error.setLine(line);
- data->error.setColumn(-1);
- data->error.setDescription(QLatin1String("Unable to assign ") +
- QLatin1String(valueType) +
- QLatin1String(" to ") +
- QLatin1String(QMetaType::typeName(data->property.propertyType())));
- }
-
- if (data->error.isValid()) {
- QmlEnginePrivate *p = (data->context() && data->context()->engine())?
- QmlEnginePrivate::get(data->context()->engine()):0;
- if (!data->addError(p))
- qWarning().nospace() << qPrintable(this->error().toString());
- } else {
- data->removeError();
- }
- }
-
- data->updating = false;
- } else {
- qmlInfo(data->property.object()) << tr("Binding loop detected for property \"%1\"").arg(data->property.name());
- }
-
- data->release();
-}
-
-void QmlBindingPrivate::emitValueChanged()
-{
- Q_Q(QmlBinding);
- q->update();
-}
-
-void QmlBinding::setEnabled(bool e, QmlMetaProperty::WriteFlags flags)
-{
- Q_D(QmlBinding);
- d->bindingData()->enabled = e;
- setNotifyOnValueChanged(e);
-
- QmlAbstractBinding::setEnabled(e, flags);
-
- if (e) {
- addToObject(d->bindingData()->property.object());
- update(flags);
- } else {
- removeFromObject();
- }
-}
-
-int QmlBinding::propertyIndex()
-{
- Q_D(QmlBinding);
- return d->bindingData()->property.coreIndex();
-}
-
-bool QmlBinding::enabled() const
-{
- Q_D(const QmlBinding);
-
- return d->bindingData()->enabled;
-}
-
-QString QmlBinding::expression() const
-{
- return QmlExpression::expression();
-}
-
-QmlAbstractBinding::QmlAbstractBinding()
-: m_object(0), m_mePtr(0), m_prevBinding(0), m_nextBinding(0)
-{
-}
-
-QmlAbstractBinding::~QmlAbstractBinding()
-{
- removeFromObject();
- if (m_mePtr)
- *m_mePtr = 0;
-}
-
-void QmlAbstractBinding::destroy()
-{
- delete this;
-}
-
-void QmlAbstractBinding::addToObject(QObject *object)
-{
- Q_ASSERT(object);
-
- removeFromObject();
-
- Q_ASSERT(!m_prevBinding);
-
- QmlDeclarativeData *data = QmlDeclarativeData::get(object, true);
- m_nextBinding = data->bindings;
- if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding;
- m_prevBinding = &data->bindings;
- data->bindings = this;
- m_object = object;
-
- data->setBindingBit(m_object, propertyIndex());
-}
-
-void QmlAbstractBinding::removeFromObject()
-{
- if (m_prevBinding) {
- Q_ASSERT(m_object);
-
- *m_prevBinding = m_nextBinding;
- if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding;
- m_prevBinding = 0;
- m_nextBinding = 0;
-
- QmlDeclarativeData *data = QmlDeclarativeData::get(m_object, false);
- if (data) data->clearBindingBit(propertyIndex());
- m_object = 0;
- }
-}
-
-void QmlAbstractBinding::clear()
-{
- if (m_mePtr)
- *m_mePtr = 0;
-}
-
-QString QmlAbstractBinding::expression() const
-{
- return QLatin1String("<Unknown>");
-}
-
-void QmlAbstractBinding::setEnabled(bool e, QmlMetaProperty::WriteFlags)
-{
- if (e) m_mePtr = 0;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlbinding_p.h b/src/declarative/qml/qmlbinding_p.h
deleted file mode 100644
index 4594476..0000000
--- a/src/declarative/qml/qmlbinding_p.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLBINDING_P_H
-#define QMLBINDING_P_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 "qml.h"
-#include "qmlpropertyvaluesource.h"
-#include "qmlexpression.h"
-
-#include <QtCore/QObject>
-#include <QtCore/QMetaProperty>
-
-QT_BEGIN_NAMESPACE
-
-class Q_AUTOTEST_EXPORT QmlAbstractBinding
-{
-public:
- QmlAbstractBinding();
- virtual ~QmlAbstractBinding();
-
- virtual void destroy();
-
- virtual QString expression() const;
-
- void setEnabled(bool e) { setEnabled(e, QmlMetaProperty::DontRemoveBinding); }
- virtual void setEnabled(bool, QmlMetaProperty::WriteFlags) = 0;
- virtual int propertyIndex() = 0;
-
- void update() { update(QmlMetaProperty::DontRemoveBinding); }
- virtual void update(QmlMetaProperty::WriteFlags) = 0;
-
- void addToObject(QObject *);
- void removeFromObject();
-
-protected:
- void clear();
-
-private:
- friend class QmlDeclarativeData;
- friend class QmlMetaProperty;
- friend class QmlMetaPropertyPrivate;
- friend class QmlVME;
-
- QObject *m_object;
- QmlAbstractBinding **m_mePtr;
- QmlAbstractBinding **m_prevBinding;
- QmlAbstractBinding *m_nextBinding;
-};
-
-class QmlContext;
-class QmlBindingPrivate;
-class Q_AUTOTEST_EXPORT QmlBinding : public QmlExpression, public QmlAbstractBinding
-{
-Q_OBJECT
-public:
- QmlBinding(const QString &, QObject *, QmlContext *, QObject *parent=0);
- QmlBinding(void *, QmlRefCount *, QObject *, QmlContext *, const QString &, int,
- QObject *parent);
- ~QmlBinding();
-
- void setTarget(const QmlMetaProperty &);
- QmlMetaProperty property() const;
-
- bool enabled() const;
-
- // Inherited from QmlAbstractBinding
- virtual void setEnabled(bool, QmlMetaProperty::WriteFlags flags);
- virtual int propertyIndex();
- virtual void update(QmlMetaProperty::WriteFlags flags);
- virtual QString expression() const;
-
-public Q_SLOTS:
- void update() { update(QmlMetaProperty::DontRemoveBinding); }
-
-protected:
- void emitValueChanged();
-
-private:
- Q_DECLARE_PRIVATE(QmlBinding)
-};
-Q_DECLARE_METATYPE(QmlBinding*);
-
-QT_END_NAMESPACE
-
-#endif // QMLBINDING_P_H
diff --git a/src/declarative/qml/qmlbinding_p_p.h b/src/declarative/qml/qmlbinding_p_p.h
deleted file mode 100644
index 131bacc..0000000
--- a/src/declarative/qml/qmlbinding_p_p.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLBINDING_P_P_H
-#define QMLBINDING_P_P_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 "qmlbinding_p.h"
-
-#include "qmlmetaproperty.h"
-#include "qmlexpression_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlBindingData : public QmlExpressionData
-{
-public:
- QmlBindingData();
- virtual ~QmlBindingData();
-
- bool updating:1;
- bool enabled:1;
-
- QmlMetaProperty property;
-
- virtual void refresh();
-};
-
-class QmlBindingPrivate : public QmlExpressionPrivate
-{
- Q_DECLARE_PUBLIC(QmlBinding)
-public:
- QmlBindingPrivate();
-
- QmlBindingData *bindingData() { return static_cast<QmlBindingData *>(data); }
- const QmlBindingData *bindingData() const { return static_cast<const QmlBindingData *>(data); }
-
- virtual void emitValueChanged();
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLBINDING_P_P_H
diff --git a/src/declarative/qml/qmlboundsignal.cpp b/src/declarative/qml/qmlboundsignal.cpp
deleted file mode 100644
index db5fd61..0000000
--- a/src/declarative/qml/qmlboundsignal.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlboundsignal_p.h"
-
-#include "qmetaobjectbuilder_p.h"
-#include "qmlengine_p.h"
-#include "qmlexpression_p.h"
-#include "qmlcontext_p.h"
-#include "qmlmetatype.h"
-#include "qml.h"
-#include "qmlcontext.h"
-#include "qmlglobal_p.h"
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlBoundSignalParameters : public QObject
-{
-Q_OBJECT
-public:
- QmlBoundSignalParameters(const QMetaMethod &, QObject * = 0);
- ~QmlBoundSignalParameters();
-
- void setValues(void **);
- void clearValues();
-
-private:
- friend class MetaObject;
- int metaCall(QMetaObject::Call, int _id, void **);
- struct MetaObject : public QAbstractDynamicMetaObject {
- MetaObject(QmlBoundSignalParameters *b)
- : parent(b) {}
-
- int metaCall(QMetaObject::Call c, int id, void **a) {
- return parent->metaCall(c, id, a);
- }
- QmlBoundSignalParameters *parent;
- };
-
- int *types;
- void **values;
- QMetaObject *myMetaObject;
-};
-
-static int evaluateIdx = -1;
-
-QmlAbstractBoundSignal::QmlAbstractBoundSignal(QObject *parent)
-: QObject(parent)
-{
-}
-
-QmlAbstractBoundSignal::~QmlAbstractBoundSignal()
-{
-}
-
-QmlBoundSignal::QmlBoundSignal(QObject *scope, const QMetaMethod &signal,
- QObject *parent)
-: m_expression(0), m_signal(signal), m_paramsValid(false), m_params(0)
-{
- // A cached evaluation of the QmlExpression::value() slot index.
- //
- // This is thread safe. Although it may be updated by two threads, they
- // will both set it to the same value - so the worst thing that can happen
- // is that they both do the work to figure it out. Boo hoo.
- if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
-
- QmlGraphics_setParent_noEvent(this, parent);
- QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
-}
-
-QmlBoundSignal::QmlBoundSignal(QmlContext *ctxt, const QString &val,
- QObject *scope, const QMetaMethod &signal,
- QObject *parent)
-: m_expression(0), m_signal(signal), m_paramsValid(false), m_params(0)
-{
- // A cached evaluation of the QmlExpression::value() slot index.
- //
- // This is thread safe. Although it may be updated by two threads, they
- // will both set it to the same value - so the worst thing that can happen
- // is that they both do the work to figure it out. Boo hoo.
- if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
-
- QmlGraphics_setParent_noEvent(this, parent);
- QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
-
- m_expression = new QmlExpression(ctxt, val, scope);
-}
-
-QmlBoundSignal::~QmlBoundSignal()
-{
- delete m_expression;
- m_expression = 0;
-}
-
-int QmlBoundSignal::index() const
-{
- return m_signal.methodIndex();
-}
-
-/*!
- Returns the signal expression.
-*/
-QmlExpression *QmlBoundSignal::expression() const
-{
- return m_expression;
-}
-
-/*!
- Sets the signal expression to \a e. Returns the current signal expression,
- or null if there is no signal expression.
-
- The QmlBoundSignal instance takes ownership of \a e. The caller is
- assumes ownership of the returned QmlExpression.
-*/
-QmlExpression *QmlBoundSignal::setExpression(QmlExpression *e)
-{
- QmlExpression *rv = m_expression;
- m_expression = e;
- if (m_expression) m_expression->setNotifyOnValueChanged(false);
- return rv;
-}
-
-QmlBoundSignal *QmlBoundSignal::cast(QObject *o)
-{
- QmlAbstractBoundSignal *s = qobject_cast<QmlAbstractBoundSignal*>(o);
- return static_cast<QmlBoundSignal *>(s);
-}
-
-int QmlBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
-{
- if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) {
- if (!m_paramsValid) {
- if (!m_signal.parameterTypes().isEmpty())
- m_params = new QmlBoundSignalParameters(m_signal, this);
- m_paramsValid = true;
- }
-
- if (m_params) m_params->setValues(a);
- if (m_expression) {
- QmlExpressionPrivate::get(m_expression)->value(m_params);
- if (m_expression && m_expression->hasError())
- qWarning().nospace() << qPrintable(m_expression->error().toString());
- }
- if (m_params) m_params->clearValues();
- return -1;
- } else {
- return QObject::qt_metacall(c, id, a);
- }
-}
-
-QmlBoundSignalParameters::QmlBoundSignalParameters(const QMetaMethod &method,
- QObject *parent)
-: QObject(parent), types(0), values(0)
-{
- MetaObject *mo = new MetaObject(this);
-
- // ### Optimize!
- // ### Ensure only supported types are allowed, otherwise it might crash
- QMetaObjectBuilder mob;
- mob.setSuperClass(&QmlBoundSignalParameters::staticMetaObject);
- mob.setClassName("QmlBoundSignalParameters");
-
- QList<QByteArray> paramTypes = method.parameterTypes();
- QList<QByteArray> paramNames = method.parameterNames();
- types = new int[paramTypes.count()];
- for (int ii = 0; ii < paramTypes.count(); ++ii) {
- const QByteArray &type = paramTypes.at(ii);
- const QByteArray &name = paramNames.at(ii);
-
- if (name.isEmpty() || type.isEmpty()) {
- types[ii] = 0;
- continue;
- }
-
- QVariant::Type t = (QVariant::Type)QMetaType::type(type.constData());
- if (QmlMetaType::isQObject(t)) {
- types[ii] = QMetaType::QObjectStar;
- QMetaPropertyBuilder prop = mob.addProperty(name, "QObject*");
- prop.setWritable(false);
- } else {
- types[ii] = t;
- QMetaPropertyBuilder prop = mob.addProperty(name, type);
- prop.setWritable(false);
- }
- }
- myMetaObject = mob.toMetaObject();
- *static_cast<QMetaObject *>(mo) = *myMetaObject;
-
- d_ptr->metaObject = mo;
-}
-
-QmlBoundSignalParameters::~QmlBoundSignalParameters()
-{
- delete [] types;
- qFree(myMetaObject);
-}
-
-void QmlBoundSignalParameters::setValues(void **v)
-{
- values = v;
-}
-
-void QmlBoundSignalParameters::clearValues()
-{
- values = 0;
-}
-
-int QmlBoundSignalParameters::metaCall(QMetaObject::Call c, int id, void **a)
-{
- if (!values)
- return -1;
-
- if (c == QMetaObject::ReadProperty && id >= 1) {
- QmlMetaType::copy(types[id - 1], a[0], values[id]);
- return -1;
- } else {
- return qt_metacall(c, id, a);
- }
-}
-
-QT_END_NAMESPACE
-
-#include <qmlboundsignal.moc>
diff --git a/src/declarative/qml/qmlboundsignal_p.h b/src/declarative/qml/qmlboundsignal_p.h
deleted file mode 100644
index 51d21d7..0000000
--- a/src/declarative/qml/qmlboundsignal_p.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLBOUNDSIGNAL_P_H
-#define QMLBOUNDSIGNAL_P_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 "qmlexpression.h"
-
-#include <QtCore/qmetaobject.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlAbstractBoundSignal : public QObject
-{
- Q_OBJECT
-public:
- QmlAbstractBoundSignal(QObject *parent = 0);
- virtual ~QmlAbstractBoundSignal() = 0;
-};
-
-class QmlBoundSignalParameters;
-class QmlBoundSignal : public QmlAbstractBoundSignal
-{
-public:
- QmlBoundSignal(QObject *scope, const QMetaMethod &signal, QObject *parent);
- QmlBoundSignal(QmlContext *ctxt, const QString &val, QObject *scope,
- const QMetaMethod &signal, QObject *parent);
- virtual ~QmlBoundSignal();
-
- int index() const;
-
- QmlExpression *expression() const;
- QmlExpression *setExpression(QmlExpression *);
-
- static QmlBoundSignal *cast(QObject *);
-
-protected:
- virtual int qt_metacall(QMetaObject::Call c, int id, void **a);
-
-private:
- QmlExpression *m_expression;
- QMetaMethod m_signal;
- bool m_paramsValid;
- QmlBoundSignalParameters *m_params;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLBOUNDSIGNAL_P_H
diff --git a/src/declarative/qml/qmlclassfactory.cpp b/src/declarative/qml/qmlclassfactory.cpp
deleted file mode 100644
index 2adff09..0000000
--- a/src/declarative/qml/qmlclassfactory.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlclassfactory_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QmlClassFactory::~QmlClassFactory()
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlclassfactory_p.h b/src/declarative/qml/qmlclassfactory_p.h
deleted file mode 100644
index 2ddadcf..0000000
--- a/src/declarative/qml/qmlclassfactory_p.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCLASSFACTORY_P_H
-#define QMLCLASSFACTORY_P_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>
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngine;
-class QByteArray;
-class QUrl;
-class QmlComponent;
-
-class QmlClassFactory
-{
-public:
- virtual ~QmlClassFactory();
- virtual QmlComponent *create(const QByteArray &, const QUrl& baseUrl, QmlEngine*) = 0;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLCLASSFACTORY_P_H
diff --git a/src/declarative/qml/qmlcleanup.cpp b/src/declarative/qml/qmlcleanup.cpp
deleted file mode 100644
index 581d4a3..0000000
--- a/src/declarative/qml/qmlcleanup.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlcleanup_p.h"
-
-#include "qmlengine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
-\internal
-\class QmlCleanup
-\brief The QmlCleanup provides a callback when a QmlEngine is deleted.
-
-Any object that needs cleanup to occur before the QmlEngine's QScriptEngine is
-destroyed should inherit from QmlCleanup. The clear() virtual method will be
-called by QmlEngine just before it deletes the QScriptEngine.
-*/
-
-/*!
-\internal
-
-Create a QmlCleanup for \a engine
-*/
-QmlCleanup::QmlCleanup(QmlEngine *engine)
-: prev(0), next(0)
-{
- if (!engine)
- return;
-
- QmlEnginePrivate *p = QmlEnginePrivate::get(engine);
-
- if (p->cleanup) next = p->cleanup;
- p->cleanup = this;
- prev = &p->cleanup;
- if (next) next->prev = &next;
-}
-
-/*!
-\internal
-*/
-QmlCleanup::~QmlCleanup()
-{
- if (prev) *prev = next;
- if (next) next->prev = prev;
- prev = 0;
- next = 0;
-}
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcleanup_p.h b/src/declarative/qml/qmlcleanup_p.h
deleted file mode 100644
index 50803f3..0000000
--- a/src/declarative/qml/qmlcleanup_p.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCLEANUP_P_H
-#define QMLCLEANUP_P_H
-
-#include <QtCore/qglobal.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.
-//
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngine;
-class QmlCleanup
-{
-public:
- QmlCleanup(QmlEngine *);
- virtual ~QmlCleanup();
-
-protected:
- virtual void clear() = 0;
-
-private:
- friend class QmlEnginePrivate;
- QmlCleanup **prev;
- QmlCleanup *next;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLCLEANUP_P_H
-
diff --git a/src/declarative/qml/qmlcompiledbindings.cpp b/src/declarative/qml/qmlcompiledbindings.cpp
deleted file mode 100644
index 7a8cf0e..0000000
--- a/src/declarative/qml/qmlcompiledbindings.cpp
+++ /dev/null
@@ -1,2738 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// #define COMPILEDBINDINGS_DEBUG
-
-#include "qmlcompiledbindings_p.h"
-
-#include <QtDeclarative/qmlinfo.h>
-#include <private/qmlcontext_p.h>
-#include <private/qmljsast_p.h>
-#include <private/qmljsengine_p.h>
-#include <private/qmlexpression_p.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qnumeric.h>
-#include <private/qmlgraphicsanchors_p_p.h>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QmlJS;
-
-namespace {
-// Supported types: int, qreal, QString (needs constr/destr), QObject*, bool
-struct Register {
- void setUndefined() { type = 0; }
- void setUnknownButDefined() { type = -1; }
- void setNaN() { setqreal(qSNaN()); }
- bool isUndefined() const { return type == 0; }
-
- void setQObject(QObject *o) { *((QObject **)data) = o; type = QMetaType::QObjectStar; }
- QObject *getQObject() const { return *((QObject **)data); }
-
- void setqreal(qreal v) { *((qreal *)data) = v; type = QMetaType::QReal; }
- qreal getqreal() const { return *((qreal *)data); }
-
- void setint(int v) { *((int *)data) = v; type = QMetaType::Int; }
- int getint() const { return *((int *)data); }
-
- void setbool(bool v) { *((bool *)data) = v; type = QMetaType::Bool; }
- bool getbool() const { return *((bool *)data); }
-
- QVariant *getvariantptr() { return (QVariant *)typeDataPtr(); }
- QString *getstringptr() { return (QString *)typeDataPtr(); }
- QUrl *geturlptr() { return (QUrl *)typeDataPtr(); }
- const QVariant *getvariantptr() const { return (QVariant *)typeDataPtr(); }
- const QString *getstringptr() const { return (QString *)typeDataPtr(); }
- const QUrl *geturlptr() const { return (QUrl *)typeDataPtr(); }
-
- void *typeDataPtr() { return (void *)&data; }
- void *typeMemory() { return (void *)data; }
- const void *typeDataPtr() const { return (void *)&data; }
- const void *typeMemory() const { return (void *)data; }
-
- int gettype() const { return type; }
- void settype(int t) { type = t; }
-
- int type; // Optional type
- void *data[2]; // Object stored here
-};
-}
-
-class QmlCompiledBindingsPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlCompiledBindings)
-
-public:
- QmlCompiledBindingsPrivate();
- virtual ~QmlCompiledBindingsPrivate();
-
- struct Binding : public QmlAbstractBinding, public QmlDelayedError {
- Binding() : enabled(false), updating(0), property(0),
- scope(0), target(0), parent(0) {}
-
- // Inherited from QmlAbstractBinding
- virtual void setEnabled(bool, QmlMetaProperty::WriteFlags flags);
- virtual int propertyIndex();
- virtual void update(QmlMetaProperty::WriteFlags flags);
- virtual void destroy();
-
- int index:30;
- bool enabled:1;
- bool updating:1;
- int property;
- QObject *scope;
- QObject *target;
-
- QmlCompiledBindingsPrivate *parent;
- };
-
- struct Subscription {
- struct Signal {
- QmlGuard<QObject> source;
- int notifyIndex;
- };
-
- enum { InvalidType, SignalType, IdType } type;
- inline Subscription();
- inline ~Subscription();
- bool isSignal() const { return type == SignalType; }
- bool isId() const { return type == IdType; }
- inline Signal *signal();
- inline QmlContextPrivate::IdNotifier *id();
- union {
- char signalData[sizeof(Signal)];
- char idData[sizeof(QmlContextPrivate::IdNotifier)];
- };
- };
- Subscription *subscriptions;
- QScriptDeclarativeClass::PersistentIdentifier *identifiers;
-
- void run(Binding *);
-
- const char *programData;
- Binding *m_bindings;
- quint32 *m_signalTable;
-
- static int methodCount;
-
- void init();
- void run(int instr, QmlContextPrivate *context,
- QmlDelayedError *error, QObject *scope, QObject *output);
-
-
- inline void unsubscribe(int subIndex);
- inline void subscribeId(QmlContextPrivate *p, int idIndex, int subIndex);
- inline void subscribe(QObject *o, int notifyIndex, int subIndex);
-
- QmlPropertyCache::Data *findproperty(QObject *obj,
- const QScriptDeclarativeClass::Identifier &name,
- QmlEnginePrivate *enginePriv,
- QmlPropertyCache::Data &local);
- bool findproperty(QObject *obj,
- Register *output,
- QmlEnginePrivate *enginePriv,
- int subIdx,
- const QScriptDeclarativeClass::Identifier &name,
- bool isTerminal);
- void findgeneric(Register *output, // value output
- int subIdx, // Subscription index in config
- QmlContextPrivate *context, // Context to search in
- const QScriptDeclarativeClass::Identifier &name,
- bool isTerminal);
-};
-
-QmlCompiledBindingsPrivate::QmlCompiledBindingsPrivate()
-: subscriptions(0), identifiers(0)
-{
-}
-
-QmlCompiledBindingsPrivate::~QmlCompiledBindingsPrivate()
-{
- delete [] subscriptions; subscriptions = 0;
- delete [] identifiers; identifiers = 0;
-}
-
-QmlCompiledBindingsPrivate::Subscription::Subscription()
-: type(InvalidType)
-{
-}
-
-QmlCompiledBindingsPrivate::Subscription::~Subscription()
-{
- if (type == SignalType) ((Signal *)signalData)->~Signal();
- else if (type == IdType) ((QmlContextPrivate::IdNotifier *)idData)->~IdNotifier();
-}
-
-
-int QmlCompiledBindingsPrivate::methodCount = -1;
-
-QmlCompiledBindings::QmlCompiledBindings(const char *program, QmlContext *context)
-: QObject(*(new QmlCompiledBindingsPrivate))
-{
- Q_D(QmlCompiledBindings);
-
- if (d->methodCount == -1)
- d->methodCount = QmlCompiledBindings::staticMetaObject.methodCount();
-
- d->programData = program;
-
- d->init();
-
- QmlAbstractExpression::setContext(context);
-}
-
-QmlCompiledBindings::~QmlCompiledBindings()
-{
- Q_D(QmlCompiledBindings);
-
- delete [] d->m_bindings;
-}
-
-QmlAbstractBinding *QmlCompiledBindings::configBinding(int index, QObject *target,
- QObject *scope, int property)
-{
- Q_D(QmlCompiledBindings);
-
- QmlCompiledBindingsPrivate::Binding *rv = d->m_bindings + index;
-
- rv->index = index;
- rv->property = property;
- rv->target = target;
- rv->scope = scope;
- rv->parent = d;
-
- addref(); // This is decremented in Binding::destroy()
-
- return rv;
-}
-
-void QmlCompiledBindingsPrivate::Binding::setEnabled(bool e, QmlMetaProperty::WriteFlags flags)
-{
- if (e) {
- addToObject(target);
- update(flags);
- } else {
- removeFromObject();
- }
-
- QmlAbstractBinding::setEnabled(e, flags);
-
- if (enabled != e) {
- enabled = e;
-
- if (e) update(flags);
- }
-}
-
-int QmlCompiledBindingsPrivate::Binding::propertyIndex()
-{
- return property & 0xFFFF;
-}
-
-void QmlCompiledBindingsPrivate::Binding::update(QmlMetaProperty::WriteFlags)
-{
- parent->run(this);
-}
-
-void QmlCompiledBindingsPrivate::Binding::destroy()
-{
- enabled = false;
- removeFromObject();
- parent->q_func()->release();
- clear();
-}
-
-int QmlCompiledBindings::qt_metacall(QMetaObject::Call c, int id, void **)
-{
- Q_D(QmlCompiledBindings);
-
- if (c == QMetaObject::InvokeMetaMethod && id >= d->methodCount) {
- id -= d->methodCount;
-
- quint32 *reeval = d->m_signalTable + d->m_signalTable[id];
- quint32 count = *reeval;
- ++reeval;
- for (quint32 ii = 0; ii < count; ++ii) {
- d->run(d->m_bindings + reeval[ii]);
- }
- }
- return -1;
-}
-
-void QmlCompiledBindingsPrivate::run(Binding *binding)
-{
- Q_Q(QmlCompiledBindings);
-
- if (!binding->enabled)
- return;
- if (binding->updating)
- qWarning("ERROR: Circular binding");
-
- QmlContext *context = q->QmlAbstractExpression::context();
- if (!context) {
- qWarning("QmlCompiledBindings: Attempted to evaluate an expression in an invalid context");
- return;
- }
- QmlContextPrivate *cp = QmlContextPrivate::get(context);
-
- if (binding->property & 0xFFFF0000) {
- QmlEnginePrivate *ep = QmlEnginePrivate::get(cp->engine);
-
- QmlValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
- Q_ASSERT(vt);
- vt->read(binding->target, binding->property & 0xFFFF);
-
- QObject *target = vt;
- run(binding->index, cp, binding, binding->scope, target);
-
- vt->write(binding->target, binding->property & 0xFFFF,
- QmlMetaProperty::DontRemoveBinding);
- } else {
- run(binding->index, cp, binding, binding->scope, binding->target);
- }
-}
-
-QmlCompiledBindingsPrivate::Subscription::Signal *QmlCompiledBindingsPrivate::Subscription::signal()
-{
- if (type == IdType) ((QmlContextPrivate::IdNotifier *)idData)->~IdNotifier();
- if (type != SignalType) new (signalData) Signal;
- type = SignalType;
- return (Signal *)signalData;
-}
-
-QmlContextPrivate::IdNotifier *QmlCompiledBindingsPrivate::Subscription::id()
-{
- if (type == SignalType) ((Signal *)signalData)->~Signal();
- if (type != IdType) new (idData) QmlContextPrivate::IdNotifier;
- type = IdType;
- return (QmlContextPrivate::IdNotifier *)idData;
-}
-
-namespace {
-// This structure is exactly 8-bytes in size
-struct Instr {
- enum {
- Noop,
-
- Subscribe, // subscribe
- SubscribeId, // subscribe
-
- LoadId, // load
- LoadScope, // load
- LoadRoot, // load
- LoadAttached, // attached
-
- ConvertIntToReal, // unaryop
- ConvertRealToInt, // unaryop
-
- Real, // real_value
- Int, // int_value
- Bool, // bool_value
- String, // string_value
-
- AddReal, // binaryop
- AddInt, // binaryop
- AddString, // binaryop
-
- MinusReal, // binaryop
- MinusInt, // binaryop
-
- CompareReal, // binaryop
- CompareString, // binaryop
-
- NotCompareReal, // binaryop
- NotCompareString, // binaryop
-
- GreaterThanReal, // binaryop
- MaxReal, // binaryop
- MinReal, // binaryop
-
- NewString, // construct
- NewUrl, // construct
-
- CleanupUrl, // cleanup
- CleanupString, // cleanup
-
- Copy, // copy
- Fetch, // fetch
- Store, // store
-
- Skip, // skip
-
- Done,
-
- // Speculative property resolution
- InitString, // initstring
- FindGeneric, // find
- FindGenericTerminal, // find
- FindProperty, // find
- FindPropertyTerminal, // find
- CleanupGeneric, // cleanup
- ConvertGenericToReal, // unaryop
- ConvertGenericToBool, // unaryop
- ConvertGenericToString, // unaryop
- ConvertGenericToUrl, // unaryop
- };
-
- union {
- struct {
- quint8 type;
- quint8 packing[7];
- } common;
- struct {
- quint8 type;
- quint8 packing[3];
- quint16 subscriptions;
- quint16 identifiers;
- } init;
- struct {
- quint8 type;
- qint8 reg;
- quint16 offset;
- quint32 index;
- } subscribe;
- struct {
- quint8 type;
- qint8 reg;
- quint8 packing[2];
- quint32 index;
- } load;
- struct {
- quint8 type;
- qint8 output;
- qint8 reg;
- quint8 exceptionId;
- quint32 index;
- } attached;
- struct {
- quint8 type;
- qint8 output;
- qint8 reg;
- quint8 exceptionId;
- quint32 index;
- } store;
- struct {
- quint8 type;
- qint8 output;
- qint8 objectReg;
- quint8 exceptionId;
- quint32 index;
- } fetch;
- struct {
- quint8 type;
- qint8 reg;
- qint8 src;
- quint8 packing[5];
- } copy;
- struct {
- quint8 type;
- qint8 reg;
- quint8 packing[6];
- } construct;
- struct {
- quint8 type;
- qint8 reg;
- quint8 packing[2];
- float value;
- } real_value;
- struct {
- quint8 type;
- qint8 reg;
- quint8 packing[2];
- int value;
- } int_value;
- struct {
- quint8 type;
- qint8 reg;
- bool value;
- quint8 packing[5];
- } bool_value;
- struct {
- quint8 type;
- qint8 reg;
- quint16 length;
- quint32 offset;
- } string_value;
- struct {
- quint8 type;
- qint8 output;
- qint8 src1;
- qint8 src2;
- quint8 packing[4];
- } binaryop;
- struct {
- quint8 type;
- qint8 output;
- qint8 src;
- quint8 packing[5];
- } unaryop;
- struct {
- quint8 type;
- qint8 reg;
- quint8 packing[2];
- quint32 count;
- } skip;
- struct {
- quint8 type;
- qint8 reg;
- qint8 src;
- quint8 exceptionId;
- quint16 name;
- quint16 subscribeIndex;
- } find;
- struct {
- quint8 type;
- qint8 reg;
- quint8 packing[6];
- } cleanup;
- struct {
- quint8 type;
- quint8 packing[1];
- quint16 offset;
- quint32 dataIdx;
- } initstring;
- };
-};
-
-struct Program {
- quint32 bindings;
- quint32 dataLength;
- quint32 signalTableOffset;
- quint32 exceptionDataOffset;
- quint16 subscriptions;
- quint16 identifiers;
- quint16 instructionCount;
- quint16 dummy;
-
- const char *data() const { return ((const char *)this) + sizeof(Program); }
- const Instr *instructions() const { return (const Instr *)(data() + dataLength); }
-};
-}
-
-struct QmlBindingCompilerPrivate
-{
- struct Result {
- Result() : unknownType(false), metaObject(0), type(-1), reg(-1) {}
- bool operator==(const Result &o) const {
- return unknownType == o.unknownType &&
- metaObject == o.metaObject &&
- type == o.type &&
- reg == o.reg;
- }
- bool operator!=(const Result &o) const {
- return !(*this == o);
- }
- bool unknownType;
- const QMetaObject *metaObject;
- int type;
- int reg;
-
- QSet<QString> subscriptionSet;
- };
-
- QmlBindingCompilerPrivate() : registers(0) {}
-
- void resetInstanceState();
- int commitCompile();
-
- QmlParser::Object *context;
- QmlParser::Object *component;
- QmlParser::Property *destination;
- QHash<QString, QmlParser::Object *> ids;
- QmlEnginePrivate::Imports imports;
- QmlEnginePrivate *engine;
-
- QString contextName() const { return QLatin1String("$$$SCOPE_") + QString::number((intptr_t)context, 16); }
-
- bool compile(QmlJS::AST::Node *);
-
- bool parseExpression(QmlJS::AST::Node *, Result &);
-
- bool tryName(QmlJS::AST::Node *);
- bool parseName(QmlJS::AST::Node *, Result &);
-
- bool tryArith(QmlJS::AST::Node *);
- bool parseArith(QmlJS::AST::Node *, Result &);
- bool numberArith(Result &, const Result &, const Result &, QSOperator::Op op);
- bool stringArith(Result &, const Result &, const Result &, QSOperator::Op op);
-
- bool tryLogic(QmlJS::AST::Node *);
- bool parseLogic(QmlJS::AST::Node *, Result &);
-
- bool tryConditional(QmlJS::AST::Node *);
- bool parseConditional(QmlJS::AST::Node *, Result &);
-
- bool tryConstant(QmlJS::AST::Node *);
- bool parseConstant(QmlJS::AST::Node *, Result &);
-
- bool tryMethod(QmlJS::AST::Node *);
- bool parseMethod(QmlJS::AST::Node *, Result &);
-
- bool buildName(QStringList &, QmlJS::AST::Node *, QList<QmlJS::AST::ExpressionNode *> *nodes = 0);
- bool fetch(Result &type, const QMetaObject *, int reg, int idx, const QStringList &, QmlJS::AST::ExpressionNode *);
-
- quint32 registers;
- QHash<int, QPair<int, int> > registerCleanups;
- int acquireReg(int cleanup = Instr::Noop, int cleanupType = 0);
- void registerCleanup(int reg, int cleanup, int cleanupType = 0);
- void releaseReg(int);
-
- int registerLiteralString(const QString &);
- int registerString(const QString &);
- QHash<QString, QPair<int, int> > registeredStrings;
- QByteArray data;
-
- bool subscription(const QStringList &, Result *);
- int subscriptionIndex(const QStringList &);
- bool subscriptionNeutral(const QSet<QString> &base, const QSet<QString> &lhs, const QSet<QString> &rhs);
-
- quint8 exceptionId(QmlJS::AST::ExpressionNode *);
- QVector<quint64> exceptions;
-
- QSet<int> usedSubscriptionIds;
- QSet<QString> subscriptionSet;
- QHash<QString, int> subscriptionIds;
- QVector<Instr> bytecode;
-
- // Committed binding data
- struct {
- QList<int> offsets;
- QList<QSet<int> > dependencies;
-
- QVector<Instr> bytecode;
- QByteArray data;
- QHash<QString, int> subscriptionIds;
- QVector<quint64> exceptions;
-
- QHash<QString, QPair<int, int> > registeredStrings;
-
- int count() const { return offsets.count(); }
- } committed;
-
- QByteArray buildSignalTable() const;
- QByteArray buildExceptionData() const;
-};
-
-void QmlCompiledBindingsPrivate::unsubscribe(int subIndex)
-{
- Q_Q(QmlCompiledBindings);
-
- QmlCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
- if (sub->isSignal()) {
- QmlCompiledBindingsPrivate::Subscription::Signal *s = sub->signal();
- if (s->source)
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
- QMetaObject::disconnectOne(s->source, s->notifyIndex,
- q, methodCount + subIndex);
-#else
- // QTBUG-6781
- QMetaObject::disconnect(s->source, s->notifyIndex,
- q, methodCount + subIndex);
-#endif
- } else if (sub->isId()) {
- sub->id()->clear();
- }
-}
-
-void QmlCompiledBindingsPrivate::subscribeId(QmlContextPrivate *p, int idIndex, int subIndex)
-{
- Q_Q(QmlCompiledBindings);
-
- unsubscribe(subIndex);
-
- if (p->idValues[idIndex]) {
- QmlCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
- QmlContextPrivate::IdNotifier *i = sub->id();
-
- i->next = p->idValues[idIndex].bindings;
- i->prev = &p->idValues[idIndex].bindings;
- p->idValues[idIndex].bindings = i;
- if (i->next) i->next->prev = &i->next;
-
- i->target = q;
- i->methodIndex = methodCount + subIndex;
- }
-}
-
-void QmlCompiledBindingsPrivate::subscribe(QObject *o, int notifyIndex, int subIndex)
-{
- Q_Q(QmlCompiledBindings);
-
- QmlCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
-
- if (sub->isId())
- unsubscribe(subIndex);
-
- QmlCompiledBindingsPrivate::Subscription::Signal *s = sub->signal();
- if (o != s->source || notifyIndex != s->notifyIndex) {
- if (s->source)
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
- QMetaObject::disconnectOne(s->source, s->notifyIndex,
- q, methodCount + subIndex);
-#else
- // QTBUG-6781
- QMetaObject::disconnect(s->source, s->notifyIndex,
- q, methodCount + subIndex);
-#endif
- s->source = o;
- s->notifyIndex = notifyIndex;
- if (s->source && s->notifyIndex != -1)
- QMetaObject::connect(s->source, s->notifyIndex, q,
- methodCount + subIndex, Qt::DirectConnection);
- }
-}
-
-// Conversion functions - these MUST match the QtScript expression path
-inline static qreal toReal(Register *reg, int type, bool *ok = 0)
-{
- if (ok) *ok = true;
-
- if (type == QMetaType::QReal) {
- return reg->getqreal();
- } else if (type == qMetaTypeId<QVariant>()) {
- return reg->getvariantptr()->toReal();
- } else {
- if (ok) *ok = false;
- return 0;
- }
-}
-
-inline static QString toString(Register *reg, int type, bool *ok = 0)
-{
- if (ok) *ok = true;
-
- if (type == QMetaType::QReal) {
- return QString::number(reg->getqreal());
- } else if (type == QMetaType::Int) {
- return QString::number(reg->getint());
- } else if (type == qMetaTypeId<QVariant>()) {
- return reg->getvariantptr()->toString();
- } else if (type == QMetaType::QString) {
- return *reg->getstringptr();
- } else {
- if (ok) *ok = false;
- return QString();
- }
-}
-
-inline static bool toBool(Register *reg, int type, bool *ok = 0)
-{
- if (ok) *ok = true;
-
- if (type == QMetaType::Bool) {
- return reg->getbool();
- } else if (type == qMetaTypeId<QVariant>()) {
- return reg->getvariantptr()->toBool();
- } else {
- if (ok) *ok = false;
- return false;
- }
-}
-
-inline static QUrl toUrl(Register *reg, int type, QmlContextPrivate *context, bool *ok = 0)
-{
- if (ok) *ok = true;
-
- QUrl base;
- if (type == qMetaTypeId<QVariant>()) {
- QVariant *var = reg->getvariantptr();
- int vt = var->type();
- if (vt == QVariant::Url) {
- base = var->toUrl();
- } else if (vt == QVariant::ByteArray) {
- base = QUrl(QString::fromUtf8(var->toByteArray()));
- } else if (vt == QVariant::String) {
- base = QUrl(var->toString());
- } else {
- if (ok) *ok = false;
- return QUrl();
- }
- } else if (type == QMetaType::QString) {
- base = QUrl(*reg->getstringptr());
- } else {
- if (ok) *ok = false;
- return QUrl();
- }
-
- if (!base.isEmpty() && base.isRelative())
- return context->url.resolved(base);
- else
- return base;
-}
-
-static QObject *variantToQObject(const QVariant &value, bool *ok)
-{
- if (ok) *ok = true;
-
- if (value.userType() == QMetaType::QObjectStar) {
- return qvariant_cast<QObject*>(value);
- } else {
- if (ok) *ok = false;
- return 0;
- }
-}
-
-bool QmlCompiledBindingsPrivate::findproperty(QObject *obj, Register *output,
- QmlEnginePrivate *enginePriv,
- int subIdx, const QScriptDeclarativeClass::Identifier &name,
- bool isTerminal)
-{
- if (!obj) {
- output->setUndefined();
- return false;
- }
-
- QmlPropertyCache::Data local;
- QmlPropertyCache::Data *property =
- QmlPropertyCache::property(QmlEnginePrivate::get(enginePriv), obj, name, local);
-
- if (property) {
- if (subIdx != -1)
- subscribe(obj, property->notifyIndex, subIdx);
-
- if (property->flags & QmlPropertyCache::Data::IsQObjectDerived) {
- void *args[] = { output->typeDataPtr(), 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
- output->settype(QMetaType::QObjectStar);
- } else if (property->propType == qMetaTypeId<QVariant>()) {
- QVariant v;
- void *args[] = { &v, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
-
- if (isTerminal) {
- new (output->typeDataPtr()) QVariant(v);
- output->settype(qMetaTypeId<QVariant>());
- } else {
- bool ok;
- output->setQObject(variantToQObject(v, &ok));
- if (!ok)
- output->setUndefined();
- else
- output->settype(QMetaType::QObjectStar);
- }
-
- } else {
- if (!isTerminal) {
- output->setUndefined();
- } else if (property->propType == QMetaType::QReal) {
- void *args[] = { output->typeDataPtr(), 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
- output->settype(QMetaType::QReal);
- } else if (property->propType == QMetaType::Int) {
- void *args[] = { output->typeDataPtr(), 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
- output->settype(QMetaType::Int);
- } else if (property->propType == QMetaType::Bool) {
- void *args[] = { output->typeDataPtr(), 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
- output->settype(QMetaType::Bool);
- } else if (property->propType == QMetaType::QString) {
- new (output->typeDataPtr()) QString();
- void *args[] = { output->typeDataPtr(), 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, property->coreIndex, args);
- output->settype(QMetaType::QString);
- } else {
- new (output->typeDataPtr())
- QVariant(obj->metaObject()->property(property->coreIndex).read(obj));
- output->settype(qMetaTypeId<QVariant>());
- }
- }
-
- return true;
- } else {
- output->setUndefined();
- return false;
- }
-}
-
-void QmlCompiledBindingsPrivate::findgeneric(Register *output,
- int subIdx,
- QmlContextPrivate *context,
- const QScriptDeclarativeClass::Identifier &name,
- bool isTerminal)
-{
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(context->engine);
-
- while (context) {
-
- int contextPropertyIndex = context->propertyNames?context->propertyNames->value(name):-1;
-
-
- if (contextPropertyIndex != -1) {
-
- if (subIdx != -1)
- subscribe(QmlContextPrivate::get(context), contextPropertyIndex + context->notifyIndex, subIdx);
-
- if (contextPropertyIndex < context->idValueCount) {
- output->setQObject(context->idValues[contextPropertyIndex]);
- output->settype(QMetaType::QObjectStar);
- } else {
- const QVariant &value = context->propertyValues.at(contextPropertyIndex);
- if (isTerminal) {
- new (output->typeDataPtr()) QVariant(value);
- output->settype(qMetaTypeId<QVariant>());
- } else {
- bool ok;
- output->setQObject(variantToQObject(value, &ok));
- if (!ok) { output->setUndefined(); }
- else { output->settype(QMetaType::QObjectStar); }
- return;
- }
- }
-
- return;
- }
-
- for (int ii = 0; ii < context->scripts.count(); ++ii) {
- QScriptValue function = QScriptDeclarativeClass::function(context->scripts.at(ii), name);
- if (function.isValid()) {
- qFatal("Binding optimizer resolved name to QScript method");
- }
- }
-
- if (QObject *root = context->defaultObjects.isEmpty()?0:context->defaultObjects.first()) {
-
- if (findproperty(root, output, enginePriv, subIdx, name, isTerminal))
- return;
-
- }
-
- if (context->parent) {
- context = QmlContextPrivate::get(context->parent);
- } else {
- context = 0;
- }
- }
-
- output->setUndefined();
-}
-
-void QmlCompiledBindingsPrivate::init()
-{
- Program *program = (Program *)programData;
- if (program->subscriptions)
- subscriptions = new QmlCompiledBindingsPrivate::Subscription[program->subscriptions];
- if (program->identifiers)
- identifiers = new QScriptDeclarativeClass::PersistentIdentifier[program->identifiers];
-
- m_signalTable = (quint32 *)(program->data() + program->signalTableOffset);
- m_bindings = new QmlCompiledBindingsPrivate::Binding[program->bindings];
-}
-
-static void throwException(int id, QmlDelayedError *error,
- Program *program, QmlContextPrivate *context,
- const QString &description = QString())
-{
- error->error.setUrl(context->url);
- if (description.isEmpty())
- error->error.setDescription(QLatin1String("TypeError: Result of expression is not an object"));
- else
- error->error.setDescription(description);
- if (id != 0xFF) {
- quint64 e = *((quint64 *)(program->data() + program->exceptionDataOffset) + id);
- error->error.setLine((e >> 32) & 0xFFFFFFFF);
- error->error.setColumn(e & 0xFFFFFFFF);
- } else {
- error->error.setLine(-1);
- error->error.setColumn(-1);
- }
- if (!context->engine || !error->addError(QmlEnginePrivate::get(context->engine)))
- qWarning() << error->error;
-}
-
-static void dumpInstruction(const Instr *instr)
-{
- switch (instr->common.type) {
- case Instr::Noop:
- qWarning().nospace() << "Noop";
- break;
- case Instr::Subscribe:
- qWarning().nospace() << "Subscribe" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index;
- break;
- case Instr::SubscribeId:
- qWarning().nospace() << "SubscribeId" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index;
- break;
- case Instr::LoadId:
- qWarning().nospace() << "LoadId" << "\t\t\t" << instr->load.index << "\t" << instr->load.reg;
- break;
- case Instr::LoadScope:
- qWarning().nospace() << "LoadScope" << "\t\t" << instr->load.index << "\t" << instr->load.reg;
- break;
- case Instr::LoadRoot:
- qWarning().nospace() << "LoadRoot" << "\t\t" << instr->load.index << "\t" << instr->load.reg;
- break;
- case Instr::LoadAttached:
- qWarning().nospace() << "LoadAttached" << "\t\t" << instr->attached.output << "\t" << instr->attached.reg << "\t" << instr->attached.index;
- break;
- case Instr::ConvertIntToReal:
- qWarning().nospace() << "ConvertIntToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- case Instr::ConvertRealToInt:
- qWarning().nospace() << "ConvertRealToInt" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- case Instr::Real:
- qWarning().nospace() << "Real" << "\t\t\t" << instr->real_value.reg << "\t" << instr->real_value.value;
- break;
- case Instr::Int:
- qWarning().nospace() << "Int" << "\t\t\t" << instr->int_value.reg << "\t" << instr->int_value.value;
- break;
- case Instr::Bool:
- qWarning().nospace() << "Bool" << "\t\t\t" << instr->bool_value.reg << "\t" << instr->bool_value.value;
- break;
- case Instr::String:
- qWarning().nospace() << "String" << "\t\t\t" << instr->string_value.reg << "\t" << instr->string_value.offset << "\t" << instr->string_value.length;
- break;
- case Instr::AddReal:
- qWarning().nospace() << "AddReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::AddInt:
- qWarning().nospace() << "AddInt" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::AddString:
- qWarning().nospace() << "AddString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::MinusReal:
- qWarning().nospace() << "MinusReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::MinusInt:
- qWarning().nospace() << "MinusInt" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::CompareReal:
- qWarning().nospace() << "CompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::CompareString:
- qWarning().nospace() << "CompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::NotCompareReal:
- qWarning().nospace() << "NotCompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::NotCompareString:
- qWarning().nospace() << "NotCompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::GreaterThanReal:
- qWarning().nospace() << "GreaterThanReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::MaxReal:
- qWarning().nospace() << "MaxReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::MinReal:
- qWarning().nospace() << "MinReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::NewString:
- qWarning().nospace() << "NewString" << "\t\t" << instr->construct.reg;
- break;
- case Instr::NewUrl:
- qWarning().nospace() << "NewUrl" << "\t\t\t" << instr->construct.reg;
- break;
- case Instr::CleanupString:
- qWarning().nospace() << "CleanupString" << "\t\t" << instr->cleanup.reg;
- break;
- case Instr::CleanupUrl:
- qWarning().nospace() << "CleanupUrl" << "\t\t" << instr->cleanup.reg;
- break;
- case Instr::Fetch:
- qWarning().nospace() << "Fetch" << "\t\t\t" << instr->fetch.output << "\t" << instr->fetch.index << "\t" << instr->fetch.objectReg;
- break;
- case Instr::Store:
- qWarning().nospace() << "Store" << "\t\t\t" << instr->store.output << "\t" << instr->store.index << "\t" << instr->store.reg;
- break;
- case Instr::Copy:
- qWarning().nospace() << "Copy" << "\t\t\t" << instr->copy.reg << "\t" << instr->copy.src;
- break;
- case Instr::Skip:
- qWarning().nospace() << "Skip" << "\t\t\t" << instr->skip.reg << "\t" << instr->skip.count;
- break;
- case Instr::Done:
- qWarning().nospace() << "Done";
- break;
- case Instr::InitString:
- qWarning().nospace() << "InitString" << "\t\t" << instr->initstring.offset << "\t" << instr->initstring.dataIdx;
- break;
- case Instr::FindGeneric:
- qWarning().nospace() << "FindGeneric" << "\t\t" << instr->find.reg << "\t" << instr->find.name;
- break;
- case Instr::FindGenericTerminal:
- qWarning().nospace() << "FindGenericTerminal" << "\t" << instr->find.reg << "\t" << instr->find.name;
- break;
- case Instr::FindProperty:
- qWarning().nospace() << "FindProperty" << "\t\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name;
- break;
- case Instr::FindPropertyTerminal:
- qWarning().nospace() << "FindPropertyTerminal" << "\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name;
- break;
- case Instr::CleanupGeneric:
- qWarning().nospace() << "CleanupGeneric" << "\t\t" << instr->cleanup.reg;
- break;
- case Instr::ConvertGenericToReal:
- qWarning().nospace() << "ConvertGenericToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- case Instr::ConvertGenericToBool:
- qWarning().nospace() << "ConvertGenericToBool" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- case Instr::ConvertGenericToString:
- qWarning().nospace() << "ConvertGenericToString" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- case Instr::ConvertGenericToUrl:
- qWarning().nospace() << "ConvertGenericToUrl" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- default:
- qWarning().nospace() << "Unknown";
- break;
- }
-}
-
-void QmlCompiledBindingsPrivate::run(int instrIndex,
- QmlContextPrivate *context, QmlDelayedError *error,
- QObject *scope, QObject *output)
-{
- error->removeError();
-
- Register registers[32];
- int storeFlags = 0;
-
- QmlEnginePrivate *engine = QmlEnginePrivate::get(context->engine);
- Program *program = (Program *)programData;
- const Instr *instr = program->instructions();
- instr += instrIndex;
- const char *data = program->data();
-
-#ifdef COMPILEDBINDINGS_DEBUG
- qWarning().nospace() << "Begin binding run";
-#endif
-
- while (instr) {
-#ifdef COMPILEDBINDINGS_DEBUG
- dumpInstruction(instr);
-#endif
-
- switch (instr->common.type) {
- case Instr::Noop:
- break;
-
- case Instr::SubscribeId:
- subscribeId(context, instr->subscribe.index, instr->subscribe.offset);
- break;
-
- case Instr::Subscribe:
- {
- QObject *o = 0;
- const Register &object = registers[instr->subscribe.reg];
- if (!object.isUndefined()) o = object.getQObject();
- subscribe(o, instr->subscribe.index, instr->subscribe.offset);
- }
- break;
-
- case Instr::LoadId:
- registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
- break;
-
- case Instr::LoadScope:
- registers[instr->load.reg].setQObject(scope);
- break;
-
- case Instr::LoadRoot:
- registers[instr->load.reg].setQObject(context->defaultObjects.at(0));
- break;
-
- case Instr::LoadAttached:
- {
- const Register &input = registers[instr->attached.reg];
- Register &output = registers[instr->attached.output];
- if (input.isUndefined()) {
- throwException(instr->attached.exceptionId, error, program, context);
- return;
- }
-
- QObject *object = registers[instr->attached.reg].getQObject();
- if (!object) {
- output.setUndefined();
- } else {
- QObject *attached =
- qmlAttachedPropertiesObjectById(instr->attached.index,
- registers[instr->attached.reg].getQObject(),
- true);
- Q_ASSERT(attached);
- output.setQObject(attached);
- }
- }
- break;
-
- case Instr::ConvertIntToReal:
- {
- const Register &input = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (input.isUndefined()) output.setUndefined();
- else output.setqreal(qreal(input.getint()));
- }
- break;
-
- case Instr::ConvertRealToInt:
- {
- const Register &input = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (input.isUndefined()) output.setUndefined();
- else output.setint(int(input.getqreal()));
- }
- break;
-
- case Instr::Real:
- registers[instr->real_value.reg].setqreal(instr->real_value.value);
- break;
-
- case Instr::Int:
- registers[instr->int_value.reg].setint(instr->int_value.value);
- break;
-
- case Instr::Bool:
- registers[instr->bool_value.reg].setbool(instr->bool_value.value);
- break;
-
- case Instr::String:
- {
- Register &output = registers[instr->string_value.reg];
- new (output.getstringptr())
- QString((QChar *)(data + instr->string_value.offset), instr->string_value.length);
- output.settype(QMetaType::QString);
- }
- break;
-
- case Instr::AddReal:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
- else output.setqreal(lhs.getqreal() + rhs.getqreal());
- }
- break;
-
- case Instr::AddInt:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
- else output.setint(lhs.getint() + rhs.getint());
- }
- break;
-
- case Instr::AddString:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() && rhs.isUndefined()) { output.setNaN(); }
- else {
- if (lhs.isUndefined())
- new (output.getstringptr())
- QString(QLatin1String("undefined") + *registers[instr->binaryop.src2].getstringptr());
- else if (rhs.isUndefined())
- new (output.getstringptr())
- QString(*registers[instr->binaryop.src1].getstringptr() + QLatin1String("undefined"));
- else
- new (output.getstringptr())
- QString(*registers[instr->binaryop.src1].getstringptr() +
- *registers[instr->binaryop.src2].getstringptr());
- output.settype(QMetaType::QString);
- }
- }
- break;
-
- case Instr::MinusReal:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
- else output.setqreal(lhs.getqreal() - rhs.getqreal());
- }
- break;
-
- case Instr::MinusInt:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
- else output.setint(lhs.getint() - rhs.getint());
- }
- break;
-
- case Instr::CompareReal:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
- else output.setbool(lhs.getqreal() == rhs.getqreal());
- }
- break;
-
- case Instr::CompareString:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
- else output.setbool(*lhs.getstringptr() == *rhs.getstringptr());
- }
- break;
-
- case Instr::NotCompareReal:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
- else output.setbool(lhs.getqreal() != rhs.getqreal());
- }
- break;
-
- case Instr::NotCompareString:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
- else output.setbool(*lhs.getstringptr() != *rhs.getstringptr());
- }
- break;
-
- case Instr::GreaterThanReal:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(false);
- else output.setbool(lhs.getqreal() > rhs.getqreal());
- }
- break;
-
- case Instr::MaxReal:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
- else output.setqreal(qMax(lhs.getqreal(), rhs.getqreal()));
- }
- break;
-
- case Instr::MinReal:
- {
- const Register &lhs = registers[instr->binaryop.src1];
- const Register &rhs = registers[instr->binaryop.src2];
- Register &output = registers[instr->binaryop.output];
- if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
- else output.setqreal(qMin(lhs.getqreal(), rhs.getqreal()));
- }
- break;
-
- case Instr::NewString:
- {
- Register &output = registers[instr->construct.reg];
- new (output.getstringptr()) QString;
- output.settype(QMetaType::QString);
- }
- break;
-
- case Instr::NewUrl:
- {
- Register &output = registers[instr->construct.reg];
- new (output.geturlptr()) QUrl;
- output.settype(QMetaType::QUrl);
- }
- break;
-
- case Instr::CleanupString:
- registers[instr->cleanup.reg].getstringptr()->~QString();
- break;
-
- case Instr::CleanupUrl:
- registers[instr->cleanup.reg].geturlptr()->~QUrl();
- break;
-
- case Instr::Fetch:
- {
- const Register &input = registers[instr->fetch.objectReg];
- Register &output = registers[instr->fetch.output];
-
- if (input.isUndefined()) {
- throwException(instr->fetch.exceptionId, error, program, context);
- return;
- }
-
- QObject *object = input.getQObject();
- if (!object) {
- output.setUndefined();
- } else {
- void *argv[] = { output.typeDataPtr(), 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv);
- }
- }
- break;
-
- case Instr::Store:
- {
- Register &data = registers[instr->store.reg];
- if (data.isUndefined()) {
- throwException(instr->store.exceptionId, error, program, context,
- QLatin1String("Unable to assign undefined value"));
- return;
- }
-
- int status = -1;
- void *argv[] = { data.typeDataPtr(), 0, &status, &storeFlags };
- QMetaObject::metacall(output, QMetaObject::WriteProperty,
- instr->store.index, argv);
- }
- break;
-
- case Instr::Copy:
- registers[instr->copy.reg] = registers[instr->copy.src];
- break;
-
- case Instr::Skip:
- if (instr->skip.reg == -1 || !registers[instr->skip.reg].getbool())
- instr += instr->skip.count;
- break;
-
- case Instr::Done:
- return;
-
- case Instr::InitString:
- if (!identifiers[instr->initstring.offset].identifier) {
- quint32 len = *(quint32 *)(data + instr->initstring.dataIdx);
- QChar *strdata = (QChar *)(data + instr->initstring.dataIdx + sizeof(quint32));
-
- QString str = QString::fromRawData(strdata, len);
-
- identifiers[instr->initstring.offset] = engine->objectClass->createPersistentIdentifier(str);
- }
- break;
-
- case Instr::FindGenericTerminal:
- case Instr::FindGeneric:
- // We start the search in the parent context, as we know that the
- // name is not present in the current context or it would have been
- // found during the static compile
- findgeneric(registers + instr->find.reg, instr->find.subscribeIndex,
- QmlContextPrivate::get(context->parent),
- identifiers[instr->find.name].identifier,
- instr->common.type == Instr::FindGenericTerminal);
- break;
-
- case Instr::FindPropertyTerminal:
- case Instr::FindProperty:
- {
- const Register &object = registers[instr->find.src];
- if (object.isUndefined()) {
- throwException(instr->find.exceptionId, error, program, context);
- return;
- }
-
- findproperty(object.getQObject(), registers + instr->find.reg,
- QmlEnginePrivate::get(context->engine),
- instr->find.subscribeIndex, identifiers[instr->find.name].identifier,
- instr->common.type == Instr::FindPropertyTerminal);
- }
- break;
-
- case Instr::CleanupGeneric:
- {
- int type = registers[instr->cleanup.reg].gettype();
- if (type == qMetaTypeId<QVariant>()) {
- registers[instr->cleanup.reg].getvariantptr()->~QVariant();
- } else if (type == QMetaType::QString) {
- registers[instr->cleanup.reg].getstringptr()->~QString();
- } else if (type == QMetaType::QUrl) {
- registers[instr->cleanup.reg].geturlptr()->~QUrl();
- }
- }
- break;
-
- case Instr::ConvertGenericToReal:
- {
- Register &output = registers[instr->unaryop.output];
- Register &input = registers[instr->unaryop.src];
- bool ok = true;
- output.setqreal(toReal(&input, input.gettype(), &ok));
- if (!ok) output.setUndefined();
- }
- break;
-
- case Instr::ConvertGenericToBool:
- {
- Register &output = registers[instr->unaryop.output];
- Register &input = registers[instr->unaryop.src];
- bool ok = true;
- output.setbool(toBool(&input, input.gettype(), &ok));
- if (!ok) output.setUndefined();
- }
- break;
-
- case Instr::ConvertGenericToString:
- {
- Register &output = registers[instr->unaryop.output];
- Register &input = registers[instr->unaryop.src];
- bool ok = true;
- QString str = toString(&input, input.gettype(), &ok);
- if (ok) { new (output.getstringptr()) QString(str); output.settype(QMetaType::QString); }
- else { output.setUndefined(); }
- }
- break;
-
- case Instr::ConvertGenericToUrl:
- {
- Register &output = registers[instr->unaryop.output];
- Register &input = registers[instr->unaryop.src];
- bool ok = true;
- QUrl url = toUrl(&input, input.gettype(), context, &ok);
- if (ok) { new (output.geturlptr()) QUrl(url); output.settype(QMetaType::QUrl); }
- else { output.setUndefined(); }
- }
- break;
-
- default:
- qFatal("EEK");
- break;
- }
-
- instr++;
- }
-}
-
-void QmlBindingCompiler::dump(const QByteArray &programData)
-{
- const Program *program = (const Program *)programData.constData();
-
- qWarning() << "Program.bindings:" << program->bindings;
- qWarning() << "Program.dataLength:" << program->dataLength;
- qWarning() << "Program.subscriptions:" << program->subscriptions;
- qWarning() << "Program.indentifiers:" << program->identifiers;
-
- int count = program->instructionCount;
- const Instr *instr = program->instructions();
-
- while (count--) {
-
- dumpInstruction(instr);
- ++instr;
- }
-}
-
-/*!
-Clear the state associated with attempting to compile a specific binding.
-This does not clear the global "commited binding" states.
-*/
-void QmlBindingCompilerPrivate::resetInstanceState()
-{
- registers = 0;
- registerCleanups.clear();
- data = committed.data;
- exceptions = committed.exceptions;
- usedSubscriptionIds.clear();
- subscriptionSet.clear();
- subscriptionIds = committed.subscriptionIds;
- registeredStrings = committed.registeredStrings;
- bytecode.clear();
-}
-
-/*!
-Mark the last compile as successful, and add it to the "committed data"
-section.
-
-Returns the index for the committed binding.
-*/
-int QmlBindingCompilerPrivate::commitCompile()
-{
- int rv = committed.count();
- committed.offsets << committed.bytecode.count();
- committed.dependencies << usedSubscriptionIds;
- committed.bytecode << bytecode;
- committed.data = data;
- committed.exceptions = exceptions;
- committed.subscriptionIds = subscriptionIds;
- committed.registeredStrings = registeredStrings;
- return rv;
-}
-
-bool QmlBindingCompilerPrivate::compile(QmlJS::AST::Node *node)
-{
- resetInstanceState();
-
- if (destination->type == -1)
- return false;
-
- Result type;
-
- if (!parseExpression(node, type))
- return false;
-
- if (subscriptionSet.count() > 0xFFFF ||
- registeredStrings.count() > 0xFFFF)
- return false;
-
- if (type.unknownType) {
- if (destination->type != QMetaType::QReal &&
- destination->type != QVariant::String &&
- destination->type != QMetaType::Bool &&
- destination->type != QVariant::Url)
- return false;
-
- int convertReg = acquireReg();
-
- if (destination->type == QMetaType::QReal) {
- Instr convert;
- convert.common.type = Instr::ConvertGenericToReal;
- convert.unaryop.output = convertReg;
- convert.unaryop.src = type.reg;
- bytecode << convert;
- } else if (destination->type == QVariant::String) {
- Instr convert;
- convert.common.type = Instr::ConvertGenericToString;
- convert.unaryop.output = convertReg;
- convert.unaryop.src = type.reg;
- bytecode << convert;
- } else if (destination->type == QMetaType::Bool) {
- Instr convert;
- convert.common.type = Instr::ConvertGenericToBool;
- convert.unaryop.output = convertReg;
- convert.unaryop.src = type.reg;
- bytecode << convert;
- } else if (destination->type == QVariant::Url) {
- Instr convert;
- convert.common.type = Instr::ConvertGenericToUrl;
- convert.unaryop.output = convertReg;
- convert.unaryop.src = type.reg;
- bytecode << convert;
- }
-
- Instr cleanup;
- cleanup.common.type = Instr::CleanupGeneric;
- cleanup.cleanup.reg = type.reg;
- bytecode << cleanup;
-
- Instr instr;
- instr.common.type = Instr::Store;
- instr.store.output = 0;
- instr.store.index = destination->index;
- instr.store.reg = convertReg;
- instr.store.exceptionId = exceptionId(node->expressionCast());
- bytecode << instr;
-
- if (destination->type == QVariant::String) {
- Instr cleanup;
- cleanup.common.type = Instr::CleanupString;
- cleanup.cleanup.reg = convertReg;
- bytecode << cleanup;
- } else if (destination->type == QVariant::Url) {
- Instr cleanup;
- cleanup.common.type = Instr::CleanupUrl;
- cleanup.cleanup.reg = convertReg;
- bytecode << cleanup;
- }
-
- releaseReg(convertReg);
-
- Instr done;
- done.common.type = Instr::Done;
- bytecode << done;
-
- return true;
- } else {
- // Can we store the final value?
- if (type.type == QVariant::Int &&
- destination->type == QMetaType::QReal) {
- Instr instr;
- instr.common.type = Instr::ConvertIntToReal;
- instr.unaryop.output = type.reg;
- instr.unaryop.src = type.reg;
- bytecode << instr;
- type.type = QMetaType::QReal;
- } else if (type.type == QMetaType::QReal &&
- destination->type == QVariant::Int) {
- Instr instr;
- instr.common.type = Instr::ConvertRealToInt;
- instr.unaryop.output = type.reg;
- instr.unaryop.src = type.reg;
- bytecode << instr;
- type.type = QVariant::Int;
- } else if (type.type == destination->type) {
- } else {
- const QMetaObject *from = type.metaObject;
- const QMetaObject *to = engine->rawMetaObjectForType(destination->type);
-
- if (QmlMetaPropertyPrivate::canConvert(from, to))
- type.type = destination->type;
- }
-
- if (type.type == destination->type) {
- Instr instr;
- instr.common.type = Instr::Store;
- instr.store.output = 0;
- instr.store.index = destination->index;
- instr.store.reg = type.reg;
- instr.store.exceptionId = exceptionId(node->expressionCast());
- bytecode << instr;
-
- releaseReg(type.reg);
-
- Instr done;
- done.common.type = Instr::Done;
- bytecode << done;
-
- return true;
- } else {
- return false;
- }
- }
-}
-
-bool QmlBindingCompilerPrivate::parseExpression(QmlJS::AST::Node *node, Result &type)
-{
- while (node->kind == AST::Node::Kind_NestedExpression)
- node = static_cast<AST::NestedExpression *>(node)->expression;
-
- if (tryArith(node)) {
- if (!parseArith(node, type)) return false;
- } else if (tryLogic(node)) {
- if (!parseLogic(node, type)) return false;
- } else if (tryConditional(node)) {
- if (!parseConditional(node, type)) return false;
- } else if (tryName(node)) {
- if (!parseName(node, type)) return false;
- } else if (tryConstant(node)) {
- if (!parseConstant(node, type)) return false;
- } else if (tryMethod(node)) {
- if (!parseMethod(node, type)) return false;
- } else {
- return false;
- }
- return true;
-}
-
-bool QmlBindingCompilerPrivate::tryName(QmlJS::AST::Node *node)
-{
- return node->kind == AST::Node::Kind_IdentifierExpression ||
- node->kind == AST::Node::Kind_FieldMemberExpression;
-}
-
-bool QmlBindingCompilerPrivate::parseName(AST::Node *node, Result &type)
-{
- QStringList nameParts;
- QList<AST::ExpressionNode *> nameNodes;
- if (!buildName(nameParts, node, &nameNodes))
- return false;
-
- int reg = acquireReg();
- if (reg == -1)
- return false;
- type.reg = reg;
-
- QmlParser::Object *absType = 0;
-
- QStringList subscribeName;
-
- bool wasAttachedObject = false;
-
- for (int ii = 0; ii < nameParts.count(); ++ii) {
- const QString &name = nameParts.at(ii);
-
- // We don't handle signal properties or attached properties
- if (name.length() > 2 && name.startsWith(QLatin1String("on")) &&
- name.at(2).isUpper())
- return false;
-
- QmlType *attachType = 0;
- if (name.at(0).isUpper()) {
- // Could be an attached property
- if (ii == nameParts.count() - 1)
- return false;
- if (nameParts.at(ii + 1).at(0).isUpper())
- return false;
-
- QmlEnginePrivate::ImportedNamespace *ns = 0;
- if (!engine->resolveType(imports, name.toUtf8(), &attachType, 0, 0, 0, &ns))
- return false;
- if (ns || !attachType || !attachType->attachedPropertiesType())
- return false;
-
- wasAttachedObject = true;
- }
-
- if (ii == 0) {
-
- if (attachType) {
- Instr instr;
- instr.common.type = Instr::LoadScope;
- instr.load.index = 0;
- instr.load.reg = reg;
- bytecode << instr;
-
- Instr attach;
- attach.common.type = Instr::LoadAttached;
- attach.attached.output = reg;
- attach.attached.reg = reg;
- attach.attached.index = attachType->index();
- attach.attached.exceptionId = exceptionId(nameNodes.at(ii));
- bytecode << attach;
-
- subscribeName << contextName();
- subscribeName << QLatin1String("$$$ATTACH_") + name;
-
- absType = 0;
- type.metaObject = attachType->attachedPropertiesType();
-
- continue;
- } else if (ids.contains(name)) {
- QmlParser::Object *idObject = ids.value(name);
- absType = idObject;
- type.metaObject = absType->metaObject();
-
- // We check if the id object is the root or
- // scope object to avoid a subscription
- if (idObject == component) {
- Instr instr;
- instr.common.type = Instr::LoadRoot;
- instr.load.index = 0;
- instr.load.reg = reg;
- bytecode << instr;
- } else if (idObject == context) {
- Instr instr;
- instr.common.type = Instr::LoadScope;
- instr.load.index = 0;
- instr.load.reg = reg;
- bytecode << instr;
- } else {
- Instr instr;
- instr.common.type = Instr::LoadId;
- instr.load.index = idObject->idIndex;
- instr.load.reg = reg;
- bytecode << instr;
-
- subscribeName << QLatin1String("$$$ID_") + name;
-
- if (subscription(subscribeName, &type)) {
- Instr sub;
- sub.common.type = Instr::SubscribeId;
- sub.subscribe.offset = subscriptionIndex(subscribeName);
- sub.subscribe.reg = reg;
- sub.subscribe.index = instr.load.index;
- bytecode << sub;
- }
- }
-
- } else {
-
- QByteArray utf8Name = name.toUtf8();
- const char *cname = utf8Name.constData();
-
- int d0Idx = (context == component)?-1:context->metaObject()->indexOfProperty(cname);
- int d1Idx = -1;
- if (d0Idx == -1)
- d1Idx = component->metaObject()->indexOfProperty(cname);
-
- if (d0Idx != -1) {
- Instr instr;
- instr.common.type = Instr::LoadScope;
- instr.load.index = 0;
- instr.load.reg = reg;
- bytecode << instr;
-
- subscribeName << contextName();
- subscribeName << name;
-
- if (!fetch(type, context->metaObject(), reg, d0Idx, subscribeName, nameNodes.at(ii)))
- return false;
- } else if(d1Idx != -1) {
- Instr instr;
- instr.common.type = Instr::LoadRoot;
- instr.load.index = 0;
- instr.load.reg = reg;
- bytecode << instr;
-
- subscribeName << QLatin1String("$$$ROOT");
- subscribeName << name;
-
- if (!fetch(type, component->metaObject(), reg, d1Idx, subscribeName, nameNodes.at(ii)))
- return false;
- } else {
- Instr find;
- if (nameParts.count() == 1)
- find.common.type = Instr::FindGenericTerminal;
- else
- find.common.type = Instr::FindGeneric;
-
- find.find.reg = reg;
- find.find.src = -1;
- find.find.name = registerString(name);
- find.find.exceptionId = exceptionId(nameNodes.at(ii));
-
- subscribeName << QString(QLatin1String("$$$Generic_") + name);
- if (subscription(subscribeName, &type))
- find.find.subscribeIndex = subscriptionIndex(subscribeName);
- else
- find.find.subscribeIndex = -1;
-
- bytecode << find;
- type.unknownType = true;
- }
-
- if (!type.unknownType && type.type == -1)
- return false; // Couldn't fetch that type
- }
-
- } else {
-
- if (attachType) {
- Instr attach;
- attach.common.type = Instr::LoadAttached;
- attach.attached.output = reg;
- attach.attached.reg = reg;
- attach.attached.index = attachType->index();
- bytecode << attach;
-
- absType = 0;
- type.metaObject = attachType->attachedPropertiesType();
-
- subscribeName << QLatin1String("$$$ATTACH_") + name;
- continue;
- }
-
- const QMetaObject *mo = 0;
- if (absType)
- mo = absType->metaObject();
- else if (type.metaObject)
- mo = type.metaObject;
-
- QByteArray utf8Name = name.toUtf8();
- const char *cname = utf8Name.constData();
- int idx = mo?mo->indexOfProperty(cname):-1;
- if (absType && idx == -1)
- return false;
-
- subscribeName << name;
-
- if (absType || (wasAttachedObject && idx != -1) || (mo && mo->property(idx).isFinal())) {
- absType = 0;
- if (!fetch(type, mo, reg, idx, subscribeName, nameNodes.at(ii)))
- return false;
- } else {
-
- Instr prop;
- if (ii == nameParts.count() -1 )
- prop.common.type = Instr::FindPropertyTerminal;
- else
- prop.common.type = Instr::FindProperty;
-
- prop.find.reg = reg;
- prop.find.src = reg;
- prop.find.name = registerString(name);
- prop.find.exceptionId = exceptionId(nameNodes.at(ii));
-
- if (subscription(subscribeName, &type))
- prop.find.subscribeIndex = subscriptionIndex(subscribeName);
- else
- prop.find.subscribeIndex = -1;
-
- type.unknownType = true;
- type.metaObject = 0;
- type.type = -1;
- type.reg = reg;
- bytecode << prop;
- }
- }
-
- wasAttachedObject = false;
- }
-
- return true;
-}
-
-bool QmlBindingCompilerPrivate::tryArith(QmlJS::AST::Node *node)
-{
- if (node->kind != AST::Node::Kind_BinaryExpression)
- return false;
-
- AST::BinaryExpression *expression = static_cast<AST::BinaryExpression *>(node);
- if (expression->op == QSOperator::Add ||
- expression->op == QSOperator::Sub)
- return true;
- else
- return false;
-}
-
-bool QmlBindingCompilerPrivate::parseArith(QmlJS::AST::Node *node, Result &type)
-{
- AST::BinaryExpression *expression = static_cast<AST::BinaryExpression *>(node);
-
- type.reg = acquireReg();
-
- Result lhs;
- Result rhs;
-
- if (!parseExpression(expression->left, lhs)) return false;
- if (!parseExpression(expression->right, rhs)) return false;
-
- if ((lhs.type == QVariant::Int || lhs.type == QMetaType::QReal) &&
- (rhs.type == QVariant::Int || rhs.type == QMetaType::QReal))
- return numberArith(type, lhs, rhs, (QSOperator::Op)expression->op);
- else if(expression->op == QSOperator::Sub)
- return numberArith(type, lhs, rhs, (QSOperator::Op)expression->op);
- else if ((lhs.type == QMetaType::QString || lhs.unknownType) &&
- (rhs.type == QMetaType::QString || rhs.unknownType) &&
- (lhs.type == QMetaType::QString || rhs.type == QMetaType::QString))
- return stringArith(type, lhs, rhs, (QSOperator::Op)expression->op);
- else
- return false;
-}
-
-bool QmlBindingCompilerPrivate::numberArith(Result &type, const Result &lhs, const Result &rhs, QSOperator::Op op)
-{
- bool nativeReal = rhs.type == QMetaType::QReal ||
- lhs.type == QMetaType::QReal ||
- lhs.unknownType ||
- rhs.unknownType;
-
- if (nativeReal && lhs.type == QMetaType::Int) {
- Instr convert;
- convert.common.type = Instr::ConvertIntToReal;
- convert.unaryop.output = lhs.reg;
- convert.unaryop.src = lhs.reg;
- bytecode << convert;
- }
-
- if (nativeReal && rhs.type == QMetaType::Int) {
- Instr convert;
- convert.common.type = Instr::ConvertIntToReal;
- convert.unaryop.output = rhs.reg;
- convert.unaryop.src = rhs.reg;
- bytecode << convert;
- }
-
- int lhsTmp = -1;
- int rhsTmp = -1;
- if (lhs.unknownType) {
- lhsTmp = acquireReg();
-
- Instr conv;
- conv.common.type = Instr::ConvertGenericToReal;
- conv.unaryop.output = lhsTmp;
- conv.unaryop.src = lhs.reg;
- bytecode << conv;
- }
-
- if (rhs.unknownType) {
- rhsTmp = acquireReg();
-
- Instr conv;
- conv.common.type = Instr::ConvertGenericToReal;
- conv.unaryop.output = rhsTmp;
- conv.unaryop.src = rhs.reg;
- bytecode << conv;
- }
-
- Instr arith;
- if (op == QSOperator::Add) {
- arith.common.type = nativeReal?Instr::AddReal:Instr::AddInt;
- } else if (op == QSOperator::Sub) {
- arith.common.type = nativeReal?Instr::MinusReal:Instr::MinusInt;
- } else {
- qFatal("Unsupported arithmetic operator");
- }
-
- arith.binaryop.output = type.reg;
- arith.binaryop.src1 = (lhsTmp == -1)?lhs.reg:lhsTmp;
- arith.binaryop.src2 = (rhsTmp == -1)?rhs.reg:rhsTmp;
- bytecode << arith;
-
- type.metaObject = 0;
- type.type = nativeReal?QMetaType::QReal:QMetaType::Int;
- type.subscriptionSet.unite(lhs.subscriptionSet);
- type.subscriptionSet.unite(rhs.subscriptionSet);
-
- if (lhsTmp != -1) releaseReg(lhsTmp);
- if (rhsTmp != -1) releaseReg(rhsTmp);
- releaseReg(lhs.reg);
- releaseReg(rhs.reg);
-
- return true;
-}
-
-bool QmlBindingCompilerPrivate::stringArith(Result &type, const Result &lhs, const Result &rhs, QSOperator::Op op)
-{
- if (op != QSOperator::Add)
- return false;
-
- int lhsTmp = -1;
- int rhsTmp = -1;
-
- if (lhs.unknownType) {
- lhsTmp = acquireReg(Instr::CleanupString);
-
- Instr convert;
- convert.common.type = Instr::ConvertGenericToString;
- convert.unaryop.output = lhsTmp;
- convert.unaryop.src = lhs.reg;
- bytecode << convert;
- }
-
- if (rhs.unknownType) {
- rhsTmp = acquireReg(Instr::CleanupString);
-
- Instr convert;
- convert.common.type = Instr::ConvertGenericToString;
- convert.unaryop.output = rhsTmp;
- convert.unaryop.src = rhs.reg;
- bytecode << convert;
- }
-
- type.reg = acquireReg(Instr::CleanupString);
- type.type = QMetaType::QString;
-
- Instr add;
- add.common.type = Instr::AddString;
- add.binaryop.output = type.reg;
- add.binaryop.src1 = (lhsTmp == -1)?lhs.reg:lhsTmp;
- add.binaryop.src2 = (rhsTmp == -1)?rhs.reg:rhsTmp;
- bytecode << add;
-
- if (lhsTmp != -1) releaseReg(lhsTmp);
- if (rhsTmp != -1) releaseReg(rhsTmp);
-
- return true;
-}
-
-bool QmlBindingCompilerPrivate::tryLogic(QmlJS::AST::Node *node)
-{
- if (node->kind != AST::Node::Kind_BinaryExpression)
- return false;
-
- AST::BinaryExpression *expression = static_cast<AST::BinaryExpression *>(node);
- if (expression->op == QSOperator::Gt ||
- expression->op == QSOperator::Equal ||
- expression->op == QSOperator::NotEqual)
- return true;
- else
- return false;
-}
-
-bool QmlBindingCompilerPrivate::parseLogic(QmlJS::AST::Node *node, Result &type)
-{
- AST::BinaryExpression *expression = static_cast<AST::BinaryExpression *>(node);
-
- Result lhs;
- Result rhs;
-
- if (!parseExpression(expression->left, lhs)) return false;
- if (!parseExpression(expression->right, rhs)) return false;
-
- type.reg = acquireReg();
- type.metaObject = 0;
- type.type = QVariant::Bool;
-
- if (lhs.type == QMetaType::QReal && rhs.type == QMetaType::QReal) {
-
- Instr op;
- if (expression->op == QSOperator::Gt)
- op.common.type = Instr::GreaterThanReal;
- else if (expression->op == QSOperator::Equal)
- op.common.type = Instr::CompareReal;
- else if (expression->op == QSOperator::NotEqual)
- op.common.type = Instr::NotCompareReal;
- else
- return false;
- op.binaryop.output = type.reg;
- op.binaryop.src1 = lhs.reg;
- op.binaryop.src2 = rhs.reg;
- bytecode << op;
-
-
- } else if (lhs.type == QMetaType::QString && rhs.type == QMetaType::QString) {
-
- Instr op;
- if (expression->op == QSOperator::Equal)
- op.common.type = Instr::CompareString;
- else if (expression->op == QSOperator::NotEqual)
- op.common.type = Instr::NotCompareString;
- else
- return false;
- op.binaryop.output = type.reg;
- op.binaryop.src1 = lhs.reg;
- op.binaryop.src2 = rhs.reg;
- bytecode << op;
-
- } else {
- return false;
- }
-
- releaseReg(lhs.reg);
- releaseReg(rhs.reg);
-
- return true;
-}
-
-bool QmlBindingCompilerPrivate::tryConditional(QmlJS::AST::Node *node)
-{
- return (node->kind == AST::Node::Kind_ConditionalExpression);
-}
-
-bool QmlBindingCompilerPrivate::parseConditional(QmlJS::AST::Node *node, Result &type)
-{
- AST::ConditionalExpression *expression = static_cast<AST::ConditionalExpression *>(node);
-
- AST::Node *test = expression->expression;
- if (test->kind == AST::Node::Kind_NestedExpression)
- test = static_cast<AST::NestedExpression*>(test)->expression;
-
- Result etype;
- if (!parseExpression(test, etype)) return false;
-
- if (etype.type != QVariant::Bool)
- return false;
-
- Instr skip;
- skip.common.type = Instr::Skip;
- skip.skip.reg = etype.reg;
- skip.skip.count = 0;
- int skipIdx = bytecode.count();
- bytecode << skip;
-
- // Release to allow reuse of reg
- releaseReg(etype.reg);
-
- QSet<QString> preSubSet = subscriptionSet;
-
- // int preConditionalSubscriptions = subscriptionSet.count();
-
- Result ok;
- if (!parseExpression(expression->ok, ok)) return false;
- if (ok.unknownType) return false;
-
- int skipIdx2 = bytecode.count();
- skip.skip.reg = -1;
- bytecode << skip;
-
- // Release to allow reuse of reg
- releaseReg(ok.reg);
- bytecode[skipIdx].skip.count = bytecode.count() - skipIdx - 1;
-
- subscriptionSet = preSubSet;
-
- Result ko;
- if (!parseExpression(expression->ko, ko)) return false;
- if (ko.unknownType) return false;
-
- // Release to allow reuse of reg
- releaseReg(ko.reg);
- bytecode[skipIdx2].skip.count = bytecode.count() - skipIdx2 - 1;
-
- if (ok != ko)
- return false; // Must be same type and in same register
-
- subscriptionSet = preSubSet;
-
- if (!subscriptionNeutral(subscriptionSet, ok.subscriptionSet, ko.subscriptionSet))
- return false; // Conditionals cannot introduce new subscriptions
-
- type = ok;
-
- return true;
-}
-
-bool QmlBindingCompilerPrivate::tryConstant(QmlJS::AST::Node *node)
-{
- return node->kind == AST::Node::Kind_TrueLiteral ||
- node->kind == AST::Node::Kind_FalseLiteral ||
- node->kind == AST::Node::Kind_NumericLiteral ||
- node->kind == AST::Node::Kind_StringLiteral;
-}
-
-bool QmlBindingCompilerPrivate::parseConstant(QmlJS::AST::Node *node, Result &type)
-{
- type.metaObject = 0;
- type.type = -1;
- type.reg = acquireReg();
-
- if (node->kind == AST::Node::Kind_TrueLiteral) {
- type.type = QVariant::Bool;
- Instr instr;
- instr.common.type = Instr::Bool;
- instr.bool_value.reg = type.reg;
- instr.bool_value.value = true;
- bytecode << instr;
- return true;
- } else if (node->kind == AST::Node::Kind_FalseLiteral) {
- type.type = QVariant::Bool;
- Instr instr;
- instr.common.type = Instr::Bool;
- instr.bool_value.reg = type.reg;
- instr.bool_value.value = false;
- bytecode << instr;
- return true;
- } else if (node->kind == AST::Node::Kind_NumericLiteral) {
- qreal value = qreal(static_cast<AST::NumericLiteral *>(node)->value);
-
- if (qreal(float(value)) != value)
- return false;
-
- type.type = QMetaType::QReal;
- Instr instr;
- instr.common.type = Instr::Real;
- instr.real_value.reg = type.reg;
- instr.real_value.value = float(value);
- bytecode << instr;
- return true;
- } else if (node->kind == AST::Node::Kind_StringLiteral) {
- QString str = static_cast<AST::StringLiteral *>(node)->value->asString();
- type.type = QMetaType::QString;
- type.reg = registerLiteralString(str);
- return true;
- } else {
- return false;
- }
-}
-
-bool QmlBindingCompilerPrivate::tryMethod(QmlJS::AST::Node *node)
-{
- return node->kind == AST::Node::Kind_CallExpression;
-}
-
-bool QmlBindingCompilerPrivate::parseMethod(QmlJS::AST::Node *node, Result &result)
-{
- AST::CallExpression *expr = static_cast<AST::CallExpression *>(node);
-
- QStringList name;
- if (!buildName(name, expr->base))
- return false;
-
- if (name.count() != 2 || name.at(0) != QLatin1String("Math"))
- return false;
-
- QString method = name.at(1);
-
- AST::ArgumentList *args = expr->arguments;
- if (!args) return false;
- AST::ExpressionNode *arg0 = args->expression;
- args = args->next;
- if (!args) return false;
- AST::ExpressionNode *arg1 = args->expression;
- if (args->next != 0) return false;
- if (!arg0 || !arg1) return false;
-
- Result r0;
- if (!parseExpression(arg0, r0)) return false;
- Result r1;
- if (!parseExpression(arg1, r1)) return false;
-
- if (r0.type != QMetaType::QReal || r1.type != QMetaType::QReal)
- return false;
-
- Instr op;
- if (method == QLatin1String("max")) {
- op.common.type = Instr::MaxReal;
- } else if (method == QLatin1String("min")) {
- op.common.type = Instr::MinReal;
- } else {
- return false;
- }
- // We release early to reuse registers
- releaseReg(r0.reg);
- releaseReg(r1.reg);
-
- op.binaryop.output = acquireReg();
- op.binaryop.src1 = r0.reg;
- op.binaryop.src2 = r1.reg;
- bytecode << op;
-
- result.type = QMetaType::QReal;
- result.reg = op.binaryop.output;
-
- return true;
-}
-
-bool QmlBindingCompilerPrivate::buildName(QStringList &name,
- QmlJS::AST::Node *node,
- QList<QmlJS::AST::ExpressionNode *> *nodes)
-{
- if (node->kind == AST::Node::Kind_IdentifierExpression) {
- name << static_cast<AST::IdentifierExpression*>(node)->name->asString();
- if (nodes) *nodes << static_cast<AST::IdentifierExpression*>(node);
- } else if (node->kind == AST::Node::Kind_FieldMemberExpression) {
- AST::FieldMemberExpression *expr =
- static_cast<AST::FieldMemberExpression *>(node);
-
- if (!buildName(name, expr->base, nodes))
- return false;
-
- name << expr->name->asString();
- if (nodes) *nodes << expr;
- } else {
- return false;
- }
-
- return true;
-}
-
-
-bool QmlBindingCompilerPrivate::fetch(Result &rv, const QMetaObject *mo, int reg,
- int idx, const QStringList &subName, QmlJS::AST::ExpressionNode *node)
-{
- QMetaProperty prop = mo->property(idx);
- rv.metaObject = 0;
- rv.type = 0;
-
- if (subscription(subName, &rv) && prop.hasNotifySignal() && prop.notifySignalIndex() != -1) {
- Instr sub;
- sub.common.type = Instr::Subscribe;
- sub.subscribe.offset = subscriptionIndex(subName);
- sub.subscribe.reg = reg;
- sub.subscribe.index = prop.notifySignalIndex();
- bytecode << sub;
- }
-
- Instr fetch;
- fetch.common.type = Instr::Fetch;
- fetch.fetch.objectReg = reg;
- fetch.fetch.index = idx;
- fetch.fetch.output = reg;
- fetch.fetch.exceptionId = exceptionId(node);
-
- rv.type = prop.userType();
- rv.metaObject = engine->metaObjectForType(rv.type);
- rv.reg = reg;
-
- if (rv.type == QMetaType::QString) {
- int tmp = acquireReg();
- Instr copy;
- copy.common.type = Instr::Copy;
- copy.copy.reg = tmp;
- copy.copy.src = reg;
- bytecode << copy;
- releaseReg(tmp);
- fetch.fetch.objectReg = tmp;
-
- Instr setup;
- setup.common.type = Instr::NewString;
- setup.construct.reg = reg;
- bytecode << setup;
- registerCleanup(reg, Instr::CleanupString);
- }
-
- bytecode << fetch;
-
- if (!rv.metaObject &&
- rv.type != QMetaType::QReal &&
- rv.type != QMetaType::Int &&
- rv.type != QMetaType::Bool &&
- rv.type != qMetaTypeId<QmlGraphicsAnchorLine>() &&
- rv.type != QMetaType::QString) {
- rv.metaObject = 0;
- rv.type = 0;
- return false; // Unsupported type (string not supported yet);
- }
-
- return true;
-}
-
-void QmlBindingCompilerPrivate::registerCleanup(int reg, int cleanup, int cleanupType)
-{
- registerCleanups.insert(reg, qMakePair(cleanup, cleanupType));
-}
-
-int QmlBindingCompilerPrivate::acquireReg(int cleanup, int cleanupType)
-{
- for (int ii = 0; ii < 32; ++ii) {
- if (!(registers & (1 << ii))) {
- registers |= (1 << ii);
-
- if (cleanup != Instr::Noop)
- registerCleanup(ii, cleanup, cleanupType);
-
- return ii;
- }
- }
- return -1;
-}
-
-void QmlBindingCompilerPrivate::releaseReg(int reg)
-{
- Q_ASSERT(reg >= 0 && reg <= 31);
-
- if (registerCleanups.contains(reg)) {
- QPair<int, int> c = registerCleanups[reg];
- registerCleanups.remove(reg);
- Instr cleanup;
- cleanup.common.type = (quint8)c.first;
- cleanup.cleanup.reg = reg;
- bytecode << cleanup;
- }
-
- quint32 mask = 1 << reg;
- registers &= ~mask;
-}
-
-// Returns a reg
-int QmlBindingCompilerPrivate::registerLiteralString(const QString &str)
-{
- QByteArray strdata((const char *)str.constData(), str.length() * sizeof(QChar));
- int offset = data.count();
- data += strdata;
-
- int reg = acquireReg(Instr::CleanupString);
-
- Instr string;
- string.common.type = Instr::String;
- string.string_value.reg = reg;
- string.string_value.offset = offset;
- string.string_value.length = str.length();
- bytecode << string;
-
- return reg;
-}
-
-// Returns an identifier offset
-int QmlBindingCompilerPrivate::registerString(const QString &string)
-{
- Q_ASSERT(!string.isEmpty());
-
- QHash<QString, QPair<int, int> >::ConstIterator iter = registeredStrings.find(string);
-
- if (iter == registeredStrings.end()) {
- quint32 len = string.length();
- QByteArray lendata((const char *)&len, sizeof(quint32));
- QByteArray strdata((const char *)string.constData(), string.length() * sizeof(QChar));
- strdata.prepend(lendata);
- int rv = data.count();
- data += strdata;
-
- iter = registeredStrings.insert(string, qMakePair(registeredStrings.count(), rv));
- }
-
- Instr reg;
- reg.common.type = Instr::InitString;
- reg.initstring.offset = iter->first;
- reg.initstring.dataIdx = iter->second;
- bytecode << reg;
- return reg.initstring.offset;
-}
-
-bool QmlBindingCompilerPrivate::subscription(const QStringList &sub, Result *result)
-{
- QString str = sub.join(QLatin1String("."));
- result->subscriptionSet.insert(str);
-
- if (subscriptionSet.contains(str)) {
- return false;
- } else {
- subscriptionSet.insert(str);
- return true;
- }
-}
-
-int QmlBindingCompilerPrivate::subscriptionIndex(const QStringList &sub)
-{
- QString str = sub.join(QLatin1String("."));
- QHash<QString, int>::ConstIterator iter = subscriptionIds.find(str);
- if (iter == subscriptionIds.end())
- iter = subscriptionIds.insert(str, subscriptionIds.count());
- usedSubscriptionIds.insert(*iter);
- return *iter;
-}
-
-/*
- Returns true if lhs contains no subscriptions that aren't also in base or rhs AND
- rhs contains no subscriptions that aren't also in base or lhs.
-*/
-bool QmlBindingCompilerPrivate::subscriptionNeutral(const QSet<QString> &base,
- const QSet<QString> &lhs,
- const QSet<QString> &rhs)
-{
- QSet<QString> difflhs = lhs;
- difflhs.subtract(rhs);
- QSet<QString> diffrhs = rhs;
- diffrhs.subtract(lhs);
-
- difflhs.unite(diffrhs);
- difflhs.subtract(base);
-
- return difflhs.isEmpty();
-}
-
-quint8 QmlBindingCompilerPrivate::exceptionId(QmlJS::AST::ExpressionNode *n)
-{
- quint8 rv = 0xFF;
- if (n && exceptions.count() < 0xFF) {
- rv = (quint8)exceptions.count();
- QmlJS::AST::SourceLocation l = n->firstSourceLocation();
- quint64 e = l.startLine;
- e <<= 32;
- e |= l.startColumn;
- exceptions.append(e);
- }
- return rv;
-}
-
-QmlBindingCompiler::QmlBindingCompiler()
-: d(new QmlBindingCompilerPrivate)
-{
-}
-
-QmlBindingCompiler::~QmlBindingCompiler()
-{
- delete d; d = 0;
-}
-
-/*
-Returns true if any bindings were compiled.
-*/
-bool QmlBindingCompiler::isValid() const
-{
- return !d->committed.bytecode.isEmpty();
-}
-
-/*
--1 on failure, otherwise the binding index to use.
-*/
-int QmlBindingCompiler::compile(const Expression &expression, QmlEnginePrivate *engine)
-{
- if (!expression.expression.asAST()) return false;
-
- d->context = expression.context;
- d->component = expression.component;
- d->destination = expression.property;
- d->ids = expression.ids;
- d->imports = expression.imports;
- d->engine = engine;
-
- if (d->compile(expression.expression.asAST())) {
- return d->commitCompile();
- } else {
- return -1;
- }
-}
-
-
-QByteArray QmlBindingCompilerPrivate::buildSignalTable() const
-{
- QHash<int, QList<int> > table;
-
- for (int ii = 0; ii < committed.count(); ++ii) {
- const QSet<int> &deps = committed.dependencies.at(ii);
- for (QSet<int>::ConstIterator iter = deps.begin(); iter != deps.end(); ++iter)
- table[*iter].append(ii);
- }
-
- QVector<quint32> header;
- QVector<quint32> data;
- for (int ii = 0; ii < committed.subscriptionIds.count(); ++ii) {
- header.append(committed.subscriptionIds.count() + data.count());
- const QList<int> &bindings = table[ii];
- data.append(bindings.count());
- for (int jj = 0; jj < bindings.count(); ++jj)
- data.append(bindings.at(jj));
- }
- header << data;
-
- return QByteArray((const char *)header.constData(), header.count() * sizeof(quint32));
-}
-
-QByteArray QmlBindingCompilerPrivate::buildExceptionData() const
-{
- QByteArray rv;
- rv.resize(committed.exceptions.count() * sizeof(quint64));
- ::memcpy(rv.data(), committed.exceptions.constData(), rv.size());
- return rv;
-}
-
-/*
-Returns the compiled program.
-*/
-QByteArray QmlBindingCompiler::program() const
-{
- QByteArray programData;
-
- if (isValid()) {
- Program prog;
- prog.bindings = d->committed.count();
-
- QVector<Instr> bytecode;
- Instr skip;
- skip.common.type = Instr::Skip;
- skip.skip.reg = -1;
- for (int ii = 0; ii < d->committed.count(); ++ii) {
- skip.skip.count = d->committed.count() - ii - 1;
- skip.skip.count+= d->committed.offsets.at(ii);
- bytecode << skip;
- }
- bytecode << d->committed.bytecode;
-
- QByteArray data = d->committed.data;
- while (data.count() % 4) data.append('\0');
- prog.signalTableOffset = data.count();
- data += d->buildSignalTable();
- while (data.count() % 4) data.append('\0');
- prog.exceptionDataOffset = data.count();
- data += d->buildExceptionData();
-
- prog.dataLength = 4 * ((data.size() + 3) / 4);
- prog.subscriptions = d->committed.subscriptionIds.count();
- prog.identifiers = d->committed.registeredStrings.count();
- prog.instructionCount = bytecode.count();
- int size = sizeof(Program) + bytecode.count() * sizeof(Instr);
- size += prog.dataLength;
-
- programData.resize(size);
- memcpy(programData.data(), &prog, sizeof(Program));
- if (prog.dataLength)
- memcpy((char *)((Program *)programData.data())->data(), data.constData(),
- data.size());
- memcpy((char *)((Program *)programData.data())->instructions(), bytecode.constData(),
- bytecode.count() * sizeof(Instr));
- }
-
- return programData;
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompiledbindings_p.h b/src/declarative/qml/qmlcompiledbindings_p.h
deleted file mode 100644
index 056cc21..0000000
--- a/src/declarative/qml/qmlcompiledbindings_p.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLBINDINGOPTIMIZATIONS_P_H
-#define QMLBINDINGOPTIMIZATIONS_P_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 "qmlexpression_p.h"
-#include "qmlbinding_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QmlBindingCompilerPrivate;
-class QmlBindingCompiler
-{
-public:
- QmlBindingCompiler();
- ~QmlBindingCompiler();
-
- // Returns true if bindings were compiled
- bool isValid() const;
-
- struct Expression
- {
- QmlParser::Object *component;
- QmlParser::Object *context;
- QmlParser::Property *property;
- QmlParser::Variant expression;
- QHash<QString, QmlParser::Object *> ids;
- QmlEnginePrivate::Imports imports;
- };
-
- // -1 on failure, otherwise the binding index to use
- int compile(const Expression &, QmlEnginePrivate *);
-
- // Returns the compiled program
- QByteArray program() const;
-
- static void dump(const QByteArray &);
-private:
- QmlBindingCompilerPrivate *d;
-};
-
-class QmlCompiledBindingsPrivate;
-class QmlCompiledBindings : public QObject, public QmlAbstractExpression, public QmlRefCount
-{
-public:
- QmlCompiledBindings(const char *program, QmlContext *context);
- virtual ~QmlCompiledBindings();
-
- QmlAbstractBinding *configBinding(int index, QObject *target, QObject *scope, int property);
-
-protected:
- int qt_metacall(QMetaObject::Call, int, void **);
-
-private:
- Q_DISABLE_COPY(QmlCompiledBindings);
- Q_DECLARE_PRIVATE(QmlCompiledBindings);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLBINDINGOPTIMIZATIONS_P_H
-
diff --git a/src/declarative/qml/qmlcompileddata.cpp b/src/declarative/qml/qmlcompileddata.cpp
deleted file mode 100644
index 0120f56..0000000
--- a/src/declarative/qml/qmlcompileddata.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlcompiler_p.h"
-#include "qmlengine.h"
-#include "qmlcomponent.h"
-#include "qmlcomponent_p.h"
-#include "qmlcontext.h"
-#include "qmlcontext_p.h"
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-int QmlCompiledData::pack(const char *data, size_t size)
-{
- const char *p = packData.constData();
- unsigned int ps = packData.size();
-
- for (unsigned int ii = 0; (ii + size) <= ps; ii += sizeof(int)) {
- if (0 == ::memcmp(p + ii, data, size))
- return ii;
- }
-
- int rv = packData.size();
- packData.append(data, size);
- return rv;
-}
-
-int QmlCompiledData::indexForString(const QString &data)
-{
- int idx = primitives.indexOf(data);
- if (idx == -1) {
- idx = primitives.count();
- primitives << data;
- }
- return idx;
-}
-
-int QmlCompiledData::indexForByteArray(const QByteArray &data)
-{
- int idx = datas.indexOf(data);
- if (idx == -1) {
- idx = datas.count();
- datas << data;
- }
- return idx;
-}
-
-int QmlCompiledData::indexForUrl(const QUrl &data)
-{
- int idx = urls.indexOf(data);
- if (idx == -1) {
- idx = urls.count();
- urls << data;
- }
- return idx;
-}
-
-int QmlCompiledData::indexForFloat(float *data, int count)
-{
- Q_ASSERT(count > 0);
-
- for (int ii = 0; ii <= floatData.count() - count; ++ii) {
- bool found = true;
- for (int jj = 0; jj < count; ++jj) {
- if (floatData.at(ii + jj) != data[jj]) {
- found = false;
- break;
- }
- }
-
- if (found)
- return ii;
- }
-
- int idx = floatData.count();
- for (int ii = 0; ii < count; ++ii)
- floatData << data[ii];
-
- return idx;
-}
-
-int QmlCompiledData::indexForInt(int *data, int count)
-{
- Q_ASSERT(count > 0);
-
- for (int ii = 0; ii <= intData.count() - count; ++ii) {
- bool found = true;
- for (int jj = 0; jj < count; ++jj) {
- if (intData.at(ii + jj) != data[jj]) {
- found = false;
- break;
- }
- }
-
- if (found)
- return ii;
- }
-
- int idx = intData.count();
- for (int ii = 0; ii < count; ++ii)
- intData << data[ii];
-
- return idx;
-}
-
-int QmlCompiledData::indexForLocation(const QmlParser::Location &l)
-{
- // ### FIXME
- int rv = locations.count();
- locations << l;
- return rv;
-}
-
-int QmlCompiledData::indexForLocation(const QmlParser::LocationSpan &l)
-{
- // ### FIXME
- int rv = locations.count();
- locations << l.start << l.end;
- return rv;
-}
-
-QmlCompiledData::QmlCompiledData(QmlEngine *engine)
-: QmlCleanup(engine), importCache(0), root(0), rootPropertyCache(0)
-{
-}
-
-QmlCompiledData::~QmlCompiledData()
-{
- for (int ii = 0; ii < types.count(); ++ii) {
- if (types.at(ii).ref)
- types.at(ii).ref->release();
- }
-
- for (int ii = 0; ii < propertyCaches.count(); ++ii)
- propertyCaches.at(ii)->release();
-
- for (int ii = 0; ii < contextCaches.count(); ++ii)
- contextCaches.at(ii)->release();
-
- if (importCache)
- importCache->release();
-
- if (rootPropertyCache)
- rootPropertyCache->release();
-
- qDeleteAll(cachedPrograms);
- qDeleteAll(cachedClosures);
-}
-
-void QmlCompiledData::clear()
-{
- qDeleteAll(cachedPrograms);
- qDeleteAll(cachedClosures);
- for (int ii = 0; ii < cachedClosures.count(); ++ii)
- cachedClosures[ii] = 0;
- for (int ii = 0; ii < cachedPrograms.count(); ++ii)
- cachedPrograms[ii] = 0;
-}
-
-
-QObject *QmlCompiledData::TypeReference::createInstance(QmlContext *ctxt, const QBitField &bindings) const
-{
- if (type) {
- QObject *rv = type->create();
- if (rv)
- QmlEngine::setContextForObject(rv, ctxt);
- return rv;
- } else {
- Q_ASSERT(component);
- return QmlComponentPrivate::get(component)->create(ctxt, bindings);
- }
-}
-
-const QMetaObject *QmlCompiledData::TypeReference::metaObject() const
-{
- if (type) {
- return type->metaObject();
- } else {
- Q_ASSERT(component);
- return static_cast<QmlComponentPrivate *>(QObjectPrivate::get(component))->cc->root;
- }
-}
-
-void QmlCompiledData::dumpInstructions()
-{
- if (!name.isEmpty())
- qWarning() << name;
- qWarning().nospace() << "Index\tLine\tOperation\t\tData1\tData2\tData3\tComments";
- qWarning().nospace() << "-------------------------------------------------------------------------------";
- for (int ii = 0; ii < bytecode.count(); ++ii) {
- dump(&bytecode[ii], ii);
- }
- qWarning().nospace() << "-------------------------------------------------------------------------------";
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
deleted file mode 100644
index 3702d0b..0000000
--- a/src/declarative/qml/qmlcompiler.cpp
+++ /dev/null
@@ -1,2779 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlcompiler_p.h"
-
-#include "qmlcompositetypedata_p.h"
-#include "qmlparser_p.h"
-#include "qmlscriptparser_p.h"
-#include "qmlpropertyvaluesource.h"
-#include "qmlcomponent.h"
-#include "qmetaobjectbuilder_p.h"
-#include "qmlstringconverters_p.h"
-#include "qmlengine_p.h"
-#include "qmlengine.h"
-#include "qmlcontext.h"
-#include "qmlmetatype.h"
-#include "qmlcustomparser_p_p.h"
-#include "qmlcontext_p.h"
-#include "qmlcomponent_p.h"
-#include "parser/qmljsast_p.h"
-#include "qmlvmemetaobject_p.h"
-#include "qmlexpression_p.h"
-#include "qmlmetaproperty_p.h"
-#include "qmlrewrite_p.h"
-#include "qmlscriptstring.h"
-#include "qmlglobal_p.h"
-#include "qmlscriptparser_p.h"
-#include "qmlbinding_p.h"
-#include "qmlcompiledbindings_p.h"
-
-#include <qfxperf_p_p.h>
-
-#include <QCoreApplication>
-#include <QColor>
-#include <QDebug>
-#include <QPointF>
-#include <QSizeF>
-#include <QRectF>
-#include <QAtomicInt>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP);
-DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATISTICS_DUMP);
-DEFINE_BOOL_CONFIG_OPTION(qmlExperimental, QML_EXPERIMENTAL);
-
-using namespace QmlParser;
-
-/*!
- Instantiate a new QmlCompiler.
-*/
-QmlCompiler::QmlCompiler()
-: output(0), engine(0), unitRoot(0), unit(0)
-{
-}
-
-/*!
- Returns true if the last call to compile() caused errors.
-
- \sa errors()
-*/
-bool QmlCompiler::isError() const
-{
- return !exceptions.isEmpty();
-}
-
-/*!
- Return the list of errors from the last call to compile(), or an empty list
- if there were no errors.
-*/
-QList<QmlError> QmlCompiler::errors() const
-{
- return exceptions;
-}
-
-/*!
- Returns true if \a val is a legal object id, false otherwise.
-
- Legal ids must start with a lower-case letter or underscore, and contain only
- letters, numbers and underscores.
-*/
-bool QmlCompiler::isValidId(const QString &val)
-{
- if (val.isEmpty())
- return false;
-
- if (val.at(0).isLetter() && !val.at(0).isLower()) {
- qWarning().nospace() << "id " << val << " is invalid: ids cannot start with uppercase letters";
- return false;
- }
-
- QChar u(QLatin1Char('_'));
- for (int ii = 0; ii < val.count(); ++ii)
- if (val.at(ii) != u &&
- ((ii == 0 && !val.at(ii).isLetter()) ||
- (ii != 0 && !val.at(ii).isLetterOrNumber())) )
- return false;
-
- return true;
-}
-
-/*!
- Returns true if \a name refers to an attached property, false otherwise.
-
- Attached property names are those that start with a capital letter.
-*/
-bool QmlCompiler::isAttachedPropertyName(const QByteArray &name)
-{
- return !name.isEmpty() && name.at(0) >= 'A' && name.at(0) <= 'Z';
-}
-
-/*!
- Returns true if \a name refers to a signal property, false otherwise.
-
- Signal property names are those that start with "on", followed by a capital
- letter.
-*/
-bool QmlCompiler::isSignalPropertyName(const QByteArray &name)
-{
- return name.length() >= 3 && name.startsWith("on") &&
- 'A' <= name.at(2) && 'Z' >= name.at(2);
-}
-
-/*!
- \macro COMPILE_EXCEPTION
- \internal
- Inserts an error into the QmlCompiler error list, and returns false
- (failure).
-
- \a token is used to source the error line and column, and \a desc is the
- error itself. \a desc can be an expression that can be piped into QDebug.
-
- For example:
-
- \code
- COMPILE_EXCEPTION(property, QCoreApplication::translate("QmlCompiler","Error for property \"%1\"").arg(QString::fromUtf8(property->name)));
- \endcode
-*/
-#define COMPILE_EXCEPTION(token, desc) \
- { \
- QString exceptionDescription; \
- QmlError error; \
- error.setUrl(output->url); \
- error.setLine((token)->location.start.line); \
- error.setColumn((token)->location.start.column); \
- error.setDescription(desc.trimmed()); \
- exceptions << error; \
- return false; \
- }
-
-/*!
- \macro COMPILE_CHECK
- \internal
- Returns false if \a is false, otherwise does nothing.
-*/
-#define COMPILE_CHECK(a) \
- { \
- if (!a) return false; \
- }
-
-/*!
- Returns true if literal \a v can be assigned to property \a prop, otherwise
- false.
-
- This test corresponds to action taken by genLiteralAssignment(). Any change
- made here, must have a corresponding action in genLiteralAssigment().
-*/
-bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop,
- QmlParser::Value *v)
-{
- QString string = v->value.asScript();
-
- if (!prop.isWritable())
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name())));
-
- if (prop.isEnumType()) {
- int value;
- if (prop.isFlagType()) {
- value = prop.enumerator().keysToValue(string.toUtf8().constData());
- } else
- value = prop.enumerator().keyToValue(string.toUtf8().constData());
- if (value == -1)
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: unknown enumeration"));
- return true;
- }
- int type = prop.userType();
- switch(type) {
- case -1:
- break;
- case QVariant::String:
- if (!v->value.isString()) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: string expected"));
- break;
- case QVariant::Url:
- if (!v->value.isString()) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: url expected"));
- break;
- case QVariant::UInt:
- {
- bool ok;
- string.toUInt(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: unsigned int expected"));
- }
- break;
- case QVariant::Int:
- {
- bool ok;
- string.toInt(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: int expected"));
- }
- break;
- case QMetaType::Float:
- {
- bool ok;
- string.toFloat(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: float expected"));
- }
- break;
- case QVariant::Double:
- {
- bool ok;
- string.toDouble(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: double expected"));
- }
- break;
- case QVariant::Color:
- {
- bool ok;
- QmlStringConverters::colorFromString(string, &ok);
- if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: color expected"));
- }
- break;
- case QVariant::Date:
- {
- bool ok;
- QmlStringConverters::dateFromString(string, &ok);
- if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: date expected"));
- }
- break;
- case QVariant::Time:
- {
- bool ok;
- QmlStringConverters::timeFromString(string, &ok);
- if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: time expected"));
- }
- break;
- case QVariant::DateTime:
- {
- bool ok;
- QmlStringConverters::dateTimeFromString(string, &ok);
- if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: datetime expected"));
- }
- break;
- case QVariant::Point:
- case QVariant::PointF:
- {
- bool ok;
- QPointF point = QmlStringConverters::pointFFromString(string, &ok);
- if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: point expected"));
- }
- break;
- case QVariant::Size:
- case QVariant::SizeF:
- {
- bool ok;
- QSizeF size = QmlStringConverters::sizeFFromString(string, &ok);
- if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: size expected"));
- }
- break;
- case QVariant::Rect:
- case QVariant::RectF:
- {
- bool ok;
- QRectF rect = QmlStringConverters::rectFFromString(string, &ok);
- if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: rect expected"));
- }
- break;
- case QVariant::Bool:
- {
- if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: boolean expected"));
- }
- break;
- case QVariant::Vector3D:
- {
- bool ok;
- QmlStringConverters::vector3DFromString(string, &ok);
- if (!ok) COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: 3D vector expected"));
- }
- break;
- default:
- {
- int t = prop.userType();
- QmlMetaType::StringConverter converter =
- QmlMetaType::customStringConverter(t);
- if (!converter)
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QVariant::typeToName(prop.type()))));
- }
- break;
- }
- return true;
-}
-
-/*!
- Generate a store instruction for assigning literal \a v to property \a prop.
-
- Any literal assignment that is approved in testLiteralAssignment() must have
- a corresponding action in this method.
-*/
-void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop,
- QmlParser::Value *v)
-{
- QString string = v->value.asScript();
-
- QmlInstruction instr;
- instr.line = v->location.start.line;
- if (prop.isEnumType()) {
- int value;
- if (prop.isFlagType()) {
- value = prop.enumerator().keysToValue(string.toUtf8().constData());
- } else
- value = prop.enumerator().keyToValue(string.toUtf8().constData());
-
- instr.type = QmlInstruction::StoreInteger;
- instr.storeInteger.propertyIndex = prop.propertyIndex();
- instr.storeInteger.value = value;
- output->bytecode << instr;
- return;
- }
-
- int type = prop.userType();
- switch(type) {
- case -1:
- {
- instr.type = QmlInstruction::StoreVariant;
- instr.storeString.propertyIndex = prop.propertyIndex();
- instr.storeString.value = output->indexForString(string);
- }
- break;
- case QVariant::String:
- {
- instr.type = QmlInstruction::StoreString;
- instr.storeString.propertyIndex = prop.propertyIndex();
- instr.storeString.value = output->indexForString(string);
- }
- break;
- case QVariant::Url:
- {
- instr.type = QmlInstruction::StoreUrl;
- QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(QUrl(string));
- instr.storeUrl.propertyIndex = prop.propertyIndex();
- instr.storeUrl.value = output->indexForUrl(u);
- }
- break;
- case QVariant::UInt:
- {
- instr.type = QmlInstruction::StoreInteger;
- instr.storeInteger.propertyIndex = prop.propertyIndex();
- instr.storeInteger.value = string.toUInt();
- }
- break;
- case QVariant::Int:
- {
- instr.type = QmlInstruction::StoreInteger;
- instr.storeInteger.propertyIndex = prop.propertyIndex();
- instr.storeInteger.value = string.toInt();
- }
- break;
- case QMetaType::Float:
- {
- instr.type = QmlInstruction::StoreFloat;
- instr.storeFloat.propertyIndex = prop.propertyIndex();
- instr.storeFloat.value = string.toFloat();
- }
- break;
- case QVariant::Double:
- {
- instr.type = QmlInstruction::StoreDouble;
- instr.storeDouble.propertyIndex = prop.propertyIndex();
- instr.storeDouble.value = string.toDouble();
- }
- break;
- case QVariant::Color:
- {
- QColor c = QmlStringConverters::colorFromString(string);
- instr.type = QmlInstruction::StoreColor;
- instr.storeColor.propertyIndex = prop.propertyIndex();
- instr.storeColor.value = c.rgba();
- }
- break;
- case QVariant::Date:
- {
- QDate d = QmlStringConverters::dateFromString(string);
- instr.type = QmlInstruction::StoreDate;
- instr.storeDate.propertyIndex = prop.propertyIndex();
- instr.storeDate.value = d.toJulianDay();
- }
- break;
- case QVariant::Time:
- {
- QTime time = QmlStringConverters::timeFromString(string);
- int data[] = { time.hour(), time.minute(),
- time.second(), time.msec() };
- int index = output->indexForInt(data, 4);
- instr.type = QmlInstruction::StoreTime;
- instr.storeTime.propertyIndex = prop.propertyIndex();
- instr.storeTime.valueIndex = index;
- }
- break;
- case QVariant::DateTime:
- {
- QDateTime dateTime = QmlStringConverters::dateTimeFromString(string);
- int data[] = { dateTime.date().toJulianDay(),
- dateTime.time().hour(),
- dateTime.time().minute(),
- dateTime.time().second(),
- dateTime.time().msec() };
- int index = output->indexForInt(data, 5);
- instr.type = QmlInstruction::StoreDateTime;
- instr.storeDateTime.propertyIndex = prop.propertyIndex();
- instr.storeDateTime.valueIndex = index;
- }
- break;
- case QVariant::Point:
- case QVariant::PointF:
- {
- bool ok;
- QPointF point =
- QmlStringConverters::pointFFromString(string, &ok);
- float data[] = { point.x(), point.y() };
- int index = output->indexForFloat(data, 2);
- if (type == QVariant::PointF)
- instr.type = QmlInstruction::StorePointF;
- else
- instr.type = QmlInstruction::StorePoint;
- instr.storeRealPair.propertyIndex = prop.propertyIndex();
- instr.storeRealPair.valueIndex = index;
- }
- break;
- case QVariant::Size:
- case QVariant::SizeF:
- {
- bool ok;
- QSizeF size = QmlStringConverters::sizeFFromString(string, &ok);
- float data[] = { size.width(), size.height() };
- int index = output->indexForFloat(data, 2);
- if (type == QVariant::SizeF)
- instr.type = QmlInstruction::StoreSizeF;
- else
- instr.type = QmlInstruction::StoreSize;
- instr.storeRealPair.propertyIndex = prop.propertyIndex();
- instr.storeRealPair.valueIndex = index;
- }
- break;
- case QVariant::Rect:
- case QVariant::RectF:
- {
- bool ok;
- QRectF rect = QmlStringConverters::rectFFromString(string, &ok);
- float data[] = { rect.x(), rect.y(),
- rect.width(), rect.height() };
- int index = output->indexForFloat(data, 4);
- if (type == QVariant::RectF)
- instr.type = QmlInstruction::StoreRectF;
- else
- instr.type = QmlInstruction::StoreRect;
- instr.storeRect.propertyIndex = prop.propertyIndex();
- instr.storeRect.valueIndex = index;
- }
- break;
- case QVariant::Bool:
- {
- bool b = v->value.asBoolean();
- instr.type = QmlInstruction::StoreBool;
- instr.storeBool.propertyIndex = prop.propertyIndex();
- instr.storeBool.value = b;
- }
- break;
- case QVariant::Vector3D:
- {
- bool ok;
- QVector3D vector =
- QmlStringConverters::vector3DFromString(string, &ok);
- float data[] = { vector.x(), vector.y(), vector.z() };
- int index = output->indexForFloat(data, 3);
- instr.type = QmlInstruction::StoreVector3D;
- instr.storeRealPair.propertyIndex = prop.propertyIndex();
- instr.storeRealPair.valueIndex = index;
- }
- break;
- default:
- {
- int t = prop.userType();
- int index = output->customTypeData.count();
- instr.type = QmlInstruction::AssignCustomType;
- instr.assignCustomType.propertyIndex = prop.propertyIndex();
- instr.assignCustomType.valueIndex = index;
-
- QmlCompiledData::CustomTypeData data;
- data.index = output->indexForString(string);
- data.type = t;
- output->customTypeData << data;
- }
- break;
- }
- output->bytecode << instr;
-}
-
-/*!
- Resets data by clearing the lists that the QmlCompiler modifies.
-*/
-void QmlCompiler::reset(QmlCompiledData *data)
-{
- data->types.clear();
- data->primitives.clear();
- data->floatData.clear();
- data->intData.clear();
- data->customTypeData.clear();
- data->datas.clear();
- data->bytecode.clear();
-}
-
-/*!
- Compile \a unit, and store the output in \a out. \a engine is the QmlEngine
- with which the QmlCompiledData will be associated.
-
- Returns true on success, false on failure. On failure, the compile errors
- are available from errors().
-
- If the environment variant QML_COMPILER_DUMP is set
- (eg. QML_COMPILER_DUMP=1) the compiled instructions will be dumped to stderr
- on a successful compiler.
-*/
-bool QmlCompiler::compile(QmlEngine *engine,
- QmlCompositeTypeData *unit,
- QmlCompiledData *out)
-{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::Compilation> pc;
-#endif
- exceptions.clear();
-
- Q_ASSERT(out);
- reset(out);
-
- output = out;
-
- // Compile types
- for (int ii = 0; ii < unit->types.count(); ++ii) {
- QmlCompositeTypeData::TypeReference &tref = unit->types[ii];
- QmlCompiledData::TypeReference ref;
- QmlScriptParser::TypeReference *parserRef = unit->data.referencedTypes().at(ii);
- if (tref.type)
- ref.type = tref.type;
- else if (tref.unit) {
- ref.component = tref.unit->toComponent(engine);
-
- if (ref.component->isError()) {
- QmlError error;
- error.setUrl(output->url);
- error.setDescription(QLatin1String("Unable to create type ") +
- parserRef->name);
- if (!parserRef->refObjects.isEmpty()) {
- QmlParser::Object *parserObject = parserRef->refObjects.first();
- error.setLine(parserObject->location.start.line);
- error.setColumn(parserObject->location.start.column);
- }
-
- exceptions << error;
- exceptions << ref.component->errors();
- reset(out);
- return false;
- }
- ref.ref = tref.unit;
- ref.ref->addref();
- }
- ref.className = parserRef->name.toUtf8();
- out->types << ref;
- }
-
- Object *root = unit->data.tree();
- Q_ASSERT(root);
-
- this->engine = engine;
- this->unit = unit;
- this->unitRoot = root;
- compileTree(root);
-
- if (!isError()) {
- if (compilerDump())
- out->dumpInstructions();
- if (compilerStatDump())
- dumpStats();
- } else {
- reset(out);
- }
-
- compileState = ComponentCompileState();
- savedCompileStates.clear();
- output = 0;
- this->engine = 0;
- this->unit = 0;
- this->unitRoot = 0;
-
- return !isError();
-}
-
-void QmlCompiler::compileTree(Object *tree)
-{
- compileState.root = tree;
-
- if (!buildObject(tree, BindingContext()) || !completeComponentBuild())
- return;
-
- QmlInstruction init;
- init.type = QmlInstruction::Init;
- init.line = 0;
- init.init.bindingsSize = compileState.bindings.count();
- init.init.parserStatusSize = compileState.parserStatusCount;
- init.init.contextCache = genContextCache();
- if (compileState.compiledBindingData.isEmpty())
- init.init.compiledBinding = -1;
- else
- init.init.compiledBinding = output->indexForByteArray(compileState.compiledBindingData);
- output->bytecode << init;
-
- genObject(tree);
-
- QmlInstruction def;
- init.line = 0;
- def.type = QmlInstruction::SetDefault;
- output->bytecode << def;
-
- output->imports = unit->imports;
- output->importCache = output->imports.cache(engine);
-
- Q_ASSERT(tree->metatype);
-
- if (tree->metadata.isEmpty()) {
- output->root = tree->metatype;
- } else {
- static_cast<QMetaObject &>(output->rootData) = *tree->metaObject();
- output->root = &output->rootData;
- }
- if (!tree->metadata.isEmpty())
- QmlEnginePrivate::get(engine)->registerCompositeType(output);
-}
-
-static bool ValuePtrLessThan(const Value *t1, const Value *t2)
-{
- return t1->location.start.line < t2->location.start.line ||
- (t1->location.start.line == t2->location.start.line &&
- t1->location.start.column < t2->location.start.column);
-}
-
-bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
-{
- componentStat.objects++;
-
- Q_ASSERT (obj->type != -1);
- const QmlCompiledData::TypeReference &tr =
- output->types.at(obj->type);
- obj->metatype = tr.metaObject();
-
- if (tr.component)
- obj->url = tr.component->url();
- if (tr.type)
- obj->typeName = tr.type->qmlTypeName();
- obj->className = tr.className;
-
- // This object is a "Component" element
- if (tr.type && obj->metatype == &QmlComponent::staticMetaObject) {
- COMPILE_CHECK(buildComponent(obj, ctxt));
- return true;
- }
-
- // Build any script blocks for this type
- for (int ii = 0; ii < obj->scriptBlockObjects.count(); ++ii)
- COMPILE_CHECK(buildScript(obj, obj->scriptBlockObjects.at(ii)));
-
- // Object instantiations reset the binding context
- BindingContext objCtxt(obj);
-
- // Create the synthesized meta object, ignoring aliases
- COMPILE_CHECK(mergeDynamicMetaProperties(obj));
- COMPILE_CHECK(buildDynamicMeta(obj, IgnoreAliases));
-
- // Find the native type and check for the QmlParserStatus interface
- QmlType *type = toQmlType(obj);
- Q_ASSERT(type);
- obj->parserStatusCast = type->parserStatusCast();
- if (obj->parserStatusCast != -1)
- compileState.parserStatusCount++;
-
- // Check if this is a custom parser type. Custom parser types allow
- // assignments to non-existent properties. These assignments are then
- // compiled by the type.
- bool isCustomParser = output->types.at(obj->type).type &&
- output->types.at(obj->type).type->customParser() != 0;
- QList<QmlCustomParserProperty> customProps;
-
- // Fetch the list of deferred properties
- QStringList deferredList = deferredProperties(obj);
-
- // Must do id property first. This is to ensure that the id given to any
- // id reference created matches the order in which the objects are
- // instantiated
- foreach(Property *prop, obj->properties) {
- if (prop->name == "id") {
- COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
- break;
- }
- }
-
- // Merge
- Property *defaultProperty = 0;
- Property *skipProperty = 0;
- if (obj->defaultProperty) {
- const QMetaObject *metaObject = obj->metaObject();
- Q_ASSERT(metaObject);
- QMetaProperty p = QmlMetaType::defaultProperty(metaObject);
- if (p.name()) {
- Property *explicitProperty = obj->getProperty(p.name(), false);
- if (explicitProperty && !explicitProperty->value) {
- skipProperty = explicitProperty;
-
- defaultProperty = new Property;
- defaultProperty->parent = obj;
- defaultProperty->isDefault = true;
- defaultProperty->location = obj->defaultProperty->location;
- defaultProperty->listValueRange = obj->defaultProperty->listValueRange;
- defaultProperty->listCommaPositions = obj->defaultProperty->listCommaPositions;
-
- defaultProperty->values = obj->defaultProperty->values;
- defaultProperty->values += explicitProperty->values;
- foreach(Value *value, defaultProperty->values)
- value->addref();
- qSort(defaultProperty->values.begin(), defaultProperty->values.end(), ValuePtrLessThan);
-
- } else {
- defaultProperty = obj->defaultProperty;
- defaultProperty->addref();
- }
- } else {
- defaultProperty = obj->defaultProperty;
- defaultProperty->addref();
- }
- }
-
- // Build all explicit properties specified
- foreach(Property *prop, obj->properties) {
-
- if (prop == skipProperty)
- continue;
- if (prop->name == "id")
- continue;
-
- bool canDefer = false;
- if (isCustomParser) {
- if (doesPropertyExist(prop, obj)) {
- int ids = compileState.ids.count();
- COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
- canDefer = ids == compileState.ids.count();
- } else {
- customProps << QmlCustomParserNodePrivate::fromProperty(prop);
- }
- } else {
- if (isSignalPropertyName(prop->name)) {
- COMPILE_CHECK(buildSignal(prop,obj,objCtxt));
- } else {
- int ids = compileState.ids.count();
- COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
- canDefer = ids == compileState.ids.count();
- }
- }
-
- if (canDefer && !deferredList.isEmpty() &&
- deferredList.contains(QString::fromUtf8(prop->name)))
- prop->isDeferred = true;
-
- }
-
- // Build the default property
- if (defaultProperty) {
- Property *prop = defaultProperty;
-
- bool canDefer = false;
- if (isCustomParser) {
- if (doesPropertyExist(prop, obj)) {
- int ids = compileState.ids.count();
- COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
- canDefer = ids == compileState.ids.count();
- } else {
- customProps << QmlCustomParserNodePrivate::fromProperty(prop);
- }
- } else {
- int ids = compileState.ids.count();
- COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
- canDefer = ids == compileState.ids.count();
- }
-
- if (canDefer && !deferredList.isEmpty() &&
- deferredList.contains(QString::fromUtf8(prop->name)))
- prop->isDeferred = true;
- }
-
- if (defaultProperty)
- defaultProperty->release();
-
- // Compile custom parser parts
- if (isCustomParser && !customProps.isEmpty()) {
- QmlCustomParser *cp = output->types.at(obj->type).type->customParser();
- cp->clearErrors();
- obj->custom = cp->compile(customProps);
- foreach (QmlError err, cp->errors()) {
- err.setUrl(output->url);
- exceptions << err;
- }
- }
-
- return true;
-}
-
-void QmlCompiler::genObject(QmlParser::Object *obj)
-{
- const QmlCompiledData::TypeReference &tr =
- output->types.at(obj->type);
- if (tr.type && obj->metatype == &QmlComponent::staticMetaObject) {
- genComponent(obj);
- return;
- }
-
- // Create the object
- QmlInstruction create;
- create.type = QmlInstruction::CreateObject;
- create.line = obj->location.start.line;
- create.create.column = obj->location.start.column;
- create.create.data = -1;
- if (!obj->custom.isEmpty())
- create.create.data = output->indexForByteArray(obj->custom);
- create.create.type = obj->type;
- if (!output->types.at(create.create.type).type &&
- !obj->bindingBitmask.isEmpty()) {
- Q_ASSERT(obj->bindingBitmask.size() % 4 == 0);
- create.create.bindingBits =
- output->indexForByteArray(obj->bindingBitmask);
- } else {
- create.create.bindingBits = -1;
- }
- output->bytecode << create;
-
- // Setup the synthesized meta object if necessary
- if (!obj->metadata.isEmpty()) {
- QmlInstruction meta;
- meta.type = QmlInstruction::StoreMetaObject;
- meta.line = 0;
- meta.storeMeta.data = output->indexForByteArray(obj->metadata);
- meta.storeMeta.aliasData = output->indexForByteArray(obj->synthdata);
- meta.storeMeta.propertyCache = output->propertyCaches.count();
- // ### Surely the creation of this property cache could be more efficient
- QmlPropertyCache *propertyCache = 0;
- if (tr.component && QmlComponentPrivate::get(tr.component)->cc->rootPropertyCache) {
- propertyCache = QmlComponentPrivate::get(tr.component)->cc->rootPropertyCache->copy();
- } else {
- propertyCache = QmlPropertyCache::create(engine, obj->metaObject()->superClass());
- }
- propertyCache->append(engine, obj->metaObject(), QmlPropertyCache::Data::NoFlags,
- QmlPropertyCache::Data::IsVMEFunction);
- if (obj == unitRoot) {
- propertyCache->addref();
- output->rootPropertyCache = propertyCache;
- }
- output->propertyCaches << propertyCache;
- output->bytecode << meta;
- }
-
- // Set the object id
- if (!obj->id.isEmpty()) {
- QmlInstruction id;
- id.type = QmlInstruction::SetId;
- id.line = 0;
- id.setId.value = output->indexForString(obj->id);
- id.setId.index = obj->idIndex;
- output->bytecode << id;
- }
-
- // Set any script blocks
- for (int ii = 0; ii < obj->scripts.count(); ++ii) {
- QmlInstruction script;
- script.type = QmlInstruction::StoreScript;
- script.line = 0; // ###
- int idx = output->scripts.count();
- output->scripts << obj->scripts.at(ii);
- script.storeScript.value = idx;
- output->bytecode << script;
- }
-
- // Begin the class
- if (obj->parserStatusCast != -1) {
- QmlInstruction begin;
- begin.type = QmlInstruction::BeginObject;
- begin.begin.castValue = obj->parserStatusCast;
- begin.line = obj->location.start.line;
- output->bytecode << begin;
- }
-
- genObjectBody(obj);
-}
-
-void QmlCompiler::genObjectBody(QmlParser::Object *obj)
-{
- typedef QPair<Property *, int> PropPair;
- foreach(const PropPair &prop, obj->scriptStringProperties) {
- QmlInstruction ss;
- ss.type = QmlInstruction::StoreScriptString;
- ss.storeScriptString.propertyIndex = prop.first->index;
- ss.storeScriptString.value =
- output->indexForString(prop.first->values.at(0)->value.asScript());
- ss.storeScriptString.scope = prop.second;
- output->bytecode << ss;
- }
-
- bool seenDefer = false;
- foreach(Property *prop, obj->valueProperties) {
- if (prop->isDeferred) {
- seenDefer = true;
- continue;
- }
- genValueProperty(prop, obj);
- }
- if (seenDefer) {
- QmlInstruction defer;
- defer.type = QmlInstruction::Defer;
- defer.line = 0;
- defer.defer.deferCount = 0;
- int deferIdx = output->bytecode.count();
- output->bytecode << defer;
-
- QmlInstruction init;
- init.type = QmlInstruction::Init;
- init.init.bindingsSize = compileState.bindings.count(); // XXX - bigger than necessary
- init.init.parserStatusSize = compileState.parserStatusCount; // XXX - bigger than necessary
- init.init.contextCache = -1;
- init.init.compiledBinding = -1;
- output->bytecode << init;
-
- foreach(Property *prop, obj->valueProperties) {
- if (!prop->isDeferred)
- continue;
- genValueProperty(prop, obj);
- }
-
- output->bytecode[deferIdx].defer.deferCount =
- output->bytecode.count() - deferIdx - 1;
- }
-
- foreach(Property *prop, obj->signalProperties) {
-
- QmlParser::Value *v = prop->values.at(0);
-
- if (v->type == Value::SignalObject) {
-
- genObject(v->object);
-
- QmlInstruction assign;
- assign.type = QmlInstruction::AssignSignalObject;
- assign.line = v->location.start.line;
- assign.assignSignalObject.signal =
- output->indexForByteArray(prop->name);
- output->bytecode << assign;
-
- } else if (v->type == Value::SignalExpression) {
-
- QmlInstruction store;
- store.type = QmlInstruction::StoreSignal;
- store.line = v->location.start.line;
- store.storeSignal.signalIndex = prop->index;
- store.storeSignal.value =
- output->indexForString(v->value.asScript().trimmed());
- output->bytecode << store;
-
- }
-
- }
-
- foreach(Property *prop, obj->attachedProperties) {
- QmlInstruction fetch;
- fetch.type = QmlInstruction::FetchAttached;
- fetch.line = prop->location.start.line;
- fetch.fetchAttached.id = prop->index;
- output->bytecode << fetch;
-
- genObjectBody(prop->value);
-
- QmlInstruction pop;
- pop.type = QmlInstruction::PopFetchedObject;
- pop.line = prop->location.start.line;
- output->bytecode << pop;
- }
-
- foreach(Property *prop, obj->groupedProperties) {
- QmlInstruction fetch;
- fetch.type = QmlInstruction::FetchObject;
- fetch.fetch.property = prop->index;
- fetch.line = prop->location.start.line;
- output->bytecode << fetch;
-
- genObjectBody(prop->value);
-
- QmlInstruction pop;
- pop.type = QmlInstruction::PopFetchedObject;
- pop.line = prop->location.start.line;
- output->bytecode << pop;
- }
-
- foreach(Property *prop, obj->valueTypeProperties) {
- QmlInstruction fetch;
- fetch.type = QmlInstruction::FetchValueType;
- fetch.fetchValue.property = prop->index;
- fetch.fetchValue.type = prop->type;
- fetch.line = prop->location.start.line;
-
- output->bytecode << fetch;
-
- foreach(Property *vprop, prop->value->valueProperties) {
- genPropertyAssignment(vprop, prop->value, prop);
- }
-
- QmlInstruction pop;
- pop.type = QmlInstruction::PopValueType;
- pop.fetchValue.property = prop->index;
- pop.fetchValue.type = prop->type;
- pop.line = prop->location.start.line;
- output->bytecode << pop;
- }
-}
-
-void QmlCompiler::genComponent(QmlParser::Object *obj)
-{
- QmlParser::Object *root = obj->defaultProperty->values.at(0)->object;
- Q_ASSERT(root);
-
- QmlInstruction create;
- create.type = QmlInstruction::CreateComponent;
- create.line = root->location.start.line;
- create.createComponent.column = root->location.start.column;
- create.createComponent.endLine = root->location.end.line;
- output->bytecode << create;
- int count = output->bytecode.count();
-
- ComponentCompileState oldCompileState = compileState;
- compileState = componentState(root);
-
- QmlInstruction init;
- init.type = QmlInstruction::Init;
- init.init.bindingsSize = compileState.bindings.count();
- init.init.parserStatusSize = compileState.parserStatusCount;
- init.init.contextCache = genContextCache();
- if (compileState.compiledBindingData.isEmpty())
- init.init.compiledBinding = -1;
- else
- init.init.compiledBinding = output->indexForByteArray(compileState.compiledBindingData);
- init.line = obj->location.start.line;
- output->bytecode << init;
-
- genObject(root);
-
- QmlInstruction def;
- init.line = 0;
- def.type = QmlInstruction::SetDefault;
- output->bytecode << def;
-
- output->bytecode[count - 1].createComponent.count =
- output->bytecode.count() - count;
-
- compileState = oldCompileState;
-
- if (!obj->id.isEmpty()) {
- QmlInstruction id;
- id.type = QmlInstruction::SetId;
- id.line = 0;
- id.setId.value = output->indexForString(obj->id);
- id.setId.index = obj->idIndex;
- output->bytecode << id;
- }
-}
-
-bool QmlCompiler::buildComponent(QmlParser::Object *obj,
- const BindingContext &ctxt)
-{
- // The special "Component" element can only have the id property and a
- // default property, that actually defines the component's tree
-
- // Find, check and set the "id" property (if any)
- Property *idProp = 0;
- if (obj->properties.count() > 1 ||
- (obj->properties.count() == 1 && obj->properties.begin().key() != "id"))
- COMPILE_EXCEPTION(*obj->properties.begin(), QCoreApplication::translate("QmlCompiler","Component elements may not contain properties other than id"));
-
- if (!obj->scriptBlockObjects.isEmpty())
- COMPILE_EXCEPTION(obj->scriptBlockObjects.first(), QCoreApplication::translate("QmlCompiler","Component elements may not contain script blocks"));
-
- if (obj->properties.count())
- idProp = *obj->properties.begin();
-
- if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive())))
- COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QmlCompiler","Invalid component id specification"));
-
- if (idProp) {
- QString idVal = idProp->values.first()->primitive();
-
- if (compileState.ids.contains(idVal))
- COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QmlCompiler","id is not unique"));
-
- obj->id = idVal;
- addId(idVal, obj);
- }
-
- // Check the Component tree is well formed
- if (obj->defaultProperty &&
- (obj->defaultProperty->value || obj->defaultProperty->values.count() > 1 ||
- (obj->defaultProperty->values.count() == 1 && !obj->defaultProperty->values.first()->object)))
- COMPILE_EXCEPTION(obj, QCoreApplication::translate("QmlCompiler","Invalid component body specification"));
-
- Object *root = 0;
- if (obj->defaultProperty && obj->defaultProperty->values.count())
- root = obj->defaultProperty->values.first()->object;
-
- if (!root)
- COMPILE_EXCEPTION(obj, QCoreApplication::translate("QmlCompiler","Cannot create empty component specification"));
-
- // Build the component tree
- COMPILE_CHECK(buildComponentFromRoot(root, ctxt));
-
- return true;
-}
-
-bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script)
-{
- Object::ScriptBlock scriptBlock;
-
- if (script->properties.count() == 1 &&
- script->properties.begin().key() == QByteArray("source")) {
-
- Property *source = *script->properties.begin();
- if (script->defaultProperty)
- COMPILE_EXCEPTION(source, QCoreApplication::translate("QmlCompiler","Invalid Script block. Specify either the source property or inline script"));
-
- if (source->value || source->values.count() != 1 ||
- source->values.at(0)->object || !source->values.at(0)->value.isStringList())
- COMPILE_EXCEPTION(source, QCoreApplication::translate("QmlCompiler","Invalid Script source value"));
-
- QStringList sources = source->values.at(0)->value.asStringList();
-
- for (int jj = 0; jj < sources.count(); ++jj) {
- QString sourceUrl = output->url.resolved(QUrl(sources.at(jj))).toString();
- QString scriptCode;
- int lineNumber = 1;
-
- for (int ii = 0; ii < unit->resources.count(); ++ii) {
- if (unit->resources.at(ii)->url == sourceUrl) {
- scriptCode = QString::fromUtf8(unit->resources.at(ii)->data);
- break;
- }
- }
-
- if (!scriptCode.isEmpty()) {
- scriptBlock.codes.append(scriptCode);
- scriptBlock.files.append(sourceUrl);
- scriptBlock.lineNumbers.append(lineNumber);
- }
- }
-
- } else if (!script->properties.isEmpty()) {
- COMPILE_EXCEPTION(*script->properties.begin(), QCoreApplication::translate("QmlCompiler","Properties cannot be set on Script block"));
- } else if (script->defaultProperty) {
-
- QString scriptCode;
- int lineNumber = 1;
- QString sourceUrl = output->url.toString();
-
- QmlParser::Location currentLocation;
-
- for (int ii = 0; ii < script->defaultProperty->values.count(); ++ii) {
- Value *v = script->defaultProperty->values.at(ii);
- if (lineNumber == 1)
- lineNumber = v->location.start.line;
- if (v->object || !v->value.isString())
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid Script block"));
-
- if (ii == 0) {
- currentLocation = v->location.start;
- scriptCode.append(QString(currentLocation.column, QLatin1Char(' ')));
- }
-
- while (currentLocation.line < v->location.start.line) {
- scriptCode.append(QLatin1Char('\n'));
- currentLocation.line++;
- currentLocation.column = 0;
- }
-
- scriptCode.append(QString(v->location.start.column - currentLocation.column, QLatin1Char(' ')));
-
- scriptCode += v->value.asString();
- currentLocation = v->location.end;
- currentLocation.column++;
- }
-
- if (!scriptCode.isEmpty()) {
- scriptBlock.codes.append(scriptCode);
- scriptBlock.files.append(sourceUrl);
- scriptBlock.lineNumbers.append(lineNumber);
- }
- }
-
- if (!scriptBlock.codes.isEmpty())
- obj->scripts << scriptBlock;
-
- return true;
-}
-
-bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj,
- const BindingContext &ctxt)
-{
- ComponentCompileState oldComponentCompileState = compileState;
- ComponentStat oldComponentStat = componentStat;
-
- compileState = ComponentCompileState();
- compileState.root = obj;
-
- componentStat = ComponentStat();
- componentStat.lineNumber = obj->location.start.line;
-
- if (obj)
- COMPILE_CHECK(buildObject(obj, ctxt));
-
- COMPILE_CHECK(completeComponentBuild());
-
- compileState = oldComponentCompileState;
- componentStat = oldComponentStat;
-
- return true;
-}
-
-
-// Build a sub-object. A sub-object is one that was not created directly by
-// QML - such as a grouped property object, or an attached object. Sub-object's
-// can't have an id, involve a custom parser, have attached properties etc.
-bool QmlCompiler::buildSubObject(Object *obj, const BindingContext &ctxt)
-{
- Q_ASSERT(obj->metatype);
- Q_ASSERT(!obj->defaultProperty);
- Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding
- // sub-context
-
- foreach(Property *prop, obj->properties) {
- if (isSignalPropertyName(prop->name)) {
- COMPILE_CHECK(buildSignal(prop, obj, ctxt));
- } else {
- COMPILE_CHECK(buildProperty(prop, obj, ctxt));
- }
- }
-
- return true;
-}
-
-int QmlCompiler::componentTypeRef()
-{
- QmlType *t = QmlMetaType::qmlType("Qt/Component",4,6);
- for (int ii = output->types.count() - 1; ii >= 0; --ii) {
- if (output->types.at(ii).type == t)
- return ii;
- }
- QmlCompiledData::TypeReference ref;
- ref.className = "Component";
- ref.type = t;
- output->types << ref;
- return output->types.count() - 1;
-}
-
-int QmlCompiler::findSignalByName(const QMetaObject *mo, const QByteArray &name)
-{
- int methods = mo->methodCount();
- for (int ii = methods - 1; ii >= 0; --ii) {
- QMetaMethod method = mo->method(ii);
- QByteArray methodName = method.signature();
- int idx = methodName.indexOf('(');
- methodName = methodName.left(idx);
-
- if (methodName == name)
- return ii;
- }
- return -1;
-}
-
-bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj,
- const BindingContext &ctxt)
-{
- Q_ASSERT(obj->metaObject());
- Q_ASSERT(!prop->isEmpty());
-
- QByteArray name = prop->name;
- Q_ASSERT(name.startsWith("on"));
- name = name.mid(2);
- if(name[0] >= 'A' && name[0] <= 'Z')
- name[0] = name[0] - 'A' + 'a';
-
- int sigIdx = findSignalByName(obj->metaObject(), name);
-
- if (sigIdx == -1) {
-
- // If the "on<Signal>" name doesn't resolve into a signal, try it as a
- // property.
- COMPILE_CHECK(buildProperty(prop, obj, ctxt));
-
- } else {
-
- if (prop->value || prop->values.count() > 1)
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Incorrectly specified signal"));
-
- prop->index = sigIdx;
- obj->addSignalProperty(prop);
-
- if (prop->values.at(0)->object) {
- COMPILE_CHECK(buildObject(prop->values.at(0)->object, ctxt));
- prop->values.at(0)->type = Value::SignalObject;
- } else {
- prop->values.at(0)->type = Value::SignalExpression;
-
- QString script = prop->values.at(0)->value.asScript().trimmed();
- if (script.isEmpty())
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Empty signal assignment"));
- }
- }
-
- return true;
-}
-
-
-/*!
- Returns true if (value) property \a prop exists on obj, false otherwise.
-*/
-bool QmlCompiler::doesPropertyExist(QmlParser::Property *prop,
- QmlParser::Object *obj)
-{
- if(isAttachedPropertyName(prop->name) || prop->name == "id")
- return true;
-
- const QMetaObject *mo = obj->metaObject();
- if (mo) {
- if (prop->isDefault) {
- QMetaProperty p = QmlMetaType::defaultProperty(mo);
- return p.name() != 0;
- } else {
- int idx = mo->indexOfProperty(prop->name.constData());
- return idx != -1;
- }
- }
-
- return false;
-}
-
-bool QmlCompiler::buildProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt)
-{
- if (prop->isEmpty())
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Empty property assignment"));
-
- const QMetaObject *metaObject = obj->metaObject();
- Q_ASSERT(metaObject);
-
- if (isAttachedPropertyName(prop->name)) {
- // Setup attached property data
-
- if (ctxt.isSubContext()) {
- // Attached properties cannot be used on sub-objects. Sub-objects
- // always exist in a binding sub-context, which is what we test
- // for here.
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Attached properties cannot be used here"));
- }
-
- QmlType *type = 0;
- QmlEnginePrivate::ImportedNamespace *typeNamespace = 0;
- QmlEnginePrivate::get(engine)->resolveType(unit->imports, prop->name,
- &type, 0, 0, 0, &typeNamespace);
-
- if (typeNamespace) {
- // ### We might need to indicate that this property is a namespace
- // for the DOM API
- COMPILE_CHECK(buildPropertyInNamespace(typeNamespace, prop, obj,
- ctxt));
- return true;
- } else if (!type || !type->attachedPropertiesType()) {
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Non-existent attached object"));
- }
-
- if (!prop->value)
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Invalid attached object assignment"));
-
- Q_ASSERT(type->attachedPropertiesFunction());
- prop->index = type->index();
- prop->value->metatype = type->attachedPropertiesType();
- } else {
- // Setup regular property data
- QMetaProperty p;
-
- if (prop->isDefault) {
- p = QmlMetaType::defaultProperty(metaObject);
-
- if (p.name()) {
- prop->index = p.propertyIndex();
- prop->name = p.name();
- }
-
- } else {
- prop->index = metaObject->indexOfProperty(prop->name.constData());
-
- if (prop->index != -1) {
- p = metaObject->property(prop->index);
- Q_ASSERT(p.name());
- }
- }
-
- // We can't error here as the "id" property does not require a
- // successful index resolution
- if (p.name()) {
- prop->type = p.userType();
- }
- }
-
- if (prop->index != -1)
- prop->parent->setBindingBit(prop->index);
-
- if (!prop->isDefault && prop->name == "id" && !ctxt.isSubContext()) {
-
- // The magic "id" behavior doesn't apply when "id" is resolved as a
- // default property or to sub-objects (which are always in binding
- // sub-contexts)
- COMPILE_CHECK(buildIdProperty(prop, obj));
- if (prop->type == QVariant::String &&
- prop->values.at(0)->value.isString())
- COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
-
- } else if (isAttachedPropertyName(prop->name)) {
-
- COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt));
-
- } else if (prop->index == -1) {
-
- if (prop->isDefault) {
- COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QmlCompiler","Cannot assign to non-existent default property"));
- } else {
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(prop->name)));
- }
-
- } else if (prop->value) {
-
- COMPILE_CHECK(buildGroupedProperty(prop, obj, ctxt));
-
- } else if (QmlEnginePrivate::get(engine)->isList(prop->type)) {
-
- COMPILE_CHECK(buildListProperty(prop, obj, ctxt));
-
- } else if (prop->type == qMetaTypeId<QmlScriptString>()) {
-
- COMPILE_CHECK(buildScriptStringProperty(prop, obj, ctxt));
-
- } else {
-
- COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
-
- }
-
- return true;
-}
-
-bool
-QmlCompiler::buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns,
- QmlParser::Property *nsProp,
- QmlParser::Object *obj,
- const BindingContext &ctxt)
-{
- if (!nsProp->value)
- COMPILE_EXCEPTION(nsProp, QCoreApplication::translate("QmlCompiler","Invalid use of namespace"));
-
- foreach (Property *prop, nsProp->value->properties) {
-
- if (!isAttachedPropertyName(prop->name))
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Not an attached property name"));
-
- // Setup attached property data
-
- QmlType *type = 0;
- QmlEnginePrivate::get(engine)->resolveTypeInNamespace(ns, prop->name,
- &type, 0, 0, 0);
-
- if (!type || !type->attachedPropertiesType())
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Non-existent attached object"));
-
- if (!prop->value)
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Invalid attached object assignment"));
-
- Q_ASSERT(type->attachedPropertiesFunction());
- prop->index = type->index();
- prop->value->metatype = type->attachedPropertiesType();
-
- COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt));
- }
-
- return true;
-}
-
-void QmlCompiler::genValueProperty(QmlParser::Property *prop,
- QmlParser::Object *obj)
-{
- if (QmlEnginePrivate::get(engine)->isList(prop->type)) {
- genListProperty(prop, obj);
- } else {
- genPropertyAssignment(prop, obj);
- }
-}
-
-void QmlCompiler::genListProperty(QmlParser::Property *prop,
- QmlParser::Object *obj)
-{
- int listType = QmlEnginePrivate::get(engine)->listType(prop->type);
-
- QmlInstruction fetch;
- fetch.type = QmlInstruction::FetchQList;
- fetch.line = prop->location.start.line;
- fetch.fetchQmlList.property = prop->index;
- bool listTypeIsInterface = QmlMetaType::isInterface(listType);
- fetch.fetchQmlList.type = listType;
- output->bytecode << fetch;
-
- for (int ii = 0; ii < prop->values.count(); ++ii) {
- Value *v = prop->values.at(ii);
-
- if (v->type == Value::CreatedObject) {
-
- genObject(v->object);
- if (listTypeIsInterface) {
- QmlInstruction assign;
- assign.type = QmlInstruction::AssignObjectList;
- assign.line = prop->location.start.line;
- output->bytecode << assign;
- } else {
- QmlInstruction store;
- store.type = QmlInstruction::StoreObjectQList;
- store.line = prop->location.start.line;
- output->bytecode << store;
- }
-
- } else if (v->type == Value::PropertyBinding) {
-
- genBindingAssignment(v, prop, obj);
-
- }
-
- }
-
- QmlInstruction pop;
- pop.type = QmlInstruction::PopQList;
- pop.line = prop->location.start.line;
- output->bytecode << pop;
-}
-
-void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- QmlParser::Property *valueTypeProperty)
-{
- for (int ii = 0; ii < prop->values.count(); ++ii) {
- QmlParser::Value *v = prop->values.at(ii);
-
- if (v->type == Value::CreatedObject) {
-
- genObject(v->object);
-
- if (QmlMetaType::isInterface(prop->type)) {
-
- QmlInstruction store;
- store.type = QmlInstruction::StoreInterface;
- store.line = v->object->location.start.line;
- store.storeObject.propertyIndex = prop->index;
- output->bytecode << store;
-
- } else if (prop->type == -1) {
-
- QmlInstruction store;
- store.type = QmlInstruction::StoreVariantObject;
- store.line = v->object->location.start.line;
- store.storeObject.propertyIndex = prop->index;
- output->bytecode << store;
-
- } else {
-
- QmlInstruction store;
- store.type = QmlInstruction::StoreObject;
- store.line = v->object->location.start.line;
- store.storeObject.propertyIndex = prop->index;
- output->bytecode << store;
-
- }
- } else if (v->type == Value::ValueSource) {
- genObject(v->object);
-
- QmlInstruction store;
- store.type = QmlInstruction::StoreValueSource;
- store.line = v->object->location.start.line;
- if (valueTypeProperty) {
- store.assignValueSource.property = genValueTypeData(prop, valueTypeProperty);
- store.assignValueSource.owner = 1;
- } else {
- store.assignValueSource.property = genPropertyData(prop);
- store.assignValueSource.owner = 0;
- }
- QmlType *valueType = toQmlType(v->object);
- store.assignValueSource.castValue = valueType->propertyValueSourceCast();
- output->bytecode << store;
-
- } else if (v->type == Value::ValueInterceptor) {
- genObject(v->object);
-
- QmlInstruction store;
- store.type = QmlInstruction::StoreValueInterceptor;
- store.line = v->object->location.start.line;
- if (valueTypeProperty) {
- store.assignValueInterceptor.property = genValueTypeData(prop, valueTypeProperty);
- store.assignValueInterceptor.owner = 1;
- } else {
- store.assignValueInterceptor.property = genPropertyData(prop);
- store.assignValueInterceptor.owner = 0;
- }
- QmlType *valueType = toQmlType(v->object);
- store.assignValueInterceptor.castValue = valueType->propertyValueInterceptorCast();
- output->bytecode << store;
-
- } else if (v->type == Value::PropertyBinding) {
-
- genBindingAssignment(v, prop, obj, valueTypeProperty);
-
- } else if (v->type == Value::Literal) {
-
- QMetaProperty mp = obj->metaObject()->property(prop->index);
- genLiteralAssignment(mp, v);
-
- }
-
- }
-}
-
-bool QmlCompiler::buildIdProperty(QmlParser::Property *prop,
- QmlParser::Object *obj)
-{
- if (prop->value ||
- prop->values.count() > 1 ||
- prop->values.at(0)->object)
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Invalid use of id property"));
-
- QmlParser::Value *idValue = prop->values.at(0);
- QString val = idValue->primitive();
-
- if (!isValidId(val))
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","\"%1\" is not a valid object id").arg(val));
-
- // We disallow id's that conflict with import prefixes and types
- QmlEnginePrivate::ImportedNamespace *ns = 0;
- QmlType *type = 0;
- QmlEnginePrivate::get(engine)->resolveType(unit->imports, val.toUtf8(),
- &type, 0, 0, 0, &ns);
- if (type)
- COMPILE_EXCEPTION(idValue, QCoreApplication::translate("QmlCompiler","id conflicts with type name"));
- if (ns)
- COMPILE_EXCEPTION(idValue, QCoreApplication::translate("QmlCompiler","id conflicts with namespace prefix"));
-
- if (compileState.ids.contains(val))
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","id is not unique"));
-
- prop->values.at(0)->type = Value::Id;
-
- obj->id = val;
- addId(val, obj);
-
- return true;
-}
-
-void QmlCompiler::addId(const QString &id, QmlParser::Object *obj)
-{
- Q_ASSERT(!compileState.ids.contains(id));
- Q_ASSERT(obj->id == id);
- obj->idIndex = compileState.ids.count();
- compileState.ids.insert(id, obj);
- compileState.idIndexes.insert(obj->idIndex, obj);
-}
-
-void QmlCompiler::addBindingReference(const BindingReference &ref)
-{
- Q_ASSERT(ref.value && !compileState.bindings.contains(ref.value));
- compileState.bindings.insert(ref.value, ref);
-}
-
-void QmlCompiler::saveComponentState()
-{
- Q_ASSERT(compileState.root);
- Q_ASSERT(!savedCompileStates.contains(compileState.root));
-
- savedCompileStates.insert(compileState.root, compileState);
- savedComponentStats.append(componentStat);
-}
-
-QmlCompiler::ComponentCompileState
-QmlCompiler::componentState(QmlParser::Object *obj)
-{
- Q_ASSERT(savedCompileStates.contains(obj));
- return savedCompileStates.value(obj);
-}
-
-// Build attached property object. In this example,
-// Text {
-// GridView.row: 10
-// }
-// GridView is an attached property object.
-bool QmlCompiler::buildAttachedProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->value);
- Q_ASSERT(prop->index != -1); // This is set in buildProperty()
-
- obj->addAttachedProperty(prop);
-
- COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
-
- return true;
-}
-
-
-// Build "grouped" properties. In this example:
-// Text {
-// font.pointSize: 12
-// font.family: "Helvetica"
-// }
-// font is a nested property. pointSize and family are not.
-bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->type != 0);
- Q_ASSERT(prop->index != -1);
-
- if (prop->values.count())
- COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QmlCompiler", "Invalid value in grouped property"));
-
- if (prop->type < (int)QVariant::UserType) {
- QmlEnginePrivate *ep =
- static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine));
- if (prop->type >= 0 /* QVariant == -1 */ && ep->valueTypes[prop->type]) {
- COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type],
- prop->value, obj, ctxt.incr()));
- obj->addValueTypeProperty(prop);
- } else {
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Invalid grouped property access"));
- }
-
- } else {
- // Load the nested property's meta type
- prop->value->metatype =
- QmlEnginePrivate::get(engine)->metaObjectForType(prop->type);
- if (!prop->value->metatype)
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Invalid grouped property access"));
-
- obj->addGroupedProperty(prop);
-
- COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
- }
-
- return true;
-}
-
-bool QmlCompiler::buildValueTypeProperty(QObject *type,
- QmlParser::Object *obj,
- QmlParser::Object *baseObj,
- const BindingContext &ctxt)
-{
- if (obj->defaultProperty)
- COMPILE_EXCEPTION(obj, QCoreApplication::translate("QmlCompiler","Invalid property use"));
- obj->metatype = type->metaObject();
-
- foreach (Property *prop, obj->properties) {
- int idx = type->metaObject()->indexOfProperty(prop->name.constData());
- if (idx == -1)
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(prop->name)));
- QMetaProperty p = type->metaObject()->property(idx);
- prop->index = idx;
- prop->type = p.userType();
-
- if (prop->value)
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Property assignment expected"));
-
- if (prop->values.count() != 1)
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Single property assignment expected"));
-
- Value *value = prop->values.at(0);
-
- if (value->object) {
- bool isPropertyValue = output->types.at(value->object->type).type->propertyValueSourceCast() != -1;
- bool isPropertyInterceptor = output->types.at(value->object->type).type->propertyValueInterceptorCast() != -1;
- if (!isPropertyValue && !isPropertyInterceptor) {
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Unexpected object assignment"));
- } else {
- COMPILE_CHECK(buildObject(value->object, ctxt));
-
- if (isPropertyInterceptor && baseObj->synthdata.isEmpty())
- buildDynamicMeta(baseObj, ForceCreation);
- value->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
- }
- } else if (value->value.isScript()) {
- // ### Check for writability
- BindingReference reference;
- reference.expression = value->value;
- reference.property = prop;
- reference.value = value;
- reference.bindingContext = ctxt;
- reference.bindingContext.owner++;
- addBindingReference(reference);
- value->type = Value::PropertyBinding;
- } else {
- COMPILE_CHECK(testLiteralAssignment(p, value));
- value->type = Value::Literal;
- }
- obj->addValueProperty(prop);
- }
-
- return true;
-}
-
-// Build assignments to QML lists. QML lists are properties of type
-// QList<T *> * and QmlList<T *> *.
-//
-// QList<T *> * types can accept a list of objects, or a single binding
-// QmlList<T *> * types can accept a list of objects
-bool QmlCompiler::buildListProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt)
-{
- Q_ASSERT(QmlEnginePrivate::get(engine)->isList(prop->type));
-
- int t = prop->type;
-
- obj->addValueProperty(prop);
-
- int listType = QmlEnginePrivate::get(engine)->listType(t);
- bool listTypeIsInterface = QmlMetaType::isInterface(listType);
-
- bool assignedBinding = false;
- for (int ii = 0; ii < prop->values.count(); ++ii) {
- Value *v = prop->values.at(ii);
- if (v->object) {
- v->type = Value::CreatedObject;
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- // We check object coercian here. We check interface assignment
- // at runtime.
- if (!listTypeIsInterface) {
- if (!canCoerce(listType, v->object)) {
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Cannot assign object to list"));
- }
- }
-
- } else if (v->value.isScript()) {
- if (assignedBinding)
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Can only assign one binding to lists"));
-
- assignedBinding = true;
- COMPILE_CHECK(buildBinding(v, prop, ctxt));
- v->type = Value::PropertyBinding;
- } else {
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Cannot assign primitives to lists"));
- }
- }
-
- return true;
-}
-
-// Compiles an assignment to a QmlScriptString property
-bool QmlCompiler::buildScriptStringProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt)
-{
- if (prop->values.count() > 1)
- COMPILE_EXCEPTION(prop->values.at(1), QCoreApplication::translate("QmlCompiler", "Cannot assign multiple values to a script property"));
-
- if (prop->values.at(0)->object || !prop->values.at(0)->value.isScript())
- COMPILE_EXCEPTION(prop->values.at(0), QCoreApplication::translate("QmlCompiler", "Invalid property assignment: script expected"));
-
- obj->addScriptStringProperty(prop, ctxt.stack);
-
- return true;
-}
-
-// Compile regular property assignments of the form "property: <value>"
-//
-// ### The following problems exist
-//
-// There is no distinction between how "lists" of values are specified. This
-// Item {
-// children: Item {}
-// children: Item {}
-// }
-// is identical to
-// Item {
-// children: [ Item {}, Item {} ]
-// }
-//
-// We allow assignming multiple values to single value properties
-bool QmlCompiler::buildPropertyAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt)
-{
- obj->addValueProperty(prop);
-
- for (int ii = 0; ii < prop->values.count(); ++ii) {
- Value *v = prop->values.at(ii);
- if (v->object) {
-
- COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
-
- } else {
-
- COMPILE_CHECK(buildPropertyLiteralAssignment(prop, obj, v, ctxt));
-
- }
- }
-
- return true;
-}
-
-// Compile assigning a single object instance to a regular property
-bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- QmlParser::Value *v,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->index != -1);
- Q_ASSERT(v->object->type != -1);
-
- if (!obj->metaObject()->property(prop->index).isWritable())
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name)));
-
- if (QmlMetaType::isInterface(prop->type)) {
-
- // Assigning an object to an interface ptr property
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- v->type = Value::CreatedObject;
-
- } else if (prop->type == -1) {
-
- // Assigning an object to a QVariant
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- v->type = Value::CreatedObject;
- } else {
- // Normally buildObject() will set this up, but we need the static
- // meta object earlier to test for assignability. It doesn't matter
- // that there may still be outstanding synthesized meta object changes
- // on this type, as they are not relevant for assignability testing
- v->object->metatype = output->types.at(v->object->type).metaObject();
- Q_ASSERT(v->object->metaObject());
-
- // Will be true if the assigned type inherits QmlPropertyValueSource
- bool isPropertyValue = false;
- // Will be true if the assigned type inherits QmlPropertyValueInterceptor
- bool isPropertyInterceptor = false;
- if (QmlType *valueType = toQmlType(v->object)) {
- isPropertyValue = valueType->propertyValueSourceCast() != -1;
- isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1;
- }
-
- // We want to raw metaObject here as the raw metaobject is the
- // actual property type before we applied any extensions that might
- // effect the properties on the type, but don't effect assignability
- const QMetaObject *propertyMetaObject =
- QmlEnginePrivate::get(engine)->rawMetaObjectForType(prop->type);
-
- // Will be true if the assgned type inherits propertyMetaObject
- bool isAssignable = false;
- // Determine isAssignable value
- if (propertyMetaObject) {
- const QMetaObject *c = v->object->metatype;
- while(c) {
- isAssignable |= (QmlMetaPropertyPrivate::equal(c, propertyMetaObject));
- c = c->superClass();
- }
- }
-
- if (isAssignable) {
- // Simple assignment
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- v->type = Value::CreatedObject;
- } else if (propertyMetaObject == &QmlComponent::staticMetaObject) {
- // Automatic "Component" insertion
- QmlParser::Object *root = v->object;
- QmlParser::Object *component = new QmlParser::Object;
- component->type = componentTypeRef();
- component->typeName = "Qt/Component";
- component->metatype = &QmlComponent::staticMetaObject;
- component->location = root->location;
- QmlParser::Value *componentValue = new QmlParser::Value;
- componentValue->object = root;
- component->getDefaultProperty()->addValue(componentValue);
- v->object = component;
- COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
- } else if (isPropertyValue || isPropertyInterceptor) {
- // Assign as a property value source
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- if (isPropertyInterceptor && prop->parent->synthdata.isEmpty())
- buildDynamicMeta(prop->parent, ForceCreation);
- v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
- } else {
- COMPILE_EXCEPTION(v->object, QCoreApplication::translate("QmlCompiler","Cannot assign object to property"));
- }
- }
-
- return true;
-}
-
-// Compile assigning a literal or binding to a regular property
-bool QmlCompiler::buildPropertyLiteralAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- QmlParser::Value *v,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->index != -1);
-
- if (v->value.isScript()) {
-
- //optimization for <Type>.<EnumValue> enum assignments
- bool isEnumAssignment = false;
- COMPILE_CHECK(testQualifiedEnumAssignment(obj->metaObject()->property(prop->index), obj, v, &isEnumAssignment));
- if (isEnumAssignment) {
- v->type = Value::Literal;
- return true;
- }
-
- COMPILE_CHECK(buildBinding(v, prop, ctxt));
-
- v->type = Value::PropertyBinding;
-
- } else {
-
- COMPILE_CHECK(testLiteralAssignment(obj->metaObject()->property(prop->index), v));
-
- v->type = Value::Literal;
- }
-
- return true;
-}
-
-bool QmlCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop,
- QmlParser::Object *obj,
- QmlParser::Value *v,
- bool *isAssignment)
-{
- *isAssignment = false;
- if (!prop.isEnumType())
- return true;
-
- if (!prop.isWritable())
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name())));
-
- QString string = v->value.asString();
- if (!string.at(0).isUpper())
- return true;
-
- QStringList parts = string.split(QLatin1Char('.'));
- if (parts.count() != 2)
- return true;
-
- QString typeName = parts.at(0);
- QmlType *type = 0;
- QmlEnginePrivate::get(engine)->resolveType(unit->imports, typeName.toUtf8(),
- &type, 0, 0, 0, 0);
-
- if (!type || obj->typeName != type->qmlTypeName())
- return true;
-
- QString enumValue = parts.at(1);
- int value;
- if (prop.isFlagType()) {
- value = prop.enumerator().keysToValue(enumValue.toUtf8().constData());
- } else
- value = prop.enumerator().keyToValue(enumValue.toUtf8().constData());
- if (value == -1)
- return true;
-
- v->type = Value::Literal;
- v->value = QmlParser::Variant(enumValue);
- *isAssignment = true;
-
- return true;
-}
-
-// Ensures that the dynamic meta specification on obj is valid
-bool QmlCompiler::checkDynamicMeta(QmlParser::Object *obj)
-{
- QSet<QByteArray> propNames;
- QSet<QByteArray> methodNames;
- bool seenDefaultProperty = false;
-
- // Check properties
- for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
- const QmlParser::Object::DynamicProperty &prop =
- obj->dynamicProperties.at(ii);
-
- if (prop.isDefaultProperty) {
- if (seenDefaultProperty)
- COMPILE_EXCEPTION(&prop, QCoreApplication::translate("QmlCompiler","Duplicate default property"));
- seenDefaultProperty = true;
- }
-
- if (propNames.contains(prop.name))
- COMPILE_EXCEPTION(&prop, QCoreApplication::translate("QmlCompiler","Duplicate property name"));
-
- propNames.insert(prop.name);
- }
-
- for (int ii = 0; ii < obj->dynamicSignals.count(); ++ii) {
- QByteArray name = obj->dynamicSignals.at(ii).name;
- if (methodNames.contains(name))
- COMPILE_EXCEPTION(obj, QCoreApplication::translate("QmlCompiler","Duplicate signal name"));
- methodNames.insert(name);
- }
- for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
- QByteArray name = obj->dynamicSlots.at(ii).name;
- if (methodNames.contains(name))
- COMPILE_EXCEPTION(obj, QCoreApplication::translate("QmlCompiler","Duplicate method name"));
- methodNames.insert(name);
- }
-
- return true;
-}
-
-bool QmlCompiler::mergeDynamicMetaProperties(QmlParser::Object *obj)
-{
- for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
- const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
-
- if (!p.defaultValue || p.type == Object::DynamicProperty::Alias)
- continue;
-
- Property *property = 0;
- if (p.isDefaultProperty)
- property = obj->getDefaultProperty();
- else
- property = obj->getProperty(p.name);
-
- if (property->value)
- COMPILE_EXCEPTION(property, QCoreApplication::translate("QmlCompiler","Invalid property nesting"));
-
- for (int ii = 0; ii < p.defaultValue->values.count(); ++ii) {
- Value *v = p.defaultValue->values.at(ii);
- v->addref();
- property->values.append(v);
- }
- }
- return true;
-}
-
-Q_GLOBAL_STATIC(QAtomicInt, classIndexCounter)
-
-bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
-{
- Q_ASSERT(obj);
- Q_ASSERT(obj->metatype);
-
- if (mode != ForceCreation &&
- obj->dynamicProperties.isEmpty() &&
- obj->dynamicSignals.isEmpty() &&
- obj->dynamicSlots.isEmpty())
- return true;
-
- COMPILE_CHECK(checkDynamicMeta(obj));
-
- QByteArray dynamicData(sizeof(QmlVMEMetaData), (char)0);
-
- QByteArray newClassName = obj->metatype->className();
- newClassName.append("_QML_");
- int idx = classIndexCounter()->fetchAndAddRelaxed(1);
- newClassName.append(QByteArray::number(idx));
- if (compileState.root == obj) {
- QString path = output->url.path();
- int lastSlash = path.lastIndexOf(QLatin1Char('/'));
- if (lastSlash > -1) {
- QString nameBase = path.mid(lastSlash + 1, path.length()-lastSlash-5);
- if (!nameBase.isEmpty() && nameBase.at(0).isUpper())
- newClassName = nameBase.toUtf8() + "_QMLTYPE_" + QByteArray::number(idx);
- }
- }
-
- QMetaObjectBuilder builder;
- builder.setClassName(newClassName);
- builder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
-
- bool hasAlias = false;
- for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
- const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
-
- int propIdx =
- obj->metaObject()->indexOfProperty(p.name.constData());
- if (-1 != propIdx) {
- QMetaProperty prop = obj->metaObject()->property(propIdx);
- if (prop.isFinal())
- COMPILE_EXCEPTION(&p, QCoreApplication::translate("QmlCompiler","Cannot override FINAL property"));
- }
-
- if (p.isDefaultProperty &&
- (p.type != Object::DynamicProperty::Alias ||
- mode == ResolveAliases))
- builder.addClassInfo("DefaultProperty", p.name);
-
- QByteArray type;
- int propertyType = 0;
- bool readonly = false;
- switch(p.type) {
- case Object::DynamicProperty::Alias:
- hasAlias = true;
- continue;
- break;
- case Object::DynamicProperty::CustomList:
- case Object::DynamicProperty::Custom:
- {
- QByteArray customTypeName;
- QmlType *qmltype = 0;
- QUrl url;
- QmlEnginePrivate *priv = QmlEnginePrivate::get(engine);
- if (!priv->resolveType(unit->imports, p.customType, &qmltype,
- &url, 0, 0, 0))
- COMPILE_EXCEPTION(&p, QCoreApplication::translate("QmlCompiler","Invalid property type"));
-
- if (!qmltype) {
- QmlCompositeTypeData *tdata = priv->typeManager.get(url);
- Q_ASSERT(tdata);
- Q_ASSERT(tdata->status == QmlCompositeTypeData::Complete);
-
- QmlCompiledData *data = tdata->toCompiledComponent(engine);
- customTypeName = data->root->className();
- } else {
- customTypeName = qmltype->typeName();
- }
-
- if (p.type == Object::DynamicProperty::Custom) {
- type = customTypeName + '*';
- propertyType = QMetaType::QObjectStar;
- } else {
- readonly = true;
- type = "QmlListProperty<";
- type.append(customTypeName);
- type.append(">");
- propertyType = qMetaTypeId<QmlListProperty<QObject> >();
- }
- }
- break;
- case Object::DynamicProperty::Variant:
- propertyType = -1;
- type = "QVariant";
- break;
- case Object::DynamicProperty::Int:
- propertyType = QVariant::Int;
- type = "int";
- break;
- case Object::DynamicProperty::Bool:
- propertyType = QVariant::Bool;
- type = "bool";
- break;
- case Object::DynamicProperty::Real:
- propertyType = QVariant::Double;
- type = "double";
- break;
- case Object::DynamicProperty::String:
- propertyType = QVariant::String;
- type = "QString";
- break;
- case Object::DynamicProperty::Url:
- propertyType = QVariant::Url;
- type = "QUrl";
- break;
- case Object::DynamicProperty::Color:
- propertyType = QVariant::Color;
- type = "QColor";
- break;
- case Object::DynamicProperty::Date:
- propertyType = QVariant::Date;
- type = "QDate";
- break;
- }
-
- ((QmlVMEMetaData *)dynamicData.data())->propertyCount++;
- QmlVMEMetaData::PropertyData propertyData = { propertyType };
- dynamicData.append((char *)&propertyData, sizeof(propertyData));
-
- builder.addSignal(p.name + "Changed()");
- QMetaPropertyBuilder propBuilder =
- builder.addProperty(p.name, type, builder.methodCount() - 1);
- propBuilder.setScriptable(true);
- propBuilder.setWritable(!readonly);
- }
-
- if (mode == ResolveAliases) {
- for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
- const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
-
- if (p.type == Object::DynamicProperty::Alias) {
- ((QmlVMEMetaData *)dynamicData.data())->aliasCount++;
- compileAlias(builder, dynamicData, obj, p);
- }
- }
- }
-
- for (int ii = 0; ii < obj->dynamicSignals.count(); ++ii) {
- const Object::DynamicSignal &s = obj->dynamicSignals.at(ii);
- QByteArray sig(s.name + '(');
- for (int jj = 0; jj < s.parameterTypes.count(); ++jj) {
- if (jj) sig.append(',');
- sig.append(s.parameterTypes.at(jj));
- }
- sig.append(')');
- QMetaMethodBuilder b = builder.addSignal(sig);
- b.setParameterNames(s.parameterNames);
- ((QmlVMEMetaData *)dynamicData.data())->signalCount++;
- }
-
- QStringList funcScripts;
-
- for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
- Object::DynamicSlot &s = obj->dynamicSlots[ii];
- QByteArray sig(s.name + '(');
- QString funcScript(QLatin1String("(function("));
-
- for (int jj = 0; jj < s.parameterNames.count(); ++jj) {
- if (jj) {
- sig.append(',');
- funcScript.append(QLatin1Char(','));
- }
- funcScript.append(QLatin1String(s.parameterNames.at(jj)));
- sig.append("QVariant");
- }
- sig.append(')');
- funcScript.append(QLatin1Char(')'));
- funcScript.append(s.body);
- funcScript.append(QLatin1Char(')'));
- funcScripts << funcScript;
-
- QMetaMethodBuilder b = builder.addSlot(sig);
- b.setReturnType("QVariant");
- b.setParameterNames(s.parameterNames);
-
- ((QmlVMEMetaData *)dynamicData.data())->methodCount++;
- QmlVMEMetaData::MethodData methodData =
- { s.parameterNames.count(), 0, funcScript.length(), 0 };
-
- dynamicData.append((char *)&methodData, sizeof(methodData));
- }
-
- for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
- const QString &funcScript = funcScripts.at(ii);
- QmlVMEMetaData::MethodData *data =
- ((QmlVMEMetaData *)dynamicData.data())->methodData() + ii;
-
- data->bodyOffset = dynamicData.size();
-
- dynamicData.append((const char *)funcScript.constData(),
- (funcScript.length() * sizeof(QChar)));
- }
-
- obj->metadata = builder.toRelocatableData();
- builder.fromRelocatableData(&obj->extObject, obj->metatype, obj->metadata);
-
- if (mode == IgnoreAliases && hasAlias)
- compileState.aliasingObjects << obj;
-
- obj->synthdata = dynamicData;
-
- return true;
-}
-
-#include <qmljsparser_p.h>
-
-static QStringList astNodeToStringList(QmlJS::AST::Node *node)
-{
- if (node->kind == QmlJS::AST::Node::Kind_IdentifierExpression) {
- QString name =
- static_cast<QmlJS::AST::IdentifierExpression *>(node)->name->asString();
- return QStringList() << name;
- } else if (node->kind == QmlJS::AST::Node::Kind_FieldMemberExpression) {
- QmlJS::AST::FieldMemberExpression *expr = static_cast<QmlJS::AST::FieldMemberExpression *>(node);
-
- QStringList rv = astNodeToStringList(expr->base);
- if (rv.isEmpty())
- return rv;
- rv.append(expr->name->asString());
- return rv;
- }
- return QStringList();
-}
-
-bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder,
- QByteArray &data,
- Object *obj,
- const Object::DynamicProperty &prop)
-{
- if (!prop.defaultValue)
- COMPILE_EXCEPTION(obj, QCoreApplication::translate("QmlCompiler","No property alias location"));
-
- if (prop.defaultValue->values.count() != 1 ||
- prop.defaultValue->values.at(0)->object ||
- !prop.defaultValue->values.at(0)->value.isScript())
- COMPILE_EXCEPTION(prop.defaultValue, QCoreApplication::translate("QmlCompiler","Invalid alias location"));
-
- QmlJS::AST::Node *node = prop.defaultValue->values.at(0)->value.asAST();
- if (!node)
- COMPILE_EXCEPTION(obj, QCoreApplication::translate("QmlCompiler","No property alias location")); // ### Can this happen?
-
- QStringList alias = astNodeToStringList(node);
-
- if (alias.count() != 1 && alias.count() != 2)
- COMPILE_EXCEPTION(prop.defaultValue, QCoreApplication::translate("QmlCompiler","Invalid alias reference. An alias reference must be specified as <id> or <id>.<property>"));
-
- if (!compileState.ids.contains(alias.at(0)))
- COMPILE_EXCEPTION(prop.defaultValue, QCoreApplication::translate("QmlCompiler","Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0)));
-
- Object *idObject = compileState.ids[alias.at(0)];
-
- QByteArray typeName;
-
- int propIdx = -1;
- int flags = 0;
- bool writable = false;
- if (alias.count() == 2) {
- propIdx = idObject->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData());
-
- if (-1 == propIdx)
- COMPILE_EXCEPTION(prop.defaultValue, QCoreApplication::translate("QmlCompiler","Invalid alias location"));
-
- QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx);
- writable = aliasProperty.isWritable();
-
- if (aliasProperty.isEnumType())
- typeName = "int"; // Avoid introducing a dependency on the aliased metaobject
- else
- typeName = aliasProperty.typeName();
- } else {
- typeName = idObject->metaObject()->className();
-
- //use the base type since it has been registered with metatype system
- int index = typeName.indexOf("_QML_");
- if (index != -1) {
- typeName = typeName.left(index);
- } else {
- index = typeName.indexOf("_QMLTYPE_");
- const QMetaObject *mo = idObject->metaObject();
- while (index != -1 && mo) {
- typeName = mo->superClass()->className();
- index = typeName.indexOf("_QMLTYPE_");
- mo = mo->superClass();
- }
- }
-
- typeName += '*';
- }
-
- if (typeName.endsWith('*'))
- flags |= QML_ALIAS_FLAG_PTR;
-
- data.append((const char *)&idObject->idIndex, sizeof(idObject->idIndex));
- data.append((const char *)&propIdx, sizeof(propIdx));
- data.append((const char *)&flags, sizeof(flags));
-
- builder.addSignal(prop.name + "Changed()");
- QMetaPropertyBuilder propBuilder =
- builder.addProperty(prop.name, typeName.constData(), builder.methodCount() - 1);
- propBuilder.setScriptable(true);
- propBuilder.setWritable(writable);
- return true;
-}
-
-bool QmlCompiler::buildBinding(QmlParser::Value *value,
- QmlParser::Property *prop,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->index != -1);
- Q_ASSERT(prop->parent);
- Q_ASSERT(prop->parent->metaObject());
-
- QMetaProperty mp = prop->parent->metaObject()->property(prop->index);
- if (!mp.isWritable() && !QmlMetaType::isList(prop->type))
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name)));
-
- BindingReference reference;
- reference.expression = value->value;
- reference.property = prop;
- reference.value = value;
- reference.bindingContext = ctxt;
- addBindingReference(reference);
-
- return true;
-}
-
-void QmlCompiler::genBindingAssignment(QmlParser::Value *binding,
- QmlParser::Property *prop,
- QmlParser::Object *obj,
- QmlParser::Property *valueTypeProperty)
-{
- Q_UNUSED(obj);
- Q_ASSERT(compileState.bindings.contains(binding));
-
- const BindingReference &ref = compileState.bindings.value(binding);
- if (ref.dataType == BindingReference::Experimental) {
- QmlInstruction store;
- store.type = QmlInstruction::StoreCompiledBinding;
- store.assignBinding.value = ref.compiledIndex;
- store.assignBinding.context = ref.bindingContext.stack;
- store.assignBinding.owner = ref.bindingContext.owner;
- if (valueTypeProperty)
- store.assignBinding.property = (valueTypeProperty->index & 0xFFFF) |
- ((valueTypeProperty->type & 0xFF)) << 16 |
- ((prop->index & 0xFF) << 24);
- else
- store.assignBinding.property = prop->index;
- store.line = binding->location.start.line;
- output->bytecode << store;
- return;
- }
-
- QmlInstruction store;
- store.type = QmlInstruction::StoreBinding;
- store.assignBinding.value = output->indexForByteArray(ref.compiledData);
- store.assignBinding.context = ref.bindingContext.stack;
- store.assignBinding.owner = ref.bindingContext.owner;
- store.line = binding->location.start.line;
-
- Q_ASSERT(ref.bindingContext.owner == 0 ||
- (ref.bindingContext.owner != 0 && valueTypeProperty));
- if (ref.bindingContext.owner) {
- store.assignBinding.property = genValueTypeData(prop, valueTypeProperty);
- } else {
- store.assignBinding.property = genPropertyData(prop);
- }
-
- output->bytecode << store;
-}
-
-int QmlCompiler::genContextCache()
-{
- if (compileState.ids.count() == 0)
- return -1;
-
- QmlIntegerCache *cache = new QmlIntegerCache(engine);
-
- for (QHash<QString, QmlParser::Object *>::ConstIterator iter = compileState.ids.begin();
- iter != compileState.ids.end();
- ++iter)
- cache->add(iter.key(), (*iter)->idIndex);
-
- output->contextCaches.append(cache);
- return output->contextCaches.count() - 1;
-}
-
-int QmlCompiler::genValueTypeData(QmlParser::Property *valueTypeProp,
- QmlParser::Property *prop)
-{
- QByteArray data =
- QmlMetaPropertyPrivate::saveValueType(prop->parent->metaObject(), prop->index,
- QmlEnginePrivate::get(engine)->valueTypes[prop->type]->metaObject(),
- valueTypeProp->index);
-// valueTypeProp->index, valueTypeProp->type);
-
- return output->indexForByteArray(data);
-}
-
-int QmlCompiler::genPropertyData(QmlParser::Property *prop)
-{
- return output->indexForByteArray(QmlMetaPropertyPrivate::saveProperty(prop->parent->metaObject(), prop->index));
-}
-
-bool QmlCompiler::completeComponentBuild()
-{
- componentStat.ids = compileState.ids.count();
-
- for (int ii = 0; ii < compileState.aliasingObjects.count(); ++ii) {
- Object *aliasObject = compileState.aliasingObjects.at(ii);
- COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases));
- }
-
- QmlBindingCompiler::Expression expr;
- expr.component = compileState.root;
- expr.ids = compileState.ids;
-
- QmlBindingCompiler bindingCompiler;
-
- for (QHash<QmlParser::Value*,BindingReference>::Iterator iter = compileState.bindings.begin(); iter != compileState.bindings.end(); ++iter) {
- BindingReference &binding = *iter;
-
- expr.context = binding.bindingContext.object;
- expr.property = binding.property;
- expr.expression = binding.expression;
- expr.imports = unit->imports;
-
- if (qmlExperimental()) {
- int index = bindingCompiler.compile(expr, QmlEnginePrivate::get(engine));
- if (index != -1) {
- qWarning() << "Accepted for optimization:" << qPrintable(expr.expression.asScript());
- binding.dataType = BindingReference::Experimental;
- binding.compiledIndex = index;
- componentStat.optimizedBindings++;
- continue;
- } else {
- qWarning() << "Rejected for optimization:" << qPrintable(expr.expression.asScript());
- }
- }
-
- binding.dataType = BindingReference::QtScript;
-
- // Pre-rewrite the expression
- QString expression = binding.expression.asScript();
-
- // ### Optimize
- QmlRewrite::SharedBindingTester sharableTest;
- bool isSharable = sharableTest.isSharable(expression);
-
- QmlRewrite::RewriteBinding rewriteBinding;
- expression = rewriteBinding(expression);
-
- quint32 length = expression.length();
- quint32 pc;
-
- if (isSharable) {
- pc = output->cachedClosures.count();
- pc |= 0x80000000;
- output->cachedClosures.append(0);
- } else {
- pc = output->cachedPrograms.length();
- output->cachedPrograms.append(0);
- }
-
- binding.compiledData =
- QByteArray((const char *)&pc, sizeof(quint32)) +
- QByteArray((const char *)&length, sizeof(quint32)) +
- QByteArray((const char *)expression.constData(),
- expression.length() * sizeof(QChar));
-
- componentStat.scriptBindings++;
- }
-
- if (bindingCompiler.isValid()) {
- compileState.compiledBindingData = bindingCompiler.program();
- QmlBindingCompiler::dump(compileState.compiledBindingData);
- }
-
- saveComponentState();
-
- return true;
-}
-
-void QmlCompiler::dumpStats()
-{
- qWarning().nospace() << "QML Document: " << output->url.toString();
- for (int ii = 0; ii < savedComponentStats.count(); ++ii) {
- const ComponentStat &stat = savedComponentStats.at(ii);
- qWarning().nospace() << " Component Line " << stat.lineNumber;
- qWarning().nospace() << " Total Objects: " << stat.objects;
- qWarning().nospace() << " IDs Used: " << stat.ids;
- qWarning().nospace() << " Optimized Bindings: " << stat.optimizedBindings;
- qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings;
- }
-}
-
-/*!
- Returns true if from can be assigned to a (QObject) property of type
- to.
-*/
-bool QmlCompiler::canCoerce(int to, QmlParser::Object *from)
-{
- const QMetaObject *toMo =
- QmlEnginePrivate::get(engine)->rawMetaObjectForType(to);
- const QMetaObject *fromMo = from->metaObject();
-
- while (fromMo) {
- if (QmlMetaPropertyPrivate::equal(fromMo, toMo))
- return true;
- fromMo = fromMo->superClass();
- }
- return false;
-}
-
-/*!
- Returns true if from can be assigned to a (QObject) property of type
- to.
-*/
-bool QmlCompiler::canCoerce(int to, int from)
-{
- const QMetaObject *toMo =
- QmlEnginePrivate::get(engine)->rawMetaObjectForType(to);
- const QMetaObject *fromMo =
- QmlEnginePrivate::get(engine)->rawMetaObjectForType(from);
-
- while (fromMo) {
- if (QmlMetaPropertyPrivate::equal(fromMo, toMo))
- return true;
- fromMo = fromMo->superClass();
- }
- return false;
-}
-
-QmlType *QmlCompiler::toQmlType(QmlParser::Object *from)
-{
- // ### Optimize
- const QMetaObject *mo = from->metatype;
- QmlType *type = 0;
- while (!type && mo) {
- type = QmlMetaType::qmlType(mo);
- mo = mo->superClass();
- }
- return type;
-}
-
-QStringList QmlCompiler::deferredProperties(QmlParser::Object *obj)
-{
- const QMetaObject *mo = obj->metatype;
-
- int idx = mo->indexOfClassInfo("DeferredPropertyNames");
- if (idx == -1)
- return QStringList();
-
- QMetaClassInfo classInfo = mo->classInfo(idx);
- QStringList rv = QString::fromUtf8(classInfo.value()).split(QLatin1Char(','));
- return rv;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h
deleted file mode 100644
index 744d397..0000000
--- a/src/declarative/qml/qmlcompiler_p.h
+++ /dev/null
@@ -1,337 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCOMPILER_P_H
-#define QMLCOMPILER_P_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 "qml.h"
-#include "qmlerror.h"
-#include "qmlinstruction_p.h"
-#include "qmlcompositetypemanager_p.h"
-#include "qmlparser_p.h"
-#include "qmlengine_p.h"
-#include "qbitfield_p.h"
-#include "qmlpropertycache_p.h"
-#include "qmlintegercache_p.h"
-#include "qmltypenamecache_p.h"
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qset.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngine;
-class QmlComponent;
-class QmlContext;
-
-class QScriptProgram;
-class Q_AUTOTEST_EXPORT QmlCompiledData : public QmlRefCount, public QmlCleanup
-{
-public:
- QmlCompiledData(QmlEngine *engine);
- virtual ~QmlCompiledData();
-
- QString name;
- QUrl url;
- QmlEnginePrivate::Imports imports;
- QmlTypeNameCache *importCache;
-
- struct TypeReference
- {
- TypeReference()
- : type(0), component(0), ref(0) {}
-
- QByteArray className;
- QmlType *type;
- QmlComponent *component;
-
- QmlRefCount *ref;
- QObject *createInstance(QmlContext *, const QBitField &) const;
- const QMetaObject *metaObject() const;
- };
- QList<TypeReference> types;
- struct CustomTypeData
- {
- int index;
- int type;
- };
-
- const QMetaObject *root;
- QAbstractDynamicMetaObject rootData;
- QmlPropertyCache *rootPropertyCache;
- QList<QString> primitives;
- QList<float> floatData;
- QList<int> intData;
- QList<CustomTypeData> customTypeData;
- QList<QByteArray> datas;
- QList<QmlParser::Location> locations;
- QList<QmlInstruction> bytecode;
- QList<QScriptProgram *> cachedPrograms;
- QList<QScriptValue *> cachedClosures;
- QList<QmlPropertyCache *> propertyCaches;
- QList<QmlIntegerCache *> contextCaches;
- QList<QmlParser::Object::ScriptBlock> scripts;
- QList<QUrl> urls;
-
- void dumpInstructions();
-
-protected:
- virtual void clear(); // From QmlCleanup
-
-private:
- void dump(QmlInstruction *, int idx = -1);
- QmlCompiledData(const QmlCompiledData &other);
- QmlCompiledData &operator=(const QmlCompiledData &other);
- QByteArray packData;
- friend class QmlCompiler;
- int pack(const char *, size_t);
-
- int indexForString(const QString &);
- int indexForByteArray(const QByteArray &);
- int indexForFloat(float *, int);
- int indexForInt(int *, int);
- int indexForLocation(const QmlParser::Location &);
- int indexForLocation(const QmlParser::LocationSpan &);
- int indexForUrl(const QUrl &);
-};
-
-class QMetaObjectBuilder;
-class Q_DECLARATIVE_EXPORT QmlCompiler
-{
-public:
- QmlCompiler();
-
- bool compile(QmlEngine *, QmlCompositeTypeData *, QmlCompiledData *);
-
- bool isError() const;
- QList<QmlError> errors() const;
-
- static bool isValidId(const QString &);
- static bool isAttachedPropertyName(const QByteArray &);
- static bool isSignalPropertyName(const QByteArray &);
-
-private:
- static void reset(QmlCompiledData *);
-
- struct BindingContext {
- BindingContext()
- : stack(0), owner(0), object(0) {}
- BindingContext(QmlParser::Object *o)
- : stack(0), owner(0), object(o) {}
- BindingContext incr() const {
- BindingContext rv(object);
- rv.stack = stack + 1;
- return rv;
- }
- bool isSubContext() const { return stack != 0; }
- int stack;
- int owner;
- QmlParser::Object *object;
- };
-
- void compileTree(QmlParser::Object *tree);
-
-
- bool buildObject(QmlParser::Object *obj, const BindingContext &);
- bool buildScript(QmlParser::Object *obj, QmlParser::Object *script);
- bool buildComponent(QmlParser::Object *obj, const BindingContext &);
- bool buildSubObject(QmlParser::Object *obj, const BindingContext &);
- bool buildSignal(QmlParser::Property *prop, QmlParser::Object *obj,
- const BindingContext &);
- bool buildProperty(QmlParser::Property *prop, QmlParser::Object *obj,
- const BindingContext &);
- bool buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns,
- QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &);
- bool buildIdProperty(QmlParser::Property *prop, QmlParser::Object *obj);
- bool buildAttachedProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt);
- bool buildGroupedProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt);
- bool buildValueTypeProperty(QObject *type,
- QmlParser::Object *obj,
- QmlParser::Object *baseObj,
- const BindingContext &ctxt);
- bool buildListProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt);
- bool buildScriptStringProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt);
- bool buildPropertyAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt);
- bool buildPropertyObjectAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- QmlParser::Value *value,
- const BindingContext &ctxt);
- bool buildPropertyLiteralAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- QmlParser::Value *value,
- const BindingContext &ctxt);
- bool doesPropertyExist(QmlParser::Property *prop, QmlParser::Object *obj);
- bool testLiteralAssignment(const QMetaProperty &prop,
- QmlParser::Value *value);
- bool testQualifiedEnumAssignment(const QMetaProperty &prop,
- QmlParser::Object *obj,
- QmlParser::Value *value,
- bool *isAssignment);
- enum DynamicMetaMode { IgnoreAliases, ResolveAliases, ForceCreation };
- bool mergeDynamicMetaProperties(QmlParser::Object *obj);
- bool buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode);
- bool checkDynamicMeta(QmlParser::Object *obj);
- bool buildBinding(QmlParser::Value *, QmlParser::Property *prop,
- const BindingContext &ctxt);
- bool buildComponentFromRoot(QmlParser::Object *obj, const BindingContext &);
- bool compileAlias(QMetaObjectBuilder &,
- QByteArray &data,
- QmlParser::Object *obj,
- const QmlParser::Object::DynamicProperty &);
- bool completeComponentBuild();
-
-
- void genObject(QmlParser::Object *obj);
- void genObjectBody(QmlParser::Object *obj);
- void genComponent(QmlParser::Object *obj);
- void genValueProperty(QmlParser::Property *prop, QmlParser::Object *obj);
- void genListProperty(QmlParser::Property *prop, QmlParser::Object *obj);
- void genPropertyAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- QmlParser::Property *valueTypeProperty = 0);
- void genLiteralAssignment(const QMetaProperty &prop,
- QmlParser::Value *value);
- void genBindingAssignment(QmlParser::Value *binding,
- QmlParser::Property *prop,
- QmlParser::Object *obj,
- QmlParser::Property *valueTypeProperty = 0);
- int genContextCache();
-
- int genValueTypeData(QmlParser::Property *prop, QmlParser::Property *valueTypeProp);
- int genPropertyData(QmlParser::Property *prop);
-
- int componentTypeRef();
-
- static int findSignalByName(const QMetaObject *, const QByteArray &name);
- static QmlType *toQmlType(QmlParser::Object *from);
- bool canCoerce(int to, QmlParser::Object *from);
- bool canCoerce(int to, int from);
-
- QStringList deferredProperties(QmlParser::Object *);
-
- void addId(const QString &, QmlParser::Object *);
-
- void dumpStats();
-
- struct BindingReference {
- QmlParser::Variant expression;
- QmlParser::Property *property;
- QmlParser::Value *value;
-
- enum DataType { QtScript, Experimental };
- DataType dataType;
-
- int compiledIndex;
-
- QByteArray compiledData;
- BindingContext bindingContext;
- };
- void addBindingReference(const BindingReference &);
-
- struct ComponentCompileState
- {
- ComponentCompileState()
- : parserStatusCount(0), pushedProperties(0), root(0) {}
- QHash<QString, QmlParser::Object *> ids;
- QHash<int, QmlParser::Object *> idIndexes;
- int parserStatusCount;
- int pushedProperties;
-
- QByteArray compiledBindingData;
-
- QHash<QmlParser::Value *, BindingReference> bindings;
- QList<QmlParser::Object *> aliasingObjects;
- QmlParser::Object *root;
- };
- ComponentCompileState compileState;
-
- struct ComponentStat
- {
- ComponentStat()
- : ids(0), scriptBindings(0), optimizedBindings(0), objects(0) {}
-
- int lineNumber;
-
- int ids;
- int scriptBindings;
- int optimizedBindings;
- int objects;
- };
- ComponentStat componentStat;
-
- void saveComponentState();
-
- ComponentCompileState componentState(QmlParser::Object *);
- QHash<QmlParser::Object *, ComponentCompileState> savedCompileStates;
- QList<ComponentStat> savedComponentStats;
-
- QList<QmlError> exceptions;
- QmlCompiledData *output;
- QmlEngine *engine;
- QmlParser::Object *unitRoot;
- QmlCompositeTypeData *unit;
-};
-QT_END_NAMESPACE
-
-#endif // QMLCOMPILER_P_H
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
deleted file mode 100644
index cda281f..0000000
--- a/src/declarative/qml/qmlcomponent.cpp
+++ /dev/null
@@ -1,798 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlcomponent.h"
-#include "qmlcomponent_p.h"
-
-#include "qmlcompiler_p.h"
-#include "qmlcontext_p.h"
-#include "qmlcompositetypedata_p.h"
-#include "qmlengine_p.h"
-#include "qmlvme_p.h"
-#include "qml.h"
-#include "qmlengine.h"
-#include "qmlbinding_p.h"
-#include "qmlbinding_p_p.h"
-#include "qmlglobal_p.h"
-#include "qmlscriptparser_p.h"
-
-#include <qfxperf_p_p.h>
-
-#include <QStack>
-#include <QStringList>
-#include <QFileInfo>
-#include <QtCore/qdebug.h>
-#include <QApplication>
-
-QT_BEGIN_NAMESPACE
-
-class QByteArray;
-int statusId = qRegisterMetaType<QmlComponent::Status>("QmlComponent::Status");
-
-/*!
- \class QmlComponent
- \since 4.7
- \brief The QmlComponent class encapsulates a QML component description.
- \mainclass
-*/
-
-/*!
- \qmlclass Component QmlComponent
- \since 4.7
- \brief The Component element encapsulates a QML component description.
-
- Components are reusable, encapsulated Qml element with a well-defined interface.
- They are often defined in \l {qmldocuments.html}{Component Files}.
-
- The \e Component element allows defining components within a QML file.
- This can be useful for reusing a small component within a single QML
- file, or for defining a component that logically belongs with the
- file containing it.
-
- \qml
-Item {
- Component {
- id: redSquare
- Rectangle {
- color: "red"
- width: 10
- height: 10
- }
- }
- Loader { sourceComponent: redSquare }
- Loader { sourceComponent: redSquare; x: 20 }
-}
- \endqml
-
- \section1 Attached Properties
-
- \e onCompleted
-
- Emitted after component "startup" has completed. This can be used to
- execute script code at startup, once the full QML environment has been
- established.
-
- The \c {Component::onCompleted} attached property can be applied to
- any element. The order of running the \c onCompleted scripts is
- undefined.
-
- \qml
- Rectangle {
- Component.onCompleted: console.log("Completed Running!")
- Rectangle {
- Component.onCompleted: console.log("Nested Completed Running!")
- }
- }
- \endqml
-*/
-
-/*!
- \enum QmlComponent::Status
-
- Specifies the loading status of the QmlComponent.
-
- \value Null This QmlComponent has no data. Call loadUrl() or setData() to add QML content.
- \value Ready This QmlComponent is ready and create() may be called.
- \value Loading This QmlComponent is loading network data.
- \value Error An error has occured. Calling errorDescription() to retrieve a description.
-*/
-
-void QmlComponentPrivate::typeDataReady()
-{
- Q_Q(QmlComponent);
-
- Q_ASSERT(typeData);
-
- fromTypeData(typeData);
- typeData = 0;
-
- emit q->statusChanged(q->status());
-}
-
-void QmlComponentPrivate::updateProgress(qreal p)
-{
- Q_Q(QmlComponent);
-
- progress = p;
- emit q->progressChanged(p);
-}
-
-void QmlComponentPrivate::fromTypeData(QmlCompositeTypeData *data)
-{
- url = data->imports.baseUrl();
- QmlCompiledData *c = data->toCompiledComponent(engine);
-
- if (!c) {
- Q_ASSERT(data->status == QmlCompositeTypeData::Error);
-
- state.errors = data->errors;
-
- } else {
-
- cc = c;
-
- }
-
- data->release();
-}
-
-void QmlComponentPrivate::clear()
-{
- if (typeData) {
- typeData->remWaiter(this);
- typeData->release();
- typeData = 0;
- }
-
- if (cc) {
- cc->release();
- cc = 0;
- }
-}
-
-/*!
- \internal
-*/
-QmlComponent::QmlComponent(QObject *parent)
- : QObject(*(new QmlComponentPrivate), parent)
-{
-}
-
-/*!
- Destruct the QmlComponent.
-*/
-QmlComponent::~QmlComponent()
-{
- Q_D(QmlComponent);
-
- if (d->state.completePending) {
- qWarning("QmlComponent: Component destroyed while completion pending");
- d->completeCreate();
- }
-
- if (d->typeData) {
- d->typeData->remWaiter(d);
- d->typeData->release();
- }
- if (d->cc)
- d->cc->release();
-}
-
-/*!
- \property QmlComponent::status
- The component's current \l{QmlComponent::Status} {status}.
- */
-QmlComponent::Status QmlComponent::status() const
-{
- Q_D(const QmlComponent);
-
- if (d->typeData)
- return Loading;
- else if (!d->state.errors.isEmpty())
- return Error;
- else if (d->engine && d->cc)
- return Ready;
- else
- return Null;
-}
-
-/*!
- \property QmlComponent::isNull
-
- Is true if the component is in the Null state, false otherwise.
-
- Equivalent to status() == QmlComponent::Null.
-*/
-bool QmlComponent::isNull() const
-{
- return status() == Null;
-}
-
-/*!
- \property QmlComponent::isReady
-
- Is true if the component is in the Ready state, false otherwise.
-
- Equivalent to status() == QmlComponent::Ready.
-*/
-bool QmlComponent::isReady() const
-{
- return status() == Ready;
-}
-
-/*!
- \property QmlComponent::isError
-
- Is true if the component is in the Error state, false otherwise.
-
- Equivalent to status() == QmlComponent::Error.
-*/
-bool QmlComponent::isError() const
-{
- return status() == Error;
-}
-
-/*!
- \property QmlComponent::isLoading
-
- Is true if the component is in the Loading state, false otherwise.
-
- Equivalent to status() == QmlComponent::Loading.
-*/
-bool QmlComponent::isLoading() const
-{
- return status() == Loading;
-}
-
-/*!
- \property QmlComponent::progress
- The progress of loading the component, from 0.0 (nothing loaded)
- to 1.0 (finished).
-*/
-qreal QmlComponent::progress() const
-{
- Q_D(const QmlComponent);
- return d->progress;
-}
-
-/*!
- \fn void QmlComponent::progressChanged(qreal progress)
-
- Emitted whenever the component's loading progress changes. \a progress will be the
- current progress between 0.0 (nothing loaded) and 1.0 (finished).
-*/
-
-/*!
- \fn void QmlComponent::statusChanged(QmlComponent::Status status)
-
- Emitted whenever the component's status changes. \a status will be the
- new status.
-*/
-
-/*!
- 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)
-{
- Q_D(QmlComponent);
- d->engine = engine;
-}
-
-/*!
- 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)
-{
- Q_D(QmlComponent);
- d->engine = engine;
- loadUrl(url);
-}
-
-/*!
- Create a QmlComponent from the given \a fileName and give it the specified
- \a parent and \a engine.
-
- \sa loadUrl()
-*/
-QmlComponent::QmlComponent(QmlEngine *engine, const QString &fileName,
- QObject *parent)
-: QObject(*(new QmlComponentPrivate), parent)
-{
- Q_D(QmlComponent);
- d->engine = engine;
- loadUrl(QUrl::fromLocalFile(fileName));
-}
-
-/*!
- \internal
-*/
-QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledData *cc, int start, int count, QObject *parent)
- : QObject(*(new QmlComponentPrivate), parent)
-{
- Q_D(QmlComponent);
- d->engine = engine;
- d->cc = cc;
- cc->addref();
- d->start = start;
- d->count = count;
- d->url = cc->url;
- d->progress = 1.0;
-}
-
-/*!
- 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)
-{
- Q_D(QmlComponent);
-
- d->clear();
-
- d->url = url;
-
- QmlCompositeTypeData *typeData =
- QmlEnginePrivate::get(d->engine)->typeManager.getImmediate(data, url);
-
- if (typeData->status == QmlCompositeTypeData::Waiting
- || typeData->status == QmlCompositeTypeData::WaitingResources)
- {
- d->typeData = typeData;
- d->typeData->addWaiter(d);
-
- } else {
-
- d->fromTypeData(typeData);
-
- }
-
- d->progress = 1.0;
- emit statusChanged(status());
- emit progressChanged(d->progress);
-}
-
-/*!
-Returns the QmlContext the component was created in. This is only
-valid for components created directly from QML.
-*/
-QmlContext *QmlComponent::creationContext() const
-{
- Q_D(const QmlComponent);
- if(d->creationContext)
- return d->creationContext;
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(this);
- if (ddata)
- return ddata->context;
- else
- return 0;
-}
-
-/*!
- \internal
- Sets the QmlContext the component was created in. This is only
- desirable for components created in QML script.
-*/
-void QmlComponent::setCreationContext(QmlContext* c)
-{
- Q_D(QmlComponent);
- d->creationContext = c;
-}
-
-/*!
- Load the QmlComponent from the provided \a url.
-*/
-void QmlComponent::loadUrl(const QUrl &url)
-{
- Q_D(QmlComponent);
-
- d->clear();
-
- if (url.isRelative() && !url.isEmpty())
- d->url = d->engine->baseUrl().resolved(url);
- else
- d->url = url;
-
- QmlCompositeTypeData *data =
- QmlEnginePrivate::get(d->engine)->typeManager.get(d->url);
-
- if (data->status == QmlCompositeTypeData::Waiting
- || data->status == QmlCompositeTypeData::WaitingResources)
- {
- d->typeData = data;
- d->typeData->addWaiter(d);
- d->progress = data->progress;
- } else {
- d->fromTypeData(data);
- d->progress = 1.0;
- }
-
- emit statusChanged(status());
- emit progressChanged(d->progress);
-}
-
-/*!
- Return the list of errors that occured during the last compile or create
- operation. An empty list is returned if isError() is not set.
-*/
-QList<QmlError> QmlComponent::errors() const
-{
- Q_D(const QmlComponent);
- if (isError())
- return d->state.errors;
- else
- return QList<QmlError>();
-}
-
-/*!
- \internal
- errorsString is only meant as a way to get the errors in script
-*/
-QString QmlComponent::errorsString() const
-{
- Q_D(const QmlComponent);
- QString ret;
- if(!isError())
- return ret;
- foreach(const QmlError &e, d->state.errors) {
- ret += e.url().toString() + QLatin1Char(':') +
- QString::number(e.line()) + QLatin1Char(' ') +
- e.description() + QLatin1Char('\n');
- }
- return ret;
-}
-
-/*!
- \property QmlComponent::url
- The component URL. This is the URL passed to either the constructor,
- or the loadUrl() or setData() methods.
-*/
-QUrl QmlComponent::url() const
-{
- Q_D(const QmlComponent);
- return d->url;
-}
-
-/*!
- \internal
-*/
-QmlComponent::QmlComponent(QmlComponentPrivate &dd, QObject *parent)
- : QObject(dd, parent)
-{
-}
-
-
-/*!
- \internal
- A version of create which returns a scriptObject, for use in script
-*/
-QScriptValue QmlComponent::createObject()
-{
- Q_D(QmlComponent);
- QmlContext* ctxt = creationContext();
- if(!ctxt){
- qWarning() << QLatin1String("createObject can only be used in QML");
- return QScriptValue();
- }
- QObject* ret = create(ctxt);
- return QmlEnginePrivate::qmlScriptObject(ret, d->engine);
-}
-
-/*!
- Create an object instance from this component. Returns 0 if creation
- failed. \a context specifies the context within which to create the object
- instance.
-
- If \a context is 0 (the default), it will create the instance in the
- engine' s \l {QmlEngine::rootContext()}{root context}.
-*/
-QObject *QmlComponent::create(QmlContext *context)
-{
- Q_D(QmlComponent);
-
- return d->create(context, QBitField());
-}
-
-QObject *QmlComponentPrivate::create(QmlContext *context,
- const QBitField &bindings)
-{
- if (!context)
- context = engine->rootContext();
-
- if (context->engine() != engine) {
- qWarning("QmlComponent::create(): Must create component in context from the same QmlEngine");
- return 0;
- }
-
- QObject *rv = beginCreate(context, bindings);
- completeCreate();
- return rv;
-}
-
-/*!
- This method provides more advanced control over component instance creation.
- In general, programmers should use QmlComponent::create() to create a
- component.
-
- Create an object instance from this component. Returns 0 if creation
- failed. \a context specifies the context within which to create the object
- instance.
-
- When QmlComponent constructs an instance, it occurs in three steps:
- \list 1
- \i The object hierarchy is created, and constant values are assigned.
- \i Property bindings are evaluated for the the first time.
- \i If applicable, QmlParserStatus::componentComplete() is called on objects.
- \endlist
- QmlComponent::beginCreate() differs from QmlComponent::create() in that it
- only performs step 1. QmlComponent::completeCreate() must be called to
- complete steps 2 and 3.
-
- This breaking point is sometimes useful when using attached properties to
- communicate information to an instantiated component, as it allows their
- initial values to be configured before property bindings take effect.
-*/
-QObject *QmlComponent::beginCreate(QmlContext *context)
-{
- Q_D(QmlComponent);
- return d->beginCreate(context, QBitField());
-}
-
-QObject *
-QmlComponentPrivate::beginCreate(QmlContext *context, const QBitField &bindings)
-{
- Q_Q(QmlComponent);
- if (!context) {
- qWarning("QmlComponent::beginCreate(): Cannot create a component in a null context");
- return 0;
- }
-
- if (context->engine() != engine) {
- qWarning("QmlComponent::beginCreate(): Must create component in context from the same QmlEngine");
- return 0;
- }
-
- if (state.completePending) {
- qWarning("QmlComponent: Cannot create new component instance before completing the previous");
- return 0;
- }
-
- if (!q->isReady()) {
- qWarning("QmlComponent: Component is not ready");
- return 0;
- }
-
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine);
-
- QmlContextPrivate *contextPriv =
- static_cast<QmlContextPrivate *>(QObjectPrivate::get(context));
- QmlContext *ctxt = new QmlContext(context, 0, true);
- static_cast<QmlContextPrivate*>(ctxt->d_func())->url = cc->url;
- static_cast<QmlContextPrivate*>(ctxt->d_func())->imports = cc->importCache;
- cc->importCache->addref();
-
- QObject *rv = begin(ctxt, ep, cc, start, count, &state, bindings);
-
- if (rv) {
- QmlGraphics_setParent_noEvent(ctxt, rv);
- } else {
- delete ctxt;
- }
-
- if (rv && !contextPriv->isInternal && ep->isDebugging)
- contextPriv->instances.append(rv);
- return rv;
-}
-
-QObject * QmlComponentPrivate::begin(QmlContext *ctxt, QmlEnginePrivate *enginePriv,
- QmlCompiledData *component, int start, int count,
- ConstructionState *state, const QBitField &bindings)
-{
- bool isRoot = !enginePriv->inBeginCreate;
- enginePriv->inBeginCreate = true;
-
- QmlVME vme;
- QObject *rv = vme.run(ctxt, component, start, count, bindings);
-
- if (vme.isError())
- state->errors = vme.errors();
-
- if (isRoot) {
- enginePriv->inBeginCreate = false;
-
- state->bindValues = enginePriv->bindValues;
- state->parserStatus = enginePriv->parserStatus;
- state->componentAttacheds = enginePriv->componentAttacheds;
- if (state->componentAttacheds)
- state->componentAttacheds->prev = &state->componentAttacheds;
-
- enginePriv->componentAttacheds = 0;
- enginePriv->bindValues.clear();
- enginePriv->parserStatus.clear();
- state->completePending = true;
- enginePriv->inProgressCreations++;
- }
-
- return rv;
-}
-
-void QmlComponentPrivate::beginDeferred(QmlContext *, QmlEnginePrivate *enginePriv,
- QObject *object, ConstructionState *state)
-{
- bool isRoot = !enginePriv->inBeginCreate;
- enginePriv->inBeginCreate = true;
-
- QmlVME vme;
- vme.runDeferred(object);
-
- if (vme.isError())
- state->errors = vme.errors();
-
- if (isRoot) {
- enginePriv->inBeginCreate = false;
-
- state->bindValues = enginePriv->bindValues;
- state->parserStatus = enginePriv->parserStatus;
- state->componentAttacheds = enginePriv->componentAttacheds;
- if (state->componentAttacheds)
- state->componentAttacheds->prev = &state->componentAttacheds;
-
- enginePriv->componentAttacheds = 0;
- enginePriv->bindValues.clear();
- enginePriv->parserStatus.clear();
- state->completePending = true;
- enginePriv->inProgressCreations++;
- }
-}
-
-void QmlComponentPrivate::complete(QmlEnginePrivate *enginePriv, ConstructionState *state)
-{
- if (state->completePending) {
-
- for (int ii = 0; ii < state->bindValues.count(); ++ii) {
- QmlEnginePrivate::SimpleList<QmlAbstractBinding> bv =
- state->bindValues.at(ii);
- for (int jj = 0; jj < bv.count; ++jj) {
- if(bv.at(jj))
- bv.at(jj)->setEnabled(true, QmlMetaProperty::BypassInterceptor |
- QmlMetaProperty::DontRemoveBinding);
- }
- QmlEnginePrivate::clear(bv);
- }
-
- for (int ii = 0; ii < state->parserStatus.count(); ++ii) {
- QmlEnginePrivate::SimpleList<QmlParserStatus> ps =
- state->parserStatus.at(ii);
-
- for (int jj = ps.count - 1; jj >= 0; --jj) {
- QmlParserStatus *status = ps.at(jj);
- if (status && status->d) {
- status->d = 0;
- status->componentComplete();
- }
- }
- QmlEnginePrivate::clear(ps);
- }
-
- while (state->componentAttacheds) {
- QmlComponentAttached *a = state->componentAttacheds;
- if (a->next) a->next->prev = &state->componentAttacheds;
- state->componentAttacheds = a->next;
- a->prev = 0; a->next = 0;
- emit a->completed();
- }
-
- state->bindValues.clear();
- state->parserStatus.clear();
- state->completePending = false;
-
- enginePriv->inProgressCreations--;
- if (0 == enginePriv->inProgressCreations) {
- while (enginePriv->erroredBindings) {
- qWarning().nospace() << qPrintable(enginePriv->erroredBindings->error.toString());
- enginePriv->erroredBindings->removeError();
- }
- }
- }
-}
-
-/*!
- This method provides more advanced control over component instance creation.
- In general, programmers should use QmlComponent::create() to create a
- component.
-
- Complete a component creation begin with QmlComponent::beginCreate().
-*/
-void QmlComponent::completeCreate()
-{
- Q_D(QmlComponent);
- d->completeCreate();
-}
-
-void QmlComponentPrivate::completeCreate()
-{
- if (state.completePending) {
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine);
- complete(ep, &state);
- }
-}
-
-QmlComponentAttached::QmlComponentAttached(QObject *parent)
-: QObject(parent), prev(0), next(0)
-{
-}
-
-QmlComponentAttached::~QmlComponentAttached()
-{
- if (prev) *prev = next;
- if (next) next->prev = prev;
- prev = 0;
- next = 0;
-}
-
-/*!
- \internal
-*/
-QmlComponentAttached *QmlComponent::qmlAttachedProperties(QObject *obj)
-{
- QmlComponentAttached *a = new QmlComponentAttached(obj);
-
- QmlEngine *engine = qmlEngine(obj);
- if (!engine || !QmlEnginePrivate::get(engine)->inBeginCreate)
- return a;
-
- QmlEnginePrivate *p = QmlEnginePrivate::get(engine);
-
- a->next = p->componentAttacheds;
- a->prev = &p->componentAttacheds;
- if (a->next) a->next->prev = &a->next;
- p->componentAttacheds = a;
-
- return a;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h
deleted file mode 100644
index 8996481..0000000
--- a/src/declarative/qml/qmlcomponent.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCOMPONENT_H
-#define QMLCOMPONENT_H
-
-#include "qml.h"
-#include "qmlerror.h"
-
-#include <QtCore/qobject.h>
-#include <QtCore/qstring.h>
-#include <QtScript/qscriptvalue.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlCompiledData;
-class QByteArray;
-class QmlComponentPrivate;
-class QmlEngine;
-class QmlComponentAttached;
-class Q_DECLARATIVE_EXPORT QmlComponent : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlComponent)
- Q_PROPERTY(bool isNull READ isNull NOTIFY statusChanged)
- Q_PROPERTY(bool isReady READ isReady NOTIFY statusChanged)
- Q_PROPERTY(bool isError READ isError NOTIFY statusChanged)
- Q_PROPERTY(bool isLoading READ isLoading NOTIFY statusChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(QUrl url READ url CONSTANT)
-
-public:
- QmlComponent(QObject *parent = 0);
- QmlComponent(QmlEngine *, QObject *parent=0);
- QmlComponent(QmlEngine *, const QString &fileName, QObject *parent = 0);
- QmlComponent(QmlEngine *, const QUrl &url, QObject *parent = 0);
- virtual ~QmlComponent();
-
- Q_ENUMS(Status)
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
-
- bool isNull() const;
- bool isReady() const;
- bool isError() const;
- bool isLoading() const;
-
- QList<QmlError> errors() const;
- Q_INVOKABLE QString errorsString() const;
-
- qreal progress() const;
-
- QUrl url() const;
-
- virtual QObject *create(QmlContext *context = 0);
- virtual QObject *beginCreate(QmlContext *);
- virtual void completeCreate();
-
- Q_INVOKABLE QScriptValue createObject();
-
- void loadUrl(const QUrl &url);
- void setData(const QByteArray &, const QUrl &baseUrl);
-
- void setCreationContext(QmlContext*);
- QmlContext *creationContext() const;
-
- static QmlComponentAttached *qmlAttachedProperties(QObject *);
-
-Q_SIGNALS:
- void statusChanged(QmlComponent::Status);
- void progressChanged(qreal);
-
-protected:
- QmlComponent(QmlComponentPrivate &dd, QObject* parent);
-
-private:
- QmlComponent(QmlEngine *, QmlCompiledData *, int, int, QObject *parent);
-
- friend class QmlVME;
- friend class QmlCompositeTypeData;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QmlComponent::Status)
-QML_DECLARE_TYPE(QmlComponent)
-QML_DECLARE_TYPEINFO(QmlComponent, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif // QMLCOMPONENT_H
diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h
deleted file mode 100644
index b7a3038..0000000
--- a/src/declarative/qml/qmlcomponent_p.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCOMPONENT_P_H
-#define QMLCOMPONENT_P_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 "qmlcomponent.h"
-
-#include "qmlengine_p.h"
-#include "qmlcompositetypemanager_p.h"
-#include "qbitfield_p.h"
-#include "qmlerror.h"
-#include "qml.h"
-
-#include <QtCore/QString>
-#include <QtCore/QStringList>
-#include <QtCore/QList>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlComponent;
-class QmlEngine;
-class QmlCompiledData;
-
-class QmlComponentAttached;
-class QmlComponentPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlComponent)
-
-public:
- QmlComponentPrivate() : typeData(0), progress(0.), start(-1), count(-1), cc(0), engine(0), creationContext(0) {}
-
- QObject *create(QmlContext *context, const QBitField &);
- QObject *beginCreate(QmlContext *, const QBitField &);
- void completeCreate();
-
- QmlCompositeTypeData *typeData;
- void typeDataReady();
- void updateProgress(qreal);
-
- void fromTypeData(QmlCompositeTypeData *data);
-
- QUrl url;
- qreal progress;
-
- int start;
- int count;
- QmlCompiledData *cc;
-
- struct ConstructionState {
- ConstructionState() : componentAttacheds(0), completePending(false) {}
- QList<QmlEnginePrivate::SimpleList<QmlAbstractBinding> > bindValues;
- QList<QmlEnginePrivate::SimpleList<QmlParserStatus> > parserStatus;
- QmlComponentAttached *componentAttacheds;
- QList<QmlError> errors;
- bool completePending;
- };
- ConstructionState state;
-
- static QObject *begin(QmlContext *ctxt, QmlEnginePrivate *enginePriv,
- QmlCompiledData *component, int start, int count,
- ConstructionState *state, const QBitField &bindings = QBitField());
- static void beginDeferred(QmlContext *ctxt, QmlEnginePrivate *enginePriv,
- QObject *object, ConstructionState *state);
- static void complete(QmlEnginePrivate *enginePriv, ConstructionState *state);
-
- QmlEngine *engine;
- QmlContext *creationContext;
-
- void clear();
-
- static QmlComponentPrivate *get(QmlComponent *c) {
- return static_cast<QmlComponentPrivate *>(QObjectPrivate::get(c));
- }
-};
-
-class QmlComponentAttached : public QObject
-{
- Q_OBJECT
-public:
- QmlComponentAttached(QObject *parent = 0);
- ~QmlComponentAttached();
-
- QmlComponentAttached **prev;
- QmlComponentAttached *next;
-
-Q_SIGNALS:
- void completed();
-
-private:
- friend class QmlComponentPrivate;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLCOMPONENT_P_H
diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h
deleted file mode 100644
index 342c88a..0000000
--- a/src/declarative/qml/qmlcompositetypedata_p.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCOMPOSITETYPEDATA_P_H
-#define QMLCOMPOSITETYPEDATA_P_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 "qmlengine_p.h"
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlCompositeTypeResource;
-class QmlCompositeTypeData : public QmlRefCount
-{
-public:
- QmlCompositeTypeData();
- virtual ~QmlCompositeTypeData();
-
- enum Status {
- Invalid,
- Complete,
- Error,
- Waiting,
- WaitingResources
- };
- Status status;
- enum ErrorType {
- NoError,
- AccessError,
- GeneralError
- };
- ErrorType errorType;
-
- QList<QmlError> errors;
-
- QmlEnginePrivate::Imports imports;
-
- QList<QmlCompositeTypeData *> dependants;
-
- // Return a QmlComponent if the QmlCompositeTypeData is not in the Waiting
- // state. The QmlComponent is owned by the QmlCompositeTypeData, so a
- // reference should be kept to keep the QmlComponent alive.
- QmlComponent *toComponent(QmlEngine *);
- // Return a QmlCompiledData if possible, or 0 if an error
- // occurs
- QmlCompiledData *toCompiledComponent(QmlEngine *);
-
- struct TypeReference
- {
- TypeReference();
-
- QmlType *type;
- QmlCompositeTypeData *unit;
- };
-
- QList<TypeReference> types;
- QList<QmlCompositeTypeResource *> resources;
-
- // Add or remove p as a waiter. When the QmlCompositeTypeData becomes
- // ready, the QmlComponentPrivate::typeDataReady() method will be invoked on
- // p. The waiter is automatically removed when the typeDataReady() method
- // is invoked, so there is no need to call remWaiter() in this case.
- void addWaiter(QmlComponentPrivate *p);
- void remWaiter(QmlComponentPrivate *p);
-
- qreal progress;
-
-private:
- friend class QmlCompositeTypeManager;
- friend class QmlCompiler;
- friend class QmlDomDocument;
-
- QmlScriptParser data;
- QList<QmlComponentPrivate *> waiters;
- QmlComponent *component;
- QmlCompiledData *compiledComponent;
-};
-
-class QmlCompositeTypeResource : public QmlRefCount
-{
-public:
- QmlCompositeTypeResource();
- virtual ~QmlCompositeTypeResource();
-
- enum Status {
- Invalid,
- Complete,
- Error,
- Waiting
- };
- Status status;
-
- QList<QmlCompositeTypeData *> dependants;
-
- QString url;
- QByteArray data;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLCOMPOSITETYPEDATA_P_H
-
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp
deleted file mode 100644
index 71d6f16..0000000
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ /dev/null
@@ -1,670 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlcompositetypemanager_p.h"
-
-#include "qmlcompositetypedata_p.h"
-#include "qmlscriptparser_p.h"
-#include "qmlengine.h"
-#include "qmlengine_p.h"
-#include "qmlcomponent.h"
-#include "qmlcomponent_p.h"
-#include "qmlcompiler_p.h"
-
-#include <QtNetwork/qnetworkreply.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qfile.h>
-
-QT_BEGIN_NAMESPACE
-
-#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 0))
-inline uint qHash(const QUrl &uri)
-{
- return qHash(uri.toEncoded(QUrl::FormattingOption(0x100)));
-}
-#endif
-
-QmlCompositeTypeData::QmlCompositeTypeData()
-: status(Invalid), errorType(NoError), component(0), compiledComponent(0)
-{
-}
-
-QmlCompositeTypeData::~QmlCompositeTypeData()
-{
- for (int ii = 0; ii < dependants.count(); ++ii)
- dependants.at(ii)->release();
-
- for (int ii = 0; ii < resources.count(); ++ii)
- resources.at(ii)->release();
-
- if (compiledComponent)
- compiledComponent->release();
-
- if (component)
- delete component;
-}
-
-QmlCompositeTypeResource::QmlCompositeTypeResource()
-{
-}
-
-QmlCompositeTypeResource::~QmlCompositeTypeResource()
-{
- for (int ii = 0; ii < dependants.count(); ++ii)
- dependants.at(ii)->release();
-}
-
-void QmlCompositeTypeData::addWaiter(QmlComponentPrivate *p)
-{
- waiters << p;
-}
-
-void QmlCompositeTypeData::remWaiter(QmlComponentPrivate *p)
-{
- waiters.removeAll(p);
-}
-
-QmlComponent *QmlCompositeTypeData::toComponent(QmlEngine *engine)
-{
- if (!component) {
-
- QmlCompiledData *cc = toCompiledComponent(engine);
- if (cc) {
- component = new QmlComponent(engine, cc, -1, -1, 0);
- cc->release();
- } else {
- component = new QmlComponent(engine, 0);
- component->d_func()->url = imports.baseUrl();
- component->d_func()->state.errors = errors;
- }
-
- }
-
- return component;
-}
-
-QmlCompiledData *
-QmlCompositeTypeData::toCompiledComponent(QmlEngine *engine)
-{
- if (status == Complete && !compiledComponent) {
-
- compiledComponent = new QmlCompiledData(engine);
- compiledComponent->url = imports.baseUrl();
- compiledComponent->name = compiledComponent->url.toString();
-
- QmlCompiler compiler;
- if (!compiler.compile(engine, this, compiledComponent)) {
- status = Error;
- errors = compiler.errors();
- compiledComponent->release();
- compiledComponent = 0;
- }
-
- // Data is no longer needed once we have a compiled component
- data.clear();
- }
-
- if (compiledComponent)
- compiledComponent->addref();
-
- return compiledComponent;
-}
-
-QmlCompositeTypeData::TypeReference::TypeReference()
-: type(0), unit(0)
-{
-}
-
-QmlCompositeTypeManager::QmlCompositeTypeManager(QmlEngine *e)
-: engine(e)
-{
-}
-
-QmlCompositeTypeManager::~QmlCompositeTypeManager()
-{
- for (Components::Iterator iter = components.begin(); iter != components.end();) {
- (*iter)->release();
- iter = components.erase(iter);
- }
- for (Resources::Iterator iter = resources.begin(); iter != resources.end();) {
- (*iter)->release();
- iter = resources.erase(iter);
- }
-}
-
-QmlCompositeTypeData *QmlCompositeTypeManager::get(const QUrl &url)
-{
- QmlCompositeTypeData *unit = components.value(url);
-
- if (!unit) {
- unit = new QmlCompositeTypeData;
- unit->status = QmlCompositeTypeData::Waiting;
- unit->progress = 0.0;
- unit->imports.setBaseUrl(url);
- components.insert(url, unit);
-
- loadSource(unit);
- }
-
- unit->addref();
- return unit;
-}
-
-QmlCompositeTypeData *
-QmlCompositeTypeManager::getImmediate(const QByteArray &data, const QUrl &url)
-{
- QmlCompositeTypeData *unit = new QmlCompositeTypeData;
- unit->status = QmlCompositeTypeData::Waiting;
- unit->imports.setBaseUrl(url);
- setData(unit, data, url);
- return unit;
-}
-
-void QmlCompositeTypeManager::clearCache()
-{
- for (Components::Iterator iter = components.begin(); iter != components.end();) {
- if ((*iter)->status != QmlCompositeTypeData::Waiting) {
- (*iter)->release();
- iter = components.erase(iter);
- } else {
- ++iter;
- }
- }
-
- for (Resources::Iterator iter = resources.begin(); iter != resources.end();) {
- if ((*iter)->status != QmlCompositeTypeResource::Waiting) {
- (*iter)->release();
- iter = resources.erase(iter);
- } else {
- ++iter;
- }
- }
-}
-
-void QmlCompositeTypeManager::replyFinished()
-{
- QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
-
- QmlCompositeTypeData *unit = components.value(reply->url());
- Q_ASSERT(unit);
-
- if (reply->error() != QNetworkReply::NoError) {
- QString errorDescription;
- // ### - Fill in error
- errorDescription = QLatin1String("Network error for URL ") +
- reply->url().toString();
-
- unit->status = QmlCompositeTypeData::Error;
- // ### FIXME
- QmlError error;
- error.setDescription(errorDescription);
- unit->errorType = QmlCompositeTypeData::AccessError;
- unit->errors << error;
- doComplete(unit);
-
- } else {
- QByteArray data = reply->readAll();
-
- setData(unit, data, reply->url());
- }
-
- reply->deleteLater();
-}
-
-void QmlCompositeTypeManager::resourceReplyFinished()
-{
- QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
-
- QmlCompositeTypeResource *resource = resources.value(reply->url());
- Q_ASSERT(resource);
-
- if (reply->error() != QNetworkReply::NoError) {
-
- resource->status = QmlCompositeTypeResource::Error;
-
- } else {
-
- resource->status = QmlCompositeTypeResource::Complete;
- resource->data = reply->readAll();
-
- }
-
- doComplete(resource);
- reply->deleteLater();
-}
-
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
-void QmlCompositeTypeManager::loadResource(QmlCompositeTypeResource *resource)
-{
- QUrl url(resource->url);
-
- QString lf = toLocalFileOrQrc(url);
- if (!lf.isEmpty()) {
-
- QFile file(lf);
- if (file.open(QFile::ReadOnly)) {
- resource->data = file.readAll();
- resource->status = QmlCompositeTypeResource::Complete;
- } else {
- resource->status = QmlCompositeTypeResource::Error;
- }
-
- } else {
-
- QNetworkReply *reply =
- engine->networkAccessManager()->get(QNetworkRequest(url));
- QObject::connect(reply, SIGNAL(finished()),
- this, SLOT(resourceReplyFinished()));
-
- }
-}
-
-void QmlCompositeTypeManager::loadSource(QmlCompositeTypeData *unit)
-{
- QUrl url(unit->imports.baseUrl());
-
- QString lf = toLocalFileOrQrc(url);
- if (!lf.isEmpty()) {
-
- QFile file(lf);
- if (file.open(QFile::ReadOnly)) {
- QByteArray data = file.readAll();
- setData(unit, data, url);
- } else {
- QString errorDescription;
- // ### - Fill in error
- errorDescription = QLatin1String("File error for URL ") + url.toString();
- unit->status = QmlCompositeTypeData::Error;
- // ### FIXME
- QmlError error;
- error.setDescription(errorDescription);
- unit->errorType = QmlCompositeTypeData::AccessError;
- unit->errors << error;
- doComplete(unit);
- }
-
- } else {
- QNetworkReply *reply =
- engine->networkAccessManager()->get(QNetworkRequest(url));
- QObject::connect(reply, SIGNAL(finished()),
- this, SLOT(replyFinished()));
- QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(requestProgress(qint64,qint64)));
- }
-}
-
-void QmlCompositeTypeManager::requestProgress(qint64 received, qint64 total)
-{
- if (total <= 0)
- return;
- QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
-
- QmlCompositeTypeData *unit = components.value(reply->url());
- Q_ASSERT(unit);
-
- unit->progress = qreal(received)/total;
-
- foreach (QmlComponentPrivate *comp, unit->waiters)
- comp->updateProgress(unit->progress);
-}
-
-void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit,
- const QByteArray &data,
- const QUrl &url)
-{
- bool ok = true;
- if (!unit->data.parse(data, url)) {
- ok = false;
- unit->errors << unit->data.errors();
- }
-
- if (ok) {
- compile(unit);
- } else {
- unit->status = QmlCompositeTypeData::Error;
- unit->errorType = QmlCompositeTypeData::GeneralError;
- doComplete(unit);
- }
-}
-
-void QmlCompositeTypeManager::doComplete(QmlCompositeTypeData *unit)
-{
- for (int ii = 0; ii < unit->dependants.count(); ++ii) {
- checkComplete(unit->dependants.at(ii));
- unit->dependants.at(ii)->release();
- }
- unit->dependants.clear();
-
- while(!unit->waiters.isEmpty()) {
- QmlComponentPrivate *p = unit->waiters.takeFirst();
- p->typeDataReady();
- }
-}
-
-void QmlCompositeTypeManager::doComplete(QmlCompositeTypeResource *resource)
-{
- for (int ii = 0; ii < resource->dependants.count(); ++ii) {
- checkComplete(resource->dependants.at(ii));
- resource->dependants.at(ii)->release();
- }
- resource->dependants.clear();
-}
-
-void QmlCompositeTypeManager::checkComplete(QmlCompositeTypeData *unit)
-{
- if (unit->status != QmlCompositeTypeData::Waiting
- && unit->status != QmlCompositeTypeData::WaitingResources)
- return;
-
- int waiting = 0;
- for (int ii = 0; ii < unit->resources.count(); ++ii) {
- QmlCompositeTypeResource *r = unit->resources.at(ii);
-
- if (!r)
- continue;
-
- if (r->status == QmlCompositeTypeResource::Error) {
- unit->status = QmlCompositeTypeData::Error;
- QmlError error;
- error.setUrl(unit->imports.baseUrl());
- error.setDescription(tr("Resource %1 unavailable").arg(r->url));
- unit->errors << error;
- doComplete(unit);
- return;
- } else if (r->status == QmlCompositeTypeResource::Waiting) {
- waiting++;
- }
- }
-
- if (waiting == 0) {
- if (unit->status == QmlCompositeTypeData::WaitingResources) {
- waiting += resolveTypes(unit);
- if (unit->status != QmlCompositeTypeData::Error) {
- if (waiting)
- unit->status = QmlCompositeTypeData::Waiting;
- } else {
- return;
- }
- } else {
- for (int ii = 0; ii < unit->types.count(); ++ii) {
- QmlCompositeTypeData *u = unit->types.at(ii).unit;
-
- if (!u)
- continue;
-
- if (u->status == QmlCompositeTypeData::Error) {
- unit->status = QmlCompositeTypeData::Error;
- unit->errors = u->errors;
- doComplete(unit);
- return;
- } else if (u->status == QmlCompositeTypeData::Waiting) {
- waiting++;
- }
- }
- }
- }
-
- if (!waiting) {
- unit->status = QmlCompositeTypeData::Complete;
- doComplete(unit);
- }
-}
-
-int QmlCompositeTypeManager::resolveTypes(QmlCompositeTypeData *unit)
-{
- // not called until all resources are loaded (they include import URLs)
-
- int waiting = 0;
-
- foreach (QmlScriptParser::Import imp, unit->data.imports()) {
- QString qmldir;
- if (imp.type == QmlScriptParser::Import::File && imp.qualifier.isEmpty()) {
- QString importUrl = unit->imports.baseUrl().resolved(QUrl(imp.uri + QLatin1String("/qmldir"))).toString();
- for (int ii = 0; ii < unit->resources.count(); ++ii) {
- if (unit->resources.at(ii)->url == importUrl) {
- qmldir = QString::fromUtf8(unit->resources.at(ii)->data);
- break;
- }
- }
- }
-
- int vmaj = -1;
- int vmin = -1;
- if (!imp.version.isEmpty()) {
- int dot = imp.version.indexOf(QLatin1Char('.'));
- if (dot < 0) {
- vmaj = imp.version.toInt();
- vmin = 0;
- } else {
- vmaj = imp.version.left(dot).toInt();
- vmin = imp.version.mid(dot+1).toInt();
- }
- }
-
- if (!QmlEnginePrivate::get(engine)->
- addToImport(&unit->imports, qmldir, imp.uri, imp.qualifier, vmaj, vmin, imp.type))
- {
- QmlError error;
- error.setUrl(unit->imports.baseUrl());
- error.setDescription(tr("Import %1 unavailable").arg(imp.uri));
- unit->status = QmlCompositeTypeData::Error;
- unit->errorType = QmlCompositeTypeData::GeneralError;
- unit->errors << error;
- doComplete(unit);
- return 0;
- }
- }
-
- QList<QmlScriptParser::TypeReference*> types = unit->data.referencedTypes();
-
- for (int ii = 0; ii < types.count(); ++ii) {
- QmlScriptParser::TypeReference *parserRef = types.at(ii);
- QByteArray typeName = parserRef->name.toUtf8();
-
- QmlCompositeTypeData::TypeReference ref;
-
- QUrl url;
- int majorVersion;
- int minorVersion;
- QmlEnginePrivate::ImportedNamespace *typeNamespace = 0;
- if (!QmlEnginePrivate::get(engine)->resolveType(unit->imports, typeName, &ref.type, &url, &majorVersion, &minorVersion, &typeNamespace)
- || typeNamespace)
- {
- // Known to not be a type:
- // - known to be a namespace (Namespace {})
- // - type with unknown namespace (UnknownNamespace.SomeType {})
- QmlError error;
- error.setUrl(unit->imports.baseUrl());
- if (typeNamespace)
- error.setDescription(tr("Namespace %1 cannot be used as a type").arg(QString::fromUtf8(typeName)));
- else
- error.setDescription(tr("%1 is not a type").arg(QString::fromUtf8(typeName)));
- if (!parserRef->refObjects.isEmpty()) {
- QmlParser::Object *obj = parserRef->refObjects.first();
- error.setLine(obj->location.start.line);
- error.setColumn(obj->location.start.column);
- }
- unit->status = QmlCompositeTypeData::Error;
- unit->errorType = QmlCompositeTypeData::GeneralError;
- unit->errors << error;
- doComplete(unit);
- return 0;
- }
-
- if (ref.type) {
- foreach (QmlParser::Object *obj, parserRef->refObjects) {
- // store namespace for DOM
- obj->majorVersion = majorVersion;
- obj->minorVersion = minorVersion;
- }
- unit->types << ref;
- continue;
- }
-
- QmlCompositeTypeData *urlUnit = components.value(url);
-
- if (!urlUnit) {
- urlUnit = new QmlCompositeTypeData;
- urlUnit->status = QmlCompositeTypeData::Waiting;
- urlUnit->imports.setBaseUrl(url);
- components.insert(url, urlUnit);
-
- loadSource(urlUnit);
- }
-
- ref.unit = urlUnit;
- switch(urlUnit->status) {
- case QmlCompositeTypeData::Invalid:
- case QmlCompositeTypeData::Error:
- unit->status = QmlCompositeTypeData::Error;
- {
- QmlError error;
- error.setUrl(unit->imports.baseUrl());
- error.setDescription(tr("Type %1 unavailable").arg(QString::fromUtf8(typeName)));
- if (!parserRef->refObjects.isEmpty()) {
- QmlParser::Object *obj = parserRef->refObjects.first();
- error.setLine(obj->location.start.line);
- error.setColumn(obj->location.start.column);
- }
- unit->errors << error;
- }
- if (urlUnit->errorType != QmlCompositeTypeData::AccessError)
- unit->errors << urlUnit->errors;
- doComplete(unit);
- return 0;
-
- case QmlCompositeTypeData::Complete:
- break;
-
- case QmlCompositeTypeData::Waiting:
- case QmlCompositeTypeData::WaitingResources:
- unit->addref();
- ref.unit->dependants << unit;
- waiting++;
- break;
- }
-
- unit->types << ref;
- }
- return waiting;
-}
-
-// ### Check ref counting in here
-void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit)
-{
- int waiting = 0;
-
- QList<QUrl> resourceList = unit->data.referencedResources();
-
- foreach (QmlScriptParser::Import imp, unit->data.imports()) {
- if (imp.type == QmlScriptParser::Import::File && imp.qualifier.isEmpty()) {
- QUrl importUrl = unit->imports.baseUrl().resolved(QUrl(imp.uri + QLatin1String("/qmldir")));
- if (toLocalFileOrQrc(importUrl).isEmpty()) {
- // Import requires remote qmldir
- resourceList.prepend(importUrl);
- }
- }
- }
-
- for (int ii = 0; ii < resourceList.count(); ++ii) {
- QUrl url = unit->imports.baseUrl().resolved(resourceList.at(ii));
-
- QmlCompositeTypeResource *resource = resources.value(url);
-
- if (!resource) {
- resource = new QmlCompositeTypeResource;
- resource->status = QmlCompositeTypeResource::Waiting;
- resource->url = url.toString();
- resources.insert(url, resource);
-
- loadResource(resource);
- }
-
- switch(resource->status) {
- case QmlCompositeTypeResource::Invalid:
- case QmlCompositeTypeResource::Error:
- unit->status = QmlCompositeTypeData::Error;
- {
- QmlError error;
- error.setUrl(unit->imports.baseUrl());
- error.setDescription(tr("Resource %1 unavailable").arg(resource->url));
- unit->errors << error;
- }
- doComplete(unit);
- return;
-
- case QmlCompositeTypeData::Complete:
- break;
-
- case QmlCompositeTypeData::Waiting:
- unit->addref();
- resource->dependants << unit;
- waiting++;
- break;
- }
-
- resource->addref();
- unit->resources << resource;
- }
-
- if (waiting == 0) {
- waiting += resolveTypes(unit);
- if (unit->status != QmlCompositeTypeData::Error) {
- if (!waiting) {
- unit->status = QmlCompositeTypeData::Complete;
- doComplete(unit);
- } else {
- unit->status = QmlCompositeTypeData::Waiting;
- }
- }
- } else {
- unit->status = QmlCompositeTypeData::WaitingResources;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h
deleted file mode 100644
index 2da5d34..0000000
--- a/src/declarative/qml/qmlcompositetypemanager_p.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCOMPOSITETYPEMANAGER_P_H
-#define QMLCOMPOSITETYPEMANAGER_P_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 "qmlscriptparser_p.h"
-#include "qmlrefcount_p.h"
-#include "qmlerror.h"
-#include "qmlengine.h"
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlCompiledData;
-class QmlComponentPrivate;
-class QmlComponent;
-class QmlDomDocument;
-
-class QmlCompositeTypeData;
-class QmlCompositeTypeResource;
-
-class QmlCompositeTypeManager : public QObject
-{
- Q_OBJECT
-public:
- QmlCompositeTypeManager(QmlEngine *);
- ~QmlCompositeTypeManager();
-
- // Return a QmlCompositeTypeData for url. The QmlCompositeTypeData may be
- // cached.
- QmlCompositeTypeData *get(const QUrl &url);
- // Return a QmlCompositeTypeData for data, with the provided base url. The
- // QmlCompositeTypeData will not be cached.
- QmlCompositeTypeData *getImmediate(const QByteArray &data, const QUrl &url);
-
- // Clear cached types. Only types that aren't in the Waiting state will
- // be cleared.
- void clearCache();
-
-private Q_SLOTS:
- void replyFinished();
- void resourceReplyFinished();
- void requestProgress(qint64 received, qint64 total);
-
-private:
- void loadSource(QmlCompositeTypeData *);
- void loadResource(QmlCompositeTypeResource *);
- void compile(QmlCompositeTypeData *);
- void setData(QmlCompositeTypeData *, const QByteArray &, const QUrl &);
-
- void doComplete(QmlCompositeTypeData *);
- void doComplete(QmlCompositeTypeResource *);
- void checkComplete(QmlCompositeTypeData *);
- int resolveTypes(QmlCompositeTypeData *);
-
- QmlEngine *engine;
- typedef QHash<QUrl, QmlCompositeTypeData *> Components;
- Components components;
- typedef QHash<QUrl, QmlCompositeTypeResource *> Resources;
- Resources resources;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLCOMPOSITETYPEMANAGER_P_H
-
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
deleted file mode 100644
index 1718387..0000000
--- a/src/declarative/qml/qmlcontext.cpp
+++ /dev/null
@@ -1,574 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlcontext.h"
-#include "qmlcontext_p.h"
-
-#include "qmlexpression_p.h"
-#include "qmlengine_p.h"
-#include "qmlengine.h"
-#include "qmlcompiledbindings_p.h"
-#include "qmlinfo.h"
-
-#include <qscriptengine.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qdebug.h>
-
-#include <private/qscriptdeclarativeclass_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QmlContextPrivate::QmlContextPrivate()
-: parent(0), engine(0), isInternal(false), propertyNames(0),
- notifyIndex(-1), highPriorityCount(0), imports(0), expressions(0), contextObjects(0),
- idValues(0), idValueCount(0), optimizedBindings(0)
-{
-}
-
-void QmlContextPrivate::addScript(const QmlParser::Object::ScriptBlock &script, QObject *scopeObject)
-{
- Q_Q(QmlContext);
-
- if (!engine)
- return;
-
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine);
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
- scriptContext->pushScope(enginePriv->contextClass->newContext(q, scopeObject));
-
- QScriptValue scope = scriptEngine->newObject();
- scriptContext->setActivationObject(scope);
-
- for (int ii = 0; ii < script.codes.count(); ++ii) {
- scriptEngine->evaluate(script.codes.at(ii), script.files.at(ii), script.lineNumbers.at(ii));
-
- if (scriptEngine->hasUncaughtException()) {
- QmlError error;
- QmlExpressionPrivate::exceptionToError(scriptEngine, error);
- qWarning().nospace() << qPrintable(error.toString());
- }
- }
-
- scriptEngine->popContext();
-
- scripts.append(scope);
-}
-
-void QmlContextPrivate::destroyed(ContextGuard *guard)
-{
- Q_Q(QmlContext);
-
- // process of being deleted (which is *probably* why obj has been destroyed
- // anyway), as we're about to get deleted which will invalidate all the
- // expressions that could depend on us
- QObject *parent = q->parent();
- if (parent && QObjectPrivate::get(parent)->wasDeleted)
- return;
-
- while(guard->bindings) {
- QObject *o = guard->bindings->target;
- int mi = guard->bindings->methodIndex;
- guard->bindings->clear();
- if (o) o->qt_metacall(QMetaObject::InvokeMetaMethod, mi, 0);
- }
-
- for (int ii = 0; ii < idValueCount; ++ii) {
- if (&idValues[ii] == guard) {
- QMetaObject::activate(q, ii + notifyIndex, 0);
- return;
- }
- }
-}
-
-void QmlContextPrivate::init()
-{
- Q_Q(QmlContext);
-
- if (parent)
- parent->d_func()->childContexts.insert(q);
-}
-
-/*!
- \class QmlContext
- \since 4.7
- \brief The QmlContext class defines a context within a QML engine.
- \mainclass
-
- Contexts allow data to be exposed to the QML components instantiated by the
- QML engine.
-
- Each QmlContext contains a set of properties, distinct from
- its QObject properties, that allow data to be
- explicitly bound to a context by name. The context properties are defined or
- updated by calling QmlContext::setContextProperty(). The following example shows
- a Qt model being bound to a context and then accessed from a QML file.
-
- \code
- QmlEngine engine;
- QmlContext context(engine.rootContext());
- context.setContextProperty("myModel", modelData);
-
- QmlComponent component(&engine, "ListView { model=myModel }");
- component.create(&context);
- \endcode
-
- To simplify binding and maintaining larger data sets, QObject's can be
- added to a QmlContext. These objects are known as the context's default
- objects. In this case all the properties of the QObject are
- made available by name in the context, as though they were all individually
- added by calling QmlContext::setContextProperty(). Changes to the property's
- values are detected through the property's notify signal. This method is
- also slightly more faster than manually adding property values.
-
- The following example has the same effect as the one above, but it is
- achieved using a default object.
-
- \code
- class MyDataSet : ... {
- ...
- Q_PROPERTY(QAbstractItemModel *myModel READ model NOTIFY modelChanged)
- ...
- };
-
- MyDataSet myDataSet;
- QmlEngine engine;
- QmlContext context(engine.rootContext());
- context.addDefaultObject(&myDataSet);
-
- QmlComponent component(&engine, "ListView { model=myModel }");
- component.create(&context);
- \endcode
-
- Default objects added first take precedence over those added later. All properties
- added explicitly by QmlContext::setContextProperty() take precedence over default
- object properties.
-
- Contexts are hierarchal, with the \l {QmlEngine::rootContext()}{root context}
- being created by the QmlEngine. A component instantiated in a given context
- has access to that context's data, as well as the data defined by its
- ancestor contexts. Data values (including those added implicitly by the
- default objects) in a context override those in ancestor contexts. Data
- that should be available to all components instantiated by the QmlEngine
- should be added to the \l {QmlEngine::rootContext()}{root context}.
-
- In the following example,
-
- \code
- QmlEngine engine;
- QmlContext context1(engine.rootContext());
- QmlContext context2(&context1);
- QmlContext context3(&context2);
-
- context1.setContextProperty("a", 12);
- context2.setContextProperty("b", 13);
- context3.setContextProperty("a", 14);
- context3.setContextProperty("c", 14);
- \endcode
-
- a QML component instantiated in context1 would have access to the "a" data,
- a QML component instantiated in context2 would have access to the "a" and
- "b" data, and a QML component instantiated in context3 would have access to
- the "a", "b" and "c" data - although its "a" data would return 14, unlike
- that in context1 or context2.
-*/
-
-/*! \internal */
-QmlContext::QmlContext(QmlEngine *e, bool)
-: QObject(*(new QmlContextPrivate))
-{
- Q_D(QmlContext);
- d->engine = e;
- d->init();
-}
-
-/*!
- Create a new QmlContext as a child of \a engine's root context, and the
- QObject \a parent.
-*/
-QmlContext::QmlContext(QmlEngine *engine, QObject *parent)
-: QObject(*(new QmlContextPrivate), parent)
-{
- Q_D(QmlContext);
- QmlContext *parentContext = engine?engine->rootContext():0;
- d->parent = parentContext;
- d->engine = parentContext->engine();
- d->init();
-}
-
-/*!
- Create a new QmlContext with the given \a parentContext, and the
- QObject \a parent.
-*/
-QmlContext::QmlContext(QmlContext *parentContext, QObject *parent)
-: QObject(*(new QmlContextPrivate), parent)
-{
- Q_D(QmlContext);
- d->parent = parentContext;
- d->engine = parentContext->engine();
- d->init();
-}
-
-/*!
- \internal
-*/
-QmlContext::QmlContext(QmlContext *parentContext, QObject *parent, bool)
-: QObject(*(new QmlContextPrivate), parent)
-{
- Q_D(QmlContext);
- d->parent = parentContext;
- d->engine = parentContext->engine();
- d->isInternal = true;
- d->init();
-}
-
-/*!
- Destroys the QmlContext.
-
- Any expressions, or sub-contexts dependent on this context will be
- invalidated, but not destroyed (unless they are parented to the QmlContext
- object).
- */
-QmlContext::~QmlContext()
-{
- Q_D(QmlContext);
- if (d->parent)
- d->parent->d_func()->childContexts.remove(this);
-
- for (QSet<QmlContext *>::ConstIterator iter = d->childContexts.begin();
- iter != d->childContexts.end();
- ++iter) {
- (*iter)->d_func()->invalidateEngines();
- (*iter)->d_func()->parent = 0;
- }
-
- QmlAbstractExpression *expression = d->expressions;
- while (expression) {
- QmlAbstractExpression *nextExpression = expression->m_nextExpression;
-
- expression->m_context = 0;
- expression->m_prevExpression = 0;
- expression->m_nextExpression = 0;
-
- expression = nextExpression;
- }
-
- while (d->contextObjects) {
- QmlDeclarativeData *co = d->contextObjects;
- d->contextObjects = d->contextObjects->nextContextObject;
-
- co->context = 0;
- co->nextContextObject = 0;
- co->prevContextObject = 0;
- }
-
- if (d->propertyNames)
- d->propertyNames->release();
-
- if (d->imports)
- d->imports->release();
-
- if (d->optimizedBindings)
- d->optimizedBindings->release();
-
- delete [] d->idValues;
-}
-
-void QmlContextPrivate::invalidateEngines()
-{
- if (!engine)
- return;
- engine = 0;
- for (QSet<QmlContext *>::ConstIterator iter = childContexts.begin();
- iter != childContexts.end();
- ++iter) {
- (*iter)->d_func()->invalidateEngines();
- }
-}
-
-/*
-Refreshes all expressions that could possibly depend on this context.
-Refreshing flushes all context-tree dependent caches in the expressions, and should occur every
-time the context tree *structure* (not values) changes.
-*/
-void QmlContextPrivate::refreshExpressions()
-{
- for (QSet<QmlContext *>::ConstIterator iter = childContexts.begin();
- iter != childContexts.end();
- ++iter) {
- (*iter)->d_func()->refreshExpressions();
- }
-
- QmlAbstractExpression *expression = expressions;
- while (expression) {
- expression->refresh();
- expression = expression->m_nextExpression;
- }
-}
-
-/*!
- Return the context's QmlEngine, or 0 if the context has no QmlEngine or the
- QmlEngine was destroyed.
-*/
-QmlEngine *QmlContext::engine() const
-{
- Q_D(const QmlContext);
- return d->engine;
-}
-
-/*!
- Return the context's parent QmlContext, or 0 if this context has no
- parent or if the parent has been destroyed.
-*/
-QmlContext *QmlContext::parentContext() const
-{
- Q_D(const QmlContext);
- return d->parent;
-}
-
-/*!
- Add \a defaultObject to this context. The object will be added after
- any existing default objects.
-*/
-void QmlContext::addDefaultObject(QObject *defaultObject)
-{
- Q_D(QmlContext);
- d->defaultObjects.prepend(defaultObject);
-}
-
-/*!
- Set a the \a value of the \a name property on this context.
-*/
-void QmlContext::setContextProperty(const QString &name, const QVariant &value)
-{
- Q_D(QmlContext);
- if (d->notifyIndex == -1)
- d->notifyIndex = this->metaObject()->methodCount();
-
- if (d->engine) {
- bool ok;
- QObject *o = QmlEnginePrivate::get(d->engine)->toQObject(value, &ok);
- if (ok) {
- setContextProperty(name, o);
- return;
- }
- }
-
- if (!d->propertyNames) d->propertyNames = new QmlIntegerCache(d->engine);
-
- int idx = d->propertyNames->value(name);
- if (idx == -1) {
- d->propertyNames->add(name, d->idValueCount + d->propertyValues.count());
- d->propertyValues.append(value);
-
- d->refreshExpressions();
- } else {
- d->propertyValues[idx] = value;
- QMetaObject::activate(this, idx + d->notifyIndex, 0);
- }
-}
-
-void QmlContextPrivate::setIdProperty(int idx, QObject *obj)
-{
- if (notifyIndex == -1) {
- Q_Q(QmlContext);
- notifyIndex = q->metaObject()->methodCount();
- }
-
- idValues[idx].priv = this;
- idValues[idx] = obj;
-}
-
-void QmlContextPrivate::setIdPropertyData(QmlIntegerCache *data)
-{
- Q_ASSERT(!propertyNames);
- propertyNames = data;
- propertyNames->addref();
-
- idValueCount = data->count();
- idValues = new ContextGuard[idValueCount];
-}
-
-/*!
- Set the \a value of the \a name property on this context.
-
- QmlContext does \bold not take ownership of \a value.
-*/
-void QmlContext::setContextProperty(const QString &name, QObject *value)
-{
- Q_D(QmlContext);
- if (d->notifyIndex == -1)
- d->notifyIndex = this->metaObject()->methodCount();
-
- if (!d->propertyNames) d->propertyNames = new QmlIntegerCache(d->engine);
- int idx = d->propertyNames->value(name);
-
- if (idx == -1) {
- d->propertyNames->add(name, d->idValueCount + d->propertyValues.count());
- d->propertyValues.append(QVariant::fromValue(value));
-
- d->refreshExpressions();
- } else {
- d->propertyValues[idx] = QVariant::fromValue(value);
- QMetaObject::activate(this, idx + d->notifyIndex, 0);
- }
-}
-
-/*!
- Returns the value of the \a name property for this context
- as a QVariant.
- */
-QVariant QmlContext::contextProperty(const QString &name) const
-{
- Q_D(const QmlContext);
- QVariant value;
- int idx = -1;
- if (d->propertyNames)
- idx = d->propertyNames->value(name);
-
- if (idx == -1) {
- QByteArray utf8Name = name.toUtf8();
- for (int ii = d->defaultObjects.count() - 1; ii >= 0; --ii) {
- QObject *obj = d->defaultObjects.at(ii);
- QmlPropertyCache::Data local;
- QmlPropertyCache::Data *property = QmlPropertyCache::property(d->engine, obj, name, local);
-
- if (property) {
- value = obj->metaObject()->property(property->coreIndex).read(obj);
- break;
- }
- }
- if (!value.isValid() && parentContext())
- value = parentContext()->contextProperty(name);
- } else {
- value = d->propertyValues[idx];
- }
-
- return value;
-}
-
-/*!
- Resolves the URL \a src relative to the URL of the
- containing component.
-
- \sa QmlEngine::baseUrl(), setBaseUrl()
-*/
-QUrl QmlContext::resolvedUrl(const QUrl &src)
-{
- Q_D(QmlContext);
- QmlContext *ctxt = this;
- if (src.isRelative() && !src.isEmpty()) {
- if (ctxt) {
- while(ctxt) {
- if(ctxt->d_func()->url.isValid())
- break;
- else
- ctxt = ctxt->parentContext();
- }
-
- if (ctxt)
- return ctxt->d_func()->url.resolved(src);
- else if (d->engine)
- return d->engine->baseUrl().resolved(src);
- }
- return QUrl();
- } else {
- return src;
- }
-}
-
-/*!
- Explicitly sets the url resolvedUrl() will use for relative references to \a baseUrl.
-
- Calling this function will override the url of the containing
- component used by default.
-
- \sa resolvedUrl()
-*/
-void QmlContext::setBaseUrl(const QUrl &baseUrl)
-{
- d_func()->url = baseUrl;
-}
-
-/*!
- Returns the base url of the component, or the containing component
- if none is set.
-*/
-QUrl QmlContext::baseUrl() const
-{
- const QmlContext* p = this;
- while (p && p->d_func()->url.isEmpty()) {
- p = p->parentContext();
- }
- if (p)
- return p->d_func()->url;
- else
- return QUrl();
-}
-
-int QmlContextPrivate::context_count(QmlListProperty<QObject> *prop)
-{
- QmlContext *context = static_cast<QmlContext*>(prop->object);
- QmlContextPrivate *d = QmlContextPrivate::get(context);
- int contextProperty = (int)(intptr_t)prop->data;
-
- if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId<QList<QObject*> >()) {
- return 0;
- } else {
- return ((const QList<QObject> *)d->propertyValues.at(contextProperty).constData())->count();
- }
-}
-
-QObject *QmlContextPrivate::context_at(QmlListProperty<QObject> *prop, int index)
-{
- QmlContext *context = static_cast<QmlContext*>(prop->object);
- QmlContextPrivate *d = QmlContextPrivate::get(context);
- int contextProperty = (int)(intptr_t)prop->data;
-
- if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId<QList<QObject*> >()) {
- return 0;
- } else {
- return ((const QList<QObject*> *)d->propertyValues.at(contextProperty).constData())->at(index);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h
deleted file mode 100644
index e96ed84..0000000
--- a/src/declarative/qml/qmlcontext.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCONTEXT_H
-#define QMLCONTEXT_H
-
-#include <QtCore/qurl.h>
-#include <QtCore/qobject.h>
-#include <QtScript/qscriptvalue.h>
-#include <QtCore/qmetatype.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QString;
-class QmlEngine;
-class QmlRefCount;
-class QmlContextPrivate;
-class QmlCompositeTypeData;
-
-class Q_DECLARATIVE_EXPORT QmlContext : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlContext)
-
-public:
- QmlContext(QmlEngine *parent, QObject *objParent=0);
- QmlContext(QmlContext *parent, QObject *objParent=0);
- virtual ~QmlContext();
-
- QmlEngine *engine() const;
- QmlContext *parentContext() const;
-
- void addDefaultObject(QObject *);
- void setContextProperty(const QString &, QObject *);
- void setContextProperty(const QString &, const QVariant &);
-
- QVariant contextProperty(const QString &) const;
-
- QUrl resolvedUrl(const QUrl &);
-
- void setBaseUrl(const QUrl &);
- QUrl baseUrl() const;
-
-private:
- friend class QmlVME;
- friend class QmlEngine;
- friend class QmlEnginePrivate;
- friend class QmlExpression;
- friend class QmlExpressionPrivate;
- friend class QmlContextScriptClass;
- friend class QmlObjectScriptClass;
- friend class QmlComponent;
- friend class QmlComponentPrivate;
- friend class QmlScriptPrivate;
- friend class QmlBoundSignalProxy;
- QmlContext(QmlContext *parent, QObject *objParent, bool);
- QmlContext(QmlEngine *, bool);
-};
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QList<QObject*>);
-
-QT_END_HEADER
-
-#endif // QMLCONTEXT_H
diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h
deleted file mode 100644
index 965eeed..0000000
--- a/src/declarative/qml/qmlcontext_p.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCONTEXT_P_H
-#define QMLCONTEXT_P_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 "qmlcontext.h"
-
-#include "qmldeclarativedata_p.h"
-#include "qmlengine_p.h"
-#include "qmlintegercache_p.h"
-#include "qmltypenamecache_p.h"
-
-#include <QtCore/qhash.h>
-#include <QtScript/qscriptvalue.h>
-#include <QtCore/qset.h>
-
-#include <private/qobject_p.h>
-#include "qmlguard_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlContext;
-class QmlExpression;
-class QmlEngine;
-class QmlExpression;
-class QmlExpressionPrivate;
-class QmlAbstractExpression;
-class QmlBinding_Id;
-class QmlCompiledBindings;
-
-class Q_DECLARATIVE_EXPORT QmlContextPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlContext)
-public:
- QmlContextPrivate();
-
- QmlContext *parent;
- QmlEngine *engine;
-
- bool isInternal;
-
- QmlIntegerCache *propertyNames;
- QList<QVariant> propertyValues;
- int notifyIndex;
-
- QObjectList defaultObjects;
- int highPriorityCount;
-
- QList<QScriptValue> scripts;
- void addScript(const QmlParser::Object::ScriptBlock &, QObject *);
-
- QUrl url;
-
- QmlTypeNameCache *imports;
-
- void init();
-
- void invalidateEngines();
- void refreshExpressions();
- QSet<QmlContext *> childContexts;
-
- QmlAbstractExpression *expressions;
-
- QmlDeclarativeData *contextObjects;
-
- struct IdNotifier
- {
- inline IdNotifier();
- inline ~IdNotifier();
-
- inline void clear();
-
- IdNotifier *next;
- IdNotifier**prev;
- QObject *target;
- int methodIndex;
- };
-
- struct ContextGuard : public QmlGuard<QObject>
- {
- inline ContextGuard();
- inline ContextGuard &operator=(QObject *obj);
- inline virtual void objectDestroyed(QObject *);
-
- QmlContextPrivate *priv;
- IdNotifier *bindings;
- };
- ContextGuard *idValues;
- int idValueCount;
- void setIdProperty(int, QObject *);
- void setIdPropertyData(QmlIntegerCache *);
- void destroyed(ContextGuard *);
-
- static QmlContextPrivate *get(QmlContext *context) {
- return static_cast<QmlContextPrivate *>(QObjectPrivate::get(context));
- }
- static QmlContext *get(QmlContextPrivate *context) {
- return static_cast<QmlContext *>(context->q_func());
- }
-
- QmlCompiledBindings *optimizedBindings;
-
- // Only used for debugging
- QList<QPointer<QObject> > instances;
-
- static int context_count(QmlListProperty<QObject> *);
- static QObject *context_at(QmlListProperty<QObject> *, int);
-};
-
-QmlContextPrivate::IdNotifier::IdNotifier()
-: next(0), prev(0), target(0), methodIndex(-1)
-{
-}
-
-QmlContextPrivate::IdNotifier::~IdNotifier()
-{
- clear();
-}
-
-void QmlContextPrivate::IdNotifier::clear()
-{
- if (next) next->prev = prev;
- if (prev) *prev = next;
- next = 0; prev = 0; target = 0;
- methodIndex = -1;
-}
-
-QmlContextPrivate::ContextGuard::ContextGuard()
-: priv(0), bindings(0)
-{
-}
-
-QmlContextPrivate::ContextGuard &QmlContextPrivate::ContextGuard::operator=(QObject *obj)
-{
- (QmlGuard<QObject>&)*this = obj; return *this;
-}
-
-void QmlContextPrivate::ContextGuard::objectDestroyed(QObject *)
-{
- priv->destroyed(this);
-}
-
-QT_END_NAMESPACE
-
-#endif // QMLCONTEXT_P_H
diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp
deleted file mode 100644
index 4c71903..0000000
--- a/src/declarative/qml/qmlcontextscriptclass.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlcontextscriptclass_p.h"
-
-#include "qmlengine_p.h"
-#include "qmlcontext_p.h"
-#include "qmltypenamescriptclass_p.h"
-#include "qmllistscriptclass_p.h"
-#include "qmlguard_p.h"
-
-QT_BEGIN_NAMESPACE
-
-struct ContextData : public QScriptDeclarativeClass::Object {
- ContextData() : isSharedContext(true) {}
- ContextData(QmlContext *c, QObject *o) : context(c), scopeObject(o), isSharedContext(false) {}
- QmlGuard<QmlContext> context;
- QmlGuard<QObject> scopeObject;
- bool isSharedContext;
-
- QmlContext *getContext(QmlEngine *engine) {
- if (isSharedContext) {
- return QmlEnginePrivate::get(engine)->sharedContext;
- } else {
- return context.data();
- }
- }
-
- QObject *getScope(QmlEngine *engine) {
- if (isSharedContext) {
- return QmlEnginePrivate::get(engine)->sharedScope;
- } else {
- return scopeObject.data();
- }
- }
-};
-
-/*
- The QmlContextScriptClass handles property access for a QmlContext
- via QtScript.
- */
-QmlContextScriptClass::QmlContextScriptClass(QmlEngine *bindEngine)
-: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine),
- lastScopeObject(0), lastContext(0), lastData(0), lastPropertyIndex(-1), lastDefaultObject(-1)
-{
-}
-
-QmlContextScriptClass::~QmlContextScriptClass()
-{
-}
-
-QScriptValue QmlContextScriptClass::newContext(QmlContext *context, QObject *scopeObject)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- return newObject(scriptEngine, this, new ContextData(context, scopeObject));
-}
-
-QScriptValue QmlContextScriptClass::newSharedContext()
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- return newObject(scriptEngine, this, new ContextData());
-}
-
-QmlContext *QmlContextScriptClass::contextFromValue(const QScriptValue &v)
-{
- if (scriptClass(v) != this)
- return 0;
-
- ContextData *data = (ContextData *)object(v);
- return data->getContext(engine);
-}
-
-QScriptClass::QueryFlags
-QmlContextScriptClass::queryProperty(Object *object, const Identifier &name,
- QScriptClass::QueryFlags flags)
-{
- Q_UNUSED(flags);
-
- lastScopeObject = 0;
- lastContext = 0;
- lastData = 0;
- lastPropertyIndex = -1;
- lastDefaultObject = -1;
-
- QmlContext *bindContext = ((ContextData *)object)->getContext(engine);
- QObject *scopeObject = ((ContextData *)object)->getScope(engine);
- if (!bindContext)
- return 0;
-
- bool includeTypes = true;
- while (bindContext) {
- QScriptClass::QueryFlags rv =
- queryProperty(bindContext, scopeObject, name, flags, includeTypes);
- scopeObject = 0; // Only applies to the first context
- includeTypes = false; // Only applies to the first context
- if (rv) return rv;
- bindContext = bindContext->parentContext();
- }
-
- return 0;
-}
-
-QScriptClass::QueryFlags
-QmlContextScriptClass::queryProperty(QmlContext *bindContext, QObject *scopeObject,
- const Identifier &name,
- QScriptClass::QueryFlags flags,
- bool includeTypes)
-{
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine);
- QmlContextPrivate *cp = QmlContextPrivate::get(bindContext);
-
- lastPropertyIndex = cp->propertyNames?cp->propertyNames->value(name):-1;
- if (lastPropertyIndex != -1) {
- lastContext = bindContext;
- return QScriptClass::HandlesReadAccess;
- }
-
- if (includeTypes && cp->imports) {
- QmlTypeNameCache::Data *data = cp->imports->data(name);
-
- if (data) {
- lastData = data;
- lastContext = bindContext;
- return QScriptClass::HandlesReadAccess;
- }
- }
-
- for (int ii = 0; ii < cp->scripts.count(); ++ii) {
- lastFunction = QScriptDeclarativeClass::function(cp->scripts.at(ii), name);
- if (lastFunction.isValid()) {
- lastContext = bindContext;
- return QScriptClass::HandlesReadAccess;
- }
- }
-
- if (scopeObject) {
- QScriptClass::QueryFlags rv =
- ep->objectClass->queryProperty(scopeObject, name, flags, bindContext,
- QmlObjectScriptClass::ImplicitObject | QmlObjectScriptClass::SkipAttachedProperties);
- if (rv) {
- lastScopeObject = scopeObject;
- lastContext = bindContext;
- return rv;
- }
- }
-
- for (int ii = cp->defaultObjects.count() - 1; ii >= 0; --ii) {
- QScriptClass::QueryFlags rv =
- ep->objectClass->queryProperty(cp->defaultObjects.at(ii), name, flags, bindContext,
- QmlObjectScriptClass::ImplicitObject | QmlObjectScriptClass::SkipAttachedProperties);
-
- if (rv) {
- lastDefaultObject = ii;
- lastContext = bindContext;
- return rv;
- }
- }
-
- return 0;
-}
-
-QmlContextScriptClass::ScriptValue
-QmlContextScriptClass::property(Object *object, const Identifier &name)
-{
- Q_UNUSED(object);
-
- QmlContext *bindContext = lastContext;
- Q_ASSERT(bindContext);
-
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine);
- QmlContextPrivate *cp = QmlContextPrivate::get(bindContext);
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- if (lastScopeObject) {
-
- return ep->objectClass->property(lastScopeObject, name);
-
- } else if (lastData) {
-
- if (lastData->type)
- return Value(scriptEngine, ep->typeNameClass->newObject(cp->defaultObjects.at(0), lastData->type));
- else
- return Value(scriptEngine, ep->typeNameClass->newObject(cp->defaultObjects.at(0), lastData->typeNamespace));
-
- } else if (lastPropertyIndex != -1) {
-
- QScriptValue rv;
- if (lastPropertyIndex < cp->idValueCount) {
- rv = ep->objectClass->newQObject(cp->idValues[lastPropertyIndex].data());
- } else {
- const QVariant &value = cp->propertyValues.at(lastPropertyIndex);
- if (value.userType() == qMetaTypeId<QList<QObject*> >()) {
- rv = ep->listClass->newList(QmlListProperty<QObject>(bindContext, (void*)lastPropertyIndex, 0, QmlContextPrivate::context_count, QmlContextPrivate::context_at), qMetaTypeId<QmlListProperty<QObject> >());
- } else {
- rv = ep->scriptValueFromVariant(value);
- }
- }
-
- ep->capturedProperties <<
- QmlEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex);
-
- return Value(scriptEngine, rv);
- } else if(lastDefaultObject != -1) {
-
- // Default object property
- return ep->objectClass->property(cp->defaultObjects.at(lastDefaultObject), name);
-
- } else {
-
- return Value(scriptEngine, lastFunction);
-
- }
-}
-
-void QmlContextScriptClass::setProperty(Object *object, const Identifier &name,
- const QScriptValue &value)
-{
- Q_UNUSED(object);
- Q_ASSERT(lastScopeObject || lastDefaultObject != -1);
-
- QmlContext *bindContext = lastContext;
- Q_ASSERT(bindContext);
-
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine);
- QmlContextPrivate *cp = QmlContextPrivate::get(bindContext);
-
- if (lastScopeObject) {
- ep->objectClass->setProperty(lastScopeObject, name, value, bindContext);
- } else {
- ep->objectClass->setProperty(cp->defaultObjects.at(lastDefaultObject), name, value,
- bindContext);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcontextscriptclass_p.h b/src/declarative/qml/qmlcontextscriptclass_p.h
deleted file mode 100644
index c878f3c..0000000
--- a/src/declarative/qml/qmlcontextscriptclass_p.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCONTEXTSCRIPTCLASS_P_H
-#define QMLCONTEXTSCRIPTCLASS_P_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 "qmltypenamecache_p.h"
-#include "qmlscriptclass_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngine;
-class QmlContext;
-class QmlContextScriptClass : public QmlScriptClass
-{
-public:
- QmlContextScriptClass(QmlEngine *);
- ~QmlContextScriptClass();
-
- QScriptValue newContext(QmlContext *, QObject * = 0);
- QScriptValue newSharedContext();
-
- QmlContext *contextFromValue(const QScriptValue &);
-
-protected:
- virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
- QScriptClass::QueryFlags flags);
- virtual ScriptValue property(Object *, const Identifier &);
- virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
-
-private:
- QScriptClass::QueryFlags queryProperty(QmlContext *, QObject *scopeObject,
- const Identifier &,
- QScriptClass::QueryFlags flags,
- bool includeTypes);
-
- QmlEngine *engine;
-
- QObject *lastScopeObject;
- QmlContext *lastContext;
- QmlTypeNameCache::Data *lastData;
- int lastPropertyIndex;
- int lastDefaultObject;
- QScriptValue lastFunction;
-
- uint m_id;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLCONTEXTSCRIPTCLASS_P_H
-
diff --git a/src/declarative/qml/qmlcustomparser.cpp b/src/declarative/qml/qmlcustomparser.cpp
deleted file mode 100644
index 8e52b72..0000000
--- a/src/declarative/qml/qmlcustomparser.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlcustomparser_p.h"
-#include "qmlcustomparser_p_p.h"
-
-#include "qmlparser_p.h"
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QmlParser;
-
-/*!
- \class QmlCustomParser
- \brief The QmlCustomParser class allows you to add new arbitrary types to QML.
- \internal
-
- By subclassing QmlCustomParser, you can add a parser for
- building a particular type.
-
- The subclass must implement compile() and setCustomData(), and register
- itself in the meta type system by calling the macro:
-
- \code
- QML_REGISTER_CUSTOM_TYPE(Module, MajorVersion, MinorVersion, Name, TypeClass, ParserClass)
- \endcode
-*/
-
-/*
- \fn QByteArray QmlCustomParser::compile(const QList<QmlCustomParserProperty> & properties)
-
- The custom parser processes \a properties, and returns
- a QByteArray containing data meaningful only to the
- custom parser; the type engine will pass this same data to
- setCustomData() when making an instance of the data.
-
- Errors must be reported via the error() functions.
-
- 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 void QmlCustomParser::setCustomData(QObject *object, const QByteArray &data)
-
- This function sets \a object to have the properties defined
- by \a data, which is a block of data previously returned by a call
- to compile().
-
- The \a object will be an instance of the TypeClass specified by QML_REGISTER_CUSTOM_TYPE.
-*/
-
-QmlCustomParserNode
-QmlCustomParserNodePrivate::fromObject(QmlParser::Object *root)
-{
- QmlCustomParserNode rootNode;
- rootNode.d->name = root->typeName;
- rootNode.d->location = root->location.start;
-
- for(QHash<QByteArray, Property *>::Iterator iter = root->properties.begin();
- iter != root->properties.end();
- ++iter) {
-
- Property *p = *iter;
-
- rootNode.d->properties << fromProperty(p);
- }
-
- return rootNode;
-}
-
-QmlCustomParserProperty
-QmlCustomParserNodePrivate::fromProperty(QmlParser::Property *p)
-{
- QmlCustomParserProperty prop;
- prop.d->name = p->name;
- prop.d->isList = (p->values.count() > 1);
- prop.d->location = p->location.start;
-
- if (p->value) {
- QmlCustomParserNode node = fromObject(p->value);
- QList<QmlCustomParserProperty> props = node.properties();
- for (int ii = 0; ii < props.count(); ++ii)
- prop.d->values << QVariant::fromValue(props.at(ii));
- } else {
- for(int ii = 0; ii < p->values.count(); ++ii) {
- Value *v = p->values.at(ii);
- v->type = QmlParser::Value::Literal;
-
- if(v->object) {
- QmlCustomParserNode node = fromObject(v->object);
- prop.d->values << QVariant::fromValue(node);
- } else {
- prop.d->values << QVariant::fromValue(v->value);
- }
-
- }
- }
-
- return prop;
-}
-
-QmlCustomParserNode::QmlCustomParserNode()
-: d(new QmlCustomParserNodePrivate)
-{
-}
-
-QmlCustomParserNode::QmlCustomParserNode(const QmlCustomParserNode &other)
-: d(new QmlCustomParserNodePrivate)
-{
- *this = other;
-}
-
-QmlCustomParserNode &QmlCustomParserNode::operator=(const QmlCustomParserNode &other)
-{
- d->name = other.d->name;
- d->properties = other.d->properties;
- d->location = other.d->location;
- return *this;
-}
-
-QmlCustomParserNode::~QmlCustomParserNode()
-{
- delete d; d = 0;
-}
-
-QByteArray QmlCustomParserNode::name() const
-{
- return d->name;
-}
-
-QList<QmlCustomParserProperty> QmlCustomParserNode::properties() const
-{
- return d->properties;
-}
-
-QmlParser::Location QmlCustomParserNode::location() const
-{
- return d->location;
-}
-
-QmlCustomParserProperty::QmlCustomParserProperty()
-: d(new QmlCustomParserPropertyPrivate)
-{
-}
-
-QmlCustomParserProperty::QmlCustomParserProperty(const QmlCustomParserProperty &other)
-: d(new QmlCustomParserPropertyPrivate)
-{
- *this = other;
-}
-
-QmlCustomParserProperty &QmlCustomParserProperty::operator=(const QmlCustomParserProperty &other)
-{
- d->name = other.d->name;
- d->isList = other.d->isList;
- d->values = other.d->values;
- d->location = other.d->location;
- return *this;
-}
-
-QmlCustomParserProperty::~QmlCustomParserProperty()
-{
- delete d; d = 0;
-}
-
-QByteArray QmlCustomParserProperty::name() const
-{
- return d->name;
-}
-
-bool QmlCustomParserProperty::isList() const
-{
- return d->isList;
-}
-
-QmlParser::Location QmlCustomParserProperty::location() const
-{
- return d->location;
-}
-
-QList<QVariant> QmlCustomParserProperty::assignedValues() const
-{
- return d->values;
-}
-
-void QmlCustomParser::clearErrors()
-{
- exceptions.clear();
-}
-
-/*!
- Reports an error in parsing \a prop, with the given \a description.
-
- An error is generated referring to the position of \a node in the source file.
-*/
-void QmlCustomParser::error(const QmlCustomParserProperty& prop, const QString& description)
-{
- QmlError error;
- QString exceptionDescription;
- error.setLine(prop.location().line);
- error.setColumn(prop.location().column);
- error.setDescription(description);
- exceptions << error;
-}
-
-/*!
- Reports an error in parsing \a node, with the given \a description.
-
- An error is generated referring to the position of \a node in the source file.
-*/
-void QmlCustomParser::error(const QmlCustomParserNode& node, const QString& description)
-{
- QmlError error;
- QString exceptionDescription;
- error.setLine(node.location().line);
- error.setColumn(node.location().column);
- error.setDescription(description);
- exceptions << error;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h
deleted file mode 100644
index e198712..0000000
--- a/src/declarative/qml/qmlcustomparser_p.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCUSTOMPARSER_H
-#define QMLCUSTOMPARSER_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 "qmlmetatype.h"
-#include "qmlerror.h"
-#include "qmlparser_p.h"
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qxmlstream.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlCustomParserPropertyPrivate;
-class Q_DECLARATIVE_EXPORT QmlCustomParserProperty
-{
-public:
- QmlCustomParserProperty();
- QmlCustomParserProperty(const QmlCustomParserProperty &);
- QmlCustomParserProperty &operator=(const QmlCustomParserProperty &);
- ~QmlCustomParserProperty();
-
- QByteArray name() const;
- QmlParser::Location location() const;
-
- bool isList() const;
- // Will be one of QmlParser::Variant, QmlCustomParserProperty or
- // QmlCustomParserNode
- QList<QVariant> assignedValues() const;
-
-private:
- friend class QmlCustomParserNodePrivate;
- friend class QmlCustomParserPropertyPrivate;
- QmlCustomParserPropertyPrivate *d;
-};
-
-class QmlCustomParserNodePrivate;
-class Q_DECLARATIVE_EXPORT QmlCustomParserNode
-{
-public:
- QmlCustomParserNode();
- QmlCustomParserNode(const QmlCustomParserNode &);
- QmlCustomParserNode &operator=(const QmlCustomParserNode &);
- ~QmlCustomParserNode();
-
- QByteArray name() const;
- QmlParser::Location location() const;
-
- QList<QmlCustomParserProperty> properties() const;
-
-private:
- friend class QmlCustomParserNodePrivate;
- QmlCustomParserNodePrivate *d;
-};
-
-class Q_DECLARATIVE_EXPORT QmlCustomParser
-{
-public:
- virtual ~QmlCustomParser() {}
-
- void clearErrors();
-
- virtual QByteArray compile(const QList<QmlCustomParserProperty> &)=0;
- virtual void setCustomData(QObject *, const QByteArray &)=0;
-
- QList<QmlError> errors() const { return exceptions; }
-
-protected:
- void error(const QmlCustomParserProperty&, const QString& description);
- void error(const QmlCustomParserNode&, const QString& description);
-
-private:
- QList<QmlError> exceptions;
-};
-
-#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
- qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE)
-
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QmlCustomParserProperty)
-Q_DECLARE_METATYPE(QmlCustomParserNode)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/qml/qmlcustomparser_p_p.h b/src/declarative/qml/qmlcustomparser_p_p.h
deleted file mode 100644
index 52e7b4f..0000000
--- a/src/declarative/qml/qmlcustomparser_p_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLCUSTOMPARSER_P_H
-#define QMLCUSTOMPARSER_P_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 "qmlcustomparser_p.h"
-
-#include "qmlparser_p.h"
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlCustomParserNodePrivate
-{
-public:
- QByteArray name;
- QList<QmlCustomParserProperty> properties;
- QmlParser::Location location;
-
- static QmlCustomParserNode fromObject(QmlParser::Object *);
- static QmlCustomParserProperty fromProperty(QmlParser::Property *);
-};
-
-class QmlCustomParserPropertyPrivate
-{
-public:
- QmlCustomParserPropertyPrivate()
- : isList(false) {}
-
- QByteArray name;
- bool isList;
- QmlParser::Location location;
- QList<QVariant> values;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLCUSTOMPARSER_P_H
diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h
deleted file mode 100644
index efdc5fd..0000000
--- a/src/declarative/qml/qmldeclarativedata_p.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLDECLARATIVEDATA_P_H
-#define QMLDECLARATIVEDATA_P_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 <QtScript/qscriptvalue.h>
-#include <private/qobject_p.h>
-#include "qmlguard_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlCompiledData;
-class QmlAbstractBinding;
-class QmlContext;
-class QmlPropertyCache;
-class Q_AUTOTEST_EXPORT QmlDeclarativeData : public QDeclarativeData
-{
-public:
- QmlDeclarativeData(QmlContext *ctxt = 0)
- : context(ctxt), bindings(0), nextContextObject(0), prevContextObject(0),
- bindingBitsSize(0), bindingBits(0), outerContext(0), lineNumber(0),
- columnNumber(0), deferredComponent(0), deferredIdx(0), attachedProperties(0),
- propertyCache(0), guards(0) {}
-
- virtual void destroyed(QObject *);
-
- QmlContext *context;
- QmlAbstractBinding *bindings;
-
- // Linked list for QmlContext::contextObjects
- QmlDeclarativeData *nextContextObject;
- QmlDeclarativeData**prevContextObject;
-
- int bindingBitsSize;
- quint32 *bindingBits;
- bool hasBindingBit(int) const;
- void clearBindingBit(int);
- void setBindingBit(QObject *obj, int);
-
- QmlContext *outerContext; // Can't this be found from context?
- ushort lineNumber;
- ushort columnNumber;
-
- QmlCompiledData *deferredComponent; // Can't this be found from the context?
- unsigned int deferredIdx;
-
- QHash<int, QObject *> *attachedProperties;
-
- QScriptValue scriptValue;
- QmlPropertyCache *propertyCache;
-
- QmlGuard<QObject> *guards;
-
- static QmlDeclarativeData *get(const QObject *object, bool create = false) {
- QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
- if (priv->declarativeData) {
- return static_cast<QmlDeclarativeData *>(priv->declarativeData);
- } else if (create) {
- priv->declarativeData = new QmlDeclarativeData;
- return static_cast<QmlDeclarativeData *>(priv->declarativeData);
- } else {
- return 0;
- }
- }
-};
-
-template<class T>
-void QmlGuard<T>::addGuard()
-{
- QmlDeclarativeData *data = QmlDeclarativeData::get(o, true);
- next = data->guards;
- if (next) reinterpret_cast<QmlGuard<T> *>(next)->prev = &next;
- data->guards = reinterpret_cast<QmlGuard<QObject> *>(this);
- prev = &data->guards;
-}
-
-template<class T>
-void QmlGuard<T>::remGuard()
-{
- if (next) reinterpret_cast<QmlGuard<T> *>(next)->prev = prev;
- *prev = next;
- next = 0;
- prev = 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QMLDECLARATIVEDATA_P_H
diff --git a/src/declarative/qml/qmldirparser.cpp b/src/declarative/qml/qmldirparser.cpp
deleted file mode 100644
index 60beb72..0000000
--- a/src/declarative/qml/qmldirparser.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmldirparser_p.h"
-#include "qmlerror.h"
-
-#include <QtCore/QTextStream>
-#include <QtCore/QtDebug>
-
-QT_BEGIN_NAMESPACE
-
-QmlDirParser::QmlDirParser()
- : _isParsed(false)
-{
-}
-
-QmlDirParser::~QmlDirParser()
-{
-}
-
-QUrl QmlDirParser::url() const
-{
- return _url;
-}
-
-void QmlDirParser::setUrl(const QUrl &url)
-{
- _url = url;
-}
-
-QString QmlDirParser::source() const
-{
- return _source;
-}
-
-void QmlDirParser::setSource(const QString &source)
-{
- _isParsed = false;
- _source = source;
-}
-
-bool QmlDirParser::isParsed() const
-{
- return _isParsed;
-}
-
-bool QmlDirParser::parse()
-{
- if (_isParsed)
- return true;
-
- _isParsed = true;
- _errors.clear();
- _plugins.clear();
- _components.clear();
-
- QTextStream stream(&_source);
- int lineNumber = 0;
-
- forever {
- ++lineNumber;
-
- const QString line = stream.readLine();
- if (line.isNull())
- break;
-
- QString sections[3];
- int sectionCount = 0;
-
- int index = 0;
- const int length = line.length();
-
- while (index != length) {
- const QChar ch = line.at(index);
-
- if (ch.isSpace()) {
- do { ++index; }
- while (index != length && line.at(index).isSpace());
-
- } else if (ch == QLatin1Char('#')) {
- // recognized a comment
- break;
-
- } else {
- const int start = index;
-
- do { ++index; }
- while (index != length && !line.at(index).isSpace());
-
- const QString lexeme = line.mid(start, index - start);
-
- if (sectionCount >= 3) {
- reportError(lineNumber, start, QLatin1String("unexpected token"));
-
- } else {
- sections[sectionCount++] = lexeme;
- }
- }
- }
-
- if (sectionCount == 0) {
- continue; // no sections, no party.
-
- } else if (sections[0] == QLatin1String("plugin")) {
- if (sectionCount < 2) {
- reportError(lineNumber, -1,
- QString::fromUtf8("plugin directive requires 2 arguments, but %1 were provided").arg(sectionCount + 1));
-
- continue;
- }
-
- const Plugin entry(sections[1], sections[2]);
-
- _plugins.append(entry);
-
- } else if (sectionCount == 3) {
- const QString &version = sections[1];
- const int dotIndex = version.indexOf(QLatin1Char('.'));
-
- if (dotIndex == -1) {
- qWarning() << "expected '.'"; // ### use reportError
-
- } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) {
- qWarning() << "unexpected '.'"; // ### use reportError
-
- } else {
- bool validVersionNumber = false;
- const int majorVersion = version.left(dotIndex).toInt(&validVersionNumber);
-
- if (validVersionNumber) {
- const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber);
-
- if (validVersionNumber) {
- const Component entry(sections[0], sections[2], majorVersion, minorVersion);
-
- _components.append(entry);
- }
- }
- }
- } else {
- // ### use reportError
- qWarning() << "a component declaration requires 3 arguments, but" << (sectionCount + 1) << "were provided";
- }
- }
-
- return hasError();
-}
-
-void QmlDirParser::reportError(int line, int column, const QString &description)
-{
- QmlError error;
- error.setUrl(_url);
- error.setLine(line);
- error.setColumn(column);
- error.setDescription(description);
- _errors.append(error);
-}
-
-bool QmlDirParser::hasError() const
-{
- if (! _errors.isEmpty())
- return true;
-
- return false;
-}
-
-QList<QmlError> QmlDirParser::errors() const
-{
- return _errors;
-}
-
-QList<QmlDirParser::Plugin> QmlDirParser::plugins() const
-{
- return _plugins;
-}
-
-QList<QmlDirParser::Component> QmlDirParser::components() const
-{
- return _components;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmldirparser_p.h b/src/declarative/qml/qmldirparser_p.h
deleted file mode 100644
index c58c03f..0000000
--- a/src/declarative/qml/qmldirparser_p.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLDIRPARSER_P_H
-#define QMLDIRPARSER_P_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/QUrl>
-#include <QtCore/QHash>
-
-QT_BEGIN_NAMESPACE
-
-class QmlError;
-
-class QmlDirParser
-{
- Q_DISABLE_COPY(QmlDirParser)
-
-public:
- QmlDirParser();
- ~QmlDirParser();
-
- QUrl url() const;
- void setUrl(const QUrl &url);
-
- QString source() const;
- void setSource(const QString &source);
-
- bool isParsed() const;
- bool parse();
-
- bool hasError() const;
- QList<QmlError> errors() const;
-
- struct Plugin
- {
- Plugin() {}
-
- Plugin(const QString &name, const QString &path)
- : name(name), path(path) {}
-
- QString name;
- QString path;
- };
-
- struct Component
- {
- Component()
- : majorVersion(0), minorVersion(0) {}
-
- Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
- : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {}
-
- QString typeName;
- QString fileName;
- int majorVersion;
- int minorVersion;
- };
-
- QList<Component> components() const;
- QList<Plugin> plugins() const;
-
-private:
- void reportError(int line, int column, const QString &message);
-
-private:
- QList<QmlError> _errors;
- QUrl _url;
- QString _source;
- QList<Component> _components;
- QList<Plugin> _plugins;
- unsigned _isParsed: 1;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLDIRPARSER_P_H
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
deleted file mode 100644
index c75a299..0000000
--- a/src/declarative/qml/qmldom.cpp
+++ /dev/null
@@ -1,1836 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmldom_p.h"
-#include "qmldom_p_p.h"
-
-#include "qmlcompositetypedata_p.h"
-#include "qmlcompiler_p.h"
-#include "qmlengine_p.h"
-#include "qmlscriptparser_p.h"
-#include "qmlglobal_p.h"
-
-#include <QtCore/QByteArray>
-#include <QtCore/QDebug>
-#include <QtCore/QString>
-
-QT_BEGIN_NAMESPACE
-
-QmlDomDocumentPrivate::QmlDomDocumentPrivate()
-: root(0)
-{
-}
-
-QmlDomDocumentPrivate::~QmlDomDocumentPrivate()
-{
- if (root) root->release();
-}
-
-/*!
- \class QmlDomDocument
- \internal
- \brief The QmlDomDocument class represents the root of a QML document
-
- A QML document is a self-contained snippet of QML, usually contained in a
- single file. Each document has a root object, accessible through
- QmlDomDocument::rootObject().
-
- The QmlDomDocument class allows the programmer to inspect a QML document by
- calling QmlDomDocument::load().
-
- The following example loads a QML file from disk, and prints out its root
- object type and the properties assigned in the root object.
- \code
- QFile file(inputFileName);
- file.open(QIODevice::ReadOnly);
- QByteArray xmlData = file.readAll();
-
- QmlDomDocument document;
- document.load(qmlengine, xmlData);
-
- QmlDomObject rootObject = document.rootObject();
- qDebug() << rootObject.objectType();
- foreach(QmlDomProperty property, rootObject.properties())
- qDebug() << property.propertyName();
- \endcode
-*/
-
-/*!
- Construct an empty QmlDomDocument.
-*/
-QmlDomDocument::QmlDomDocument()
-: d(new QmlDomDocumentPrivate)
-{
-}
-
-/*!
- Create a copy of \a other QmlDomDocument.
-*/
-QmlDomDocument::QmlDomDocument(const QmlDomDocument &other)
-: d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomDocument
-*/
-QmlDomDocument::~QmlDomDocument()
-{
-}
-
-/*!
- Assign \a other to this QmlDomDocument.
-*/
-QmlDomDocument &QmlDomDocument::operator=(const QmlDomDocument &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Returns all import statements in qml.
-*/
-QList<QmlDomImport> QmlDomDocument::imports() const
-{
- return d->imports;
-}
-
-/*!
- Loads a QmlDomDocument from \a data. \a data should be valid QML
- data. On success, true is returned. If the \a data is malformed, false
- is returned and QmlDomDocument::errors() contains an error description.
-
- \sa QmlDomDocument::loadError()
-*/
-bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl &url)
-{
- d->errors.clear();
- d->imports.clear();
-
- QmlCompiledData *component = new QmlCompiledData(engine);
- QmlCompiler compiler;
-
- QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, url);
-
- if(td->status == QmlCompositeTypeData::Error) {
- d->errors = td->errors;
- td->release();
- component->release();
- return false;
- } else if(td->status == QmlCompositeTypeData::Waiting ||
- td->status == QmlCompositeTypeData::WaitingResources) {
- QmlError error;
- error.setDescription(QLatin1String("QmlDomDocument supports local types only"));
- d->errors << error;
- td->release();
- component->release();
- return false;
- }
-
- compiler.compile(engine, td, component);
-
- if (compiler.isError()) {
- d->errors = compiler.errors();
- td->release();
- component->release();
- return false;
- }
-
- for (int i = 0; i < td->data.imports().size(); ++i) {
- QmlScriptParser::Import parserImport = td->data.imports().at(i);
- QmlDomImport domImport;
- domImport.d->type = static_cast<QmlDomImportPrivate::Type>(parserImport.type);
- domImport.d->uri = parserImport.uri;
- domImport.d->qualifier = parserImport.qualifier;
- domImport.d->version = parserImport.version;
- d->imports += domImport;
- }
-
- if (td->data.tree()) {
- d->root = td->data.tree();
- d->root->addref();
- }
-
- component->release();
- return true;
-}
-
-/*!
- Returns the last load errors. The load errors will be reset after a
- successful call to load().
-
- \sa load()
-*/
-QList<QmlError> QmlDomDocument::errors() const
-{
- return d->errors;
-}
-
-/*!
- Returns the document's root object, or an invalid QmlDomObject if the
- document has no root.
-
- In the sample QML below, the root object will be the QmlGraphicsItem type.
- \qml
-Item {
- Text {
- text: "Hello World"
- }
-}
- \endqml
-*/
-QmlDomObject QmlDomDocument::rootObject() const
-{
- QmlDomObject rv;
- rv.d->object = d->root;
- if (rv.d->object) rv.d->object->addref();
- return rv;
-}
-
-QmlDomPropertyPrivate::QmlDomPropertyPrivate()
-: property(0)
-{
-}
-
-QmlDomPropertyPrivate::~QmlDomPropertyPrivate()
-{
- if (property) property->release();
-}
-
-QmlDomDynamicPropertyPrivate::QmlDomDynamicPropertyPrivate():
- valid(false)
-{
-}
-
-QmlDomDynamicPropertyPrivate::~QmlDomDynamicPropertyPrivate()
-{
- if (valid && property.defaultValue) property.defaultValue->release();
-}
-
-/*!
- \class QmlDomProperty
- \internal
- \brief The QmlDomProperty class represents one property assignment in the
- QML DOM tree
-
- Properties in QML can be assigned QML \l {QmlDomValue}{values}.
-
- \sa QmlDomObject
-*/
-
-/*!
- Construct an invalid QmlDomProperty.
-*/
-QmlDomProperty::QmlDomProperty()
-: d(new QmlDomPropertyPrivate)
-{
-}
-
-/*!
- Create a copy of \a other QmlDomProperty.
-*/
-QmlDomProperty::QmlDomProperty(const QmlDomProperty &other)
-: d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomProperty.
-*/
-QmlDomProperty::~QmlDomProperty()
-{
-}
-
-/*!
- Assign \a other to this QmlDomProperty.
-*/
-QmlDomProperty &QmlDomProperty::operator=(const QmlDomProperty &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Returns true if this is a valid QmlDomProperty, false otherwise.
-*/
-bool QmlDomProperty::isValid() const
-{
- return d->property != 0;
-}
-
-
-/*!
- Return the name of this property.
-
- \qml
-Text {
- x: 10
- y: 10
- font.bold: true
-}
- \endqml
-
- As illustrated above, a property name can be a simple string, such as "x" or
- "y", or a more complex "dot property", such as "font.bold". In both cases
- the full name is returned ("x", "y" and "font.bold") by this method.
-
- For dot properties, a split version of the name can be accessed by calling
- QmlDomProperty::propertyNameParts().
-
- \sa QmlDomProperty::propertyNameParts()
-*/
-QByteArray QmlDomProperty::propertyName() const
-{
- return d->propertyName;
-}
-
-/*!
- Return the name of this property, split into multiple parts in the case
- of dot properties.
-
- \qml
-Text {
- x: 10
- y: 10
- font.bold: true
-}
- \endqml
-
- For each of the properties shown above, this method would return ("x"),
- ("y") and ("font", "bold").
-
- \sa QmlDomProperty::propertyName()
-*/
-QList<QByteArray> QmlDomProperty::propertyNameParts() const
-{
- if (d->propertyName.isEmpty()) return QList<QByteArray>();
- else return d->propertyName.split('.');
-}
-
-/*!
- Return true if this property is used as a default property in the QML
- document.
-
- \qml
-<Text text="hello"/>
-<Text>hello</Text>
- \endqml
-
- The above two examples return the same DOM tree, except that the second has
- the default property flag set on the text property. Observe that whether
- or not a property has isDefaultProperty set is determined by how the
- property is used, and not only by whether the property is the types default
- property.
-*/
-bool QmlDomProperty::isDefaultProperty() const
-{
- return d->property && d->property->isDefault;
-}
-
-/*!
- Returns the QmlDomValue that is assigned to this property, or an invalid
- QmlDomValue if no value is assigned.
-*/
-QmlDomValue QmlDomProperty::value() const
-{
- QmlDomValue rv;
- if (d->property) {
- rv.d->property = d->property;
- rv.d->value = d->property->values.at(0);
- rv.d->property->addref();
- rv.d->value->addref();
- }
- return rv;
-}
-
-/*!
- Returns the position in the input data where the property ID startd, or -1 if
- the property is invalid.
-*/
-int QmlDomProperty::position() const
-{
- if (d && d->property) {
- return d->property->location.range.offset;
- } else
- return -1;
-}
-
-/*!
- Returns the length in the input data from where the property ID started upto
- the end of it, or -1 if the property is invalid.
-*/
-int QmlDomProperty::length() const
-{
- if (d && d->property)
- return d->property->location.range.length;
- else
- return -1;
-}
-
-/*!
- Construct an invalid QmlDomDynamicProperty.
-*/
-QmlDomDynamicProperty::QmlDomDynamicProperty():
- d(new QmlDomDynamicPropertyPrivate)
-{
-}
-
-/*!
- Create a copy of \a other QmlDomDynamicProperty.
-*/
-QmlDomDynamicProperty::QmlDomDynamicProperty(const QmlDomDynamicProperty &other):
- d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomDynamicProperty.
-*/
-QmlDomDynamicProperty::~QmlDomDynamicProperty()
-{
-}
-
-/*!
- Assign \a other to this QmlDomDynamicProperty.
-*/
-QmlDomDynamicProperty &QmlDomDynamicProperty::operator=(const QmlDomDynamicProperty &other)
-{
- d = other.d;
- return *this;
-}
-
-bool QmlDomDynamicProperty::isValid() const
-{
- return d && d->valid;
-}
-
-/*!
- Return the name of this dynamic property.
-
- \qml
-Item {
- property int count: 10;
-}
- \endqml
-
- As illustrated above, a dynamic property name can have a name and a
- default value ("10").
-*/
-QByteArray QmlDomDynamicProperty::propertyName() const
-{
- if (isValid())
- return d->property.name;
- else
- return QByteArray();
-}
-
-/*!
- Returns the type of the dynamic property. Note that when the property is an
- alias property, this will return -1. Use QmlDomProperty::isAlias() to check
- if the property is an alias.
-*/
-int QmlDomDynamicProperty::propertyType() const
-{
- if (isValid()) {
- switch (d->property.type) {
- case QmlParser::Object::DynamicProperty::Bool:
- return QMetaType::type("bool");
-
- case QmlParser::Object::DynamicProperty::Color:
- return QMetaType::type("QColor");
-
- case QmlParser::Object::DynamicProperty::Date:
- return QMetaType::type("QDate");
-
- case QmlParser::Object::DynamicProperty::Int:
- return QMetaType::type("int");
-
- case QmlParser::Object::DynamicProperty::Real:
- return QMetaType::type("double");
-
- case QmlParser::Object::DynamicProperty::String:
- return QMetaType::type("QString");
-
- case QmlParser::Object::DynamicProperty::Url:
- return QMetaType::type("QUrl");
-
- case QmlParser::Object::DynamicProperty::Variant:
- return QMetaType::type("QVariant");
-
- default:
- break;
- }
- }
-
- return -1;
-}
-
-QByteArray QmlDomDynamicProperty::propertyTypeName() const
-{
- if (isValid())
- return d->property.customType;
-
- return QByteArray();
-}
-
-/*!
- Return true if this property is used as a default property in the QML
- document.
-
- \qml
-<Text text="hello"/>
-<Text>hello</Text>
- \endqml
-
- The above two examples return the same DOM tree, except that the second has
- the default property flag set on the text property. Observe that whether
- or not a property has isDefaultProperty set is determined by how the
- property is used, and not only by whether the property is the types default
- property.
-*/
-bool QmlDomDynamicProperty::isDefaultProperty() const
-{
- if (isValid())
- return d->property.isDefaultProperty;
- else
- return false;
-}
-
-/*!
- Returns the default value as a QmlDomProperty.
-*/
-QmlDomProperty QmlDomDynamicProperty::defaultValue() const
-{
- QmlDomProperty rp;
-
- if (isValid() && d->property.defaultValue) {
- rp.d->property = d->property.defaultValue;
- rp.d->propertyName = propertyName();
- rp.d->property->addref();
- }
-
- return rp;
-}
-
-/*!
- Returns true if this dynamic property is an alias for another property,
- false otherwise.
-*/
-bool QmlDomDynamicProperty::isAlias() const
-{
- if (isValid())
- return d->property.type == QmlParser::Object::DynamicProperty::Alias;
- else
- return false;
-}
-
-/*!
- Returns the position in the input data where the property ID startd, or 0 if
- the property is invalid.
-*/
-int QmlDomDynamicProperty::position() const
-{
- if (isValid()) {
- return d->property.location.range.offset;
- } else
- return -1;
-}
-
-/*!
- Returns the length in the input data from where the property ID started upto
- the end of it, or 0 if the property is invalid.
-*/
-int QmlDomDynamicProperty::length() const
-{
- if (isValid())
- return d->property.location.range.length;
- else
- return -1;
-}
-
-QmlDomObjectPrivate::QmlDomObjectPrivate()
-: object(0)
-{
-}
-
-QmlDomObjectPrivate::~QmlDomObjectPrivate()
-{
- if (object) object->release();
-}
-
-QmlDomObjectPrivate::Properties
-QmlDomObjectPrivate::properties() const
-{
- Properties rv;
-
- for (QHash<QByteArray, QmlParser::Property *>::ConstIterator iter =
- object->properties.begin();
- iter != object->properties.end();
- ++iter) {
-
- rv << properties(*iter);
-
- }
- return rv;
-}
-
-QmlDomObjectPrivate::Properties
-QmlDomObjectPrivate::properties(QmlParser::Property *property) const
-{
- Properties rv;
-
- if (property->value) {
-
- for (QHash<QByteArray, QmlParser::Property *>::ConstIterator iter =
- property->value->properties.begin();
- iter != property->value->properties.end();
- ++iter) {
-
- rv << properties(*iter);
-
- }
-
- QByteArray name(property->name + '.');
- for (Properties::Iterator iter = rv.begin(); iter != rv.end(); ++iter)
- iter->second.prepend(name);
-
- } else {
- rv << qMakePair(property, property->name);
- }
-
- return rv;
-}
-
-/*!
- \class QmlDomObject
- \internal
- \brief The QmlDomObject class represents an object instantiation.
-
- Each object instantiated in a QML file has a corresponding QmlDomObject
- node in the QML DOM.
-
- In addition to the type information that determines the object to
- instantiate, QmlDomObject's also have a set of associated QmlDomProperty's.
- Each QmlDomProperty represents a QML property assignment on the instantiated
- object. For example,
-
- \qml
-QGraphicsWidget {
- opacity: 0.5
- size: "100x100"
-}
- \endqml
-
- describes a single QmlDomObject - "QGraphicsWidget" - with two properties,
- "opacity" and "size". Obviously QGraphicsWidget has many more properties than just
- these two, but the QML DOM representation only contains those assigned
- values (or bindings) in the QML file.
-*/
-
-/*!
- Construct an invalid QmlDomObject.
-*/
-QmlDomObject::QmlDomObject()
-: d(new QmlDomObjectPrivate)
-{
-}
-
-/*!
- Create a copy of \a other QmlDomObject.
-*/
-QmlDomObject::QmlDomObject(const QmlDomObject &other)
-: d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomObject.
-*/
-QmlDomObject::~QmlDomObject()
-{
-}
-
-/*!
- Assign \a other to this QmlDomObject.
-*/
-QmlDomObject &QmlDomObject::operator=(const QmlDomObject &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Returns true if this is a valid QmlDomObject, false otherwise.
-*/
-bool QmlDomObject::isValid() const
-{
- return d->object != 0;
-}
-
-/*!
- Returns the fully-qualified type name of this object.
-
- For example, the type of this object would be "Qt/4.6/Rectangle".
- \qml
-Rectangle { }
- \endqml
-*/
-QByteArray QmlDomObject::objectType() const
-{
- if (d->object) return d->object->typeName;
- else return QByteArray();
-}
-
-/*!
- Returns the type name as referenced in the qml file.
-
- For example, the type of this object would be "Rectangle".
- \qml
-Rectangle { }
- \endqml
-*/
-QByteArray QmlDomObject::objectClassName() const
-{
- if (d->object)
- return d->object->className;
- else
- return QByteArray();
-}
-
-int QmlDomObject::objectTypeMajorVersion() const
-{
- if (d->object)
- return d->object->majorVersion;
- else
- return -1;
-}
-
-int QmlDomObject::objectTypeMinorVersion() const
-{
- if (d->object)
- return d->object->minorVersion;
- else
- return -1;
-}
-
-/*!
- Returns the QML id assigned to this object, or an empty QByteArray if no id
- has been assigned.
-
- For example, the object id of this object would be "MyText".
- \qml
-Text { id: myText }
- \endqml
-*/
-QString QmlDomObject::objectId() const
-{
- if (d->object) {
- return d->object->id;
- } else {
- return QString();
- }
-}
-
-/*!
- Returns the list of assigned properties on this object.
-
- In the following example, "text" and "x" properties would be returned.
- \qml
-Text {
- text: "Hello world!"
- x: 100
-}
- \endqml
-*/
-QList<QmlDomProperty> QmlDomObject::properties() const
-{
- QList<QmlDomProperty> rv;
-
- if (!d->object || isComponent())
- return rv;
-
- QmlDomObjectPrivate::Properties properties = d->properties();
- for (int ii = 0; ii < properties.count(); ++ii) {
-
- QmlDomProperty domProperty;
- domProperty.d->property = properties.at(ii).first;
- domProperty.d->property->addref();
- domProperty.d->propertyName = properties.at(ii).second;
- rv << domProperty;
-
- }
-
- if (d->object->defaultProperty) {
- QmlDomProperty domProperty;
- domProperty.d->property = d->object->defaultProperty;
- domProperty.d->property->addref();
- domProperty.d->propertyName = d->object->defaultProperty->name;
- rv << domProperty;
- }
-
- return rv;
-}
-
-/*!
- Returns the object's \a name property if a value has been assigned to
- it, or an invalid QmlDomProperty otherwise.
-
- In the example below, \c {object.property("source")} would return a valid
- QmlDomProperty, and \c {object.property("tile")} an invalid QmlDomProperty.
-
- \qml
-Image { source: "sample.jpg" }
- \endqml
-*/
-QmlDomProperty QmlDomObject::property(const QByteArray &name) const
-{
- QList<QmlDomProperty> props = properties();
- for (int ii = 0; ii < props.count(); ++ii)
- if (props.at(ii).propertyName() == name)
- return props.at(ii);
- return QmlDomProperty();
-}
-
-QList<QmlDomDynamicProperty> QmlDomObject::dynamicProperties() const
-{
- QList<QmlDomDynamicProperty> properties;
-
- for (int i = 0; i < d->object->dynamicProperties.size(); ++i) {
- QmlDomDynamicProperty p;
- p.d = new QmlDomDynamicPropertyPrivate;
- p.d->property = d->object->dynamicProperties.at(i);
- p.d->valid = true;
-
- if (p.d->property.defaultValue)
- p.d->property.defaultValue->addref();
-
- properties.append(p);
- }
-
- return properties;
-}
-
-QmlDomDynamicProperty QmlDomObject::dynamicProperty(const QByteArray &name) const
-{
- QmlDomDynamicProperty p;
-
- if (!isValid())
- return p;
-
- for (int i = 0; i < d->object->dynamicProperties.size(); ++i) {
- if (d->object->dynamicProperties.at(i).name == name) {
- p.d = new QmlDomDynamicPropertyPrivate;
- p.d->property = d->object->dynamicProperties.at(i);
- if (p.d->property.defaultValue) p.d->property.defaultValue->addref();
- p.d->valid = true;
- }
- }
-
- return p;
-}
-
-/*!
- Returns true if this object is a custom type. Custom types are special
- types that allow embeddeding non-QML data, such as SVG or HTML data,
- directly into QML files.
-
- \note Currently this method will always return false, and is a placekeeper
- for future functionality.
-
- \sa QmlDomObject::customTypeData()
-*/
-bool QmlDomObject::isCustomType() const
-{
- return false;
-}
-
-/*!
- If this object represents a custom type, returns the data associated with
- the custom type, otherwise returns an empty QByteArray().
- QmlDomObject::isCustomType() can be used to check if this object represents
- a custom type.
-*/
-QByteArray QmlDomObject::customTypeData() const
-{
- return QByteArray();
-}
-
-/*!
- Returns true if this object is a sub-component object. Sub-component
- objects can be converted into QmlDomComponent instances by calling
- QmlDomObject::toComponent().
-
- \sa QmlDomObject::toComponent()
-*/
-bool QmlDomObject::isComponent() const
-{
- return (d->object && d->object->typeName == "Qt/Component");
-}
-
-/*!
- Returns a QmlDomComponent for this object if it is a sub-component, or
- an invalid QmlDomComponent if not. QmlDomObject::isComponent() can be used
- to check if this object represents a sub-component.
-
- \sa QmlDomObject::isComponent()
-*/
-QmlDomComponent QmlDomObject::toComponent() const
-{
- QmlDomComponent rv;
- if (isComponent())
- rv.d = d;
- return rv;
-}
-
-/*!
- Returns the position in the input data where the property assignment started
-, or -1 if the property is invalid.
-*/
-int QmlDomObject::position() const
-{
- if (d && d->object)
- return d->object->location.range.offset;
- else
- return -1;
-}
-
-/*!
- Returns the length in the input data from where the property assignment star
-ted upto the end of it, or -1 if the property is invalid.
-*/
-int QmlDomObject::length() const
-{
- if (d && d->object)
- return d->object->location.range.length;
- else
- return -1;
-}
-
-// Returns the URL of the type, if it is an external type, or an empty URL if
-// not
-QUrl QmlDomObject::url() const
-{
- if (d && d->object)
- return d->object->url;
- else
- return QUrl();
-}
-
-QmlDomBasicValuePrivate::QmlDomBasicValuePrivate()
-: value(0)
-{
-}
-
-QmlDomBasicValuePrivate::~QmlDomBasicValuePrivate()
-{
- if (value) value->release();
-}
-
-/*!
- \class QmlDomValueLiteral
- \internal
- \brief The QmlDomValueLiteral class represents a literal value.
-
- A literal value is a simple value, written inline with the QML. In the
- example below, the "x", "y" and "color" properties are being assigned
- literal values.
-
- \qml
-Rectangle {
- x: 10
- y: 10
- color: "red"
-}
- \endqml
-*/
-
-/*!
- Construct an empty QmlDomValueLiteral.
-*/
-QmlDomValueLiteral::QmlDomValueLiteral():
- d(new QmlDomBasicValuePrivate)
-{
-}
-
-/*!
- Create a copy of \a other QmlDomValueLiteral.
-*/
-QmlDomValueLiteral::QmlDomValueLiteral(const QmlDomValueLiteral &other)
-: d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomValueLiteral.
-*/
-QmlDomValueLiteral::~QmlDomValueLiteral()
-{
-}
-
-/*!
- Assign \a other to this QmlDomValueLiteral.
-*/
-QmlDomValueLiteral &QmlDomValueLiteral::operator=(const QmlDomValueLiteral &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Return the literal value.
-
- In the example below, the literal value will be the string "10".
- \qml
-Rectangle { x: 10 }
- \endqml
-*/
-QString QmlDomValueLiteral::literal() const
-{
- if (d->value) return d->value->primitive();
- else return QString();
-}
-
-/*!
- \class QmlDomValueBinding
- \internal
- \brief The QmlDomValueBinding class represents a property binding.
-
- A property binding is an ECMAScript expression assigned to a property. In
- the example below, the "x" property is being assigned a property binding.
-
- \qml
-Rectangle { x: Other.x }
- \endqml
-*/
-
-/*!
- Construct an empty QmlDomValueBinding.
-*/
-QmlDomValueBinding::QmlDomValueBinding():
- d(new QmlDomBasicValuePrivate)
-{
-}
-
-/*!
- Create a copy of \a other QmlDomValueBinding.
-*/
-QmlDomValueBinding::QmlDomValueBinding(const QmlDomValueBinding &other)
-: d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomValueBinding.
-*/
-QmlDomValueBinding::~QmlDomValueBinding()
-{
-}
-
-/*!
- Assign \a other to this QmlDomValueBinding.
-*/
-QmlDomValueBinding &QmlDomValueBinding::operator=(const QmlDomValueBinding &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Return the binding expression.
-
- In the example below, the string "Other.x" will be returned.
- \qml
-Rectangle { x: Other.x }
- \endqml
-*/
-QString QmlDomValueBinding::binding() const
-{
- if (d->value)
- return d->value->value.asScript();
- else
- return QString();
-}
-
-/*!
- \class QmlDomValueValueSource
- \internal
- \brief The QmlDomValueValueSource class represents a value source assignment value.
-
- In QML, value sources are special value generating types that may be
- assigned to properties. Value sources inherit the QmlPropertyValueSource
- class. In the example below, the "x" property is being assigned the
- NumberAnimation value source.
-
- \qml
-Rectangle {
- x: NumberAnimation {
- from: 0
- to: 100
- repeat: true
- running: true
- }
-}
- \endqml
-*/
-
-/*!
- Construct an empty QmlDomValueValueSource.
-*/
-QmlDomValueValueSource::QmlDomValueValueSource():
- d(new QmlDomBasicValuePrivate)
-{
-}
-
-/*!
- Create a copy of \a other QmlDomValueValueSource.
-*/
-QmlDomValueValueSource::QmlDomValueValueSource(const QmlDomValueValueSource &other)
-: d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomValueValueSource.
-*/
-QmlDomValueValueSource::~QmlDomValueValueSource()
-{
-}
-
-/*!
- Assign \a other to this QmlDomValueValueSource.
-*/
-QmlDomValueValueSource &QmlDomValueValueSource::operator=(const QmlDomValueValueSource &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Return the value source object.
-
- In the example below, an object representing the NumberAnimation will be
- returned.
- \qml
-Rectangle {
- x: NumberAnimation {
- from: 0
- to: 100
- repeat: true
- running: true
- }
-}
- \endqml
-*/
-QmlDomObject QmlDomValueValueSource::object() const
-{
- QmlDomObject rv;
- if (d->value) {
- rv.d->object = d->value->object;
- rv.d->object->addref();
- }
- return rv;
-}
-
-/*!
- \class QmlDomValueValueInterceptor
- \internal
- \brief The QmlDomValueValueInterceptor class represents a value interceptor assignment value.
-
- In QML, value interceptor are special write-intercepting types that may be
- assigned to properties. Value interceptor inherit the QmlPropertyValueInterceptor
- class. In the example below, the "x" property is being assigned the
- Behavior value interceptor.
-
- \qml
-Rectangle {
- x: Behavior { NumberAnimation { duration: 500 } }
-}
- \endqml
-*/
-
-/*!
- Construct an empty QmlDomValueValueInterceptor.
-*/
-QmlDomValueValueInterceptor::QmlDomValueValueInterceptor():
- d(new QmlDomBasicValuePrivate)
-{
-}
-
-/*!
- Create a copy of \a other QmlDomValueValueInterceptor.
-*/
-QmlDomValueValueInterceptor::QmlDomValueValueInterceptor(const QmlDomValueValueInterceptor &other)
-: d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomValueValueInterceptor.
-*/
-QmlDomValueValueInterceptor::~QmlDomValueValueInterceptor()
-{
-}
-
-/*!
- Assign \a other to this QmlDomValueValueInterceptor.
-*/
-QmlDomValueValueInterceptor &QmlDomValueValueInterceptor::operator=(const QmlDomValueValueInterceptor &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Return the value interceptor object.
-
- In the example below, an object representing the Behavior will be
- returned.
- \qml
-Rectangle {
- x: Behavior { NumberAnimation { duration: 500 } }
-}
- \endqml
-*/
-QmlDomObject QmlDomValueValueInterceptor::object() const
-{
- QmlDomObject rv;
- if (d->value) {
- rv.d->object = d->value->object;
- rv.d->object->addref();
- }
- return rv;
-}
-
-QmlDomValuePrivate::QmlDomValuePrivate()
-: property(0), value(0)
-{
-}
-
-QmlDomValuePrivate::~QmlDomValuePrivate()
-{
- if (property) property->release();
- if (value) value->release();
-}
-
-/*!
- \class QmlDomValue
- \internal
- \brief The QmlDomValue class represents a generic Qml value.
-
- QmlDomValue's can be assigned to QML \l {QmlDomProperty}{properties}. In
- QML, properties can be assigned various different values, including basic
- literals, property bindings, property value sources, objects and lists of
- values. The QmlDomValue class allows a programmer to determine the specific
- value type being assigned and access more detailed information through a
- corresponding value type class.
-
- For example, in the following example,
-
- \qml
-Text {
- text: "Hello World!"
- y: Other.y
-}
- \endqml
-
- The text property is being assigned a literal, and the y property a property
- binding. To output the values assigned to the text and y properties in the
- above example from C++,
-
- \code
- QmlDomDocument document;
- QmlDomObject root = document.rootObject();
-
- QmlDomProperty text = root.property("text");
- if (text.value().isLiteral()) {
- QmlDomValueLiteral literal = text.value().toLiteral();
- qDebug() << literal.literal();
- }
-
- QmlDomProperty y = root.property("y");
- if (y.value().isBinding()) {
- QmlDomValueBinding binding = y.value().toBinding();
- qDebug() << binding.binding();
- }
- \endcode
-*/
-
-/*!
- Construct an invalid QmlDomValue.
-*/
-QmlDomValue::QmlDomValue()
-: d(new QmlDomValuePrivate)
-{
-}
-
-/*!
- Create a copy of \a other QmlDomValue.
-*/
-QmlDomValue::QmlDomValue(const QmlDomValue &other)
-: d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomValue
-*/
-QmlDomValue::~QmlDomValue()
-{
-}
-
-/*!
- Assign \a other to this QmlDomValue.
-*/
-QmlDomValue &QmlDomValue::operator=(const QmlDomValue &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- \enum QmlDomValue::Type
-
- The type of the QmlDomValue node.
-
- \value Invalid The QmlDomValue is invalid.
- \value Literal The QmlDomValue is a literal value assignment. Use QmlDomValue::toLiteral() to access the type instance.
- \value PropertyBinding The QmlDomValue is a property binding. Use QmlDomValue::toBinding() to access the type instance.
- \value ValueSource The QmlDomValue is a property value source. Use QmlDomValue::toValueSource() to access the type instance.
- \value ValueInterceptor The QmlDomValue is a property value interceptor. Use QmlDomValue::toValueInterceptor() to access the type instance.
- \value Object The QmlDomValue is an object assignment. Use QmlDomValue::toObject() to access the type instnace.
- \value List The QmlDomValue is a list of other values. Use QmlDomValue::toList() to access the type instance.
-*/
-
-/*!
- Returns the type of this QmlDomValue.
-*/
-QmlDomValue::Type QmlDomValue::type() const
-{
- if (d->property)
- if (QmlMetaType::isList(d->property->type) ||
- (d->property && d->property->values.count() > 1))
- return List;
-
- QmlParser::Value *value = d->value;
- if (!value && !d->property)
- return Invalid;
-
- switch(value->type) {
- case QmlParser::Value::Unknown:
- return Invalid;
- case QmlParser::Value::Literal:
- return Literal;
- case QmlParser::Value::PropertyBinding:
- return PropertyBinding;
- case QmlParser::Value::ValueSource:
- return ValueSource;
- case QmlParser::Value::ValueInterceptor:
- return ValueInterceptor;
- case QmlParser::Value::CreatedObject:
- return Object;
- case QmlParser::Value::SignalObject:
- return Invalid;
- case QmlParser::Value::SignalExpression:
- return Literal;
- case QmlParser::Value::Id:
- return Literal;
- }
- return Invalid;
-}
-
-/*!
- Returns true if this is an invalid value, otherwise false.
-*/
-bool QmlDomValue::isInvalid() const
-{
- return type() == Invalid;
-}
-
-/*!
- Returns true if this is a literal value, otherwise false.
-*/
-bool QmlDomValue::isLiteral() const
-{
- return type() == Literal;
-}
-
-/*!
- Returns true if this is a property binding value, otherwise false.
-*/
-bool QmlDomValue::isBinding() const
-{
- return type() == PropertyBinding;
-}
-
-/*!
- Returns true if this is a value source value, otherwise false.
-*/
-bool QmlDomValue::isValueSource() const
-{
- return type() == ValueSource;
-}
-
-/*!
- Returns true if this is a value interceptor value, otherwise false.
-*/
-bool QmlDomValue::isValueInterceptor() const
-{
- return type() == ValueInterceptor;
-}
-
-/*!
- Returns true if this is an object value, otherwise false.
-*/
-bool QmlDomValue::isObject() const
-{
- return type() == Object;
-}
-
-/*!
- Returns true if this is a list value, otherwise false.
-*/
-bool QmlDomValue::isList() const
-{
- return type() == List;
-}
-
-/*!
- Returns a QmlDomValueLiteral if this value is a literal type, otherwise
- returns an invalid QmlDomValueLiteral.
-
- \sa QmlDomValue::type()
-*/
-QmlDomValueLiteral QmlDomValue::toLiteral() const
-{
- QmlDomValueLiteral rv;
- if (type() == Literal) {
- rv.d->value = d->value;
- rv.d->value->addref();
- }
- return rv;
-}
-
-/*!
- Returns a QmlDomValueBinding if this value is a property binding type,
- otherwise returns an invalid QmlDomValueBinding.
-
- \sa QmlDomValue::type()
-*/
-QmlDomValueBinding QmlDomValue::toBinding() const
-{
- QmlDomValueBinding rv;
- if (type() == PropertyBinding) {
- rv.d->value = d->value;
- rv.d->value->addref();
- }
- return rv;
-}
-
-/*!
- Returns a QmlDomValueValueSource if this value is a property value source
- type, otherwise returns an invalid QmlDomValueValueSource.
-
- \sa QmlDomValue::type()
-*/
-QmlDomValueValueSource QmlDomValue::toValueSource() const
-{
- QmlDomValueValueSource rv;
- if (type() == ValueSource) {
- rv.d->value = d->value;
- rv.d->value->addref();
- }
- return rv;
-}
-
-/*!
- Returns a QmlDomValueValueInterceptor if this value is a property value interceptor
- type, otherwise returns an invalid QmlDomValueValueInterceptor.
-
- \sa QmlDomValue::type()
-*/
-QmlDomValueValueInterceptor QmlDomValue::toValueInterceptor() const
-{
- QmlDomValueValueInterceptor rv;
- if (type() == ValueInterceptor) {
- rv.d->value = d->value;
- rv.d->value->addref();
- }
- return rv;
-}
-
-/*!
- Returns a QmlDomObject if this value is an object assignment type, otherwise
- returns an invalid QmlDomObject.
-
- \sa QmlDomValue::type()
-*/
-QmlDomObject QmlDomValue::toObject() const
-{
- QmlDomObject rv;
- if (type() == Object) {
- rv.d->object = d->value->object;
- rv.d->object->addref();
- }
- return rv;
-}
-
-/*!
- Returns a QmlDomList if this value is a list type, otherwise returns an
- invalid QmlDomList.
-
- \sa QmlDomValue::type()
-*/
-QmlDomList QmlDomValue::toList() const
-{
- QmlDomList rv;
- if (type() == List) {
- rv.d = d;
- }
- return rv;
-}
-
-/*!
- Returns the position in the input data where the property value startd, or -1
- if the value is invalid.
-*/
-int QmlDomValue::position() const
-{
- if (type() == Invalid)
- return -1;
- else
- return d->value->location.range.offset;
-}
-
-/*!
- Returns the length in the input data from where the property value started u
-pto the end of it, or -1 if the value is invalid.
-*/
-int QmlDomValue::length() const
-{
- if (type() == Invalid)
- return -1;
- else
- return d->value->location.range.length;
-}
-
-/*!
- \class QmlDomList
- \internal
- \brief The QmlDomList class represents a list of values assigned to a QML property.
-
- Lists of values can be assigned to properties. For example, the following
- example assigns multiple objects to Item's "children" property
- \qml
-Item {
- children: [
- Text { },
- Rectangle { }
- ]
-}
- \endqml
-
- Lists can also be implicitly created by assigning multiple
- \l {QmlDomValueValueSource}{value sources} or constants to a property.
- \qml
-Item {
- x: 10
- x: NumberAnimation {
- running: false
- from: 0
- to: 100
- }
-}
- \endqml
-*/
-
-/*!
- Construct an empty QmlDomList.
-*/
-QmlDomList::QmlDomList()
-{
-}
-
-/*!
- Create a copy of \a other QmlDomList.
-*/
-QmlDomList::QmlDomList(const QmlDomList &other)
-: d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomList.
-*/
-QmlDomList::~QmlDomList()
-{
-}
-
-/*!
- Assign \a other to this QmlDomList.
-*/
-QmlDomList &QmlDomList::operator=(const QmlDomList &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Returns the list of QmlDomValue's.
-*/
-QList<QmlDomValue> QmlDomList::values() const
-{
- QList<QmlDomValue> rv;
- if (!d->property)
- return rv;
-
- for (int ii = 0; ii < d->property->values.count(); ++ii) {
- QmlDomValue v;
- v.d->value = d->property->values.at(ii);
- v.d->value->addref();
- rv << v;
- }
-
- return rv;
-}
-
-/*!
- Returns the position in the input data where the list started, or -1 if
- the property is invalid.
-*/
-int QmlDomList::position() const
-{
- if (d && d->property) {
- return d->property->listValueRange.offset;
- } else
- return -1;
-}
-
-/*!
- Returns the length in the input data from where the list started upto
- the end of it, or 0 if the property is invalid.
-*/
-int QmlDomList::length() const
-{
- if (d && d->property)
- return d->property->listValueRange.length;
- else
- return -1;
-}
-
-/*!
- Returns a list of positions of the commas in the QML file.
-*/
-QList<int> QmlDomList:: commaPositions() const
-{
- if (d && d->property)
- return d->property->listCommaPositions;
- else
- return QList<int>();
-}
-
-/*!
- \class QmlDomComponent
- \internal
- \brief The QmlDomComponent class represents sub-component within a QML document.
-
- Sub-components are QmlComponents defined within a QML document. The
- following example shows the definition of a sub-component with the id
- "listDelegate".
-
- \qml
-Item {
- Component {
- id: listDelegate
- Text {
- text: modelData.text
- }
- }
-}
- \endqml
-
- Like QmlDomDocument's, components contain a single root object.
-*/
-
-/*!
- Construct an empty QmlDomComponent.
-*/
-QmlDomComponent::QmlDomComponent()
-{
-}
-
-/*!
- Create a copy of \a other QmlDomComponent.
-*/
-QmlDomComponent::QmlDomComponent(const QmlDomComponent &other)
-: QmlDomObject(other)
-{
-}
-
-/*!
- Destroy the QmlDomComponent.
-*/
-QmlDomComponent::~QmlDomComponent()
-{
-}
-
-/*!
- Assign \a other to this QmlDomComponent.
-*/
-QmlDomComponent &QmlDomComponent::operator=(const QmlDomComponent &other)
-{
- static_cast<QmlDomObject &>(*this) = other;
- return *this;
-}
-
-/*!
- Returns the component's root object.
-
- In the example below, the root object is the "Text" object.
- \qml
-Item {
- Component {
- id: listDelegate
- Text {
- text: modelData.text
- }
- }
-}
- \endqml
-*/
-QmlDomObject QmlDomComponent::componentRoot() const
-{
- QmlDomObject rv;
- if (d->object) {
- QmlParser::Object *obj = 0;
- if (d->object->defaultProperty &&
- d->object->defaultProperty->values.count() == 1 &&
- d->object->defaultProperty->values.at(0)->object)
- obj = d->object->defaultProperty->values.at(0)->object;
-
- if (obj) {
- rv.d->object = obj;
- rv.d->object->addref();
- }
- }
-
- return rv;
-}
-
-QmlDomImportPrivate::QmlDomImportPrivate()
-: type(File)
-{
-}
-
-QmlDomImportPrivate::~QmlDomImportPrivate()
-{
-}
-
-/*!
- \class QmlDomImport
- \internal
- \brief The QmlDomImport class represents an import statement.
-*/
-
-/*!
- Construct an empty QmlDomImport.
-*/
-QmlDomImport::QmlDomImport()
-: d(new QmlDomImportPrivate)
-{
-}
-
-/*!
- Create a copy of \a other QmlDomImport.
-*/
-QmlDomImport::QmlDomImport(const QmlDomImport &other)
-: d(other.d)
-{
-}
-
-/*!
- Destroy the QmlDomImport.
-*/
-QmlDomImport::~QmlDomImport()
-{
-}
-
-/*!
- Assign \a other to this QmlDomImport.
-*/
-QmlDomImport &QmlDomImport::operator=(const QmlDomImport &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Returns the type of the import.
- */
-QmlDomImport::Type QmlDomImport::type() const
-{
- return static_cast<QmlDomImport::Type>(d->type);
-}
-
-/*!
- Returns the URI of the import (e.g. 'subdir' or 'com.nokia.Qt')
- */
-QString QmlDomImport::uri() const
-{
- return d->uri;
-}
-
-/*!
- Returns the version specified by the import. An empty string if no version was specified.
- */
-QString QmlDomImport::version() const
-{
- return d->version;
-}
-
-/*!
- Returns the (optional) qualifier string (the token following the 'as' keyword) of the import.
- */
-QString QmlDomImport::qualifier() const
-{
- return d->qualifier;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h
deleted file mode 100644
index 8c7288e..0000000
--- a/src/declarative/qml/qmldom_p.h
+++ /dev/null
@@ -1,360 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLDOM_P_H
-#define QMLDOM_P_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 "qmlerror.h"
-
-#include <QtCore/qlist.h>
-#include <QtCore/qshareddata.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QString;
-class QByteArray;
-class QmlDomObject;
-class QmlDomList;
-class QmlDomValue;
-class QmlEngine;
-class QmlDomComponent;
-class QmlDomImport;
-class QIODevice;
-
-class QmlDomDocumentPrivate;
-
-class Q_DECLARATIVE_EXPORT QmlDomDocument
-{
-public:
- QmlDomDocument();
- QmlDomDocument(const QmlDomDocument &);
- ~QmlDomDocument();
- QmlDomDocument &operator=(const QmlDomDocument &);
-
- QList<QmlDomImport> imports() const;
-
- QList<QmlError> errors() const;
- bool load(QmlEngine *, const QByteArray &, const QUrl & = QUrl());
-
- QmlDomObject rootObject() const;
-
-private:
- QSharedDataPointer<QmlDomDocumentPrivate> d;
-};
-
-class QmlDomPropertyPrivate;
-class Q_DECLARATIVE_EXPORT QmlDomProperty
-{
-public:
- QmlDomProperty();
- QmlDomProperty(const QmlDomProperty &);
- ~QmlDomProperty();
- QmlDomProperty &operator=(const QmlDomProperty &);
-
- bool isValid() const;
-
- QByteArray propertyName() const;
- QList<QByteArray> propertyNameParts() const;
-
- bool isDefaultProperty() const;
-
- QmlDomValue value() const;
-
- int position() const;
- int length() const;
-
-private:
- friend class QmlDomObject;
- friend class QmlDomDynamicProperty;
- QSharedDataPointer<QmlDomPropertyPrivate> d;
-};
-
-class QmlDomDynamicPropertyPrivate;
-class Q_DECLARATIVE_EXPORT QmlDomDynamicProperty
-{
-public:
- QmlDomDynamicProperty();
- QmlDomDynamicProperty(const QmlDomDynamicProperty &);
- ~QmlDomDynamicProperty();
- QmlDomDynamicProperty &operator=(const QmlDomDynamicProperty &);
-
- bool isValid() const;
-
- QByteArray propertyName() const;
- int propertyType() const;
- QByteArray propertyTypeName() const;
-
- bool isDefaultProperty() const;
- QmlDomProperty defaultValue() const;
-
- bool isAlias() const;
-
- int position() const;
- int length() const;
-
-private:
- friend class QmlDomObject;
- QSharedDataPointer<QmlDomDynamicPropertyPrivate> d;
-};
-
-class QmlDomObjectPrivate;
-class Q_DECLARATIVE_EXPORT QmlDomObject
-{
-public:
- QmlDomObject();
- QmlDomObject(const QmlDomObject &);
- ~QmlDomObject();
- QmlDomObject &operator=(const QmlDomObject &);
-
- bool isValid() const;
-
- QByteArray objectType() const;
- QByteArray objectClassName() const;
-
- int objectTypeMajorVersion() const;
- int objectTypeMinorVersion() const;
-
- QString objectId() const;
-
- QList<QmlDomProperty> properties() const;
- QmlDomProperty property(const QByteArray &) const;
-
- QList<QmlDomDynamicProperty> dynamicProperties() const;
- QmlDomDynamicProperty dynamicProperty(const QByteArray &) const;
-
- bool isCustomType() const;
- QByteArray customTypeData() const;
-
- bool isComponent() const;
- QmlDomComponent toComponent() const;
-
- int position() const;
- int length() const;
-
- QUrl url() const;
-private:
- friend class QmlDomDocument;
- friend class QmlDomComponent;
- friend class QmlDomValue;
- friend class QmlDomValueValueSource;
- friend class QmlDomValueValueInterceptor;
- QSharedDataPointer<QmlDomObjectPrivate> d;
-};
-
-class QmlDomValuePrivate;
-class QmlDomBasicValuePrivate;
-class Q_DECLARATIVE_EXPORT QmlDomValueLiteral
-{
-public:
- QmlDomValueLiteral();
- QmlDomValueLiteral(const QmlDomValueLiteral &);
- ~QmlDomValueLiteral();
- QmlDomValueLiteral &operator=(const QmlDomValueLiteral &);
-
- QString literal() const;
-
-private:
- friend class QmlDomValue;
- QSharedDataPointer<QmlDomBasicValuePrivate> d;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDomValueBinding
-{
-public:
- QmlDomValueBinding();
- QmlDomValueBinding(const QmlDomValueBinding &);
- ~QmlDomValueBinding();
- QmlDomValueBinding &operator=(const QmlDomValueBinding &);
-
- QString binding() const;
-
-private:
- friend class QmlDomValue;
- QSharedDataPointer<QmlDomBasicValuePrivate> d;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDomValueValueSource
-{
-public:
- QmlDomValueValueSource();
- QmlDomValueValueSource(const QmlDomValueValueSource &);
- ~QmlDomValueValueSource();
- QmlDomValueValueSource &operator=(const QmlDomValueValueSource &);
-
- QmlDomObject object() const;
-
-private:
- friend class QmlDomValue;
- QSharedDataPointer<QmlDomBasicValuePrivate> d;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDomValueValueInterceptor
-{
-public:
- QmlDomValueValueInterceptor();
- QmlDomValueValueInterceptor(const QmlDomValueValueInterceptor &);
- ~QmlDomValueValueInterceptor();
- QmlDomValueValueInterceptor &operator=(const QmlDomValueValueInterceptor &);
-
- QmlDomObject object() const;
-
-private:
- friend class QmlDomValue;
- QSharedDataPointer<QmlDomBasicValuePrivate> d;
-};
-
-
-class Q_DECLARATIVE_EXPORT QmlDomComponent : public QmlDomObject
-{
-public:
- QmlDomComponent();
- QmlDomComponent(const QmlDomComponent &);
- ~QmlDomComponent();
- QmlDomComponent &operator=(const QmlDomComponent &);
-
- QmlDomObject componentRoot() const;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDomValue
-{
-public:
- enum Type {
- Invalid,
- Literal,
- PropertyBinding,
- ValueSource,
- ValueInterceptor,
- Object,
- List
- };
-
- QmlDomValue();
- QmlDomValue(const QmlDomValue &);
- ~QmlDomValue();
- QmlDomValue &operator=(const QmlDomValue &);
-
- Type type() const;
-
- bool isInvalid() const;
- bool isLiteral() const;
- bool isBinding() const;
- bool isValueSource() const;
- bool isValueInterceptor() const;
- bool isObject() const;
- bool isList() const;
-
- QmlDomValueLiteral toLiteral() const;
- QmlDomValueBinding toBinding() const;
- QmlDomValueValueSource toValueSource() const;
- QmlDomValueValueInterceptor toValueInterceptor() const;
- QmlDomObject toObject() const;
- QmlDomList toList() const;
-
- int position() const;
- int length() const;
-
-private:
- friend class QmlDomProperty;
- friend class QmlDomList;
- QSharedDataPointer<QmlDomValuePrivate> d;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDomList
-{
-public:
- QmlDomList();
- QmlDomList(const QmlDomList &);
- ~QmlDomList();
- QmlDomList &operator=(const QmlDomList &);
-
- QList<QmlDomValue> values() const;
-
- int position() const;
- int length() const;
-
- QList<int> commaPositions() const;
-
-private:
- friend class QmlDomValue;
- QSharedDataPointer<QmlDomValuePrivate> d;
-};
-
-class QmlDomImportPrivate;
-class Q_DECLARATIVE_EXPORT QmlDomImport
-{
-public:
- enum Type { Library, File };
-
- QmlDomImport();
- QmlDomImport(const QmlDomImport &);
- ~QmlDomImport();
- QmlDomImport &operator=(const QmlDomImport &);
-
- Type type() const;
- QString uri() const;
- QString version() const;
- QString qualifier() const;
-
-private:
- friend class QmlDomDocument;
- QSharedDataPointer<QmlDomImportPrivate> d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLDOM_P_H
diff --git a/src/declarative/qml/qmldom_p_p.h b/src/declarative/qml/qmldom_p_p.h
deleted file mode 100644
index 9d955b0..0000000
--- a/src/declarative/qml/qmldom_p_p.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLDOM_P_P_H
-#define QMLDOM_P_P_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 "qmlparser_p.h"
-
-#include <QtCore/QtGlobal>
-
-QT_BEGIN_NAMESPACE
-
-class QmlDomDocumentPrivate : public QSharedData
-{
-public:
- QmlDomDocumentPrivate();
- QmlDomDocumentPrivate(const QmlDomDocumentPrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomDocumentPrivate();
-
- QList<QmlError> errors;
- QList<QmlDomImport> imports;
- QmlParser::Object *root;
- QList<int> automaticSemicolonOffsets;
-};
-
-class QmlDomObjectPrivate : public QSharedData
-{
-public:
- QmlDomObjectPrivate();
- QmlDomObjectPrivate(const QmlDomObjectPrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomObjectPrivate();
-
- typedef QList<QPair<QmlParser::Property *, QByteArray> > Properties;
- Properties properties() const;
- Properties properties(QmlParser::Property *) const;
-
- QmlParser::Object *object;
-};
-
-class QmlDomPropertyPrivate : public QSharedData
-{
-public:
- QmlDomPropertyPrivate();
- QmlDomPropertyPrivate(const QmlDomPropertyPrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomPropertyPrivate();
-
- QByteArray propertyName;
- QmlParser::Property *property;
-};
-
-class QmlDomDynamicPropertyPrivate : public QSharedData
-{
-public:
- QmlDomDynamicPropertyPrivate();
- QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomDynamicPropertyPrivate();
-
- bool valid;
- QmlParser::Object::DynamicProperty property;
-};
-
-class QmlDomValuePrivate : public QSharedData
-{
-public:
- QmlDomValuePrivate();
- QmlDomValuePrivate(const QmlDomValuePrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomValuePrivate();
-
- QmlParser::Property *property;
- QmlParser::Value *value;
-};
-
-class QmlDomBasicValuePrivate : public QSharedData
-{
-public:
- QmlDomBasicValuePrivate();
- QmlDomBasicValuePrivate(const QmlDomBasicValuePrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomBasicValuePrivate();
-
- QmlParser::Value *value;
-};
-
-class QmlDomImportPrivate : public QSharedData
-{
-public:
- QmlDomImportPrivate();
- QmlDomImportPrivate(const QmlDomImportPrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomImportPrivate();
-
- enum Type { Library, File };
-
- Type type;
- QString uri;
- QString version;
- QString qualifier;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLDOM_P_P_H
-
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
deleted file mode 100644
index 2d904d1..0000000
--- a/src/declarative/qml/qmlengine.cpp
+++ /dev/null
@@ -1,1901 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlengine_p.h"
-#include "qmlengine.h"
-
-#include "qmlcontext_p.h"
-#include "qmlcompiler_p.h"
-#include "qmlglobalscriptclass_p.h"
-#include "qml.h"
-#include "qmlcontext.h"
-#include "qmlexpression.h"
-#include "qmlcomponent.h"
-#include "qmlmetaproperty_p.h"
-#include "qmlbinding_p_p.h"
-#include "qmlvme_p.h"
-#include "qmlenginedebug_p.h"
-#include "qmlstringconverters_p.h"
-#include "qmlxmlhttprequest_p.h"
-#include "qmlsqldatabase_p.h"
-#include "qmltypenamescriptclass_p.h"
-#include "qmllistscriptclass_p.h"
-#include "qmlscriptstring.h"
-#include "qmlglobal_p.h"
-#include "qmlworkerscript_p.h"
-#include "qmlcomponent_p.h"
-#include "qmlscriptclass_p.h"
-#include "qmlnetworkaccessmanagerfactory.h"
-#include "qmlimageprovider.h"
-#include "qmldirparser_p.h"
-#include "qmlextensioninterface.h"
-#include "qmllist_p.h"
-
-#include <qfxperf_p_p.h>
-
-#include <QtCore/qmetaobject.h>
-#include <QScriptClass>
-#include <QNetworkReply>
-#include <QNetworkRequest>
-#include <QNetworkAccessManager>
-#include <QDesktopServices>
-#include <QTimer>
-#include <QList>
-#include <QPair>
-#include <QDebug>
-#include <QMetaObject>
-#include <QStack>
-#include <QPluginLoader>
-#include <QtCore/qlibraryinfo.h>
-#include <QtCore/qthreadstorage.h>
-#include <QtCore/qthread.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qmutex.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qsound.h>
-#include <QGraphicsObject>
-#include <QtCore/qcryptographichash.h>
-
-#include <private/qobject_p.h>
-#include <private/qscriptdeclarativeclass_p.h>
-
-#include <private/qmlgraphicsitemsmodule_p.h>
-#include <private/qmlgraphicsutilmodule_p.h>
-
-#ifdef Q_OS_WIN // for %APPDATA%
-#include <qt_windows.h>
-#include <qlibrary.h>
-
-#define CSIDL_APPDATA 0x001a // <username>\Application Data
-#endif
-
-Q_DECLARE_METATYPE(QmlMetaProperty)
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
-
-/*!
- \qmlclass QtObject QObject
- \since 4.7
- \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.
-
- 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.
-
- See \l{scripting.html#accessing-child-qobjects}{Accessing Child QObjects}
- in the scripting documentation for details how objectName can be used from
- scripts.
-*/
-
-struct StaticQtMetaObject : public QObject
-{
- static const QMetaObject *get()
- { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
-};
-
-static bool qt_QmlQtModule_registered = false;
-
-void QmlEnginePrivate::defineModule()
-{
- QML_REGISTER_TYPE(Qt,4,6,Component,QmlComponent);
- QML_REGISTER_TYPE(Qt,4,6,QtObject,QObject);
- QML_REGISTER_TYPE(Qt,4,6,WorkerScript,QmlWorkerScript);
- QML_REGISTER_TYPE(Qt,4,6,WorkerListModel,QmlWorkerListModel);
-
- QML_REGISTER_NOCREATE_TYPE(QmlBinding);
-}
-
-QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
-: captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false),
- contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0),
- globalClass(0), cleanup(0), erroredBindings(0), inProgressCreations(0),
- scriptEngine(this), workerScriptEngine(0), componentAttacheds(0), inBeginCreate(false),
- networkAccessManager(0), networkAccessManagerFactory(0),
- typeManager(e), uniqueId(1)
-{
- if (!qt_QmlQtModule_registered) {
- qt_QmlQtModule_registered = true;
- QmlGraphicsItemModule::defineModule();
- QmlGraphicsUtilModule::defineModule();
- QmlEnginePrivate::defineModule();
- }
- globalClass = new QmlGlobalScriptClass(&scriptEngine);
- fileImportPath.append(QLibraryInfo::location(QLibraryInfo::DataPath)+QDir::separator()+QLatin1String("qml"));
-
- // env import paths
- QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
- if (!envImportPath.isEmpty()) {
-#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
- QLatin1Char pathSep(';');
-#else
- QLatin1Char pathSep(':');
-#endif
- foreach (const QString &path, QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts)) {
- QString canonicalPath = QDir(path).canonicalPath();
- if (!canonicalPath.isEmpty() && !environmentImportPath.contains(canonicalPath))
- environmentImportPath.append(canonicalPath);
- }
- }
-}
-
-QUrl QmlScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url)
-{
- if (p) {
- QmlContext *ctxt = QmlEnginePrivate::get(this)->getContext(context);
- Q_ASSERT(ctxt);
- return ctxt->resolvedUrl(url);
- }
- return baseUrl.resolved(url);
-}
-
-QmlScriptEngine::QmlScriptEngine(QmlEnginePrivate *priv)
-: p(priv), sqlQueryClass(0), namedNodeMapClass(0), nodeListClass(0)
-{
- // Note that all documentation for stuff put on the global object goes in
- // doc/src/declarative/globalobject.qdoc
-
- bool mainthread = priv != 0;
-
- QScriptValue qtObject =
- newQMetaObject(StaticQtMetaObject::get());
- globalObject().setProperty(QLatin1String("Qt"), qtObject);
-
- offlineStoragePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation).replace(QLatin1Char('/'), QDir::separator())
- + QDir::separator() + QLatin1String("QML")
- + QDir::separator() + QLatin1String("OfflineStorage");
-
-
- qt_add_qmlxmlhttprequest(this);
- 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.
- // XXX When the above a done some better way, that way should also be
- // XXX used to add Qt.Sound class.
-
-
- //types
- qtObject.setProperty(QLatin1String("rgba"), newFunction(QmlEnginePrivate::rgba, 4));
- qtObject.setProperty(QLatin1String("hsla"), newFunction(QmlEnginePrivate::hsla, 4));
- qtObject.setProperty(QLatin1String("rect"), newFunction(QmlEnginePrivate::rect, 4));
- qtObject.setProperty(QLatin1String("point"), newFunction(QmlEnginePrivate::point, 2));
- qtObject.setProperty(QLatin1String("size"), newFunction(QmlEnginePrivate::size, 2));
- qtObject.setProperty(QLatin1String("vector3d"), newFunction(QmlEnginePrivate::vector, 3));
-
- if (mainthread) {
- //color helpers
- qtObject.setProperty(QLatin1String("lighter"), newFunction(QmlEnginePrivate::lighter, 1));
- qtObject.setProperty(QLatin1String("darker"), newFunction(QmlEnginePrivate::darker, 1));
- qtObject.setProperty(QLatin1String("tint"), newFunction(QmlEnginePrivate::tint, 2));
- }
-
- //misc methods
- qtObject.setProperty(QLatin1String("closestAngle"), newFunction(QmlEnginePrivate::closestAngle, 2));
- qtObject.setProperty(QLatin1String("playSound"), newFunction(QmlEnginePrivate::playSound, 1));
- qtObject.setProperty(QLatin1String("openUrlExternally"),newFunction(QmlEnginePrivate::desktopOpenUrl, 1));
- qtObject.setProperty(QLatin1String("md5"),newFunction(QmlEnginePrivate::md5, 1));
- qtObject.setProperty(QLatin1String("btoa"),newFunction(QmlEnginePrivate::btoa, 1));
- qtObject.setProperty(QLatin1String("atob"),newFunction(QmlEnginePrivate::atob, 1));
- qtObject.setProperty(QLatin1String("quit"), newFunction(QmlEnginePrivate::quit, 0));
- qtObject.setProperty(QLatin1String("resolvedUrl"),newFunction(QmlScriptEngine::resolvedUrl, 1));
-
- //firebug/webkit compat
- QScriptValue consoleObject = newObject();
- consoleObject.setProperty(QLatin1String("log"),newFunction(QmlEnginePrivate::consoleLog, 1));
- consoleObject.setProperty(QLatin1String("debug"),newFunction(QmlEnginePrivate::consoleLog, 1));
- globalObject().setProperty(QLatin1String("console"), consoleObject);
-
- if (mainthread) {
- globalObject().setProperty(QLatin1String("createQmlObject"),
- newFunction(QmlEnginePrivate::createQmlObject, 1));
- globalObject().setProperty(QLatin1String("createComponent"),
- newFunction(QmlEnginePrivate::createComponent, 1));
- }
-
- // translation functions need to be installed
- // before the global script class is constructed (QTBUG-6437)
- installTranslatorFunctions();
-}
-
-QmlScriptEngine::~QmlScriptEngine()
-{
- delete sqlQueryClass;
- delete nodeListClass;
- delete namedNodeMapClass;
-}
-
-QScriptValue QmlScriptEngine::resolvedUrl(QScriptContext *ctxt, QScriptEngine *engine)
-{
- QString arg = ctxt->argument(0).toString();
- QUrl r = QmlScriptEngine::get(engine)->resolvedUrl(ctxt,QUrl(arg));
- return QScriptValue(r.toString());
-}
-
-QNetworkAccessManager *QmlScriptEngine::networkAccessManager()
-{
- return p->getNetworkAccessManager();
-}
-
-QmlEnginePrivate::~QmlEnginePrivate()
-{
- while (cleanup) {
- QmlCleanup *c = cleanup;
- cleanup = c->next;
- if (cleanup) cleanup->prev = &cleanup;
- c->next = 0;
- c->prev = 0;
- c->clear();
- }
-
- delete rootContext;
- rootContext = 0;
- delete contextClass;
- contextClass = 0;
- delete objectClass;
- objectClass = 0;
- delete valueTypeClass;
- valueTypeClass = 0;
- delete typeNameClass;
- typeNameClass = 0;
- delete listClass;
- listClass = 0;
- delete globalClass;
- globalClass = 0;
-
- for(int ii = 0; ii < bindValues.count(); ++ii)
- clear(bindValues[ii]);
- for(int ii = 0; ii < parserStatus.count(); ++ii)
- clear(parserStatus[ii]);
- for(QHash<int, QmlCompiledData*>::ConstIterator iter = m_compositeTypes.constBegin(); iter != m_compositeTypes.constEnd(); ++iter)
- (*iter)->release();
- for(QHash<const QMetaObject *, QmlPropertyCache *>::Iterator iter = propertyCache.begin(); iter != propertyCache.end(); ++iter)
- (*iter)->release();
-
-}
-
-void QmlEnginePrivate::clear(SimpleList<QmlAbstractBinding> &bvs)
-{
- bvs.clear();
-}
-
-void QmlEnginePrivate::clear(SimpleList<QmlParserStatus> &pss)
-{
- for (int ii = 0; ii < pss.count; ++ii) {
- QmlParserStatus *ps = pss.at(ii);
- if(ps)
- ps->d = 0;
- }
- pss.clear();
-}
-
-Q_GLOBAL_STATIC(QmlEngineDebugServer, qmlEngineDebugServer);
-
-void QmlEnginePrivate::init()
-{
- Q_Q(QmlEngine);
- qRegisterMetaType<QVariant>("QVariant");
- qRegisterMetaType<QmlScriptString>("QmlScriptString");
- qRegisterMetaType<QScriptValue>("QScriptValue");
-
- contextClass = new QmlContextScriptClass(q);
- objectClass = new QmlObjectScriptClass(q);
- valueTypeClass = new QmlValueTypeScriptClass(q);
- typeNameClass = new QmlTypeNameScriptClass(q);
- listClass = new QmlListScriptClass(q);
- rootContext = new QmlContext(q,true);
-
- if (QCoreApplication::instance()->thread() == q->thread() &&
- QmlEngineDebugServer::isDebuggingEnabled()) {
- qmlEngineDebugServer();
- isDebugging = true;
- QmlEngineDebugServer::addEngine(q);
-
- qmlEngineDebugServer()->waitForClients();
- }
-}
-
-QmlWorkerScriptEngine *QmlEnginePrivate::getWorkerScriptEngine()
-{
- Q_Q(QmlEngine);
- if (!workerScriptEngine)
- workerScriptEngine = new QmlWorkerScriptEngine(q);
- return workerScriptEngine;
-}
-
-/*!
- \class QmlEngine
- \since 4.7
- \brief The QmlEngine class provides an environment for instantiating QML components.
- \mainclass
-
- Each QML component is instantiated in a QmlContext. QmlContext's are
- essential for passing data to QML components. In QML, contexts are arranged
- hierarchically and this hierarchy is managed by the QmlEngine.
-
- Prior to creating any QML components, an application must have created a
- QmlEngine to gain access to a QML context. The following example shows how
- to create a simple Text item.
-
- \code
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData("import Qt 4.6\nText { text: \"Hello world!\" }", QUrl());
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(component.create());
-
- //add item to view, etc
- ...
- \endcode
-
- In this case, the Text item will be created in the engine's
- \l {QmlEngine::rootContext()}{root context}.
-
- \sa QmlComponent QmlContext
-*/
-
-/*!
- Create a new QmlEngine with the given \a parent.
-*/
-QmlEngine::QmlEngine(QObject *parent)
-: QObject(*new QmlEnginePrivate(this), parent)
-{
- Q_D(QmlEngine);
- d->init();
-}
-
-/*!
- Destroys the QmlEngine.
-
- Any QmlContext's created on this engine will be invalidated, but not
- destroyed (unless they are parented to the QmlEngine object).
-*/
-QmlEngine::~QmlEngine()
-{
- Q_D(QmlEngine);
- if (d->isDebugging)
- QmlEngineDebugServer::remEngine(this);
-}
-
-/*! \fn void QmlEngine::quit()
- This signal is emitted when the QmlEngine quits.
- */
-
-/*!
- Clears the engine's internal component cache.
-
- Normally the QmlEngine caches components loaded from qml files. This method
- clears this cache and forces the component to be reloaded.
- */
-void QmlEngine::clearComponentCache()
-{
- Q_D(QmlEngine);
- d->typeManager.clearCache();
-}
-
-/*!
- Returns the engine's root context.
-
- The root context is automatically created by the QmlEngine. Data that
- should be available to all QML component instances instantiated by the
- engine should be put in the root context.
-
- Additional data that should only be available to a subset of component
- instances should be added to sub-contexts parented to the root context.
-*/
-QmlContext *QmlEngine::rootContext()
-{
- Q_D(QmlEngine);
- return d->rootContext;
-}
-
-/*!
- Sets the \a factory to use for creating QNetworkAccessManager(s).
-
- QNetworkAccessManager is used for all network access by QML.
- By implementing a factory it is possible to create custom
- QNetworkAccessManager with specialized caching, proxy and
- cookie support.
-
- The factory must be set before exceuting the engine.
-*/
-void QmlEngine::setNetworkAccessManagerFactory(QmlNetworkAccessManagerFactory *factory)
-{
- Q_D(QmlEngine);
- QMutexLocker locker(&d->mutex);
- d->networkAccessManagerFactory = factory;
-}
-
-/*!
- Returns the current QmlNetworkAccessManagerFactory.
-
- \sa setNetworkAccessManagerFactory()
-*/
-QmlNetworkAccessManagerFactory *QmlEngine::networkAccessManagerFactory() const
-{
- Q_D(const QmlEngine);
- return d->networkAccessManagerFactory;
-}
-
-QNetworkAccessManager *QmlEnginePrivate::createNetworkAccessManager(QObject *parent) const
-{
- QMutexLocker locker(&mutex);
- QNetworkAccessManager *nam;
- if (networkAccessManagerFactory) {
- nam = networkAccessManagerFactory->create(parent);
- } else {
- nam = new QNetworkAccessManager(parent);
- }
-
- return nam;
-}
-
-QNetworkAccessManager *QmlEnginePrivate::getNetworkAccessManager() const
-{
- Q_Q(const QmlEngine);
- if (!networkAccessManager)
- networkAccessManager = createNetworkAccessManager(const_cast<QmlEngine*>(q));
- return networkAccessManager;
-}
-
-/*!
- Returns a common QNetworkAccessManager which can be used by any QML element
- instantiated by this engine.
-
- If a QmlNetworkAccessManagerFactory has been set and a QNetworkAccessManager
- has not yet been created, the QmlNetworkAccessManagerFactory will be used
- to create the QNetworkAccessManager; otherwise the returned QNetworkAccessManager
- will have no proxy or cache set.
-
- \sa setNetworkAccessManagerFactory()
-*/
-QNetworkAccessManager *QmlEngine::networkAccessManager() const
-{
- Q_D(const QmlEngine);
- return d->getNetworkAccessManager();
-}
-
-/*!
- Sets the \a provider to use for images requested via the \e image: url
- scheme, with host \a providerId.
-
- QmlImageProvider allows images to be provided to QML asynchronously.
- The image request will be run in a low priority thread. This allows
- potentially costly image loading to be done in the background, without
- affecting the performance of the UI.
-
- Note that images loaded from a QmlImageProvider are cached by
- QPixmapCache, similar to any image loaded by QML.
-
- The QmlEngine assumes ownership of the provider.
-
- This example creates a provider with id \e colors:
-
- \snippet examples/declarative/imageprovider/main.cpp 0
-
- \snippet examples/declarative/imageprovider/view.qml 0
-
- \sa removeImageProvider()
-*/
-void QmlEngine::addImageProvider(const QString &providerId, QmlImageProvider *provider)
-{
- Q_D(QmlEngine);
- QMutexLocker locker(&d->mutex);
- d->imageProviders.insert(providerId, provider);
-}
-
-/*!
- Returns the QmlImageProvider set for \a providerId.
-*/
-QmlImageProvider *QmlEngine::imageProvider(const QString &providerId) const
-{
- Q_D(const QmlEngine);
- QMutexLocker locker(&d->mutex);
- return d->imageProviders.value(providerId);
-}
-
-/*!
- Removes the QmlImageProvider for \a providerId.
-
- Returns the provider if it was found; otherwise returns 0.
-
- \sa addImageProvider()
-*/
-void QmlEngine::removeImageProvider(const QString &providerId)
-{
- Q_D(QmlEngine);
- QMutexLocker locker(&d->mutex);
- delete d->imageProviders.take(providerId);
-}
-
-QImage QmlEnginePrivate::getImageFromProvider(const QUrl &url)
-{
- QMutexLocker locker(&mutex);
- QImage image;
- QmlImageProvider *provider = imageProviders.value(url.host());
- if (provider)
- image = provider->request(url.path().mid(1));
- return image;
-}
-
-/*!
- Return the base URL for this engine. The base URL is only used to resolve
- components when a relative URL is passed to the QmlComponent constructor.
-
- If a base URL has not been explicitly set, this method returns the
- application's current working directory.
-
- \sa setBaseUrl()
-*/
-QUrl QmlEngine::baseUrl() const
-{
- Q_D(const QmlEngine);
- if (d->baseUrl.isEmpty()) {
- return QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
- } else {
- return d->baseUrl;
- }
-}
-
-/*!
- Set the base URL for this engine to \a url.
-
- \sa baseUrl()
-*/
-void QmlEngine::setBaseUrl(const QUrl &url)
-{
- Q_D(QmlEngine);
- d->baseUrl = url;
-}
-
-/*!
- Returns the QmlContext for the \a object, or 0 if no context has been set.
-
- When the QmlEngine instantiates a QObject, the context is set automatically.
- */
-QmlContext *QmlEngine::contextForObject(const QObject *object)
-{
- if(!object)
- return 0;
-
- QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
-
- QmlDeclarativeData *data =
- static_cast<QmlDeclarativeData *>(priv->declarativeData);
-
- if (!data)
- return 0;
- else if (data->outerContext)
- return data->outerContext;
- else
- return data->context;
-}
-
-/*!
- 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.
-
- When the QmlEngine instantiates a QObject, the context is set automatically.
- */
-void QmlEngine::setContextForObject(QObject *object, QmlContext *context)
-{
- if (!object || !context)
- return;
-
- QmlDeclarativeData *data = QmlDeclarativeData::get(object, true);
- if (data->context) {
- qWarning("QmlEngine::setContextForObject(): Object already has a QmlContext");
- return;
- }
-
- data->context = context;
- data->nextContextObject = context->d_func()->contextObjects;
- if (data->nextContextObject)
- data->nextContextObject->prevContextObject = &data->nextContextObject;
- data->prevContextObject = &context->d_func()->contextObjects;
- context->d_func()->contextObjects = data;
-}
-
-void qmlExecuteDeferred(QObject *object)
-{
- QmlDeclarativeData *data = QmlDeclarativeData::get(object);
-
- if (data && data->deferredComponent) {
-
- QmlEnginePrivate *ep = QmlEnginePrivate::get(data->context->engine());
-
- QmlComponentPrivate::ConstructionState state;
- QmlComponentPrivate::beginDeferred(data->context, ep, object, &state);
-
- data->deferredComponent->release();
- data->deferredComponent = 0;
-
- QmlComponentPrivate::complete(ep, &state);
-
- if (!state.errors.isEmpty())
- qWarning() << state.errors;
-
- }
-}
-
-QmlContext *qmlContext(const QObject *obj)
-{
- return QmlEngine::contextForObject(obj);
-}
-
-QmlEngine *qmlEngine(const QObject *obj)
-{
- QmlContext *context = QmlEngine::contextForObject(obj);
- return context?context->engine():0;
-}
-
-QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create)
-{
- QmlDeclarativeData *data = QmlDeclarativeData::get(object);
- if (!data)
- return 0; // Attached properties are only on objects created by QML
-
- QObject *rv = data->attachedProperties?data->attachedProperties->value(id):0;
- if (rv || !create)
- return rv;
-
- QmlAttachedPropertiesFunc pf = QmlMetaType::attachedPropertiesFuncById(id);
- if (!pf)
- return 0;
-
- rv = pf(const_cast<QObject *>(object));
-
- if (rv) {
- if (!data->attachedProperties)
- data->attachedProperties = new QHash<int, QObject *>();
- data->attachedProperties->insert(id, rv);
- }
-
- return rv;
-}
-
-void QmlDeclarativeData::destroyed(QObject *object)
-{
- if (deferredComponent)
- deferredComponent->release();
- if (attachedProperties)
- delete attachedProperties;
-
- if (nextContextObject)
- nextContextObject->prevContextObject = prevContextObject;
- if (prevContextObject)
- *prevContextObject = nextContextObject;
-
- QmlAbstractBinding *binding = bindings;
- while (binding) {
- QmlAbstractBinding *next = binding->m_nextBinding;
- binding->m_prevBinding = 0;
- binding->m_nextBinding = 0;
- binding->destroy();
- binding = next;
- }
-
- if (bindingBits)
- free(bindingBits);
-
- if (propertyCache)
- propertyCache->release();
-
- QmlGuard<QObject> *guard = guards;
- while (guard) {
- QmlGuard<QObject> *g = guard;
- guard = guard->next;
- g->o = 0;
- g->prev = 0;
- g->next = 0;
- g->objectDestroyed(object);
- }
-
- delete this;
-}
-
-bool QmlDeclarativeData::hasBindingBit(int bit) const
-{
- if (bindingBitsSize > bit)
- return bindingBits[bit / 32] & (1 << (bit % 32));
- else
- return false;
-}
-
-void QmlDeclarativeData::clearBindingBit(int bit)
-{
- if (bindingBitsSize > bit)
- bindingBits[bit / 32] &= ~(1 << (bit % 32));
-}
-
-void QmlDeclarativeData::setBindingBit(QObject *obj, int bit)
-{
- if (bindingBitsSize <= bit) {
- int props = obj->metaObject()->propertyCount();
- Q_ASSERT(bit < props);
-
- int arraySize = (props + 31) / 32;
- int oldArraySize = bindingBitsSize / 32;
-
- bindingBits = (quint32 *)realloc(bindingBits,
- arraySize * sizeof(quint32));
-
- memset(bindingBits + oldArraySize,
- 0x00,
- sizeof(quint32) * (arraySize - oldArraySize));
-
- bindingBitsSize = arraySize * 32;
- }
-
- bindingBits[bit / 32] |= (1 << (bit % 32));
-}
-
-/*!
- Creates a QScriptValue allowing you to use \a object in QML script.
- \a engine is the QmlEngine it is to be created in.
-
- The QScriptValue returned is a QtScript Object, not a QtScript QObject, due
- to the special needs of QML requiring more functionality than a standard
- QtScript QObject.
-*/
-QScriptValue QmlEnginePrivate::qmlScriptObject(QObject* object,
- QmlEngine* engine)
-{
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine);
- return enginePriv->objectClass->newQObject(object);
-}
-
-/*!
- Returns the QmlContext for the executing QScript \a ctxt.
-*/
-QmlContext *QmlEnginePrivate::getContext(QScriptContext *ctxt)
-{
- QScriptValue scopeNode = QScriptDeclarativeClass::scopeChainValue(ctxt, -3);
- Q_ASSERT(scopeNode.isValid());
- Q_ASSERT(QScriptDeclarativeClass::scriptClass(scopeNode) == contextClass);
- return contextClass->contextFromValue(scopeNode);
-}
-
-QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt,
- QScriptEngine *engine)
-{
- QmlEnginePrivate *activeEnginePriv =
- static_cast<QmlScriptEngine*>(engine)->p;
- QmlEngine* activeEngine = activeEnginePriv->q_func();
-
- QmlContext* context = activeEnginePriv->getContext(ctxt);
- Q_ASSERT(context);
- if(ctxt->argumentCount() != 1) {
- return engine->nullValue();
- }else{
- QString arg = ctxt->argument(0).toString();
- if (arg.isEmpty())
- return engine->nullValue();
- QUrl url = QUrl(context->resolvedUrl(QUrl(arg)));
- QmlComponent *c = new QmlComponent(activeEngine, url, activeEngine);
- c->setCreationContext(context);
- return activeEnginePriv->objectClass->newQObject(c, qMetaTypeId<QmlComponent*>());
- }
-}
-
-QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
-{
- QmlEnginePrivate *activeEnginePriv =
- static_cast<QmlScriptEngine*>(engine)->p;
- QmlEngine* activeEngine = activeEnginePriv->q_func();
-
- if(ctxt->argumentCount() < 2 || ctxt->argumentCount() > 3)
- return engine->nullValue();
-
- QmlContext* context = activeEnginePriv->getContext(ctxt);
- Q_ASSERT(context);
-
- QString qml = ctxt->argument(0).toString();
- if (qml.isEmpty())
- return engine->nullValue();
-
- QUrl url;
- if(ctxt->argumentCount() > 2)
- url = QUrl(ctxt->argument(2).toString());
- else
- url = QUrl(QLatin1String("inline"));
-
- if (url.isValid() && url.isRelative())
- url = context->resolvedUrl(url);
-
- QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1));
- if(!parentArg)
- return engine->nullValue();
-
- QmlComponent component(activeEngine);
- component.setData(qml.toUtf8(), url);
-
- if(component.isError()) {
- QList<QmlError> errors = component.errors();
- qWarning().nospace() << "QmlEngine::createQmlObject():";
- foreach (const QmlError &error, errors)
- qWarning().nospace() << " " << error;
-
- return engine->nullValue();
- }
-
- if (!component.isReady()) {
- qWarning().nospace() << "QmlEngine::createQmlObject(): Component is not ready";
-
- return engine->nullValue();
- }
-
- QObject *obj = component.create(context);
-
- if(component.isError()) {
- QList<QmlError> errors = component.errors();
- qWarning().nospace() << "QmlEngine::createQmlObject():";
- foreach (const QmlError &error, errors)
- qWarning().nospace() << " " << error;
-
- return engine->nullValue();
- }
-
- Q_ASSERT(obj);
-
- obj->setParent(parentArg);
- QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj);
- QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parentArg);
- if(gobj && gparent)
- gobj->setParentItem(gparent);
-
- return qmlScriptObject(obj, activeEngine);
-}
-
-QScriptValue QmlEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if(ctxt->argumentCount() != 3)
- return engine->nullValue();
- qsreal x = ctxt->argument(0).toNumber();
- qsreal y = ctxt->argument(1).toNumber();
- qsreal z = ctxt->argument(2).toNumber();
- return engine->newVariant(qVariantFromValue(QVector3D(x, y, z)));
-}
-
-QScriptValue QmlEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine)
-{
- int argCount = ctxt->argumentCount();
- if(argCount < 3 || argCount > 4)
- return engine->nullValue();
- qsreal r = ctxt->argument(0).toNumber();
- qsreal g = ctxt->argument(1).toNumber();
- qsreal b = ctxt->argument(2).toNumber();
- qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1;
-
- if (r < 0 || r > 1 || g < 0 || g > 1 || b < 0 || b > 1 || a < 0 || a > 1)
- return engine->nullValue();
-
- return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromRgbF(r, g, b, a)));
-}
-
-QScriptValue QmlEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine *engine)
-{
- int argCount = ctxt->argumentCount();
- if(argCount < 3 || argCount > 4)
- return engine->nullValue();
- qsreal h = ctxt->argument(0).toNumber();
- qsreal s = ctxt->argument(1).toNumber();
- qsreal l = ctxt->argument(2).toNumber();
- qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1;
-
- if (h < 0 || h > 1 || s < 0 || s > 1 || l < 0 || l > 1 || a < 0 || a > 1)
- return engine->nullValue();
-
- return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromHslF(h, s, l, a)));
-}
-
-QScriptValue QmlEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if(ctxt->argumentCount() != 4)
- return engine->nullValue();
-
- qsreal x = ctxt->argument(0).toNumber();
- qsreal y = ctxt->argument(1).toNumber();
- qsreal w = ctxt->argument(2).toNumber();
- qsreal h = ctxt->argument(3).toNumber();
-
- if (w < 0 || h < 0)
- return engine->nullValue();
-
- return qScriptValueFromValue(engine, qVariantFromValue(QRectF(x, y, w, h)));
-}
-
-QScriptValue QmlEnginePrivate::point(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if(ctxt->argumentCount() != 2)
- return engine->nullValue();
- qsreal x = ctxt->argument(0).toNumber();
- qsreal y = ctxt->argument(1).toNumber();
- return qScriptValueFromValue(engine, qVariantFromValue(QPointF(x, y)));
-}
-
-QScriptValue QmlEnginePrivate::size(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if(ctxt->argumentCount() != 2)
- return engine->nullValue();
- qsreal w = ctxt->argument(0).toNumber();
- qsreal h = ctxt->argument(1).toNumber();
- return qScriptValueFromValue(engine, qVariantFromValue(QSizeF(w, h)));
-}
-
-QScriptValue QmlEnginePrivate::lighter(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if(ctxt->argumentCount() != 1)
- return engine->nullValue();
- QVariant v = ctxt->argument(0).toVariant();
- QColor color;
- if (v.userType() == QVariant::Color)
- color = v.value<QColor>();
- else if (v.userType() == QVariant::String) {
- bool ok;
- color = QmlStringConverters::colorFromString(v.toString(), &ok);
- if (!ok)
- return engine->nullValue();
- } else
- return engine->nullValue();
- color = color.lighter();
- return qScriptValueFromValue(engine, qVariantFromValue(color));
-}
-
-QScriptValue QmlEnginePrivate::darker(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if(ctxt->argumentCount() != 1)
- return engine->nullValue();
- QVariant v = ctxt->argument(0).toVariant();
- QColor color;
- if (v.userType() == QVariant::Color)
- color = v.value<QColor>();
- else if (v.userType() == QVariant::String) {
- bool ok;
- color = QmlStringConverters::colorFromString(v.toString(), &ok);
- if (!ok)
- return engine->nullValue();
- } else
- return engine->nullValue();
- color = color.darker();
- return qScriptValueFromValue(engine, qVariantFromValue(color));
-}
-
-QScriptValue QmlEnginePrivate::playSound(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if (ctxt->argumentCount() != 1)
- return engine->undefinedValue();
-
- QUrl url(ctxt->argument(0).toString());
-
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine);
- if (url.isRelative()) {
- QmlContext *context = enginePriv->getContext(ctxt);
- if (!context)
- return engine->undefinedValue();
-
- url = context->resolvedUrl(url);
- }
-
- if (url.scheme() == QLatin1String("file")) {
-
- QSound::play(url.toLocalFile());
-
- }
- return engine->undefinedValue();
-}
-
-QScriptValue QmlEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e)
-{
- if(ctxt->argumentCount() < 1)
- return e->newVariant(QVariant(false));
- bool ret = QDesktopServices::openUrl(QUrl(ctxt->argument(0).toString()));
- return e->newVariant(QVariant(ret));
-}
-
-QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *)
-{
- QByteArray data;
-
- if (ctxt->argumentCount() >= 1)
- data = ctxt->argument(0).toString().toUtf8();
-
- QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5);
-
- return QScriptValue(QLatin1String(result.toHex()));
-}
-
-QScriptValue QmlEnginePrivate::btoa(QScriptContext *ctxt, QScriptEngine *)
-{
- QByteArray data;
-
- if (ctxt->argumentCount() >= 1)
- data = ctxt->argument(0).toString().toUtf8();
-
- return QScriptValue(QLatin1String(data.toBase64()));
-}
-
-QScriptValue QmlEnginePrivate::atob(QScriptContext *ctxt, QScriptEngine *)
-{
- QByteArray data;
-
- if (ctxt->argumentCount() >= 1)
- data = ctxt->argument(0).toString().toUtf8();
-
- return QScriptValue(QLatin1String(QByteArray::fromBase64(data)));
-}
-
-QScriptValue QmlEnginePrivate::consoleLog(QScriptContext *ctxt, QScriptEngine *e)
-{
- if(ctxt->argumentCount() < 1)
- return e->newVariant(QVariant(false));
-
- QByteArray msg;
-
- for (int i=0; i<ctxt->argumentCount(); ++i) {
- if (!msg.isEmpty()) msg += ' ';
- msg += ctxt->argument(i).toString().toLocal8Bit();
- // does not support firebug "%[a-z]" formatting, since firebug really
- // does just ignore the format letter, which makes it pointless.
- }
-
- qDebug("%s",msg.constData());
-
- return e->newVariant(QVariant(true));
-}
-
-void QmlEnginePrivate::sendQuit ()
-{
- Q_Q(QmlEngine);
- emit q->quit();
-}
-
-QScriptValue QmlEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptEngine *e)
-{
- QmlEnginePrivate *qe = get (e);
- qe->sendQuit ();
- return QScriptValue();
-}
-
-QScriptValue QmlEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e)
-{
- if(ctxt->argumentCount() < 2)
- return e->newVariant(QVariant(0.0));
- qreal a = ctxt->argument(0).toNumber();
- qreal b = ctxt->argument(1).toNumber();
- qreal ret = b;
- qreal diff = b-a;
- while(diff > 180.0){
- ret -= 360.0;
- diff -= 360.0;
- }
- while(diff < -180.0){
- ret += 360.0;
- diff += 360.0;
- }
- return e->newVariant(QVariant(ret));
-}
-
-QScriptValue QmlEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if(ctxt->argumentCount() != 2)
- return engine->nullValue();
- //get color
- QVariant v = ctxt->argument(0).toVariant();
- QColor color;
- if (v.userType() == QVariant::Color)
- color = v.value<QColor>();
- else if (v.userType() == QVariant::String) {
- bool ok;
- color = QmlStringConverters::colorFromString(v.toString(), &ok);
- if (!ok)
- return engine->nullValue();
- } else
- return engine->nullValue();
-
- //get tint color
- v = ctxt->argument(1).toVariant();
- QColor tintColor;
- if (v.userType() == QVariant::Color)
- tintColor = v.value<QColor>();
- else if (v.userType() == QVariant::String) {
- bool ok;
- tintColor = QmlStringConverters::colorFromString(v.toString(), &ok);
- if (!ok)
- return engine->nullValue();
- } else
- return engine->nullValue();
-
- //tint
- QColor finalColor;
- int a = tintColor.alpha();
- if (a == 0xFF)
- finalColor = tintColor;
- else if (a == 0x00)
- finalColor = color;
- else {
- uint src = tintColor.rgba();
- uint dest = color.rgba();
-
- uint res = (((a * (src & 0xFF00FF)) +
- ((0xFF - a) * (dest & 0xFF00FF))) >> 8) & 0xFF00FF;
- res |= (((a * ((src >> 8) & 0xFF00FF)) +
- ((0xFF - a) * ((dest >> 8) & 0xFF00FF)))) & 0xFF00FF00;
- if ((src & 0xFF000000) == 0xFF000000)
- res |= 0xFF000000;
-
- finalColor = QColor::fromRgba(res);
- }
-
- return qScriptValueFromValue(engine, qVariantFromValue(finalColor));
-}
-
-
-QScriptValue QmlEnginePrivate::scriptValueFromVariant(const QVariant &val)
-{
- if (val.userType() == qMetaTypeId<QmlListReference>()) {
- QmlListReferencePrivate *p = QmlListReferencePrivate::get((QmlListReference*)val.constData());
- if (p->object) {
- return listClass->newList(p->property, p->propertyType);
- } else {
- return scriptEngine.nullValue();
- }
- }
-
- bool objOk;
- QObject *obj = QmlMetaType::toQObject(val, &objOk);
- if (objOk) {
- return objectClass->newQObject(obj);
- } else {
- return qScriptValueFromValue(&scriptEngine, val);
- }
-}
-
-QVariant QmlEnginePrivate::scriptValueToVariant(const QScriptValue &val)
-{
- QScriptDeclarativeClass *dc = QScriptDeclarativeClass::scriptClass(val);
- if (dc == objectClass)
- return QVariant::fromValue(objectClass->toQObject(val));
- else if (dc == contextClass)
- return QVariant();
-
- QScriptDeclarativeClass *sc = QScriptDeclarativeClass::scriptClass(val);
- if (!sc) {
- return val.toVariant();
- } else if (sc == valueTypeClass) {
- return valueTypeClass->toVariant(val);
- } else {
- return QVariant();
- }
-}
-
-QmlScriptClass::QmlScriptClass(QScriptEngine *engine)
-: QScriptDeclarativeClass(engine)
-{
-}
-
-QVariant QmlScriptClass::toVariant(QmlEngine *engine, const QScriptValue &val)
-{
- QmlEnginePrivate *ep =
- static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine));
-
- return ep->scriptValueToVariant(val);
-}
-
-// XXX this beyonds in QUrl::toLocalFile()
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
-/////////////////////////////////////////////////////////////
-struct QmlEnginePrivate::ImportedNamespace {
- QStringList uris;
- QStringList urls;
- QList<int> majversions;
- QList<int> minversions;
- QList<bool> isLibrary;
- QList<QString> qmlDirContent;
-
- bool find(const QByteArray& type, int *vmajor, int *vminor, QmlType** type_return, QUrl* url_return) const
- {
- for (int i=0; i<urls.count(); ++i) {
- int vmaj = majversions.at(i);
- int vmin = minversions.at(i);
-
- QByteArray qt = uris.at(i).toUtf8();
- qt += '/';
- qt += type;
-
- if (qmlImportTrace())
- qDebug() << "Look in" << qt;
- QmlType *t = QmlMetaType::qmlType(qt,vmaj,vmin);
- if (t) {
- if (vmajor) *vmajor = vmaj;
- if (vminor) *vminor = vmin;
- if (qmlImportTrace())
- qDebug() << "Found" << qt;
- if (type_return)
- *type_return = t;
- return true;
- }
-
- QUrl url = QUrl(urls.at(i) + QLatin1Char('/') + QString::fromUtf8(type) + QLatin1String(".qml"));
- QString qmldircontent = qmlDirContent.at(i);
- if (vmaj>=0 || !qmldircontent.isEmpty()) {
- // Check version file - XXX cache these in QmlEngine!
- if (qmldircontent.isEmpty()) {
- QFile qmldir(toLocalFileOrQrc(QUrl(urls.at(i)+QLatin1String("/qmldir"))));
- if (qmldir.open(QIODevice::ReadOnly)) {
- qmldircontent = QString::fromUtf8(qmldir.readAll());
- }
- }
-
- const QString typeName = QString::fromUtf8(type);
-
- QmlDirParser qmldirParser;
- qmldirParser.setUrl(url);
- qmldirParser.setSource(qmldircontent);
- qmldirParser.parse();
-
- foreach (const QmlDirParser::Component &c, qmldirParser.components()) { // ### TODO: cache the components
- if (c.majorVersion < vmaj || (c.majorVersion == vmaj && vmin >= c.minorVersion)) {
- if (c.typeName == typeName) {
- if (url_return)
- *url_return = url.resolved(QUrl(c.fileName));
-
- return true;
- }
- }
- }
-
- } else {
- // XXX search non-files too! (eg. zip files, see QT-524)
- QFileInfo f(toLocalFileOrQrc(url));
- if (f.exists()) {
- if (url_return)
- *url_return = url;
- return true;
- }
- }
- }
- return false;
- }
-};
-
-class QmlImportsPrivate {
-public:
- QmlImportsPrivate() : ref(1)
- {
- }
-
- ~QmlImportsPrivate()
- {
- foreach (QmlEnginePrivate::ImportedNamespace* s, set.values())
- delete s;
- }
-
- QSet<QString> qmlDirFilesForWhichPluginsHaveBeenLoaded;
-
- bool add(const QUrl& base, const QString& qmldircontent, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType, const QStringList& importPath, QmlEngine *engine)
- {
- QmlEnginePrivate::ImportedNamespace *s;
- if (prefix.isEmpty()) {
- s = &unqualifiedset;
- } else {
- s = set.value(prefix);
- if (!s)
- set.insert(prefix,(s=new QmlEnginePrivate::ImportedNamespace));
- }
- QString url = uri;
- if (importType == QmlScriptParser::Import::Library) {
- url.replace(QLatin1Char('.'), QLatin1Char('/'));
- bool found = false;
- QString content;
- QString dir;
-
- // user import paths
- QStringList paths;
-
- // base..
- paths += QFileInfo(base.toLocalFile()).path();
- paths += importPath;
- paths += QmlEnginePrivate::get(engine)->environmentImportPath;
-
- foreach (const QString &p, paths) {
- dir = p+QLatin1Char('/')+url;
- QFileInfo fi(dir+QLatin1String("/qmldir"));
- const QString absoluteFilePath = fi.absoluteFilePath();
-
- if (fi.isFile()) {
- found = true;
-
- url = QUrl::fromLocalFile(fi.absolutePath()).toString();
-
- QFile file(absoluteFilePath);
- if (file.open(QFile::ReadOnly))
- content = QString::fromUtf8(file.readAll());
-
- if (! qmlDirFilesForWhichPluginsHaveBeenLoaded.contains(absoluteFilePath)) {
- qmlDirFilesForWhichPluginsHaveBeenLoaded.insert(absoluteFilePath);
-
- QmlDirParser qmldirParser;
- qmldirParser.setSource(content);
- qmldirParser.parse();
-
- foreach (const QmlDirParser::Plugin &plugin, qmldirParser.plugins()) {
- QString resolvedFilePath = QmlEnginePrivate::get(engine)->resolvePlugin(dir + QDir::separator() + plugin.path,
- plugin.name);
-
- if (!resolvedFilePath.isEmpty())
- engine->importExtension(resolvedFilePath, uri);
- }
- }
-
- break;
- }
- }
-
- } else {
- url = base.resolved(QUrl(url)).toString();
- }
-
- s->uris.prepend(uri);
- s->urls.prepend(url);
- s->majversions.prepend(vmaj);
- s->minversions.prepend(vmin);
- s->isLibrary.prepend(importType == QmlScriptParser::Import::Library);
- s->qmlDirContent.prepend(qmldircontent);
- return true;
- }
-
- bool find(const QByteArray& type, int *vmajor, int *vminor, QmlType** type_return, QUrl* url_return)
- {
- QmlEnginePrivate::ImportedNamespace *s = 0;
- int slash = type.indexOf('/');
- if (slash >= 0) {
- s = set.value(QString::fromUtf8(type.left(slash)));
- if (!s)
- return false; // qualifier must be a namespace
- int nslash = type.indexOf('/',slash+1);
- if (nslash > 0)
- return false; // only single qualification allowed
- } else {
- s = &unqualifiedset;
- }
- QByteArray unqualifiedtype = slash < 0 ? type : type.mid(slash+1); // common-case opt (QString::mid works fine, but slower)
- if (s) {
- if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return))
- return true;
- if (s->urls.count() == 1 && !s->isLibrary[0] && url_return) {
- *url_return = QUrl(s->urls[0]+QLatin1Char('/')).resolved(QUrl(QString::fromUtf8(unqualifiedtype) + QLatin1String(".qml")));
- return true;
- }
-
- }
- if (url_return) {
- *url_return = base.resolved(QUrl(QString::fromUtf8(type + ".qml")));
- return true;
- } else {
- return false;
- }
- }
-
- QmlEnginePrivate::ImportedNamespace *findNamespace(const QString& type)
- {
- return set.value(type);
- }
-
- QUrl base;
- int ref;
-
-private:
- friend struct QmlEnginePrivate::Imports;
- QmlEnginePrivate::ImportedNamespace unqualifiedset;
- QHash<QString,QmlEnginePrivate::ImportedNamespace* > set;
-};
-
-QmlEnginePrivate::Imports::Imports(const Imports &copy) :
- d(copy.d)
-{
- ++d->ref;
-}
-
-QmlEnginePrivate::Imports &QmlEnginePrivate::Imports::operator =(const Imports &copy)
-{
- ++copy.d->ref;
- if (--d->ref == 0)
- delete d;
- d = copy.d;
- return *this;
-}
-
-QmlEnginePrivate::Imports::Imports() :
- d(new QmlImportsPrivate)
-{
-}
-
-QmlEnginePrivate::Imports::~Imports()
-{
- if (--d->ref == 0)
- delete d;
-}
-
-#include "qmlmetatype.h"
-#include "qmltypenamecache_p.h"
-
-static QmlTypeNameCache *cacheForNamespace(QmlEngine *engine, const QmlEnginePrivate::ImportedNamespace &set, QmlTypeNameCache *cache)
-{
- if (!cache)
- cache = new QmlTypeNameCache(engine);
-
- QList<QmlType *> types = QmlMetaType::qmlTypes();
-
- for (int ii = 0; ii < set.uris.count(); ++ii) {
- QByteArray base = set.uris.at(ii).toUtf8() + '/';
- int major = set.majversions.at(ii);
- int minor = set.minversions.at(ii);
-
- foreach (QmlType *type, types) {
- if (type->qmlTypeName().startsWith(base) &&
- type->qmlTypeName().lastIndexOf('/') == (base.length() - 1) &&
- type->availableInVersion(major,minor))
- {
- QString name = QString::fromUtf8(type->qmlTypeName().mid(base.length()));
-
- cache->add(name, type);
- }
- }
- }
-
- return cache;
-}
-
-QmlTypeNameCache *QmlEnginePrivate::Imports::cache(QmlEngine *engine) const
-{
- const QmlEnginePrivate::ImportedNamespace &set = d->unqualifiedset;
-
- QmlTypeNameCache *cache = new QmlTypeNameCache(engine);
-
- for (QHash<QString,QmlEnginePrivate::ImportedNamespace* >::ConstIterator iter = d->set.begin();
- iter != d->set.end(); ++iter) {
-
- QmlTypeNameCache::Data *d = cache->data(iter.key());
- if (d) {
- if (!d->typeNamespace)
- cacheForNamespace(engine, *(*iter), d->typeNamespace);
- } else {
- QmlTypeNameCache *nc = cacheForNamespace(engine, *(*iter), 0);
- cache->add(iter.key(), nc);
- nc->release();
- }
- }
-
- cacheForNamespace(engine, set, cache);
-
- return cache;
-}
-
-/*
-QStringList QmlEnginePrivate::Imports::unqualifiedSet() const
-{
- QStringList rv;
-
- const QmlEnginePrivate::ImportedNamespace &set = d->unqualifiedset;
-
- for (int ii = 0; ii < set.urls.count(); ++ii) {
- if (set.isBuiltin.at(ii))
- rv << set.urls.at(ii);
- }
-
- return rv;
-}
-*/
-
-/*!
- Sets the base URL to be used for all relative file imports added.
-*/
-void QmlEnginePrivate::Imports::setBaseUrl(const QUrl& url)
-{
- d->base = url;
-}
-
-/*!
- Returns the base URL to be used for all relative file imports added.
-*/
-QUrl QmlEnginePrivate::Imports::baseUrl() const
-{
- return d->base;
-}
-
-/*!
- Adds \a path as a directory where installed QML components are
- defined in a URL-based directory structure.
-
- For example, if you add \c /opt/MyApp/lib/qml and then load QML
- that imports \c com.mycompany.Feature, then QmlEngine will look
- in \c /opt/MyApp/lib/qml/com/mycompany/Feature/ for the components
- provided by that module (and in the case of versioned imports,
- for the \c qmldir file definiting the type version mapping.
-
- By default, only the "qml" subdirectory of QLibraryInfo::location(QLibraryInfo::DataPath)
- is included on the import path.
-*/
-void QmlEngine::addImportPath(const QString& path)
-{
- if (qmlImportTrace())
- qDebug() << "QmlEngine::addImportPath" << path;
- Q_D(QmlEngine);
- d->fileImportPath.prepend(path);
-}
-
-/*!
- Imports the given \a extension into this QmlEngine. Returns
- true if the extension was successfully imported.
-
- \sa QmlExtensionInterface
-*/
-bool QmlEngine::importExtension(const QString &fileName, const QString &uri)
-{
- QPluginLoader loader(fileName);
-
- if (QmlExtensionInterface *iface = qobject_cast<QmlExtensionInterface *>(loader.instance())) {
- iface->initialize(this, uri.toUtf8().constData());
- return true;
- }
-
- return false;
-}
-
-/*!
- \property QmlEngine::offlineStoragePath
- \brief the directory for storing offline user data
-
- Returns the directory where SQL and other offline
- storage is placed.
-
- QmlGraphicsWebView and the SQL databases created with openDatabase()
- are stored here.
-
- The default is QML/OfflineStorage in the platform-standard
- user application data directory.
-
- Note that the path may not currently exist on the filesystem, so
- callers wanting to \e create new files at this location should create
- it first - see QDir::mkpath().
-*/
-void QmlEngine::setOfflineStoragePath(const QString& dir)
-{
- Q_D(QmlEngine);
- d->scriptEngine.offlineStoragePath = dir;
-}
-
-QString QmlEngine::offlineStoragePath() const
-{
- Q_D(const QmlEngine);
- return d->scriptEngine.offlineStoragePath;
-}
-
-/*!
- \internal
-
- Returns the result of the merge of \a baseName with \a dir, \a suffixes, and \a prefix.
- */
-QString QmlEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName,
- const QStringList &suffixes,
- const QString &prefix)
-{
- foreach (const QString &suffix, suffixes) {
- QString pluginFileName = prefix;
-
- pluginFileName += baseName;
- pluginFileName += QLatin1Char('.');
- pluginFileName += suffix;
-
- QFileInfo fileInfo(dir, pluginFileName);
-
- if (fileInfo.exists())
- return fileInfo.absoluteFilePath();
- }
-
- return QString();
-}
-
-/*!
- \internal
-
- Returns the result of the merge of \a baseName with \a dir and the platform suffix.
-
- \table
- \header \i Platform \i Valid suffixes
- \row \i Windows \i \c .dll
- \row \i Unix/Linux \i \c .so
- \row \i AIX \i \c .a
- \row \i HP-UX \i \c .sl, \c .so (HP-UXi)
- \row \i Mac OS X \i \c .dylib, \c .bundle, \c .so
- \row \i Symbian \i \c .dll
- \endtable
-
- Version number on unix are ignored.
-*/
-QString QmlEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName)
-{
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- return resolvePlugin(dir, baseName, QStringList(QLatin1String("dll")));
-#elif defined(Q_OS_SYMBIAN)
- return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dll") << QLatin1String("qtplugin"));
-#else
-
-# if defined(Q_OS_DARWIN)
-
- return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dylib") << QLatin1String("so") << QLatin1String("bundle"),
- QLatin1String("lib"));
-# else // Generic Unix
- QStringList validSuffixList;
-
-# if defined(Q_OS_HPUX)
-/*
- See "HP-UX Linker and Libraries User's Guide", section "Link-time Differences between PA-RISC and IPF":
- "In PA-RISC (PA-32 and PA-64) shared libraries are suffixed with .sl. In IPF (32-bit and 64-bit),
- the shared libraries are suffixed with .so. For compatibility, the IPF linker also supports the .sl suffix."
- */
- validSuffixList << QLatin1String("sl");
-# if defined __ia64
- validSuffixList << QLatin1String("so");
-# endif
-# elif defined(Q_OS_AIX)
- validSuffixList << QLatin1String("a") << QLatin1String("so");
-# elif defined(Q_OS_UNIX)
- validSuffixList << QLatin1String("so");
-# endif
-
- // Examples of valid library names:
- // libfoo.so
-
- return resolvePlugin(dir, baseName, validSuffixList, QLatin1String("lib"));
-# endif
-
-#endif
-}
-
-/*!
- \internal
-
- Adds information to \a imports such that subsequent calls to resolveType()
- will resolve types qualified by \a prefix by considering types found at the given \a uri.
-
- The uri is either a directory (if importType is FileImport), or a URI resolved using paths
- added via addImportPath() (if importType is LibraryImport).
-
- The \a prefix may be empty, in which case the import location is considered for
- unqualified types.
-
- The base URL must already have been set with Import::setBaseUrl().
-*/
-bool QmlEnginePrivate::addToImport(Imports* imports, const QString& qmldircontent, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const
-{
- QmlEngine *engine = QmlEnginePrivate::get(const_cast<QmlEnginePrivate *>(this));
- bool ok = imports->d->add(imports->d->base,qmldircontent,uri,prefix,vmaj,vmin,importType,fileImportPath, engine);
- if (qmlImportTrace())
- qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << vmaj << '.' << vmin << (importType==QmlScriptParser::Import::Library? "Library" : "File") << ": " << ok;
- return ok;
-}
-
-/*!
- \internal
-
- Using the given \a imports, the given (namespace qualified) \a type is resolved to either
- an ImportedNamespace stored at \a ns_return,
- a QmlType stored at \a type_return, or
- a component located at \a url_return.
-
- If any return pointer is 0, the corresponding search is not done.
-
- \sa addToImport()
-*/
-bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& type, QmlType** type_return, QUrl* url_return, int *vmaj, int *vmin, ImportedNamespace** ns_return) const
-{
- ImportedNamespace* ns = imports.d->findNamespace(QString::fromUtf8(type));
- if (ns) {
- if (qmlImportTrace())
- qDebug() << "QmlEngine::resolveType" << type << "is namespace for" << ns->urls;
- if (ns_return)
- *ns_return = ns;
- return true;
- }
- if (type_return || url_return) {
- if (imports.d->find(type,vmaj,vmin,type_return,url_return)) {
- if (qmlImportTrace()) {
- if (type_return && *type_return)
- qDebug() << "QmlEngine::resolveType" << type << '=' << (*type_return)->typeName();
- if (url_return)
- qDebug() << "QmlEngine::resolveType" << type << '=' << *url_return;
- }
- return true;
- }
- if (qmlImportTrace())
- qDebug() << "QmlEngine::resolveType" << type << "not found";
- }
- return false;
-}
-
-/*!
- \internal
-
- Searching \e only in the namespace \a ns (previously returned in a call to
- resolveType(), \a type is found and returned to either
- a QmlType stored at \a type_return, or
- a component located at \a url_return.
-
- If either return pointer is 0, the corresponding search is not done.
-*/
-void QmlEnginePrivate::resolveTypeInNamespace(ImportedNamespace* ns, const QByteArray& type, QmlType** type_return, QUrl* url_return, int *vmaj, int *vmin ) const
-{
- ns->find(type,vmaj,vmin,type_return,url_return);
-}
-
-static void voidptr_destructor(void *v)
-{
- void **ptr = (void **)v;
- delete ptr;
-}
-
-static void *voidptr_constructor(const void *v)
-{
- if (!v) {
- return new void*;
- } else {
- return new void*(*(void **)v);
- }
-}
-
-void QmlEnginePrivate::registerCompositeType(QmlCompiledData *data)
-{
- QByteArray name = data->root->className();
-
- QByteArray ptr = name + '*';
- QByteArray lst = "QmlListProperty<" + name + ">";
-
- int ptr_type = QMetaType::registerType(ptr.constData(), voidptr_destructor,
- voidptr_constructor);
- int lst_type = QMetaType::registerType(lst.constData(), voidptr_destructor,
- voidptr_constructor);
-
- m_qmlLists.insert(lst_type, ptr_type);
- m_compositeTypes.insert(ptr_type, data);
- data->addref();
-}
-
-bool QmlEnginePrivate::isList(int t) const
-{
- return m_qmlLists.contains(t) || QmlMetaType::isList(t);
-}
-
-int QmlEnginePrivate::listType(int t) const
-{
- QHash<int, int>::ConstIterator iter = m_qmlLists.find(t);
- if (iter != m_qmlLists.end())
- return *iter;
- else
- return QmlMetaType::listType(t);
-}
-
-bool QmlEnginePrivate::isQObject(int t)
-{
- return m_compositeTypes.contains(t) || QmlMetaType::isQObject(t);
-}
-
-QObject *QmlEnginePrivate::toQObject(const QVariant &v, bool *ok) const
-{
- int t = v.userType();
- if (m_compositeTypes.contains(t)) {
- if (ok) *ok = true;
- return *(QObject **)(v.constData());
- } else {
- return QmlMetaType::toQObject(v, ok);
- }
-}
-
-QmlMetaType::TypeCategory QmlEnginePrivate::typeCategory(int t) const
-{
- if (m_compositeTypes.contains(t))
- return QmlMetaType::Object;
- else if (m_qmlLists.contains(t))
- return QmlMetaType::List;
- else
- return QmlMetaType::typeCategory(t);
-}
-
-const QMetaObject *QmlEnginePrivate::rawMetaObjectForType(int t) const
-{
- QHash<int, QmlCompiledData*>::ConstIterator iter = m_compositeTypes.find(t);
- if (iter != m_compositeTypes.end()) {
- return (*iter)->root;
- } else {
- QmlType *type = QmlMetaType::qmlType(t);
- return type?type->baseMetaObject():0;
- }
-}
-
-const QMetaObject *QmlEnginePrivate::metaObjectForType(int t) const
-{
- QHash<int, QmlCompiledData*>::ConstIterator iter = m_compositeTypes.find(t);
- if (iter != m_compositeTypes.end()) {
- return (*iter)->root;
- } else {
- QmlType *type = QmlMetaType::qmlType(t);
- return type?type->metaObject():0;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h
deleted file mode 100644
index dd2012a..0000000
--- a/src/declarative/qml/qmlengine.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLENGINE_H
-#define QMLENGINE_H
-
-#include <QtCore/qurl.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qmap.h>
-#include <QtScript/qscriptvalue.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlComponent;
-class QmlEnginePrivate;
-class QmlImportsPrivate;
-class QmlExpression;
-class QmlContext;
-class QmlType;
-class QUrl;
-class QScriptEngine;
-class QScriptContext;
-class QmlImageProvider;
-class QNetworkAccessManager;
-class QmlNetworkAccessManagerFactory;
-class Q_DECLARATIVE_EXPORT QmlEngine : public QObject
-{
- Q_PROPERTY(QString offlineStoragePath READ offlineStoragePath WRITE setOfflineStoragePath)
- Q_OBJECT
-public:
- QmlEngine(QObject *p = 0);
- virtual ~QmlEngine();
-
- QmlContext *rootContext();
-
- void clearComponentCache();
-
- void addImportPath(const QString& dir);
- bool importExtension(const QString &fileName, const QString &uri);
-
- void setNetworkAccessManagerFactory(QmlNetworkAccessManagerFactory *);
- QmlNetworkAccessManagerFactory *networkAccessManagerFactory() const;
-
- QNetworkAccessManager *networkAccessManager() const;
-
- void addImageProvider(const QString &id, QmlImageProvider *);
- QmlImageProvider *imageProvider(const QString &id) const;
- void removeImageProvider(const QString &id);
-
- void setOfflineStoragePath(const QString& dir);
- QString offlineStoragePath() const;
-
- QUrl baseUrl() const;
- void setBaseUrl(const QUrl &);
-
- static QmlContext *contextForObject(const QObject *);
- static void setContextForObject(QObject *, QmlContext *);
-
-Q_SIGNALS:
- void quit ();
-
-private:
- Q_DECLARE_PRIVATE(QmlEngine)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLENGINE_H
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
deleted file mode 100644
index b18ab24..0000000
--- a/src/declarative/qml/qmlengine_p.h
+++ /dev/null
@@ -1,340 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLENGINE_P_H
-#define QMLENGINE_P_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 "qmlengine.h"
-
-#include "qmlclassfactory_p.h"
-#include "qmlcompositetypemanager_p.h"
-#include "qpodvector_p.h"
-#include "qml.h"
-#include "qmlvaluetype_p.h"
-#include "qmlcontext.h"
-#include "qmlexpression.h"
-#include "qmlmetaproperty_p.h"
-#include "qmlpropertycache_p.h"
-#include "qmlobjectscriptclass_p.h"
-#include "qmlcontextscriptclass_p.h"
-#include "qmlvaluetypescriptclass_p.h"
-
-#include <QtScript/QScriptClass>
-#include <QtScript/QScriptValue>
-#include <QtScript/QScriptString>
-#include <QtCore/qstring.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qpair.h>
-#include <QtCore/qstack.h>
-#include <QtCore/qmutex.h>
-#include <QtScript/qscriptengine.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlContext;
-class QmlEngine;
-class QmlContextPrivate;
-class QmlExpression;
-class QmlContextScriptClass;
-class QmlObjectScriptClass;
-class QmlTypeNameScriptClass;
-class QmlValueTypeScriptClass;
-class QScriptEngineDebugger;
-class QNetworkReply;
-class QNetworkAccessManager;
-class QmlNetworkAccessManagerFactory;
-class QmlAbstractBinding;
-class QScriptDeclarativeClass;
-class QmlTypeNameScriptClass;
-class QmlTypeNameCache;
-class QmlComponentAttached;
-class QmlListScriptClass;
-class QmlCleanup;
-class QmlDelayedError;
-class QmlWorkerScriptEngine;
-class QmlGlobalScriptClass;
-class QDir;
-
-class QmlScriptEngine : public QScriptEngine
-{
-public:
- QmlScriptEngine(QmlEnginePrivate *priv);
- virtual ~QmlScriptEngine();
-
- QUrl resolvedUrl(QScriptContext *context, const QUrl& url); // resolved against p's context, or baseUrl if no p
- static QScriptValue resolvedUrl(QScriptContext *ctxt, QScriptEngine *engine);
-
- static QmlScriptEngine *get(QScriptEngine* e) { return static_cast<QmlScriptEngine*>(e); }
-
- QmlEnginePrivate *p;
-
- // User by SQL API
- QScriptClass *sqlQueryClass;
- QString offlineStoragePath;
-
- // Used by DOM Core 3 API
- QScriptClass *namedNodeMapClass;
- QScriptClass *nodeListClass;
-
- QUrl baseUrl;
-
- virtual QNetworkAccessManager *networkAccessManager();
-};
-
-class Q_AUTOTEST_EXPORT QmlEnginePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlEngine)
-public:
- QmlEnginePrivate(QmlEngine *);
- ~QmlEnginePrivate();
-
- void init();
-
- struct CapturedProperty {
- CapturedProperty(QObject *o, int c, int n)
- : object(o), coreIndex(c), notifyIndex(n) {}
-
- QObject *object;
- int coreIndex;
- int notifyIndex;
- };
- bool captureProperties;
- QPODVector<CapturedProperty> capturedProperties;
-
- QmlContext *rootContext;
- QmlExpression *currentExpression;
- bool isDebugging;
-
- struct ImportedNamespace;
- QmlContextScriptClass *contextClass;
- QmlContext *sharedContext;
- QObject *sharedScope;
- QmlObjectScriptClass *objectClass;
- QmlValueTypeScriptClass *valueTypeClass;
- QmlTypeNameScriptClass *typeNameClass;
- QmlListScriptClass *listClass;
- // Global script class
- QmlGlobalScriptClass *globalClass;
-
- // Registered cleanup handlers
- QmlCleanup *cleanup;
-
- // Bindings that have had errors during startup
- QmlDelayedError *erroredBindings;
- int inProgressCreations;
-
- QmlScriptEngine scriptEngine;
-
- QmlWorkerScriptEngine *getWorkerScriptEngine();
- QmlWorkerScriptEngine *workerScriptEngine;
-
- QUrl baseUrl;
-
- template<class T>
- struct SimpleList {
- SimpleList()
- : count(0), values(0) {}
- SimpleList(int r)
- : count(0), values(new T*[r]) {}
-
- int count;
- T **values;
-
- void append(T *v) {
- values[count++] = v;
- }
-
- T *at(int idx) const {
- return values[idx];
- }
-
- void clear() {
- delete [] values;
- }
- };
-
- static void clear(SimpleList<QmlAbstractBinding> &);
- static void clear(SimpleList<QmlParserStatus> &);
-
- QList<SimpleList<QmlAbstractBinding> > bindValues;
- QList<SimpleList<QmlParserStatus> > parserStatus;
- QmlComponentAttached *componentAttacheds;
-
- bool inBeginCreate;
-
- QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const;
- QNetworkAccessManager *getNetworkAccessManager() const;
- mutable QNetworkAccessManager *networkAccessManager;
- mutable QmlNetworkAccessManagerFactory *networkAccessManagerFactory;
-
- QHash<QString,QmlImageProvider*> imageProviders;
- QImage getImageFromProvider(const QUrl &url);
-
- mutable QMutex mutex;
-
- QmlCompositeTypeManager typeManager;
- QStringList fileImportPath;
- QString offlineStoragePath;
-
- mutable quint32 uniqueId;
- quint32 getUniqueId() const {
- return uniqueId++;
- }
-
- QmlValueTypeFactory valueTypes;
-
- QHash<const QMetaObject *, QmlPropertyCache *> propertyCache;
- QmlPropertyCache *cache(QObject *obj) {
- Q_Q(QmlEngine);
- if (!obj || QObjectPrivate::get(obj)->metaObject) return 0;
- const QMetaObject *mo = obj->metaObject();
- QmlPropertyCache *rv = propertyCache.value(mo);
- if (!rv) {
- rv = QmlPropertyCache::create(q, mo);
- propertyCache.insert(mo, rv);
- }
- return rv;
- }
-
- // ### This whole class is embarrassing
- struct Imports {
- Imports();
- ~Imports();
- Imports(const Imports &copy);
- Imports &operator =(const Imports &copy);
-
- void setBaseUrl(const QUrl& url);
- QUrl baseUrl() const;
-
- QmlTypeNameCache *cache(QmlEngine *) const;
-
- private:
- friend class QmlEnginePrivate;
- QmlImportsPrivate *d;
- };
-
-
- QStringList environmentImportPath;
-
- QString resolvePlugin(const QDir &dir, const QString &baseName,
- const QStringList &suffixes,
- const QString &prefix = QString());
- QString resolvePlugin(const QDir &dir, const QString &baseName);
-
-
- bool addToImport(Imports*, const QString& qmlDirContent,const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const;
- bool resolveType(const Imports&, const QByteArray& type,
- QmlType** type_return, QUrl* url_return,
- int *version_major, int *version_minor,
- ImportedNamespace** ns_return) const;
- void resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type,
- QmlType** type_return, QUrl* url_return,
- int *version_major, int *version_minor ) const;
-
-
- void registerCompositeType(QmlCompiledData *);
-
- bool isQObject(int);
- QObject *toQObject(const QVariant &, bool *ok = 0) const;
- QmlMetaType::TypeCategory typeCategory(int) const;
- bool isList(int) const;
- int listType(int) const;
- const QMetaObject *rawMetaObjectForType(int) const;
- const QMetaObject *metaObjectForType(int) const;
- QHash<int, int> m_qmlLists;
- QHash<int, QmlCompiledData *> m_compositeTypes;
-
- QScriptValue scriptValueFromVariant(const QVariant &);
- QVariant scriptValueToVariant(const QScriptValue &);
-
- void sendQuit ();
-
- static QScriptValue qmlScriptObject(QObject*, QmlEngine*);
-
- static QScriptValue createComponent(QScriptContext*, QScriptEngine*);
- static QScriptValue createQmlObject(QScriptContext*, QScriptEngine*);
- static QScriptValue vector(QScriptContext*, QScriptEngine*);
- static QScriptValue rgba(QScriptContext*, QScriptEngine*);
- static QScriptValue hsla(QScriptContext*, QScriptEngine*);
- static QScriptValue point(QScriptContext*, QScriptEngine*);
- static QScriptValue size(QScriptContext*, QScriptEngine*);
- static QScriptValue rect(QScriptContext*, QScriptEngine*);
-
- static QScriptValue lighter(QScriptContext*, QScriptEngine*);
- static QScriptValue darker(QScriptContext*, QScriptEngine*);
- static QScriptValue tint(QScriptContext*, QScriptEngine*);
-
- static QScriptValue closestAngle(QScriptContext*, QScriptEngine*);
- static QScriptValue playSound(QScriptContext*, QScriptEngine*);
- static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*);
- static QScriptValue md5(QScriptContext*, QScriptEngine*);
- static QScriptValue btoa(QScriptContext*, QScriptEngine*);
- static QScriptValue atob(QScriptContext*, QScriptEngine*);
- static QScriptValue consoleLog(QScriptContext*, QScriptEngine*);
- static QScriptValue quit(QScriptContext*, QScriptEngine*);
-
- static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; }
- static QmlEngine *getEngine(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p->q_func(); }
- static QmlEnginePrivate *get(QmlEngine *e) { return e->d_func(); }
- static QmlEnginePrivate *get(QmlContext *c) { return (c && c->engine()) ? QmlEnginePrivate::get(c->engine()) : 0; }
- static QmlEnginePrivate *get(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p; }
- static QmlEngine *get(QmlEnginePrivate *p) { return p->q_func(); }
- QmlContext *getContext(QScriptContext *);
-
- static void defineModule();
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLENGINE_P_H
diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp
deleted file mode 100644
index 973e5e5..0000000
--- a/src/declarative/qml/qmlenginedebug.cpp
+++ /dev/null
@@ -1,456 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlenginedebug_p.h"
-
-#include "qmlboundsignal_p.h"
-#include "qmlengine.h"
-#include "qmlmetatype.h"
-#include "qmlmetaproperty.h"
-#include "qmlbinding_p.h"
-#include "qmlcontext_p.h"
-#include "qmlwatcher_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qmetaobject.h>
-
-QT_BEGIN_NAMESPACE
-
-QList<QmlEngine *> QmlEngineDebugServer::m_engines;
-QmlEngineDebugServer::QmlEngineDebugServer(QObject *parent)
-: QmlDebugService(QLatin1String("QmlEngine"), parent),
- m_watch(new QmlWatcher(this))
-{
- QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)),
- this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant)));
-}
-
-QDataStream &operator<<(QDataStream &ds,
- const QmlEngineDebugServer::QmlObjectData &data)
-{
- ds << data.url << data.lineNumber << data.columnNumber << data.objectName
- << data.objectType << data.objectId << data.contextId;
- return ds;
-}
-
-QDataStream &operator>>(QDataStream &ds,
- QmlEngineDebugServer::QmlObjectData &data)
-{
- ds >> data.url >> data.lineNumber >> data.columnNumber >> data.objectName
- >> data.objectType >> data.objectId >> data.contextId;
- return ds;
-}
-
-QDataStream &operator<<(QDataStream &ds,
- const QmlEngineDebugServer::QmlObjectProperty &data)
-{
- ds << (int)data.type << data.name << data.value << data.valueTypeName
- << data.binding << data.hasNotifySignal;
- return ds;
-}
-
-QDataStream &operator>>(QDataStream &ds,
- QmlEngineDebugServer::QmlObjectProperty &data)
-{
- int type;
- ds >> type >> data.name >> data.value >> data.valueTypeName
- >> data.binding >> data.hasNotifySignal;
- data.type = (QmlEngineDebugServer::QmlObjectProperty::Type)type;
- return ds;
-}
-
-QmlEngineDebugServer::QmlObjectProperty
-QmlEngineDebugServer::propertyData(QObject *obj, int propIdx)
-{
- QmlObjectProperty rv;
-
- QMetaProperty prop = obj->metaObject()->property(propIdx);
-
- rv.type = QmlObjectProperty::Unknown;
- rv.valueTypeName = QString::fromUtf8(prop.typeName());
- rv.name = QString::fromUtf8(prop.name());
- rv.hasNotifySignal = prop.hasNotifySignal();
- QmlAbstractBinding *binding = QmlMetaProperty(obj, rv.name).binding();
- if (binding)
- rv.binding = binding->expression();
-
- QVariant value = prop.read(obj);
- rv.value = valueContents(value);
-
- if (QVariant::Type(prop.userType()) < QVariant::UserType) {
- rv.type = QmlObjectProperty::Basic;
- } else if (QmlMetaType::isQObject(prop.userType())) {
- rv.type = QmlObjectProperty::Object;
- } else if (QmlMetaType::isList(prop.userType())) {
- rv.type = QmlObjectProperty::List;
- }
-
- return rv;
-}
-
-QVariant QmlEngineDebugServer::valueContents(const QVariant &value) const
-{
- int userType = value.userType();
- if (QVariant::Type(userType) < QVariant::UserType)
- return value;
-
- /*
- if (QmlMetaType::isList(userType)) {
- int count = QmlMetaType::listCount(value);
- QVariantList contents;
- for (int i=0; i<count; i++)
- contents << valueContents(QmlMetaType::listAt(value, i));
- return contents;
- } else */
- if (QmlMetaType::isQObject(userType)) {
- QObject *o = QmlMetaType::toQObject(value);
- if (o) {
- QString name = o->objectName();
- if (name.isEmpty())
- name = QLatin1String("<unnamed object>");
- return name;
- }
- }
-
- return QLatin1String("<unknown value>");
-}
-
-void QmlEngineDebugServer::buildObjectDump(QDataStream &message,
- QObject *object, bool recur)
-{
- message << objectData(object);
-
- // Some children aren't added to an object until particular properties are read
- // - e.g. child state objects aren't added until the 'states' property is read -
- // but this should only affect internal objects that aren't shown by the
- // debugger anyway.
-
- QObjectList children = object->children();
-
- int childrenCount = children.count();
- for (int ii = 0; ii < children.count(); ++ii) {
- if (qobject_cast<QmlContext*>(children[ii]) || QmlBoundSignal::cast(children[ii]))
- --childrenCount;
- }
-
- message << childrenCount << recur;
-
- QList<QmlObjectProperty> fakeProperties;
-
- for (int ii = 0; ii < children.count(); ++ii) {
- QObject *child = children.at(ii);
- if (qobject_cast<QmlContext*>(child))
- continue;
- QmlBoundSignal *signal = QmlBoundSignal::cast(child);
- if (signal) {
- QmlObjectProperty prop;
- prop.type = QmlObjectProperty::SignalProperty;
- prop.hasNotifySignal = false;
- QmlExpression *expr = signal->expression();
- if (expr) {
- prop.value = expr->expression();
- QObject *scope = expr->scopeObject();
- if (scope) {
- QString sig = QLatin1String(scope->metaObject()->method(signal->index()).signature());
- int lparen = sig.indexOf(QLatin1Char('('));
- if (lparen >= 0) {
- QString methodName = sig.mid(0, lparen);
- prop.name = QLatin1String("on") + methodName[0].toUpper()
- + methodName.mid(1);
- }
- }
- }
- fakeProperties << prop;
- } else {
- if (recur)
- buildObjectDump(message, child, recur);
- else
- message << objectData(child);
- }
- }
-
- message << (object->metaObject()->propertyCount() + fakeProperties.count());
-
- for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii)
- message << propertyData(object, ii);
-
- for (int ii = 0; ii < fakeProperties.count(); ++ii)
- message << fakeProperties[ii];
-}
-
-void QmlEngineDebugServer::buildObjectList(QDataStream &message,
- QmlContext *ctxt)
-{
- QmlContextPrivate *p = (QmlContextPrivate *)QObjectPrivate::get(ctxt);
-
- QString ctxtName = ctxt->objectName();
- int ctxtId = QmlDebugService::idForObject(ctxt);
-
- message << ctxtName << ctxtId;
-
- int count = 0;
-
- for (QSet<QmlContext *>::ConstIterator iter = p->childContexts.begin();
- iter != p->childContexts.end(); ++iter) {
- QmlContextPrivate *p = (QmlContextPrivate *)QObjectPrivate::get(*iter);
- if (p->isInternal)
- continue;
- ++count;
- }
-
- message << count;
-
- for (QSet<QmlContext *>::ConstIterator iter = p->childContexts.begin();
- iter != p->childContexts.end(); ++iter) {
- QmlContextPrivate *p = (QmlContextPrivate *)QObjectPrivate::get(*iter);
- if (p->isInternal)
- continue;
- buildObjectList(message, *iter);
- }
-
- // Clean deleted objects
- for (int ii = 0; ii < p->instances.count(); ++ii) {
- if (!p->instances.at(ii)) {
- p->instances.removeAt(ii);
- --ii;
- }
- }
-
- message << p->instances.count();
- for (int ii = 0; ii < p->instances.count(); ++ii) {
- message << objectData(p->instances.at(ii));
- }
-}
-
-QmlEngineDebugServer::QmlObjectData
-QmlEngineDebugServer::objectData(QObject *object)
-{
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(object);
- QmlObjectData rv;
- if (ddata) {
- rv.url = ddata->outerContext->baseUrl();
- rv.lineNumber = ddata->lineNumber;
- rv.columnNumber = ddata->columnNumber;
- } else {
- rv.lineNumber = -1;
- rv.columnNumber = -1;
- }
-
- rv.objectName = object->objectName();
- rv.objectId = QmlDebugService::idForObject(object);
- rv.contextId = QmlDebugService::idForObject(qmlContext(object));
-
- QmlType *type = QmlMetaType::qmlType(object->metaObject());
- if (type) {
- QString typeName = QLatin1String(type->qmlTypeName());
- int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
- rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1);
- } else {
- rv.objectType = QString::fromUtf8(object->metaObject()->className());
- int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_"));
- if (marker != -1)
- rv.objectType = rv.objectType.left(marker);
- }
-
- return rv;
-}
-
-void QmlEngineDebugServer::messageReceived(const QByteArray &message)
-{
- QDataStream ds(message);
-
- QByteArray type;
- ds >> type;
-
- //qDebug() << "QmlEngineDebugServer::messageReceived()" << type;
-
- if (type == "LIST_ENGINES") {
- int queryId;
- ds >> queryId;
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("LIST_ENGINES_R");
- rs << queryId << m_engines.count();
-
- for (int ii = 0; ii < m_engines.count(); ++ii) {
- QmlEngine *engine = m_engines.at(ii);
-
- QString engineName = engine->objectName();
- int engineId = QmlDebugService::idForObject(engine);
-
- rs << engineName << engineId;
- }
-
- sendMessage(reply);
- } else if (type == "LIST_OBJECTS") {
- int queryId;
- int engineId = -1;
- ds >> queryId >> engineId;
-
- QmlEngine *engine =
- qobject_cast<QmlEngine *>(QmlDebugService::objectForId(engineId));
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("LIST_OBJECTS_R") << queryId;
-
- if (engine)
- buildObjectList(rs, engine->rootContext());
-
- sendMessage(reply);
- } else if (type == "FETCH_OBJECT") {
- int queryId;
- int objectId;
- bool recurse;
-
- ds >> queryId >> objectId >> recurse;
-
- QObject *object = QmlDebugService::objectForId(objectId);
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("FETCH_OBJECT_R") << queryId;
-
- if (object)
- buildObjectDump(rs, object, recurse);
-
- sendMessage(reply);
- } else if (type == "WATCH_OBJECT") {
- int queryId;
- int objectId;
-
- ds >> queryId >> objectId;
- bool ok = m_watch->addWatch(queryId, objectId);
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("WATCH_OBJECT_R") << queryId << ok;
-
- sendMessage(reply);
- } else if (type == "WATCH_PROPERTY") {
- int queryId;
- int objectId;
- QByteArray property;
-
- ds >> queryId >> objectId >> property;
- bool ok = m_watch->addWatch(queryId, objectId, property);
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok;
-
- sendMessage(reply);
- } else if (type == "WATCH_EXPR_OBJECT") {
- int queryId;
- int debugId;
- QString expr;
-
- ds >> queryId >> debugId >> expr;
- bool ok = m_watch->addWatch(queryId, debugId, expr);
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok;
-
- sendMessage(reply);
- } else if (type == "NO_WATCH") {
- int queryId;
-
- ds >> queryId;
- m_watch->removeWatch(queryId);
- } else if (type == "EVAL_EXPRESSION") {
- int queryId;
- int objectId;
- QString expr;
-
- ds >> queryId >> objectId >> expr;
-
- QObject *object = QmlDebugService::objectForId(objectId);
- QmlContext *context = qmlContext(object);
- QVariant result;
- if (object && context) {
- QmlExpression exprObj(context, expr, object);
- bool undefined = false;
- QVariant value = exprObj.value(&undefined);
- if (undefined)
- result = QLatin1String("<undefined>");
- else
- result = valueContents(value);
- } else {
- result = QLatin1String("<unknown context>");
- }
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result;
-
- sendMessage(reply);
- }
-}
-
-void QmlEngineDebugServer::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
-{
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
-
- rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value);
-
- sendMessage(reply);
-}
-
-void QmlEngineDebugServer::addEngine(QmlEngine *engine)
-{
- Q_ASSERT(engine);
- Q_ASSERT(!m_engines.contains(engine));
-
- m_engines.append(engine);
-}
-
-void QmlEngineDebugServer::remEngine(QmlEngine *engine)
-{
- Q_ASSERT(engine);
- Q_ASSERT(m_engines.contains(engine));
-
- m_engines.removeAll(engine);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlenginedebug_p.h b/src/declarative/qml/qmlenginedebug_p.h
deleted file mode 100644
index a6f296a..0000000
--- a/src/declarative/qml/qmlenginedebug_p.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLENGINEDEBUG_P_H
-#define QMLENGINEDEBUG_P_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 "../debugger/qmldebugservice_p.h"
-
-#include <QtCore/qurl.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngine;
-class QmlContext;
-class QmlWatcher;
-class QDataStream;
-
-class QmlEngineDebugServer : public QmlDebugService
-{
- Q_OBJECT
-public:
- QmlEngineDebugServer(QObject * = 0);
-
- struct QmlObjectData {
- QUrl url;
- int lineNumber;
- int columnNumber;
- QString objectName;
- QString objectType;
- int objectId;
- int contextId;
- };
-
- struct QmlObjectProperty {
- enum Type { Unknown, Basic, Object, List, SignalProperty };
- Type type;
- QString name;
- QVariant value;
- QString valueTypeName;
- QString binding;
- bool hasNotifySignal;
- };
-
- static void addEngine(QmlEngine *);
- static void remEngine(QmlEngine *);
-
-protected:
- virtual void messageReceived(const QByteArray &);
-
-private Q_SLOTS:
- void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value);
-
-private:
- void buildObjectList(QDataStream &, QmlContext *);
- void buildObjectDump(QDataStream &, QObject *, bool);
- QmlObjectData objectData(QObject *);
- QmlObjectProperty propertyData(QObject *, int);
- QVariant valueContents(const QVariant &defaultValue) const;
-
- static QList<QmlEngine *> m_engines;
- QmlWatcher *m_watch;
-};
-Q_DECLARATIVE_EXPORT QDataStream &operator<<(QDataStream &, const QmlEngineDebugServer::QmlObjectData &);
-Q_DECLARATIVE_EXPORT QDataStream &operator>>(QDataStream &, QmlEngineDebugServer::QmlObjectData &);
-Q_DECLARATIVE_EXPORT QDataStream &operator<<(QDataStream &, const QmlEngineDebugServer::QmlObjectProperty &);
-Q_DECLARATIVE_EXPORT QDataStream &operator>>(QDataStream &, QmlEngineDebugServer::QmlObjectProperty &);
-
-QT_END_NAMESPACE
-
-#endif // QMLENGINEDEBUG_P_H
-
diff --git a/src/declarative/qml/qmlerror.cpp b/src/declarative/qml/qmlerror.cpp
deleted file mode 100644
index fc4bcd5..0000000
--- a/src/declarative/qml/qmlerror.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlerror.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qstringlist.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlError
- \since 4.7
- \brief The QmlError class encapsulates a QML error
-*/
-class QmlErrorPrivate
-{
-public:
- QmlErrorPrivate();
-
- QUrl url;
- QString description;
- int line;
- int column;
-};
-
-QmlErrorPrivate::QmlErrorPrivate()
-: line(-1), column(-1)
-{
-}
-
-/*!
- Create an empty error object.
-*/
-QmlError::QmlError()
-: d(0)
-{
-}
-
-/*!
- Create a copy of \a other.
-*/
-QmlError::QmlError(const QmlError &other)
-: d(0)
-{
- *this = other;
-}
-
-/*!
- Assign \a other to this error object.
-*/
-QmlError &QmlError::operator=(const QmlError &other)
-{
- if (!other.d) {
- delete d;
- d = 0;
- } else {
- if (!d) d = new QmlErrorPrivate;
- d->url = other.d->url;
- d->description = other.d->description;
- d->line = other.d->line;
- d->column = other.d->column;
- }
- return *this;
-}
-
-/*!
- \internal
-*/
-QmlError::~QmlError()
-{
- delete d; d = 0;
-}
-
-/*!
- Return true if this error is valid, otherwise false.
-*/
-bool QmlError::isValid() const
-{
- return d != 0;
-}
-
-/*!
- Return the url for the file that caused this error.
-*/
-QUrl QmlError::url() const
-{
- if (d) return d->url;
- else return QUrl();
-}
-
-/*!
- Set the \a url for the file that caused this error.
-*/
-void QmlError::setUrl(const QUrl &url)
-{
- if (!d) d = new QmlErrorPrivate;
- d->url = url;
-}
-
-/*!
- Return the error description.
-*/
-QString QmlError::description() const
-{
- if (d) return d->description;
- else return QString();
-}
-
-/*!
- Set the error \a description.
-*/
-void QmlError::setDescription(const QString &description)
-{
- if (!d) d = new QmlErrorPrivate;
- d->description = description;
-}
-
-/*!
- Return the error line number.
-*/
-int QmlError::line() const
-{
- if (d) return d->line;
- else return -1;
-}
-
-/*!
- Set the error \a line number.
-*/
-void QmlError::setLine(int line)
-{
- if (!d) d = new QmlErrorPrivate;
- d->line = line;
-}
-
-/*!
- Return the error column number.
-*/
-int QmlError::column() const
-{
- if (d) return d->column;
- else return -1;
-}
-
-/*!
- Set the error \a column number.
-*/
-void QmlError::setColumn(int column)
-{
- if (!d) d = new QmlErrorPrivate;
- d->column = column;
-}
-
-/*!
- Return the error as a human readable string.
-*/
-QString QmlError::toString() const
-{
- QString rv;
- rv = url().toString() + QLatin1Char(':') + QString::number(line());
- if(column() != -1)
- rv += QLatin1Char(':') + QString::number(column());
-
- rv += QLatin1String(": ") + description();
-
- return rv;
-}
-
-/*!
- \relates QmlError
- \fn QDebug operator<<(QDebug debug, const QmlError &error)
-
- Output a human readable version of \a error to \a debug.
-*/
-
-QDebug operator<<(QDebug debug, const QmlError &error)
-{
- debug << qPrintable(error.toString());
-
- QUrl url = error.url();
-
- if (error.line() > 0 && url.scheme() == QLatin1String("file")) {
- QString file = url.toLocalFile();
- QFile f(file);
- if (f.open(QIODevice::ReadOnly)) {
- QByteArray data = f.readAll();
- QTextStream stream(data, QIODevice::ReadOnly);
- stream.setCodec("UTF-8");
- const QString code = stream.readAll();
- const QStringList lines = code.split(QLatin1Char('\n'));
-
- if (lines.count() >= error.line()) {
- const QString &line = lines.at(error.line() - 1);
- debug << "\n " << qPrintable(line);
-
- if(error.column() > 0) {
- int column = qMax(0, error.column() - 1);
- column = qMin(column, line.length());
-
- QByteArray ind;
- ind.reserve(column);
- for (int i = 0; i < column; ++i) {
- const QChar ch = line.at(i);
- if (ch.isSpace())
- ind.append(ch.unicode());
- else
- ind.append(' ');
- }
- ind.append('^');
- debug << "\n " << ind.constData();
- }
- }
- }
- }
- return debug;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlerror.h b/src/declarative/qml/qmlerror.h
deleted file mode 100644
index 8c4d785..0000000
--- a/src/declarative/qml/qmlerror.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLERROR_H
-#define QMLERROR_H
-
-#include <QtCore/qurl.h>
-#include <QtCore/qstring.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDebug;
-class QmlErrorPrivate;
-class Q_DECLARATIVE_EXPORT QmlError
-{
-public:
- QmlError();
- QmlError(const QmlError &);
- QmlError &operator=(const QmlError &);
- ~QmlError();
-
- bool isValid() const;
-
- QUrl url() const;
- void setUrl(const QUrl &);
- QString description() const;
- void setDescription(const QString &);
- int line() const;
- void setLine(int);
- int column() const;
- void setColumn(int);
-
- QString toString() const;
-private:
- QmlErrorPrivate *d;
-};
-
-QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, const QmlError &error);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLERROR_H
diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp
deleted file mode 100644
index 217f002..0000000
--- a/src/declarative/qml/qmlexpression.cpp
+++ /dev/null
@@ -1,810 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlexpression.h"
-#include "qmlexpression_p.h"
-
-#include "qmlengine_p.h"
-#include "qmlcontext_p.h"
-#include "qmlrewrite_p.h"
-#include "qmlcompiler_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtScript/qscriptprogram.h>
-
-#include <private/qscriptdeclarativeclass_p.h>
-
-QT_BEGIN_NAMESPACE
-
-bool QmlDelayedError::addError(QmlEnginePrivate *e)
-{
- if (!e || prevError) return false;
-
- if (e->inProgressCreations == 0) return false; // Not in construction
-
- prevError = &e->erroredBindings;
- nextError = e->erroredBindings;
- e->erroredBindings = this;
- if (nextError) nextError->prevError = &nextError;
-
- return true;
-}
-
-QmlExpressionData::QmlExpressionData()
-: q(0), dataRef(0), expressionFunctionValid(false), expressionRewritten(false), me(0),
- trackChange(false), isShared(false), line(-1), guardList(0), guardListLength(0)
-{
-}
-
-QmlExpressionData::~QmlExpressionData()
-{
- if (guardList) { delete [] guardList; guardList = 0; }
- if (dataRef) dataRef->release();
-}
-
-QmlExpressionPrivate::QmlExpressionPrivate()
-: data(new QmlExpressionData)
-{
- data->q = this;
-}
-
-QmlExpressionPrivate::QmlExpressionPrivate(QmlExpressionData *d)
-: data(d)
-{
- data->q = this;
-}
-
-QmlExpressionPrivate::~QmlExpressionPrivate()
-{
- if (data) { data->q = 0; data->release(); data = 0; }
-}
-
-void QmlExpressionPrivate::init(QmlContext *ctxt, const QString &expr,
- QObject *me)
-{
- data->expression = expr;
-
- data->QmlAbstractExpression::setContext(ctxt);
- data->me = me;
-}
-
-void QmlExpressionPrivate::init(QmlContext *ctxt, void *expr, QmlRefCount *rc,
- QObject *me, const QString &url, int lineNumber)
-{
- data->url = url;
- data->line = lineNumber;
-
- if (data->dataRef) data->dataRef->release();
- data->dataRef = rc;
- if (data->dataRef) data->dataRef->addref();
-
- quint32 *exprData = (quint32 *)expr;
- QmlCompiledData *dd = (QmlCompiledData *)rc;
-
- data->expressionRewritten = true;
- data->expression = QString::fromRawData((QChar *)(exprData + 2), exprData[1]);
-
- int progIdx = *(exprData);
- bool isShared = progIdx & 0x80000000;
- progIdx &= 0x7FFFFFFF;
-
- QmlEngine *engine = ctxt->engine();
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine);
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- if (isShared) {
-
- if (!dd->cachedClosures.at(progIdx)) {
- QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
- scriptContext->pushScope(ep->contextClass->newSharedContext());
- dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line));
- scriptEngine->popContext();
- }
-
- data->expressionFunction = *dd->cachedClosures.at(progIdx);
- data->isShared = true;
- data->expressionFunctionValid = true;
-
- } else {
-
-#if !defined(Q_OS_SYMBIAN) //XXX Why doesn't this work?
- if (!dd->cachedPrograms.at(progIdx)) {
- dd->cachedPrograms[progIdx] =
- new QScriptProgram(data->expression, data->url, data->line);
- }
-
- data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx));
-#else
- data->expressionFunction = evalInObjectScope(ctxt, me, data->expression);
-#endif
-
- data->expressionFunctionValid = true;
- }
-
- data->QmlAbstractExpression::setContext(ctxt);
- data->me = me;
-}
-
-QScriptValue QmlExpressionPrivate::evalInObjectScope(QmlContext *context, QObject *object,
- const QString &program)
-{
- QmlEnginePrivate *ep = QmlEnginePrivate::get(context->engine());
- QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(context, object));
- QScriptValue rv = ep->scriptEngine.evaluate(program);
- ep->scriptEngine.popContext();
- return rv;
-}
-
-QScriptValue QmlExpressionPrivate::evalInObjectScope(QmlContext *context, QObject *object,
- const QScriptProgram &program)
-{
- QmlEnginePrivate *ep = QmlEnginePrivate::get(context->engine());
- QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(context, object));
- QScriptValue rv = ep->scriptEngine.evaluate(program);
- ep->scriptEngine.popContext();
- return rv;
-}
-
-/*!
- \class QmlExpression
- \since 4.7
- \brief The QmlExpression class evaluates JavaScript in a QML context.
-*/
-
-/*!
- Create an invalid QmlExpression.
-
- As the expression will not have an associated QmlContext, this will be a
- null expression object and its value will always be an invalid QVariant.
- */
-QmlExpression::QmlExpression()
-: QObject(*new QmlExpressionPrivate, 0)
-{
-}
-
-/*! \internal */
-QmlExpression::QmlExpression(QmlContext *ctxt, void *expr,
- QmlRefCount *rc, QObject *me,
- const QString &url, int lineNumber,
- QmlExpressionPrivate &dd)
-: QObject(dd, 0)
-{
- Q_D(QmlExpression);
- d->init(ctxt, expr, rc, me, url, lineNumber);
-}
-
-/*!
- Create a QmlExpression object.
-
- The \a expression JavaScript will be executed in the \a ctxt QmlContext.
- If specified, the \a scope object's properties will also be in scope during
- the expression's execution.
-*/
-QmlExpression::QmlExpression(QmlContext *ctxt, const QString &expression,
- QObject *scope)
-: QObject(*new QmlExpressionPrivate, 0)
-{
- Q_D(QmlExpression);
- d->init(ctxt, expression, scope);
-}
-
-/*! \internal */
-QmlExpression::QmlExpression(QmlContext *ctxt, const QString &expression,
- QObject *scope, QmlExpressionPrivate &dd)
-: QObject(dd, 0)
-{
- Q_D(QmlExpression);
- d->init(ctxt, expression, scope);
-}
-
-/*!
- Destroy the QmlExpression instance.
-*/
-QmlExpression::~QmlExpression()
-{
-}
-
-/*!
- Returns the QmlEngine this expression is associated with, or 0 if there
- is no association or the QmlEngine has been destroyed.
-*/
-QmlEngine *QmlExpression::engine() const
-{
- Q_D(const QmlExpression);
- return d->data->context()?d->data->context()->engine():0;
-}
-
-/*!
- Returns the QmlContext this expression is associated with, or 0 if there
- is no association or the QmlContext has been destroyed.
-*/
-QmlContext *QmlExpression::context() const
-{
- Q_D(const QmlExpression);
- return d->data->context();
-}
-
-/*!
- Returns the expression string.
-*/
-QString QmlExpression::expression() const
-{
- Q_D(const QmlExpression);
- return d->data->expression;
-}
-
-/*!
- Set the expression to \a expression.
-*/
-void QmlExpression::setExpression(const QString &expression)
-{
- Q_D(QmlExpression);
-
- d->clearGuards();
-
- d->data->expression = expression;
- d->data->expressionFunctionValid = false;
- d->data->expressionRewritten = false;
- d->data->expressionFunction = QScriptValue();
-}
-
-void QmlExpressionPrivate::exceptionToError(QScriptEngine *scriptEngine,
- QmlError &error)
-{
- if (scriptEngine->hasUncaughtException() &&
- scriptEngine->uncaughtException().isError()) {
-
- QString fileName;
- int lineNumber = scriptEngine->uncaughtExceptionLineNumber();
-
- QScriptValue exception = scriptEngine->uncaughtException();
- QLatin1String fileNameProp("fileName");
-
- if (!exception.property(fileNameProp).toString().isEmpty()){
- fileName = exception.property(fileNameProp).toString();
- } else {
- fileName = QLatin1String("<Unknown File>");
- }
-
- error.setUrl(QUrl(fileName));
- error.setLine(lineNumber);
- error.setColumn(-1);
- error.setDescription(exception.toString());
- } else {
- error = QmlError();
- }
-}
-
-QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope, bool *isUndefined)
-{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::BindValueQt> perfqt;
-#endif
-
- QmlExpressionData *data = this->data;
- QmlContextPrivate *ctxtPriv = data->context()->d_func();
- QmlEngine *engine = data->context()->engine();
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine);
-
- if (secondaryScope)
- ctxtPriv->defaultObjects.append(secondaryScope);
-
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- if (!data->expressionFunctionValid) {
-
- QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(data->context(), data->me));
-
- if (data->expressionRewritten) {
- data->expressionFunction = scriptEngine->evaluate(data->expression,
- data->url, data->line);
- } else {
- QmlRewrite::RewriteBinding rewriteBinding;
-
- bool ok = true;
- const QString code = rewriteBinding(data->expression, &ok);
- if (!ok) {
- scriptEngine->popContext();
- return QVariant();
- }
- data->expressionFunction = scriptEngine->evaluate(code, data->url, data->line);
- }
-
- scriptEngine->popContext();
- data->expressionFunctionValid = true;
- }
-
- QmlContext *oldSharedContext = 0;
- QObject *oldSharedScope = 0;
- if (data->isShared) {
- oldSharedContext = ep->sharedContext;
- oldSharedScope = ep->sharedScope;
- ep->sharedContext = data->context();
- ep->sharedScope = data->me;
- }
-
- QScriptValue svalue = data->expressionFunction.call();
-
- if (data->isShared) {
- ep->sharedContext = oldSharedContext;
- ep->sharedScope = oldSharedScope;
- }
-
- if (isUndefined)
- *isUndefined = svalue.isUndefined() || scriptEngine->hasUncaughtException();
-
- // Handle exception
- if (scriptEngine->hasUncaughtException()) {
- exceptionToError(scriptEngine, data->error);
- scriptEngine->clearExceptions();
- return QVariant();
- } else {
- data->error = QmlError();
- }
-
- if (secondaryScope) {
- QObject *last = ctxtPriv->defaultObjects.takeLast();
- Q_ASSERT(last == secondaryScope);
- Q_UNUSED(last);
- }
-
- QVariant rv;
-
- if (svalue.isArray()) {
- int length = svalue.property(QLatin1String("length")).toInt32();
- if (length && svalue.property(0).isObject()) {
- QList<QObject *> list;
- for (int ii = 0; ii < length; ++ii) {
- QScriptValue arrayItem = svalue.property(ii);
- QObject *d = arrayItem.toQObject();
- list << d;
- }
- rv = QVariant::fromValue(list);
- }
- } else if (svalue.isObject() &&
- ep->objectClass->scriptClass(svalue) == ep->objectClass) {
- QObject *o = svalue.toQObject();
- int type = QMetaType::QObjectStar;
- // If the object is null, we extract the predicted type. While this isn't
- // 100% reliable, in many cases it gives us better error messages if we
- // assign this null-object to an incompatible property
- if (!o) type = ep->objectClass->objectType(svalue);
-
- return QVariant(type, &o);
- }
-
- if (rv.isNull())
- rv = svalue.toVariant();
-
- return rv;
-}
-
-QVariant QmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined)
-{
- Q_Q(QmlExpression);
-
- QVariant rv;
- if (!q->engine()) {
- qWarning("QmlExpression: Attempted to evaluate an expression in an invalid context");
- return rv;
- }
-
- if (data->expression.isEmpty())
- return rv;
-
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::BindValue> perf;
-#endif
-
- QmlEnginePrivate *ep = QmlEnginePrivate::get(q->engine());
-
- QmlExpression *lastCurrentExpression = ep->currentExpression;
- bool lastCaptureProperties = ep->captureProperties;
- QPODVector<QmlEnginePrivate::CapturedProperty> lastCapturedProperties;
- ep->capturedProperties.copyAndClear(lastCapturedProperties);
-
- ep->currentExpression = q;
- ep->captureProperties = data->trackChange;
-
- // This object might be deleted during the eval
- QmlExpressionData *localData = data;
- localData->addref();
-
- rv = evalQtScript(secondaryScope, isUndefined);
-
- ep->currentExpression = lastCurrentExpression;
- ep->captureProperties = lastCaptureProperties;
-
- // Check if we were deleted
- if (localData->q) {
- if ((!data->trackChange || !ep->capturedProperties.count()) && data->guardList) {
- clearGuards();
- } else if(data->trackChange) {
- updateGuards(ep->capturedProperties);
- }
- }
-
- localData->release();
-
- lastCapturedProperties.copyAndClear(ep->capturedProperties);
-
- return rv;
-}
-
-/*!
- Returns the value of the expression, or an invalid QVariant if the
- expression is invalid or has an error.
-
- \a isUndefined is set to true if the expression resulted in an
- undefined value.
-
- \sa hasError(), error()
-*/
-QVariant QmlExpression::value(bool *isUndefined)
-{
- Q_D(QmlExpression);
- return d->value(0, isUndefined);
-}
-
-/*!
-Returns true if the valueChanged() signal is emitted when the expression's evaluated
-value changes.
-*/
-bool QmlExpression::notifyOnValueChanged() const
-{
- Q_D(const QmlExpression);
- return d->data->trackChange;
-}
-
-/*!
-Sets whether the valueChanged() signal is emitted when the expression's evaluated
-value changes.
-
-If true, the QmlExpression will monitor properties involved in the expression's
-evaluation, and emit QmlExpression::valueChanged() if they have changed. This allows
-an application to ensure that any value associated with the result of the expression
-remains up to date.
-
-If false, the QmlExpression will not montitor properties involved in the expression's
-evaluation, and QmlExpression::valueChanged() will never be emitted. This is more efficient
-if an application wants a "one off" evaluation of the expression.
-
-By default, notifyOnChange is false.
-*/
-void QmlExpression::setNotifyOnValueChanged(bool notifyOnChange)
-{
- Q_D(QmlExpression);
- d->data->trackChange = notifyOnChange;
-}
-
-/*!
- Returns the source file URL for this expression. The source location must
- have been previously set by calling setSourceLocation().
-*/
-QString QmlExpression::sourceFile() const
-{
- Q_D(const QmlExpression);
- return d->data->url;
-}
-
-/*!
- Returns the source file line number for this expression. The source location
- must have been previously set by calling setSourceLocation().
-*/
-int QmlExpression::lineNumber() const
-{
- Q_D(const QmlExpression);
- return d->data->line;
-}
-
-/*!
- Set the location of this expression to \a line of \a url. This information
- is used by the script engine.
-*/
-void QmlExpression::setSourceLocation(const QString &url, int line)
-{
- Q_D(QmlExpression);
- d->data->url = url;
- d->data->line = line;
-}
-
-/*!
- Returns the expression's scope object, if provided, otherwise 0.
-
- In addition to data provided by the expression's QmlContext, the scope
- object's properties are also in scope during the expression's evaluation.
-*/
-QObject *QmlExpression::scopeObject() const
-{
- Q_D(const QmlExpression);
- return d->data->me;
-}
-
-/*!
- Returns true if the last call to value() resulted in an error,
- otherwise false.
-
- \sa error(), clearError()
-*/
-bool QmlExpression::hasError() const
-{
- Q_D(const QmlExpression);
- return d->data->error.isValid();
-}
-
-/*!
- Clear any expression errors. Calls to hasError() following this will
- return false.
-
- \sa hasError(), error()
-*/
-void QmlExpression::clearError()
-{
- Q_D(QmlExpression);
- d->data->error = QmlError();
-}
-
-/*!
- Return any error from the last call to value(). If there was no error,
- this returns an invalid QmlError instance.
-
- \sa hasError(), clearError()
-*/
-
-QmlError QmlExpression::error() const
-{
- Q_D(const QmlExpression);
- return d->data->error;
-}
-
-/*! \internal */
-void QmlExpression::__q_notify()
-{
- Q_D(QmlExpression);
- d->emitValueChanged();
-}
-
-void QmlExpressionPrivate::clearGuards()
-{
- Q_Q(QmlExpression);
-
- static int notifyIdx = -1;
- if (notifyIdx == -1)
- notifyIdx =
- QmlExpression::staticMetaObject.indexOfMethod("__q_notify()");
-
- for (int ii = 0; ii < data->guardListLength; ++ii) {
- if (data->guardList[ii].data()) {
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
- QMetaObject::disconnectOne(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#else
- // QTBUG-6781
- QMetaObject::disconnect(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#endif
- }
- }
-
- delete [] data->guardList; data->guardList = 0;
- data->guardListLength = 0;
-}
-
-void QmlExpressionPrivate::updateGuards(const QPODVector<QmlEnginePrivate::CapturedProperty> &properties)
-{
- //clearGuards();
- Q_Q(QmlExpression);
-
- static int notifyIdx = -1;
- if (notifyIdx == -1)
- notifyIdx =
- QmlExpression::staticMetaObject.indexOfMethod("__q_notify()");
-
- QmlExpressionData::SignalGuard *newGuardList = 0;
-
- if (properties.count() != data->guardListLength)
- newGuardList = new QmlExpressionData::SignalGuard[properties.count()];
-
- bool outputWarningHeader = false;
- int hit = 0;
- for (int ii = 0; ii < properties.count(); ++ii) {
- const QmlEnginePrivate::CapturedProperty &property = properties.at(ii);
-
- bool needGuard = true;
- if (ii >= data->guardListLength) {
- // New guard
- } else if(data->guardList[ii].data() == property.object &&
- data->guardList[ii].notifyIndex == property.notifyIndex) {
- // Cache hit
- if (!data->guardList[ii].isDuplicate ||
- (data->guardList[ii].isDuplicate && hit == ii)) {
- needGuard = false;
- ++hit;
- }
- } else if(data->guardList[ii].data() && !data->guardList[ii].isDuplicate) {
- // Cache miss
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
- QMetaObject::disconnectOne(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#else
- // QTBUG-6781
- QMetaObject::disconnect(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#endif
- }
- /* else {
- // Cache miss, but nothing to do
- } */
-
- if (needGuard) {
- if (!newGuardList) {
- newGuardList = new QmlExpressionData::SignalGuard[properties.count()];
- for (int jj = 0; jj < ii; ++jj)
- newGuardList[jj] = data->guardList[jj];
- }
-
- if (property.notifyIndex != -1) {
- bool existing = false;
- for (int jj = 0; !existing && jj < ii; ++jj)
- existing = newGuardList[jj].data() == property.object &&
- newGuardList[jj].notifyIndex == property.notifyIndex;
-
- newGuardList[ii] = property.object;
- newGuardList[ii].notifyIndex = property.notifyIndex;
- if (existing)
- newGuardList[ii].isDuplicate = true;
- else
- QMetaObject::connect(property.object, property.notifyIndex,
- q, notifyIdx);
- } else {
- if (!outputWarningHeader) {
- outputWarningHeader = true;
- qWarning() << "QmlExpression: Expression" << q->expression()
- << "depends on non-NOTIFYable properties:";
- }
-
- const QMetaObject *metaObj = property.object->metaObject();
- QMetaProperty metaProp = metaObj->property(property.coreIndex);
-
- qWarning().nospace() << " " << metaObj->className()
- << "::" << metaProp.name();
- }
- } else if (newGuardList) {
- newGuardList[ii] = data->guardList[ii];
- }
- }
-
- for (int ii = properties.count(); ii < data->guardListLength; ++ii) {
- if (data->guardList[ii].data() && !data->guardList[ii].isDuplicate) {
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
- QMetaObject::disconnectOne(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#else
- // QTBUG-6781
- QMetaObject::disconnect(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#endif
- }
- }
-
- if (newGuardList) {
- if (data->guardList) delete [] data->guardList;
- data->guardList = newGuardList;
- data->guardListLength = properties.count();
- }
-}
-
-/*!
- \fn void QmlExpression::valueChanged()
-
- Emitted each time the expression value changes from the last time it was
- evaluated. The expression must have been evaluated at least once (by
- calling QmlExpression::value()) before this signal will be emitted.
-*/
-
-void QmlExpressionPrivate::emitValueChanged()
-{
- Q_Q(QmlExpression);
- emit q->valueChanged();
-}
-
-QmlAbstractExpression::QmlAbstractExpression()
-: m_context(0), m_prevExpression(0), m_nextExpression(0)
-{
-}
-
-QmlAbstractExpression::~QmlAbstractExpression()
-{
- if (m_prevExpression) {
- *m_prevExpression = m_nextExpression;
- if (m_nextExpression)
- m_nextExpression->m_prevExpression = m_prevExpression;
- }
-}
-
-QmlContext *QmlAbstractExpression::context() const
-{
- return m_context;
-}
-
-void QmlAbstractExpression::setContext(QmlContext *context)
-{
- if (m_prevExpression) {
- *m_prevExpression = m_nextExpression;
- if (m_nextExpression)
- m_nextExpression->m_prevExpression = m_prevExpression;
- m_prevExpression = 0;
- m_nextExpression = 0;
- }
-
- m_context = context;
-
- if (m_context) {
- QmlContextPrivate *cp =
- static_cast<QmlContextPrivate *>(QObjectPrivate::get(m_context));
- m_nextExpression = cp->expressions;
- if (m_nextExpression)
- m_nextExpression->m_prevExpression = &m_nextExpression;
- m_prevExpression = &cp->expressions;
- cp->expressions = this;
- }
-}
-
-void QmlAbstractExpression::refresh()
-{
-}
-
-bool QmlAbstractExpression::isValid() const
-{
- return m_context != 0;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qmlexpression.h b/src/declarative/qml/qmlexpression.h
deleted file mode 100644
index 61374f2..0000000
--- a/src/declarative/qml/qmlexpression.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLEXPRESSION_H
-#define QMLEXPRESSION_H
-
-#include "qmlerror.h"
-
-#include <QtCore/qobject.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QString;
-class QmlRefCount;
-class QmlEngine;
-class QmlContext;
-class QmlExpressionPrivate;
-class Q_DECLARATIVE_EXPORT QmlExpression : public QObject
-{
- Q_OBJECT
-public:
- QmlExpression();
- QmlExpression(QmlContext *, const QString &, QObject *);
- virtual ~QmlExpression();
-
- QmlEngine *engine() const;
- QmlContext *context() const;
-
- QString expression() const;
- void setExpression(const QString &);
-
- bool notifyOnValueChanged() const;
- void setNotifyOnValueChanged(bool);
-
- QString sourceFile() const;
- int lineNumber() const;
- void setSourceLocation(const QString &fileName, int line);
-
- QObject *scopeObject() const;
-
- bool hasError() const;
- void clearError();
- QmlError error() const;
-
- QVariant value(bool *isUndefined = 0);
-
-Q_SIGNALS:
- void valueChanged();
-
-protected:
- QmlExpression(QmlContext *, const QString &, QObject *,
- QmlExpressionPrivate &dd);
- QmlExpression(QmlContext *, void *, QmlRefCount *rc, QObject *me, const QString &,
- int, QmlExpressionPrivate &dd);
-
-private Q_SLOTS:
- void __q_notify();
-
-private:
- Q_DECLARE_PRIVATE(QmlExpression)
- friend class QmlDebugger;
- friend class QmlContext;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLEXPRESSION_H
-
diff --git a/src/declarative/qml/qmlexpression_p.h b/src/declarative/qml/qmlexpression_p.h
deleted file mode 100644
index e4bed05..0000000
--- a/src/declarative/qml/qmlexpression_p.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLEXPRESSION_P_H
-#define QMLEXPRESSION_P_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 "qmlexpression.h"
-
-#include "qmlengine_p.h"
-#include "qmlguard_p.h"
-
-#include <QtScript/qscriptvalue.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlAbstractExpression
-{
-public:
- QmlAbstractExpression();
- virtual ~QmlAbstractExpression();
-
- bool isValid() const;
-
- QmlContext *context() const;
- void setContext(QmlContext *);
-
- virtual void refresh();
-
-private:
- friend class QmlContext;
- friend class QmlContextPrivate;
- QmlContext *m_context;
- QmlAbstractExpression **m_prevExpression;
- QmlAbstractExpression *m_nextExpression;
-};
-
-class QmlDelayedError
-{
-public:
- inline QmlDelayedError() : nextError(0), prevError(0) {}
- inline ~QmlDelayedError() { removeError(); }
-
- QmlError error;
-
- bool addError(QmlEnginePrivate *);
-
- inline void removeError() {
- if (!prevError) return;
- if (nextError) nextError->prevError = prevError;
- *prevError = nextError;
- nextError = 0;
- prevError = 0;
- }
-
-private:
- QmlDelayedError *nextError;
- QmlDelayedError **prevError;
-};
-
-class QmlExpressionData : public QmlAbstractExpression, public QmlDelayedError, public QmlRefCount
-{
-public:
- QmlExpressionData();
- virtual ~QmlExpressionData();
-
- QmlExpressionPrivate *q;
-
- QmlRefCount *dataRef;
- QString expression;
- bool expressionFunctionValid:1;
- bool expressionRewritten:1;
- QScriptValue expressionFunction;
-
- QObject *me;
- bool trackChange;
-
- bool isShared;
-
- QString url; // This is a QString for a reason. QUrls are slooooooow...
- int line;
-
- struct SignalGuard : public QmlGuard<QObject> {
- SignalGuard() : isDuplicate(false), notifyIndex(-1) {}
-
- SignalGuard &operator=(QObject *obj) {
- QmlGuard<QObject>::operator=(obj);
- return *this;
- }
- SignalGuard &operator=(const SignalGuard &o) {
- QmlGuard<QObject>::operator=(o);
- isDuplicate = o.isDuplicate;
- notifyIndex = o.notifyIndex;
- return *this;
- }
-
- bool isDuplicate:1;
- int notifyIndex:31;
- };
- SignalGuard *guardList;
- int guardListLength;
-};
-
-class QmlExpression;
-class QString;
-class QmlExpressionPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlExpression)
-public:
- QmlExpressionPrivate();
- QmlExpressionPrivate(QmlExpressionData *);
- ~QmlExpressionPrivate();
-
- void init(QmlContext *, const QString &, QObject *);
- void init(QmlContext *, void *, QmlRefCount *, QObject *, const QString &, int);
-
- QmlExpressionData *data;
-
- QVariant value(QObject *secondaryScope = 0, bool *isUndefined = 0);
- QVariant evalQtScript(QObject *secondaryScope, bool *isUndefined = 0);
-
- void updateGuards(const QPODVector<QmlEnginePrivate::CapturedProperty> &properties);
- void clearGuards();
-
- static QmlExpressionPrivate *get(QmlExpression *expr) {
- return static_cast<QmlExpressionPrivate *>(QObjectPrivate::get(expr));
- }
- static QmlExpression *get(QmlExpressionPrivate *expr) {
- return expr->q_func();
- }
-
- virtual void emitValueChanged();
-
- static void exceptionToError(QScriptEngine *, QmlError &);
- static QScriptValue evalInObjectScope(QmlContext *, QObject *, const QString &);
- static QScriptValue evalInObjectScope(QmlContext *, QObject *, const QScriptProgram &);
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLEXPRESSION_P_H
diff --git a/src/declarative/qml/qmlextensioninterface.h b/src/declarative/qml/qmlextensioninterface.h
deleted file mode 100644
index 644ef1e..0000000
--- a/src/declarative/qml/qmlextensioninterface.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLEXTENSIONINTERFACE_H
-#define QMLEXTENSIONINTERFACE_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlEngine;
-
-struct Q_DECLARATIVE_EXPORT QmlExtensionInterface
-{
- virtual ~QmlExtensionInterface() {}
- virtual void initialize(QmlEngine *engine, const char *uri) = 0;
-};
-
-Q_DECLARE_INTERFACE(QmlExtensionInterface, "com.trolltech.Qt.QmlExtensionInterface/1.0")
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLEXTENSIONINTERFACE_H
diff --git a/src/declarative/qml/qmlextensionplugin.cpp b/src/declarative/qml/qmlextensionplugin.cpp
deleted file mode 100644
index c1195d2..0000000
--- a/src/declarative/qml/qmlextensionplugin.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlextensionplugin.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \since 4.7
- \class QmlExtensionPlugin
- \brief The QmlExtensionPlugin class provides an abstract base for custom QML extension plugins.
-
- \ingroup plugins
-
- QmlExtensionPlugin is a plugin interface that makes it
- possible to offer extensions that can be loaded dynamically into
- applications using the QmlEngine class.
-
- Writing a QML extension plugin is achieved by subclassing this
- base class, reimplementing the pure virtual initialize()
- function, and exporting the class using the Q_EXPORT_PLUGIN2()
- macro. See \l {How to Create Qt Plugins} for details.
-
- \sa QmlEngine::importExtension()
-*/
-
-/*!
- \fn void QmlExtensionPlugin::initialize(QmlEngine *engine)
-
- Initializes the extension specified in the given \a engine.
-*/
-
-/*!
- Constructs a QML extension plugin with the given \a parent.
-
- Note that this constructor is invoked automatically by the
- Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
- explicitly.
-*/
-QmlExtensionPlugin::QmlExtensionPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-QmlExtensionPlugin::~QmlExtensionPlugin()
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlextensionplugin.h b/src/declarative/qml/qmlextensionplugin.h
deleted file mode 100644
index 8cc64ad..0000000
--- a/src/declarative/qml/qmlextensionplugin.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLEXTENSIONPLUGIN_H
-#define QMLEXTENSIONPLUGIN_H
-
-#include <QtCore/qplugin.h>
-
-#include "qmlextensioninterface.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlEngine;
-
-class Q_DECLARATIVE_EXPORT QmlExtensionPlugin : public QObject, public QmlExtensionInterface
-{
- Q_OBJECT
- Q_INTERFACES(QmlExtensionInterface)
-public:
- explicit QmlExtensionPlugin(QObject *parent = 0);
- ~QmlExtensionPlugin();
-
- virtual void initialize(QmlEngine *engine, const char *uri) = 0;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLEXTENSIONPLUGIN_H
diff --git a/src/declarative/qml/qmlglobal_p.h b/src/declarative/qml/qmlglobal_p.h
deleted file mode 100644
index 06ae6e6..0000000
--- a/src/declarative/qml/qmlglobal_p.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGLOBAL_H
-#define QMLGLOBAL_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/QObject>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-#define DEFINE_BOOL_CONFIG_OPTION(name, var) \
- static bool name() \
- { \
- static enum { Yes, No, Unknown } status = Unknown; \
- if (status == Unknown) { \
- QByteArray v = qgetenv(#var); \
- bool value = !v.isEmpty() && v != "0" && v != "false"; \
- if (value) status = Yes; \
- else status = No; \
- } \
- return status == Yes; \
- }
-
-struct QmlGraphics_DerivedObject : public QObject
-{
- void setParent_noEvent(QObject *parent) {
- bool sce = d_ptr->sendChildEvents;
- d_ptr->sendChildEvents = false;
- setParent(parent);
- d_ptr->sendChildEvents = sce;
- }
-};
-
-/*!
- Makes the \a object a child of \a parent. Note that when using this method,
- neither \a parent nor the object's previous parent (if it had one) will
- receive ChildRemoved or ChildAdded events.
-*/
-inline void QmlGraphics_setParent_noEvent(QObject *object, QObject *parent)
-{
- static_cast<QmlGraphics_DerivedObject *>(object)->setParent_noEvent(parent);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLGLOBAL_H
diff --git a/src/declarative/qml/qmlglobalscriptclass.cpp b/src/declarative/qml/qmlglobalscriptclass.cpp
deleted file mode 100644
index d2198b6..0000000
--- a/src/declarative/qml/qmlglobalscriptclass.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlglobalscriptclass_p.h"
-
-#include <QtScript/qscriptstring.h>
-#include <QtScript/qscriptengine.h>
-#include <QtScript/qscriptvalueiterator.h>
-
-QT_BEGIN_NAMESPACE
-
-/*
- Used to prevent any writes to the global object.
-*/
-QmlGlobalScriptClass::QmlGlobalScriptClass(QScriptEngine *engine)
-: QScriptClass(engine)
-{
- QScriptValue v = engine->newObject();
- globalObject = engine->globalObject();
-
- QScriptValueIterator iter(globalObject);
- while (iter.hasNext()) {
- iter.next();
- v.setProperty(iter.scriptName(), iter.value());
- }
-
- v.setScriptClass(this);
- engine->setGlobalObject(v);
-}
-
-QScriptClass::QueryFlags
-QmlGlobalScriptClass::queryProperty(const QScriptValue &object,
- const QScriptString &name,
- QueryFlags flags, uint *id)
-{
- Q_UNUSED(object);
- Q_UNUSED(name);
- Q_UNUSED(flags);
- Q_UNUSED(id);
- return HandlesReadAccess | HandlesWriteAccess;
-}
-
-QScriptValue
-QmlGlobalScriptClass::property(const QScriptValue &object,
- const QScriptString &name,
- uint id)
-{
- Q_UNUSED(object);
- Q_UNUSED(name);
- Q_UNUSED(id);
- return engine()->undefinedValue();
-}
-
-void QmlGlobalScriptClass::setProperty(QScriptValue &object,
- const QScriptString &name,
- uint id, const QScriptValue &value)
-{
- Q_UNUSED(object);
- Q_UNUSED(id);
- Q_UNUSED(value);
- QString error = QLatin1String("Invalid write to global property \"") +
- name.toString() + QLatin1Char('\"');
- engine()->currentContext()->throwError(error);
-}
-
-void QmlGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value)
-{
- QScriptValue v = engine()->newObject();
- globalObject = engine()->globalObject();
-
- QScriptValueIterator iter(globalObject);
- while (iter.hasNext()) {
- iter.next();
- v.setProperty(iter.scriptName(), iter.value());
- }
-
- v.setProperty(name, value);
- v.setScriptClass(this);
- engine()->setGlobalObject(v);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qmlglobalscriptclass_p.h b/src/declarative/qml/qmlglobalscriptclass_p.h
deleted file mode 100644
index d002da6..0000000
--- a/src/declarative/qml/qmlglobalscriptclass_p.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGLOBALSCRIPTCLASS_P_H
-#define QMLGLOBALSCRIPTCLASS_P_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 <QtScript/qscriptclass.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_AUTOTEST_EXPORT QmlGlobalScriptClass : public QScriptClass
-{
-public:
- QmlGlobalScriptClass(QScriptEngine *);
-
- virtual QueryFlags queryProperty(const QScriptValue &object,
- const QScriptString &name,
- QueryFlags flags, uint *id);
-
- virtual QScriptValue property(const QScriptValue &object,
- const QScriptString &name, uint id);
-
- virtual void setProperty(QScriptValue &object, const QScriptString &name,
- uint id, const QScriptValue &value);
-
- void explicitSetProperty(const QString &, const QScriptValue &);
-
-private:
- QScriptValue globalObject;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLGLOBALSCRIPTCLASS_P_H
diff --git a/src/declarative/qml/qmlguard_p.h b/src/declarative/qml/qmlguard_p.h
deleted file mode 100644
index 0e90f79..0000000
--- a/src/declarative/qml/qmlguard_p.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLGUARD_P_H
-#define QMLGUARD_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
-// file may change from version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-template<class T>
-class QmlGuard
-{
- QObject *o;
- QmlGuard<QObject> *next;
- QmlGuard<QObject> **prev;
- friend class QmlDeclarativeData;
-public:
- inline QmlGuard();
- inline QmlGuard(T *);
- inline QmlGuard(const QmlGuard<T> &);
- inline virtual ~QmlGuard();
-
- inline QmlGuard<T> &operator=(const QmlGuard<T> &o);
- inline QmlGuard<T> &operator=(T *);
-
- inline bool isNull() const
- { return !o; }
-
- inline T* operator->() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
- inline T& operator*() const
- { return *static_cast<T*>(const_cast<QObject*>(o)); }
- inline operator T*() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
- inline T* data() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
-
-protected:
- virtual void objectDestroyed(T *) {}
-
-private:
- inline void addGuard();
- inline void remGuard();
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QmlGuard<QObject>);
-
-#include "qmldeclarativedata_p.h"
-
-QT_BEGIN_NAMESPACE
-
-template<class T>
-QmlGuard<T>::QmlGuard()
-: o(0), next(0), prev(0)
-{
-}
-
-template<class T>
-QmlGuard<T>::QmlGuard(T *g)
-: o(g), next(0), prev(0)
-{
- if (o) addGuard();
-}
-
-template<class T>
-QmlGuard<T>::QmlGuard(const QmlGuard<T> &g)
-: o(g.o), next(0), prev(0)
-{
- if (o) addGuard();
-}
-
-template<class T>
-QmlGuard<T>::~QmlGuard()
-{
- if (prev) remGuard();
- o = 0;
-}
-
-template<class T>
-QmlGuard<T> &QmlGuard<T>::operator=(const QmlGuard<T> &g)
-{
- if (g.o != o) {
- if (prev) remGuard();
- o = g.o;
- if (o) addGuard();
- }
- return *this;
-}
-
-template<class T>
-QmlGuard<T> &QmlGuard<T>::operator=(T *g)
-{
- if (g != o) {
- if (prev) remGuard();
- o = g;
- if (o) addGuard();
- }
- return *this;
-}
-
-QT_END_NAMESPACE
-
-#endif // QMLGUARD_P_H
diff --git a/src/declarative/qml/qmlimageprovider.cpp b/src/declarative/qml/qmlimageprovider.cpp
deleted file mode 100644
index 7f15d08..0000000
--- a/src/declarative/qml/qmlimageprovider.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlimageprovider.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlImageProvider
- \brief The QmlImageProvider class provides an interface for threaded image requests.
-
- Note: the request() method may be called by multiple threads, so ensure the
- implementation of this method is reentrant.
-
- \sa QmlEngine::addImageProvider()
-*/
-QmlImageProvider::~QmlImageProvider()
-{
-}
-
-/*!
- \fn QImage QmlImageProvider::request(const QString &id)
-
- Implement this method to return the image with \a id.
-
- Note: this method may be called by multiple threads, so ensure the
- implementation of this method is reentrant.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlimageprovider.h b/src/declarative/qml/qmlimageprovider.h
deleted file mode 100644
index 52fe066..0000000
--- a/src/declarative/qml/qmlimageprovider.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLIMAGEPROVIDER_H
-#define QMLIMAGEPROVIDER_H
-
-#include <QtGui/qimage.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QmlImageProvider
-{
-public:
- virtual ~QmlImageProvider();
- virtual QImage request(const QString &id) = 0;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLIMAGEPROVIDER
diff --git a/src/declarative/qml/qmlinfo.cpp b/src/declarative/qml/qmlinfo.cpp
deleted file mode 100644
index 1f3d434..0000000
--- a/src/declarative/qml/qmlinfo.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlinfo.h"
-
-#include "qmldeclarativedata_p.h"
-#include "qmlcontext.h"
-#include "qmlmetatype.h"
-
-#include <QCoreApplication>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \fn QmlInfo qmlInfo(const QObject *object)
-
- \brief Prints warnings messages that include the file and line number for QML types.
-
- When QML types display warning messages, it improves traceability
- if they include the QML file and line number on which the
- particular instance was instantiated.
-
- To include the file and line number, an object must be passed. If
- the file and line number is not available for that instance
- (either it was not instantiated by the QML engine or location
- information is disabled), "unknown location" will be used instead.
-
- For example,
-
- \code
- qmlInfo(object) << tr("component property is a write-once property");
- \endcode
-
- prints
-
- \code
- QML MyCustomType (unknown location): component property is a write-once property
- \endcode
-*/
-
-QmlInfo::QmlInfo(const QObject *object)
-: QDebug(QtWarningMsg)
-{
- QString pos = QLatin1String("QML");
- if (object) {
- pos += QLatin1Char(' ');
-
- QString typeName;
- QmlType *type = QmlMetaType::qmlType(object->metaObject());
- if (type) {
- typeName = QLatin1String(type->qmlTypeName());
- int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
- if (lastSlash != -1)
- typeName = typeName.mid(lastSlash+1);
- } else {
- typeName = QString::fromUtf8(object->metaObject()->className());
- int marker = typeName.indexOf(QLatin1String("_QMLTYPE_"));
- if (marker != -1)
- typeName = typeName.left(marker);
- }
-
- pos += typeName;
- }
- QmlDeclarativeData *ddata = object?QmlDeclarativeData::get(object):0;
- pos += QLatin1String(" (");
- if (ddata) {
- if (ddata->outerContext) {
- pos += ddata->outerContext->baseUrl().toString();
- pos += QLatin1Char(':');
- pos += QString::number(ddata->lineNumber);
- pos += QLatin1Char(':');
- pos += QString::number(ddata->columnNumber);
- } else {
- pos += QCoreApplication::translate("QmlInfo","unknown location");
- }
- } else {
- pos += QCoreApplication::translate("QmlInfo","unknown location");
- }
- pos += QLatin1Char(')');
- *this << pos;
- nospace();
-}
-
-QmlInfo::~QmlInfo()
-{
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlinfo.h b/src/declarative/qml/qmlinfo.h
deleted file mode 100644
index 379f211..0000000
--- a/src/declarative/qml/qmlinfo.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLINFO_H
-#define QMLINFO_H
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QmlInfo : public QDebug
-{
-public:
- QmlInfo(const QObject *);
- ~QmlInfo();
-
- inline QmlInfo &operator<<(QChar t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(QBool t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(bool t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(char t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(signed short t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(unsigned short t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(signed int t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(unsigned int t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(signed long t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(unsigned long t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(qint64 t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(quint64 t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(float t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(double t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(const char* t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(const QString & t) { QDebug::operator<<(t.toLocal8Bit().constData()); return *this; }
- inline QmlInfo &operator<<(const QStringRef & t) { return operator<<(t.toString()); }
- inline QmlInfo &operator<<(const QLatin1String &t) { QDebug::operator<<(t.latin1()); return *this; }
- inline QmlInfo &operator<<(const QByteArray & t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(const void * t) { QDebug::operator<<(t); return *this; }
- inline QmlInfo &operator<<(QTextStreamFunction f) { QDebug::operator<<(f); return *this; }
- inline QmlInfo &operator<<(QTextStreamManipulator m) { QDebug::operator<<(m); return *this; }
-};
-
-Q_DECLARATIVE_EXPORT inline QmlInfo qmlInfo(const QObject *me)
-{
- return QmlInfo(me);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLINFO_H
diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp
deleted file mode 100644
index e37ade7..0000000
--- a/src/declarative/qml/qmlinstruction.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlinstruction_p.h"
-
-#include "qmlcompiler_p.h"
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-void QmlCompiledData::dump(QmlInstruction *instr, int idx)
-{
- QByteArray lineNumber = QByteArray::number(instr->line);
- if (instr->line == (unsigned short)-1)
- lineNumber = "NA";
- const char *line = lineNumber.constData();
-
- switch(instr->type) {
- case QmlInstruction::Init:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "INIT\t\t\t" << instr->init.bindingsSize << "\t" << instr->init.parserStatusSize << "\t" << instr->init.contextCache << "\t" << instr->init.compiledBinding;
- break;
- case QmlInstruction::CreateObject:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "CREATE\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className;
- break;
- case QmlInstruction::SetId:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "SETID\t\t\t" << instr->setId.value << "\t\t\t" << primitives.at(instr->setId.value);
- break;
- case QmlInstruction::SetDefault:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "SET_DEFAULT";
- break;
- case QmlInstruction::CreateComponent:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "CREATE_COMPONENT\t" << instr->createComponent.count;
- break;
- case QmlInstruction::StoreMetaObject:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_META\t\t" << instr->storeMeta.data;
- break;
-
- case QmlInstruction::StoreFloat:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_FLOAT\t\t" << instr->storeFloat.propertyIndex << "\t" << instr->storeFloat.value;
- break;
- case QmlInstruction::StoreDouble:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
- break;
- case QmlInstruction::StoreInteger:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
- break;
- case QmlInstruction::StoreBool:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
- break;
- case QmlInstruction::StoreString:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_STRING\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
- break;
- case QmlInstruction::StoreUrl:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_URL\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << primitives.at(instr->storeUrl.value);
- break;
- case QmlInstruction::StoreColor:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_COLOR\t\t" << instr->storeColor.propertyIndex << "\t\t\t" << QString::number(instr->storeColor.value, 16);
- break;
- case QmlInstruction::StoreDate:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_DATE\t\t" << instr->storeDate.propertyIndex << "\t" << instr->storeDate.value;
- break;
- case QmlInstruction::StoreTime:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_TIME\t\t" << instr->storeTime.propertyIndex << "\t" << instr->storeTime.valueIndex;
- break;
- case QmlInstruction::StoreDateTime:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_DATETIME\t\t" << instr->storeDateTime.propertyIndex << "\t" << instr->storeDateTime.valueIndex;
- break;
- case QmlInstruction::StorePoint:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_POINT\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
- break;
- case QmlInstruction::StorePointF:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_POINTF\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
- break;
- case QmlInstruction::StoreSize:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SIZE\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
- break;
- case QmlInstruction::StoreSizeF:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SIZEF\t\t" << instr->storeRealPair.propertyIndex << "\t" << instr->storeRealPair.valueIndex;
- break;
- case QmlInstruction::StoreRect:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_RECT\t\t" << instr->storeRect.propertyIndex << "\t" << instr->storeRect.valueIndex;
- break;
- case QmlInstruction::StoreRectF:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_RECTF\t\t" << instr->storeRect.propertyIndex << "\t" << instr->storeRect.valueIndex;
- break;
- case QmlInstruction::StoreVector3D:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VECTOR3D\t\t" << instr->storeVector3D.propertyIndex << "\t" << instr->storeVector3D.valueIndex;
- break;
- case QmlInstruction::StoreVariant:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
- break;
- case QmlInstruction::StoreObject:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
- break;
- case QmlInstruction::StoreVariantObject:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT_OBJECT\t" << instr->storeObject.propertyIndex;
- break;
- case QmlInstruction::StoreInterface:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_INTERFACE\t\t" << instr->storeObject.propertyIndex;
- break;
-
- case QmlInstruction::StoreSignal:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value << "\t\t" << primitives.at(instr->storeSignal.value);
- break;
- case QmlInstruction::StoreScript:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SCRIPT\t\t" << instr->storeScript.value;
- break;
- case QmlInstruction::StoreScriptString:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SCRIPT_STRING\t" << instr->storeScriptString.propertyIndex << "\t" << instr->storeScriptString.value << "\t" << instr->storeScriptString.scope;
- break;
-
- case QmlInstruction::AssignSignalObject:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal << "\t\t\t" << datas.at(instr->assignSignalObject.signal);
- break;
- case QmlInstruction::AssignCustomType:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.valueIndex;
- break;
-
- case QmlInstruction::StoreBinding:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
- break;
- case QmlInstruction::StoreCompiledBinding:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_COMPILED_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
- break;
- case QmlInstruction::StoreValueSource:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property << "\t" << instr->assignValueSource.castValue;
- break;
- case QmlInstruction::StoreValueInterceptor:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VALUE_INTERCEPTOR\t" << instr->assignValueInterceptor.property << "\t" << instr->assignValueInterceptor.castValue;
- break;
-
- case QmlInstruction::BeginObject:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "BEGIN\t\t\t" << instr->begin.castValue;
- break;
- case QmlInstruction::StoreObjectQList:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_OBJECT_QLIST";
- break;
- case QmlInstruction::AssignObjectList:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "ASSIGN_OBJECT_LIST";
- break;
- case QmlInstruction::FetchAttached:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH_ATTACHED\t\t" << instr->fetchAttached.id;
- break;
- case QmlInstruction::FetchQList:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH_QLIST\t\t" << instr->fetch.property;
- break;
- case QmlInstruction::FetchObject:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH\t\t\t" << instr->fetch.property;
- break;
- case QmlInstruction::FetchValueType:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type;
- break;
- case QmlInstruction::PopFetchedObject:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "POP";
- break;
- case QmlInstruction::PopQList:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "POP_QLIST";
- break;
- case QmlInstruction::PopValueType:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "POP_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type;
- break;
- case QmlInstruction::Defer:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "DEFER" << "\t\t\t" << instr->defer.deferCount;
- break;
- default:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "XXX UNKOWN INSTRUCTION" << "\t" << instr->type;
- break;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
deleted file mode 100644
index ea785b6..0000000
--- a/src/declarative/qml/qmlinstruction_p.h
+++ /dev/null
@@ -1,319 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLINSTRUCTION_P_H
-#define QMLINSTRUCTION_P_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>
-
-QT_BEGIN_NAMESPACE
-
-class QmlCompiledData;
-class Q_DECLARATIVE_EXPORT QmlInstruction
-{
-public:
- enum Type {
- //
- // Object Creation
- //
- // CreateObject - Create a new object instance and push it on the
- // object stack
- // SetId - Set the id of the object on the top of the object stack
- // SetDefault - Sets the instance on the top of the object stack to
- // be the context's default object.
- // StoreMetaObject - Assign the dynamic metaobject to object on the
- // top of the stack.
- Init, /* init */
- CreateObject, /* create */
- SetId, /* setId */
- SetDefault,
- CreateComponent, /* createComponent */
- StoreMetaObject, /* storeMeta */
-
- //
- // Precomputed single assignment
- //
- // StoreFloat - Store a float in a core property
- // StoreDouble - Store a double in a core property
- // StoreInteger - Store a int or uint in a core property
- // StoreBool - Store a bool in a core property
- // StoreString - Store a QString in a core property
- // StoreUrl - Store a QUrl in a core property
- // StoreColor - Store a QColor in a core property
- // StoreDate - Store a QDate in a core property
- // StoreTime - Store a QTime in a core property
- // StoreDateTime - Store a QDateTime in a core property
- // StoreVariant - Store a QVariant in a core property
- // StoreObject - Pop the object on the top of the object stack and
- // store it in a core property
- StoreFloat, /* storeFloat */
- StoreDouble, /* storeDouble */
- StoreInteger, /* storeInteger */
- StoreBool, /* storeBool */
- StoreString, /* storeString */
- StoreUrl, /* storeUrl */
- StoreColor, /* storeColor */
- StoreDate, /* storeDate */
- StoreTime, /* storeTime */
- StoreDateTime, /* storeDateTime */
- StorePoint, /* storeRealPair */
- StorePointF, /* storeRealPair */
- StoreSize, /* storeRealPair */
- StoreSizeF, /* storeRealPair */
- StoreRect, /* storeRect */
- StoreRectF, /* storeRect */
- StoreVector3D, /* storeVector3D */
- StoreVariant, /* storeString */
- StoreObject, /* storeObject */
- StoreVariantObject, /* storeObject */
- StoreInterface, /* storeObject */
-
- StoreSignal, /* storeSignal */
- StoreScript, /* storeScript */
- StoreScriptString, /* storeScriptString */
-
- //
- // Unresolved single assignment
- //
- AssignSignalObject, /* assignSignalObject */
- AssignCustomType, /* assignCustomType */
-
- StoreBinding, /* assignBinding */
- StoreCompiledBinding, /* assignBinding */
- StoreValueSource, /* assignValueSource */
- StoreValueInterceptor, /* assignValueInterceptor */
-
- BeginObject, /* begin */
-
- StoreObjectQList, /* NA */
- AssignObjectList, /* NA */
-
- FetchAttached, /* fetchAttached */
- FetchQList, /* fetch */
- FetchObject, /* fetch */
- FetchValueType, /* fetchValue */
-
- //
- // Stack manipulation
- //
- // PopFetchedObject - Remove an object from the object stack
- // PopQList - Remove a list from the list stack
- PopFetchedObject,
- PopQList,
- PopValueType, /* fetchValue */
-
- //
- // Deferred creation
- //
- Defer, /* defer */
- };
- QmlInstruction()
- : line(0) {}
-
- Type type;
- unsigned short line;
- union {
- struct {
- int bindingsSize;
- int parserStatusSize;
- int contextCache;
- int compiledBinding;
- } init;
- struct {
- int type;
- int data;
- int bindingBits;
- ushort column;
- } create;
- struct {
- int data;
- int aliasData;
- int propertyCache;
- } storeMeta;
- struct {
- int value;
- int index;
- } setId;
- struct {
- int property;
- int owner;
- int castValue;
- } assignValueSource;
- struct {
- int property;
- int owner;
- int castValue;
- } assignValueInterceptor;
- struct {
- unsigned int property;
- int value;
- short context;
- short owner;
- } assignBinding;
- struct {
- int property;
- int id;
- } assignIdOptBinding;
- struct {
- int property;
- int contextIdx;
- short context;
- short notifyIdx;
- } assignObjPropBinding;
- struct {
- int property;
- } fetch;
- struct {
- int property;
- int type;
- } fetchValue;
- struct {
- int property;
- int type;
- } fetchQmlList;
- struct {
- int castValue;
- } begin;
- struct {
- int propertyIndex;
- float value;
- } storeFloat;
- struct {
- int propertyIndex;
- double value;
- } storeDouble;
- struct {
- int propertyIndex;
- int value;
- } storeInteger;
- struct {
- int propertyIndex;
- bool value;
- } storeBool;
- struct {
- int propertyIndex;
- int value;
- } storeString;
- struct {
- int propertyIndex;
- int value;
- int scope;
- } storeScriptString;
- struct {
- int value;
- } storeScript;
- struct {
- int propertyIndex;
- int value;
- } storeUrl;
- struct {
- int propertyIndex;
- unsigned int value;
- } storeColor;
- struct {
- int propertyIndex;
- int value;
- } storeDate;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeTime;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeDateTime;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeRealPair;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeRect;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeVector3D;
- struct {
- int propertyIndex;
- } storeObject;
- struct {
- int propertyIndex;
- int valueIndex;
- } assignCustomType;
- struct {
- int signalIndex;
- int value;
- } storeSignal;
- struct {
- int signal;
- } assignSignalObject;
- struct {
- int count;
- ushort column;
- int endLine;
- int metaObject;
- } createComponent;
- struct {
- int id;
- } fetchAttached;
- struct {
- int deferCount;
- } defer;
- };
-
- void dump(QmlCompiledData *);
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLINSTRUCTION_P_H
diff --git a/src/declarative/qml/qmlintegercache.cpp b/src/declarative/qml/qmlintegercache.cpp
deleted file mode 100644
index 2c2d494..0000000
--- a/src/declarative/qml/qmlintegercache.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlintegercache_p.h"
-
-#include "qmlengine_p.h"
-#include "qmlmetatype.h"
-
-QT_BEGIN_NAMESPACE
-
-QmlIntegerCache::QmlIntegerCache(QmlEngine *e)
-: QmlCleanup(e), engine(e)
-{
-}
-
-QmlIntegerCache::~QmlIntegerCache()
-{
- clear();
-}
-
-void QmlIntegerCache::clear()
-{
- qDeleteAll(stringCache);
- stringCache.clear();
- identifierCache.clear();
- engine = 0;
-}
-
-void QmlIntegerCache::add(const QString &id, int value)
-{
- Q_ASSERT(!stringCache.contains(id));
-
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine);
-
- // ### use contextClass
- Data *d = new Data(enginePriv->objectClass->createPersistentIdentifier(id), value);
-
- stringCache.insert(id, d);
- identifierCache.insert(d->identifier, d);
-}
-
-int QmlIntegerCache::value(const QString &id)
-{
- Data *d = stringCache.value(id);
- return d?d->value:-1;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlintegercache_p.h b/src/declarative/qml/qmlintegercache_p.h
deleted file mode 100644
index f38138f..0000000
--- a/src/declarative/qml/qmlintegercache_p.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLINTEGERCACHE_P_H
-#define QMLINTEGERCACHE_P_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 "qmlrefcount_p.h"
-#include "qmlcleanup_p.h"
-
-#include <QtCore/qhash.h>
-
-#include <private/qscriptdeclarativeclass_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlType;
-class QmlEngine;
-class QmlIntegerCache : public QmlRefCount, public QmlCleanup
-{
-public:
- QmlIntegerCache(QmlEngine *);
- virtual ~QmlIntegerCache();
-
- inline int count() const;
- void add(const QString &, int);
- int value(const QString &);
- inline int value(const QScriptDeclarativeClass::Identifier &id) const;
-
-protected:
- virtual void clear();
-
-private:
- struct Data : public QScriptDeclarativeClass::PersistentIdentifier {
- Data(const QScriptDeclarativeClass::PersistentIdentifier &i, int v)
- : QScriptDeclarativeClass::PersistentIdentifier(i), value(v) {}
-
- int value;
- };
-
- typedef QHash<QString, Data *> StringCache;
- typedef QHash<QScriptDeclarativeClass::Identifier, Data *> IdentifierCache;
-
- StringCache stringCache;
- IdentifierCache identifierCache;
- QmlEngine *engine;
-};
-
-int QmlIntegerCache::value(const QScriptDeclarativeClass::Identifier &id) const
-{
- Data *d = identifierCache.value(id);
- return d?d->value:-1;
-}
-
-int QmlIntegerCache::count() const
-{
- return stringCache.count();
-}
-
-QT_END_NAMESPACE
-
-#endif // QMLINTEGERCACHE_P_H
-
diff --git a/src/declarative/qml/qmllist.cpp b/src/declarative/qml/qmllist.cpp
deleted file mode 100644
index 4cd2120..0000000
--- a/src/declarative/qml/qmllist.cpp
+++ /dev/null
@@ -1,312 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmllist.h"
-#include "qmllist_p.h"
-#include "qmlengine_p.h"
-#include "qmlmetaproperty_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QmlListReferencePrivate::QmlListReferencePrivate()
-: propertyType(-1), refCount(1)
-{
-}
-
-QmlListReference QmlListReferencePrivate::init(const QmlListProperty<QObject> &prop, int propType, QmlEngine *engine)
-{
- QmlListReference rv;
-
- if (!prop.object) return rv;
-
- QmlEnginePrivate *p = engine?QmlEnginePrivate::get(engine):0;
-
- int listType = p?p->listType(propType):QmlMetaType::listType(propType);
- if (listType == -1) return rv;
-
- rv.d = new QmlListReferencePrivate;
- rv.d->object = prop.object;
- rv.d->elementType = p?p->rawMetaObjectForType(listType):QmlMetaType::qmlType(listType)->baseMetaObject();
- rv.d->property = prop;
- rv.d->propertyType = propType;
-
- return rv;
-}
-
-void QmlListReferencePrivate::addref()
-{
- Q_ASSERT(refCount > 0);
- ++refCount;
-}
-
-void QmlListReferencePrivate::release()
-{
- Q_ASSERT(refCount > 0);
- --refCount;
- if (!refCount)
- delete this;
-}
-
-QmlListReference::QmlListReference()
-: d(0)
-{
-}
-
-QmlListReference::QmlListReference(QObject *o, const char *property, QmlEngine *engine)
-: d(0)
-{
- if (!o || !property) return;
-
- QmlPropertyCache::Data local;
- QmlPropertyCache::Data *data = QmlPropertyCache::property(engine, o, QLatin1String(property), local);
-
- if (!data || !(data->flags & QmlPropertyCache::Data::IsQList)) return;
-
- QmlEnginePrivate *p = engine?QmlEnginePrivate::get(engine):0;
-
- int listType = p?p->listType(data->propType):QmlMetaType::listType(data->propType);
- if (listType == -1) return;
-
- d = new QmlListReferencePrivate;
- d->object = o;
- d->elementType = p?p->rawMetaObjectForType(listType):QmlMetaType::qmlType(listType)->baseMetaObject();
- d->propertyType = data->propType;
-
- void *args[] = { &d->property, 0 };
- QMetaObject::metacall(o, QMetaObject::ReadProperty, data->coreIndex, args);
-}
-
-QmlListReference::QmlListReference(const QmlListReference &o)
-: d(o.d)
-{
- if (d) d->addref();
-}
-
-QmlListReference &QmlListReference::operator=(const QmlListReference &o)
-{
- if (o.d) o.d->addref();
- if (d) d->release();
- d = o.d;
- return *this;
-}
-
-QmlListReference::~QmlListReference()
-{
- if (d) d->release();
-}
-
-bool QmlListReference::isValid() const
-{
- return d && d->object;
-}
-
-QObject *QmlListReference::object() const
-{
- if (isValid()) return d->object;
- else return 0;
-}
-
-const QMetaObject *QmlListReference::listElementType() const
-{
- if (isValid()) return d->elementType;
- else return 0;
-}
-
-bool QmlListReference::canAppend() const
-{
- return (isValid() && d->property.append);
-}
-
-bool QmlListReference::canAt() const
-{
- return (isValid() && d->property.at);
-}
-
-bool QmlListReference::canClear() const
-{
- return (isValid() && d->property.clear);
-}
-
-bool QmlListReference::canCount() const
-{
- return (isValid() && d->property.count);
-}
-
-bool QmlListReference::append(QObject *o) const
-{
- if (!canAppend()) return false;
-
- if (o && !QmlMetaPropertyPrivate::canConvert(o->metaObject(), d->elementType))
- return false;
-
- d->property.append(&d->property, o);
-
- return true;
-}
-
-QObject *QmlListReference::at(int index) const
-{
- if (!canAt()) return 0;
-
- return d->property.at(&d->property, index);
-}
-
-bool QmlListReference::clear() const
-{
- if (!canClear()) return false;
-
- d->property.clear(&d->property);
-
- return true;
-}
-
-int QmlListReference::count() const
-{
- if (!canCount()) return 0;
-
- return d->property.count(&d->property);
-}
-
-/*!
-\class QmlListProperty
-\brief The QmlListProperty class allows applications to explose list-like
-properties to QML.
-
-QML has many list properties, where more than one object value can be assigned.
-The use of a list property from QML looks like this:
-
-\code
-FruitBasket {
- fruit: [
- Apple {},
- Orange{},
- Banana {}
- ]
-}
-\endcode
-
-The QmlListProperty encapsulates a group of function pointers that represet the
-set of actions QML can perform on the list - adding items, retrieving items and
-clearing the list. In the future, additional operations may be supported. All
-list properties must implement the append operation, but the rest are optional.
-
-To provide a list property, a C++ class must implement the operation callbacks,
-and then return an appropriate QmlListProperty value from the property getter.
-List properties should have no setter. In the example above, the Q_PROPERTY()
-declarative will look like this:
-
-\code
-Q_PROPERTY(QmlListProperty<Fruit> fruit READ fruit);
-\endcode
-
-QML list properties are typesafe - in this case \c {Fruit} is a QObject type that
-\c {Apple}, \c {Orange} and \c {Banana} all derive from.
-*/
-
-/*!
-\fn QmlListProperty::QmlListProperty()
-\internal
-*/
-
-/*!
-\fn QmlListProperty::QmlListProperty(QObject *object, QList<T *> &list)
-
-Convenience constructor for making a QmlListProperty value from an existing
-QList \a list. The \a list reference must remain valid for as long as \a object
-exists. \a object must be provided.
-
-Generally this constructor should not be used in production code, as a
-writable QList violates QML's memory management rules. However, this constructor
-can very useful while prototyping.
-*/
-
-/*!
-\fn QmlListProperty::QmlListProperty(QObject *object, void *data, AppendFunction append,
- CountFunction count = 0, AtFunction at = 0,
- ClearFunction clear = 0)
-
-Construct a QmlListProperty from a set of operation functions. An opaque \a data handle
-may be passed which can be accessed from within the operation functions. The list property
-remains valid while \a object exists.
-
-The \a append operation is compulsory and must be provided, while the \a count, \a at and
-\a clear methods are optional.
-*/
-
-/*!
-\typedef QmlListProperty::AppendFunction
-
-Synonym for \c {void (*)(QmlListProperty<T> *property, T *value)}.
-
-Append the \a value to the list \a property.
-*/
-
-/*!
-\typedef QmlListProperty::CountFunction
-
-Synonym for \c {int (*)(QmlListProperty<T> *property)}.
-
-Return the number of elements in the list \a property.
-*/
-
-/*!
-\fn bool QmlListProperty::operator==(const QmlListProperty &other) const
-
-Returns true if this QmlListProperty is equal to \a other, otherwise false.
-*/
-
-/*!
-\typedef QmlListProperty::AtFunction
-
-Synonym for \c {T *(*)(QmlListProperty<T> *property, int index)}.
-
-Return the element at position \a index in the list \a property.
-*/
-
-/*!
-\typedef QmlListProperty::ClearFunction
-
-Synonym for \c {void (*)(QmlListProperty<T> *property)}.
-
-Clear the list \a property.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmllist.h b/src/declarative/qml/qmllist.h
deleted file mode 100644
index 5528d8d..0000000
--- a/src/declarative/qml/qmllist.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLLIST_H
-#define QMLLIST_H
-
-#include "qmlprivate.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-template<typename T>
-struct QmlListProperty {
- typedef void (*AppendFunction)(QmlListProperty<T> *, T*);
- typedef int (*CountFunction)(QmlListProperty<T> *);
- typedef T *(*AtFunction)(QmlListProperty<T> *, int);
- typedef void (*ClearFunction)(QmlListProperty<T> *);
-
- QmlListProperty()
- : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {}
- QmlListProperty(QObject *o, QList<T *> &list)
- : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at),
- clear(qlist_clear), dummy1(0), dummy2(0) {}
- QmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0,
- ClearFunction r = 0)
- : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {}
-
- bool operator==(const QmlListProperty &o) const {
- return object == o.object &&
- data == o.data &&
- append == o.append &&
- count == o.count &&
- at == o.at &&
- clear == o.clear;
- }
-
- QObject *object;
- void *data;
-
- AppendFunction append;
-
- CountFunction count;
- AtFunction at;
-
- ClearFunction clear;
-
- void *dummy1;
- void *dummy2;
-
-private:
- static void qlist_append(QmlListProperty *p, T *v) {
- ((QList<T *> *)p->data)->append(v);
- }
- static int qlist_count(QmlListProperty *p) {
- return ((QList<T *> *)p->data)->count();
- }
- static T *qlist_at(QmlListProperty *p, int idx) {
- return ((QList<T *> *)p->data)->at(idx);
- }
- static void qlist_clear(QmlListProperty *p) {
- return ((QList<T *> *)p->data)->clear();
- }
-};
-
-class QmlEngine;
-class QmlListReferencePrivate;
-class Q_DECLARATIVE_EXPORT QmlListReference
-{
-public:
- QmlListReference();
- QmlListReference(QObject *, const char *property, QmlEngine * = 0);
- QmlListReference(const QmlListReference &);
- QmlListReference &operator=(const QmlListReference &);
- ~QmlListReference();
-
- bool isValid() const;
-
- QObject *object() const;
- const QMetaObject *listElementType() const;
-
- bool canAppend() const;
- bool canAt() const;
- bool canClear() const;
- bool canCount() const;
-
- bool append(QObject *) const;
- QObject *at(int) const;
- bool clear() const;
- int count() const;
-
-private:
- friend class QmlListReferencePrivate;
- QmlListReferencePrivate* d;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QmlListReference);
-
-QT_END_HEADER
-
-#endif // QMLLIST_H
diff --git a/src/declarative/qml/qmllist_p.h b/src/declarative/qml/qmllist_p.h
deleted file mode 100644
index 4660e47..0000000
--- a/src/declarative/qml/qmllist_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLLIST_P_H
-#define QMLLIST_P_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 "qmllist.h"
-#include "qmlguard_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlListReferencePrivate
-{
-public:
- QmlListReferencePrivate();
-
- static QmlListReference init(const QmlListProperty<QObject> &, int, QmlEngine *);
-
- QmlGuard<QObject> object;
- const QMetaObject *elementType;
- QmlListProperty<QObject> property;
- int propertyType;
-
- void addref();
- void release();
- int refCount;
-
- static inline QmlListReferencePrivate *get(QmlListReference *ref) {
- return ref->d;
- }
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QMLLIST_P_H
diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp
deleted file mode 100644
index bb29763..0000000
--- a/src/declarative/qml/qmllistscriptclass.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmllistscriptclass_p.h"
-
-#include "qmlengine_p.h"
-#include "qmlguard_p.h"
-#include "qmllist_p.h"
-
-QT_BEGIN_NAMESPACE
-
-struct ListData : public QScriptDeclarativeClass::Object {
- QmlGuard<QObject> object;
- QmlListProperty<QObject> property;
- int propertyType;
-};
-
-QmlListScriptClass::QmlListScriptClass(QmlEngine *e)
-: QmlScriptClass(QmlEnginePrivate::getScriptEngine(e)), engine(e)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
- Q_UNUSED(scriptEngine);
-
- m_lengthId = createPersistentIdentifier(QLatin1String("length"));
-}
-
-QmlListScriptClass::~QmlListScriptClass()
-{
-}
-
-QScriptValue QmlListScriptClass::newList(QObject *object, int propId, int propType)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- if (!object || propId == -1)
- return scriptEngine->nullValue();
-
- ListData *data = new ListData;
- data->object = object;
- data->propertyType = propType;
- void *args[] = { &data->property, 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, propId, args);
-
- return newObject(scriptEngine, this, data);
-}
-
-QScriptValue QmlListScriptClass::newList(const QmlListProperty<QObject> &prop, int propType)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- ListData *data = new ListData;
- data->object = prop.object;
- data->property = prop;
- data->propertyType = propType;
-
- return newObject(scriptEngine, this, data);
-}
-
-QScriptClass::QueryFlags
-QmlListScriptClass::queryProperty(Object *object, const Identifier &name,
- QScriptClass::QueryFlags flags)
-{
- Q_UNUSED(object);
- Q_UNUSED(flags);
- if (name == m_lengthId.identifier)
- return QScriptClass::HandlesReadAccess;
-
- bool ok = false;
- quint32 idx = toArrayIndex(name, &ok);
-
- if (ok) {
- lastIndex = idx;
- return QScriptClass::HandlesReadAccess;
- } else {
- return 0;
- }
-}
-
-QmlListScriptClass::ScriptValue QmlListScriptClass::property(Object *obj, const Identifier &name)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine);
-
- ListData *data = (ListData *)obj;
- if (!data->object)
- return Value();
-
- quint32 count = data->property.count?data->property.count(&data->property):0;
-
- if (name == m_lengthId.identifier)
- return Value(scriptEngine, count);
- else if (lastIndex < count && data->property.at)
- return Value(scriptEngine, enginePriv->objectClass->newQObject(data->property.at(&data->property, lastIndex)));
- else
- return Value();
-}
-
-QVariant QmlListScriptClass::toVariant(Object *obj, bool *ok)
-{
- ListData *data = (ListData *)obj;
-
- if (!data->object) {
- if (ok) *ok = false;
- return QVariant();
- }
-
- return QVariant::fromValue(QmlListReferencePrivate::init(data->property, data->propertyType, engine));
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qmllistscriptclass_p.h b/src/declarative/qml/qmllistscriptclass_p.h
deleted file mode 100644
index 07b09c3..0000000
--- a/src/declarative/qml/qmllistscriptclass_p.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLLISTSCRIPTCLASS_P_H
-#define QMLLISTSCRIPTCLASS_P_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 <private/qmlscriptclass_p.h>
-#include "qmllist.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngine;
-class QmlListScriptClass : public QmlScriptClass
-{
-public:
- QmlListScriptClass(QmlEngine *);
- ~QmlListScriptClass();
-
- QScriptValue newList(QObject *, int, int);
- QScriptValue newList(const QmlListProperty<QObject> &, int);
-
-protected:
- virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
- QScriptClass::QueryFlags flags);
- virtual ScriptValue property(Object *, const Identifier &);
- virtual QVariant toVariant(Object *, bool *ok);
-
-private:
- PersistentIdentifier m_lengthId;
- QmlEngine *engine;
-
- quint32 lastIndex;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLLISTSCRIPTCLASS_P_H
-
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
deleted file mode 100644
index d731393..0000000
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ /dev/null
@@ -1,1238 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlmetaproperty.h"
-#include "qmlmetaproperty_p.h"
-
-#include "qmlcompositetypedata_p.h"
-#include "qml.h"
-#include "qmlbinding_p.h"
-#include "qmlcontext.h"
-#include "qmlcontext_p.h"
-#include "qmlboundsignal_p.h"
-#include "qmlengine.h"
-#include "qmlengine_p.h"
-#include "qmldeclarativedata_p.h"
-#include "qmlstringconverters_p.h"
-#include "qmllist_p.h"
-
-#include <QStringList>
-#include <QtCore/qdebug.h>
-
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlMetaProperty
- \brief The QmlMetaProperty class abstracts accessing QML properties.
- \internal
- */
-
-/*!
- Create an invalid QmlMetaProperty.
-*/
-QmlMetaProperty::QmlMetaProperty()
-: d(new QmlMetaPropertyPrivate)
-{
- d->q = this;
-}
-
-/*! \internal */
-QmlMetaProperty::~QmlMetaProperty()
-{
- delete d; d = 0;
-}
-
-/*!
- Creates a QmlMetaProperty for the default property of \a obj. If there is no
- default property, an invalid QmlMetaProperty will be created.
- */
-QmlMetaProperty::QmlMetaProperty(QObject *obj)
-: d(new QmlMetaPropertyPrivate)
-{
- d->q = this;
- d->initDefault(obj);
-}
-
-/*!
- \internal
- Creates a QmlMetaProperty for the default property of \a obj. If there is no
- default property, an invalid QmlMetaProperty will be created.
- */
-QmlMetaProperty::QmlMetaProperty(QObject *obj, QmlContext *ctxt)
-: d(new QmlMetaPropertyPrivate)
-{
- d->q = this;
- d->context = ctxt;
- d->initDefault(obj);
-}
-
-/*!
- Initialize from the default property of \a obj
-*/
-void QmlMetaPropertyPrivate::initDefault(QObject *obj)
-{
- if (!obj)
- return;
-
- QMetaProperty p = QmlMetaType::defaultProperty(obj);
- core.load(p);
- if (core.isValid()) {
- isDefaultProperty = true;
- object = obj;
- }
-}
-
-/*!
- Creates a QmlMetaProperty for the property \a name of \a obj.
- */
-QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name)
-: d(new QmlMetaPropertyPrivate)
-{
- d->q = this;
- d->initProperty(obj, name);
- if (!isValid()) d->object = 0;
-}
-
-/*!
- \internal
- Creates a QmlMetaProperty for the property \a name of \a obj.
- */
-QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name, QmlContext *ctxt)
-: d(new QmlMetaPropertyPrivate)
-{
- d->q = this;
- d->context = ctxt;
- d->initProperty(obj, name);
- if (!isValid()) { d->object = 0; d->context = 0; }
-}
-
-void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name)
-{
- QmlEnginePrivate *enginePrivate = 0;
- if (context && context->engine())
- enginePrivate = QmlEnginePrivate::get(context->engine());
-
- object = obj;
-
- if (name.isEmpty() || !obj)
- return;
-
- if (enginePrivate && name.at(0).isUpper()) {
- // Attached property
- // ### What about qualified types?
- QmlTypeNameCache *tnCache = QmlContextPrivate::get(context)->imports;
- if (tnCache) {
- QmlTypeNameCache::Data *d = tnCache->data(name);
- if (d && d->type && d->type->attachedPropertiesFunction()) {
- attachedFunc = d->type->index();
- }
- }
- return;
-
- } else if (name.count() >= 3 &&
- name.at(0) == QChar(QLatin1Char('o')) &&
- name.at(1) == QChar(QLatin1Char('n')) &&
- name.at(2).isUpper()) {
- // Signal
- QString signalName = name.mid(2);
- signalName[0] = signalName.at(0).toLower();
-
- QMetaMethod method = findSignal(obj, signalName);
- if (method.signature()) {
- core.load(method);
- return;
- }
- }
-
- // Property
- QmlPropertyCache::Data local;
- QmlPropertyCache::Data *property =
- QmlPropertyCache::property(context?context->engine():0, obj, name, local);
- if (property && !(property->flags & QmlPropertyCache::Data::IsFunction))
- core = *property;
-}
-
-/*!
- Create a copy of \a other.
-*/
-QmlMetaProperty::QmlMetaProperty(const QmlMetaProperty &other)
-: d(new QmlMetaPropertyPrivate(*other.d))
-{
- d->q = this;
-}
-
-/*!
- \enum QmlMetaProperty::PropertyCategory
-
- This enum specifies a category of QML property.
-
- \value Unknown The category is unknown. This will never be returned from propertyCategory()
- \value InvalidProperty The property is invalid.
- \value Bindable The property is a QmlBinding.
- \value List The property is a QList pointer
- \value Object The property is a QObject derived type pointer
- \value Normal The property is none of the above.
- */
-
-/*!
- \enum QmlMetaProperty::Type
-
- This enum specifies a type of QML property.
-
- \value Invalid The property is invalid.
- \value Property The property is a regular Qt property.
- \value SignalProperty The property is a signal property.
- \value Default The property is the default property.
- \value Attached The property is an attached property.
-*/
-
-/*!
- Returns the property category.
-*/
-QmlMetaProperty::PropertyCategory QmlMetaProperty::propertyCategory() const
-{
- return d->propertyCategory();
-}
-
-QmlMetaProperty::PropertyCategory
-QmlMetaPropertyPrivate::propertyCategory() const
-{
- uint type = q->type();
-
- if (type & QmlMetaProperty::ValueTypeProperty) {
- return QmlMetaProperty::Normal;
- } else if (type & QmlMetaProperty::Attached) {
- return QmlMetaProperty::Object;
- } else if (type & QmlMetaProperty::Property) {
- int type = propertyType();
- if (type == QVariant::Invalid)
- return QmlMetaProperty::InvalidProperty;
- else if ((uint)type < QVariant::UserType)
- return QmlMetaProperty::Normal;
- else if (type == qMetaTypeId<QmlBinding *>())
- return QmlMetaProperty::Bindable;
- else if (core.flags & QmlPropertyCache::Data::IsQObjectDerived)
- return QmlMetaProperty::Object;
- else if (core.flags & QmlPropertyCache::Data::IsQList)
- return QmlMetaProperty::List;
- else
- return QmlMetaProperty::Normal;
- } else {
- return QmlMetaProperty::InvalidProperty;
- }
-}
-
-/*!
- Returns the type name of the property, or 0 if the property has no type
- name.
-*/
-const char *QmlMetaProperty::propertyTypeName() const
-{
- if (type() & ValueTypeProperty) {
-
- QmlEnginePrivate *ep = QmlEnginePrivate::get(d->context);
- QmlValueType *valueType = 0;
- if (ep) valueType = ep->valueTypes[d->core.propType];
- else valueType = QmlValueTypeFactory::valueType(d->core.propType);
- Q_ASSERT(valueType);
-
- const char *rv = valueType->metaObject()->property(d->valueType.valueTypeCoreIdx).typeName();
-
- if (!ep) delete valueType;
-
- return rv;
- } else if (d->object && type() & Property && d->core.isValid()) {
- return d->object->metaObject()->property(d->core.coreIndex).typeName();
- } else {
- return 0;
- }
-}
-
-/*!
- Returns true if \a other and this QmlMetaProperty represent the same
- property.
-*/
-bool QmlMetaProperty::operator==(const QmlMetaProperty &other) const
-{
- // category is intentially omitted here as it is generated
- // from the other members
- return d->object == other.d->object &&
- d->core == other.d->core &&
- d->valueType == other.d->valueType &&
- d->attachedFunc == other.d->attachedFunc;
-}
-
-/*!
- Returns the QVariant type of the property, or QVariant::Invalid if the
- property has no QVariant type.
-*/
-int QmlMetaProperty::propertyType() const
-{
- return d->propertyType();
-}
-
-int QmlMetaPropertyPrivate::propertyType() const
-{
- uint type = q->type();
- if (type & QmlMetaProperty::ValueTypeProperty) {
- return valueType.valueTypePropType;
- } else if (type & QmlMetaProperty::Attached) {
- return qMetaTypeId<QObject *>();
- } else if (type & QmlMetaProperty::Property) {
- if (core.propType == (int)QVariant::LastType)
- return qMetaTypeId<QVariant>();
- else
- return core.propType;
- } else {
- return QVariant::Invalid;
- }
-}
-
-/*!
- Returns the type of the property.
-*/
-QmlMetaProperty::Type QmlMetaProperty::type() const
-{
- if (d->core.flags & QmlPropertyCache::Data::IsFunction)
- return SignalProperty;
- else if (d->attachedFunc != -1)
- return Attached;
- else if (d->valueType.valueTypeCoreIdx != -1)
- return (Type)(Property | ValueTypeProperty);
- else if (d->core.isValid())
- return (Type)(Property | ((d->isDefaultProperty)?Default:0));
- else
- return Invalid;
-}
-
-/*!
- Returns true if this QmlMetaProperty represents a regular Qt property.
-*/
-bool QmlMetaProperty::isProperty() const
-{
- return type() & Property;
-}
-
-/*!
- Returns true if this QmlMetaProperty represents a default property.
-*/
-bool QmlMetaProperty::isDefault() const
-{
- return type() & Default;
-}
-
-/*!
- Returns the QmlMetaProperty's QObject.
-*/
-QObject *QmlMetaProperty::object() const
-{
- return d->object;
-}
-
-/*!
- Assign \a other to this QmlMetaProperty.
-*/
-QmlMetaProperty &QmlMetaProperty::operator=(const QmlMetaProperty &other)
-{
- d->context = other.d->context;
- d->object = other.d->object;
-
- d->isDefaultProperty = other.d->isDefaultProperty;
- d->isNameCached = other.d->isNameCached;
- d->core = other.d->core;
- d->nameCache = other.d->nameCache;
-
- d->valueType = other.d->valueType;
-
- d->attachedFunc = other.d->attachedFunc;
- return *this;
-}
-
-/*!
- Returns true if the property is writable, otherwise false.
-*/
-bool QmlMetaProperty::isWritable() const
-{
- QmlMetaProperty::PropertyCategory category = propertyCategory();
-
- if (!d->object)
- return false;
- if (category == List)
- return true;
- else if (type() & SignalProperty)
- return false;
- else if (d->core.isValid() && d->object)
- return d->core.flags & QmlPropertyCache::Data::IsWritable;
- else
- return false;
-}
-
-/*!
- Returns true if the property is designable, otherwise false.
-*/
-bool QmlMetaProperty::isDesignable() const
-{
- if (type() & Property && d->core.isValid() && d->object)
- return d->object->metaObject()->property(d->core.coreIndex).isDesignable();
- else
- return false;
-}
-
-/*!
- Returns true if the property is resettable, otherwise false.
-*/
-bool QmlMetaProperty::isResettable() const
-{
- if (type() & Property && d->core.isValid() && d->object)
- return d->core.flags & QmlPropertyCache::Data::IsResettable;
- else
- return false;
-}
-
-/*!
- Returns true if the QmlMetaProperty refers to a valid property, otherwise
- false.
-*/
-bool QmlMetaProperty::isValid() const
-{
- return type() != Invalid;
-}
-
-/*!
- Return the name of this QML property.
-*/
-QString QmlMetaProperty::name() const
-{
- if (!d->isNameCached) {
- // ###
- if (!d->object) {
- } else if (type() & ValueTypeProperty) {
- QString rv = d->core.name(d->object) + QLatin1Char('.');
-
- QmlEnginePrivate *ep = d->context?QmlEnginePrivate::get(d->context->engine()):0;
- QmlValueType *valueType = 0;
- if (ep) valueType = ep->valueTypes[d->core.propType];
- else valueType = QmlValueTypeFactory::valueType(d->core.propType);
- Q_ASSERT(valueType);
-
- rv += QString::fromUtf8(valueType->metaObject()->property(d->valueType.valueTypeCoreIdx).name());
-
- if (!ep) delete valueType;
-
- d->nameCache = rv;
- } else if (type() & SignalProperty) {
- QString name = QLatin1String("on") + d->core.name(d->object);
- name[2] = name.at(2).toUpper();
- d->nameCache = name;
- } else {
- d->nameCache = d->core.name(d->object);
- }
- d->isNameCached = true;
- }
-
- return d->nameCache;
-}
-
-/*!
- Returns the \l{QMetaProperty} {Qt property} associated with
- this QML property.
- */
-QMetaProperty QmlMetaProperty::property() const
-{
- if (type() & Property && d->core.isValid() && d->object)
- return d->object->metaObject()->property(d->core.coreIndex);
- else
- return QMetaProperty();
-}
-
-/*!
- Return the QMetaMethod for this property if it is a SignalProperty,
- otherwise returns an invalid QMetaMethod.
-*/
-QMetaMethod QmlMetaProperty::method() const
-{
- if (type() & SignalProperty && d->object)
- return d->object->metaObject()->method(d->core.coreIndex);
- else
- return QMetaMethod();
-}
-
-
-/*!
- Returns the binding associated with this property, or 0 if no binding
- exists.
-*/
-QmlAbstractBinding *QmlMetaProperty::binding() const
-{
- if (!isProperty() || (type() & Attached) || !d->object)
- return 0;
-
- QmlDeclarativeData *data = QmlDeclarativeData::get(d->object);
- if (!data)
- return 0;
-
- if (!data->hasBindingBit(d->core.coreIndex))
- return 0;
-
- QmlAbstractBinding *binding = data->bindings;
- while (binding) {
- // ### This wont work for value types
- if (binding->propertyIndex() == d->core.coreIndex)
- return binding;
- binding = binding->m_nextBinding;
- }
- return 0;
-}
-
-/*!
- Set the binding associated with this property to \a newBinding. Returns
- the existing binding (if any), otherwise 0.
-
- \a newBinding will be enabled, and the returned binding (if any) will be
- disabled.
-
- Ownership of \a newBinding transfers to QML. Ownership of the return value
- is assumed by the caller.
-
- \a flags is passed through to the binding and is used for the initial update (when
- the binding sets the intial value, it will use these flags for the write).
-*/
-QmlAbstractBinding *
-QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding, QmlMetaProperty::WriteFlags flags) const
-{
- if (!isProperty() || (type() & Attached) || !d->object) {
- if (newBinding)
- newBinding->destroy();
- return 0;
- }
-
- return d->setBinding(d->object, d->core, newBinding, flags);
-}
-
-QmlAbstractBinding *
-QmlMetaPropertyPrivate::setBinding(QObject *object, const QmlPropertyCache::Data &core,
- QmlAbstractBinding *newBinding, QmlMetaProperty::WriteFlags flags)
-{
- QmlDeclarativeData *data = QmlDeclarativeData::get(object, 0 != newBinding);
-
- if (data && data->hasBindingBit(core.coreIndex)) {
- QmlAbstractBinding *binding = data->bindings;
- while (binding) {
- // ### This wont work for value types
- if (binding->propertyIndex() == core.coreIndex) {
- binding->setEnabled(false);
-
- if (newBinding)
- newBinding->setEnabled(true, flags);
-
- return binding; // ### QmlAbstractBinding;
- }
-
- binding = binding->m_nextBinding;
- }
- }
-
- if (newBinding)
- newBinding->setEnabled(true, flags);
-
- return 0;
-}
-/*!
- Returns the expression associated with this signal property, or 0 if no
- signal expression exists.
-*/
-QmlExpression *QmlMetaProperty::signalExpression() const
-{
- if (!(type() & SignalProperty))
- return 0;
-
- const QObjectList &children = d->object->children();
-
- for (int ii = 0; ii < children.count(); ++ii) {
- QObject *child = children.at(ii);
-
- QmlBoundSignal *signal = QmlBoundSignal::cast(child);
- if (signal && signal->index() == coreIndex())
- return signal->expression();
- }
-
- return 0;
-}
-
-/*!
- Set the signal expression associated with this signal property to \a expr.
- Returns the existing signal expression (if any), otherwise 0.
-
- Ownership of \a expr transfers to QML. Ownership of the return value is
- assumed by the caller.
-*/
-QmlExpression *QmlMetaProperty::setSignalExpression(QmlExpression *expr) const
-{
- if (!(type() & SignalProperty)) {
- delete expr;
- return 0;
- }
-
- const QObjectList &children = d->object->children();
-
- for (int ii = 0; ii < children.count(); ++ii) {
- QObject *child = children.at(ii);
-
- QmlBoundSignal *signal = QmlBoundSignal::cast(child);
- if (signal && signal->index() == coreIndex())
- return signal->setExpression(expr);
- }
-
- if (expr) {
- QmlBoundSignal *signal = new QmlBoundSignal(d->object, method(), d->object);
- return signal->setExpression(expr);
- } else {
- return 0;
- }
-}
-
-QMetaMethod QmlMetaPropertyPrivate::findSignal(QObject *obj, const QString &name)
-{
- const QMetaObject *mo = obj->metaObject();
-
- int methods = mo->methodCount();
- for (int ii = methods - 1; ii >= 0; --ii) {
- QMetaMethod method = mo->method(ii);
- QString methodName = QString::fromUtf8(method.signature());
- int idx = methodName.indexOf(QLatin1Char('('));
- methodName = methodName.left(idx);
-
- if (methodName == name)
- return method;
- }
- return QMetaMethod();
-}
-
-QObject *QmlMetaPropertyPrivate::attachedObject() const
-{
- if (attachedFunc == -1)
- return 0;
- else
- return qmlAttachedPropertiesObjectById(attachedFunc, object);
-}
-
-/*!
- Returns the property value.
-*/
-QVariant QmlMetaProperty::read() const
-{
- if (!d->object)
- return QVariant();
-
- if (type() & SignalProperty) {
-
- return QVariant();
-
- } else if (type() & Property || type() & Attached) {
-
- return d->readValueProperty();
-
- }
- return QVariant();
-}
-
-QVariant QmlMetaPropertyPrivate::readValueProperty()
-{
- uint type = q->type();
- if (type & QmlMetaProperty::Attached) {
-
- return QVariant::fromValue(attachedObject());
-
- } else if(type & QmlMetaProperty::ValueTypeProperty) {
-
- QmlEnginePrivate *ep = QmlEnginePrivate::get(context);
- QmlValueType *valueType = 0;
- if (ep) valueType = ep->valueTypes[core.propType];
- else valueType = QmlValueTypeFactory::valueType(core.propType);
- Q_ASSERT(valueType);
-
- valueType->read(object, core.coreIndex);
-
- QVariant rv =
- valueType->metaObject()->property(this->valueType.valueTypeCoreIdx).read(valueType);
-
- if (!ep) delete valueType;
- return rv;
-
- } else if(core.flags & QmlPropertyCache::Data::IsQList) {
-
- QmlListProperty<QObject> prop;
- void *args[] = { &prop, 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
- return QVariant::fromValue(QmlListReferencePrivate::init(prop, core.propType, context?context->engine():0));
-
- } else {
-
- return object->metaObject()->property(core.coreIndex).read(object.data());
-
- }
-}
-
-//###
-//writeEnumProperty MIRRORS the relelvant bit of QMetaProperty::write AND MUST BE KEPT IN SYNC!
-//###
-bool QmlMetaPropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags)
-{
- if (!object || !prop.isWritable())
- return false;
-
- QVariant v = value;
- if (prop.isEnumType()) {
- QMetaEnum menum = prop.enumerator();
- if (v.userType() == QVariant::String
-#ifdef QT3_SUPPORT
- || v.userType() == QVariant::CString
-#endif
- ) {
- if (prop.isFlagType())
- v = QVariant(menum.keysToValue(value.toByteArray()));
- else
- v = QVariant(menum.keyToValue(value.toByteArray()));
- } else if (v.userType() != QVariant::Int && v.userType() != QVariant::UInt) {
- int enumMetaTypeId = QMetaType::type(QByteArray(menum.scope()) + "::" + menum.name());
- if ((enumMetaTypeId == 0) || (v.userType() != enumMetaTypeId) || !v.constData())
- return false;
- v = QVariant(*reinterpret_cast<const int *>(v.constData()));
- }
- v.convert(QVariant::Int);
- }
-
- // the status variable is changed by qt_metacall to indicate what it did
- // this feature is currently only used by QtDBus and should not be depended
- // upon. Don't change it without looking into QDBusAbstractInterface first
- // -1 (unchanged): normal qt_metacall, result stored in argv[0]
- // changed: result stored directly in value, return the value of status
- int status = -1;
- void *argv[] = { v.data(), &v, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, idx, argv);
- return status;
-}
-
-bool QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value,
- QmlMetaProperty::WriteFlags flags)
-{
- // Remove any existing bindings on this property
- if (!(flags & QmlMetaProperty::DontRemoveBinding)) {
- QmlAbstractBinding *binding = q->setBinding(0);
- if (binding) binding->destroy();
- }
-
- bool rv = false;
- uint type = q->type();
- if (type & QmlMetaProperty::ValueTypeProperty) {
- QmlEnginePrivate *ep = QmlEnginePrivate::get(context);
-
- QmlValueType *writeBack = 0;
- if (ep) {
- writeBack = ep->valueTypes[core.propType];
- } else {
- writeBack = QmlValueTypeFactory::valueType(core.propType);
- }
-
- writeBack->read(object, core.coreIndex);
-
- QmlPropertyCache::Data data = core;
- data.flags = valueType.flags;
- data.coreIndex = valueType.valueTypeCoreIdx;
- data.propType = valueType.valueTypePropType;
- rv = write(writeBack, data, value, context, flags);
-
- writeBack->write(object, core.coreIndex, flags);
- if (!ep) delete writeBack;
-
- } else {
-
- rv = write(object, core, value, context, flags);
-
- }
-
- return rv;
-}
-
-bool QmlMetaPropertyPrivate::write(QObject *object, const QmlPropertyCache::Data &property,
- const QVariant &value, QmlContext *context,
- QmlMetaProperty::WriteFlags flags)
-{
- int coreIdx = property.coreIndex;
- int status = -1; //for dbus
-
- if (property.flags & QmlPropertyCache::Data::IsEnumType) {
- QMetaProperty prop = object->metaObject()->property(property.coreIndex);
- QVariant v = value;
- // Enum values come through the script engine as doubles
- if (value.userType() == QVariant::Double) {
- double integral;
- double fractional = modf(value.toDouble(), &integral);
- if (qFuzzyIsNull(fractional))
- v.convert(QVariant::Int);
- }
- return writeEnumProperty(prop, coreIdx, object, v, flags);
- }
-
- int propertyType = property.propType;
- int variantType = value.userType();
-
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(context);
-
- if (propertyType == QVariant::Url) {
-
- QUrl u;
- bool found = false;
- if (variantType == QVariant::Url) {
- u = value.toUrl();
- found = true;
- } else if (variantType == QVariant::ByteArray) {
- u = QUrl(QString::fromUtf8(value.toByteArray()));
- found = true;
- } else if (variantType == QVariant::String) {
- u = QUrl(value.toString());
- found = true;
- }
-
- if (!found)
- return false;
-
- if (context && u.isRelative() && !u.isEmpty())
- u = context->resolvedUrl(u);
- int status = -1;
- void *argv[] = { &u, 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, argv);
-
- } else if (variantType == propertyType) {
-
- void *a[] = { (void *)value.constData(), 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
-
- } else if (qMetaTypeId<QVariant>() == propertyType) {
-
- void *a[] = { (void *)&value, 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
-
- } else if (property.flags & QmlPropertyCache::Data::IsQObjectDerived) {
-
- const QMetaObject *valMo = rawMetaObjectForType(enginePriv, value.userType());
-
- if (!valMo)
- return false;
-
- QObject *o = *(QObject **)value.constData();
- const QMetaObject *propMo = rawMetaObjectForType(enginePriv, propertyType);
-
- if (o) valMo = o->metaObject();
-
- if (canConvert(valMo, propMo)) {
- void *args[] = { &o, 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx,
- args);
- } else if (!o && canConvert(propMo, valMo)) {
- // In the case of a null QObject, we assign the null if there is
- // any change that the null variant type could be up or down cast to
- // the property type.
- void *args[] = { &o, 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx,
- args);
- } else {
- return false;
- }
-
- } else if (property.flags & QmlPropertyCache::Data::IsQList) {
-
- const QMetaObject *listType = 0;
- if (enginePriv) {
- listType = enginePriv->rawMetaObjectForType(enginePriv->listType(property.propType));
- } else {
- QmlType *type = QmlMetaType::qmlType(QmlMetaType::listType(property.propType));
- if (!type) return false;
- listType = type->baseMetaObject();
- }
- if (!listType) return false;
-
- QmlListProperty<void> prop;
- void *args[] = { &prop, 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, coreIdx, args);
-
- if (!prop.clear) return false;
-
- prop.clear(&prop);
-
- if (value.userType() == qMetaTypeId<QList<QObject *> >()) {
- const QList<QObject *> &list = qvariant_cast<QList<QObject *> >(value);
-
- for (int ii = 0; ii < list.count(); ++ii) {
- QObject *o = list.at(ii);
- if (!canConvert(o->metaObject(), listType))
- o = 0;
- prop.append(&prop, (void *)o);
- }
- } else {
- QObject *o = enginePriv?enginePriv->toQObject(value):QmlMetaType::toQObject(value);
- if (!canConvert(o->metaObject(), listType))
- o = 0;
- prop.append(&prop, (void *)o);
- }
-
- } else {
- Q_ASSERT(variantType != propertyType);
-
- QVariant v = value;
- if (v.convert((QVariant::Type)propertyType)) {
- void *a[] = { (void *)v.constData(), 0, &status, &flags};
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
- } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) {
- QmlMetaType::StringConverter con = QmlMetaType::customStringConverter(propertyType);
- if (!con)
- return false;
-
- QVariant v = con(value.toString());
- if (v.userType() == propertyType) {
- void *a[] = { (void *)v.constData(), 0, &status, &flags};
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
- }
- } else if (variantType == QVariant::String) {
- bool ok = false;
- QVariant v = QmlStringConverters::variantFromString(value.toString(), propertyType, &ok);
- if (!ok)
- return false;
-
- void *a[] = { (void *)v.constData(), 0, &status, &flags};
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
- } else {
- return false;
- }
- }
-
- return true;
-}
-
-const QMetaObject *QmlMetaPropertyPrivate::rawMetaObjectForType(QmlEnginePrivate *engine, int userType)
-{
- if (engine) {
- return engine->rawMetaObjectForType(userType);
- } else {
- QmlType *type = QmlMetaType::qmlType(userType);
- return type?type->baseMetaObject():0;
- }
-}
-
-/*!
- Set the property value to \a value.
-*/
-bool QmlMetaProperty::write(const QVariant &value) const
-{
- return write(value, 0);
-}
-
-/*!
- Resets the property value.
-*/
-bool QmlMetaProperty::reset() const
-{
- if (isResettable()) {
- void *args[] = { 0 };
- QMetaObject::metacall(d->object, QMetaObject::ResetProperty, d->core.coreIndex, args);
- return true;
- } else {
- return false;
- }
-}
-
-bool QmlMetaProperty::write(const QVariant &value, QmlMetaProperty::WriteFlags flags) const
-{
- if (d->object && type() & Property && d->core.isValid() && isWritable())
- return d->writeValueProperty(value, flags);
- else
- return false;
-}
-
-/*!
- Returns true if the property has a change notifier signal, otherwise false.
-*/
-bool QmlMetaProperty::hasChangedNotifier() const
-{
- if (type() & Property && !(type() & Attached) && d->object) {
- return d->object->metaObject()->property(d->core.coreIndex).hasNotifySignal();
- }
- return false;
-}
-
-/*!
- Returns true if the property needs a change notifier signal for bindings
- to remain upto date, false otherwise.
-
- Some properties, such as attached properties or those whose value never
- changes, do not require a change notifier.
-*/
-bool QmlMetaProperty::needsChangedNotifier() const
-{
- return type() & Property && !(type() & Attached) &&
- !property().isConstant();
-}
-
-/*!
- Connects the property's change notifier signal to the
- specified \a method of the \a dest object and returns
- true. Returns false if this metaproperty does not
- represent a regular Qt property or if it has no
- change notifier signal, or if the \a dest object does
- not have the specified \a method.
-*/
-bool QmlMetaProperty::connectNotifier(QObject *dest, int method) const
-{
- if (!(type() & Property) || (type() & Attached) || !d->object)
- return false;
-
- QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
- if (prop.hasNotifySignal()) {
- return QMetaObject::connect(d->object, prop.notifySignalIndex(), dest, method, Qt::DirectConnection);
- } else {
- return false;
- }
-}
-
-/*!
- Connects the property's change notifier signal to the
- specified \a slot of the \a dest object and returns
- true. Returns false if this metaproperty does not
- represent a regular Qt property or if it has no
- change notifier signal, or if the \a dest object does
- not have the specified \a slot.
-*/
-bool QmlMetaProperty::connectNotifier(QObject *dest, const char *slot) const
-{
- if (!(type() & Property) || (type() & Attached) || !d->object)
- return false;
-
- QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
- if (prop.hasNotifySignal()) {
- QByteArray signal(QByteArray("2") + prop.notifySignal().signature());
- return QObject::connect(d->object, signal.constData(), dest, slot);
- } else {
- return false;
- }
-}
-
-/*!
- Return the Qt metaobject index of the property.
-*/
-int QmlMetaProperty::coreIndex() const
-{
- return d->core.coreIndex;
-}
-
-/*! \internal */
-int QmlMetaProperty::valueTypeCoreIndex() const
-{
- return d->valueType.valueTypeCoreIdx;
-}
-
-Q_GLOBAL_STATIC(QmlValueTypeFactory, qmlValueTypes);
-
-
-struct SerializedData {
- QmlMetaProperty::Type type;
- QmlPropertyCache::Data core;
-};
-
-struct ValueTypeSerializedData : public SerializedData {
- QmlPropertyCache::ValueTypeData valueType;
-};
-
-QByteArray QmlMetaPropertyPrivate::saveValueType(const QMetaObject *metaObject, int index,
- const QMetaObject *subObject, int subIndex)
-{
- QMetaProperty prop = metaObject->property(index);
- QMetaProperty subProp = subObject->property(subIndex);
-
- ValueTypeSerializedData sd;
- sd.type = QmlMetaProperty::ValueTypeProperty;
- sd.core.load(metaObject->property(index));
- sd.valueType.flags = QmlPropertyCache::Data::flagsForProperty(subProp);
- sd.valueType.valueTypeCoreIdx = subIndex;
- sd.valueType.valueTypePropType = subProp.userType();
-
- QByteArray rv((const char *)&sd, sizeof(sd));
-
- return rv;
-}
-
-QByteArray QmlMetaPropertyPrivate::saveProperty(const QMetaObject *metaObject, int index)
-{
- SerializedData sd;
- sd.type = QmlMetaProperty::Property;
- sd.core.load(metaObject->property(index));
-
- QByteArray rv((const char *)&sd, sizeof(sd));
- return rv;
-}
-
-QmlMetaProperty
-QmlMetaPropertyPrivate::restore(const QByteArray &data, QObject *object, QmlContext *ctxt)
-{
- QmlMetaProperty prop;
-
- if (data.isEmpty())
- return prop;
-
- prop.d->object = object;
- prop.d->context = ctxt;
-
- const SerializedData *sd = (const SerializedData *)data.constData();
- if (sd->type == QmlMetaProperty::Property) {
- prop.d->core = sd->core;
- } else if(sd->type == QmlMetaProperty::ValueTypeProperty) {
- const ValueTypeSerializedData *vt = (const ValueTypeSerializedData *)sd;
- prop.d->core = vt->core;
- prop.d->valueType = vt->valueType;
- }
-
- return prop;
-}
-
-/*!
- \internal
-
- Creates a QmlMetaProperty for the property \a name of \a obj. Unlike
- the QmlMetaProperty(QObject*, QString, QmlContext*) constructor, this static function
- will correctly handle dot properties, including value types and attached properties.
-*/
-QmlMetaProperty QmlMetaProperty::createProperty(QObject *obj,
- const QString &name,
- QmlContext *context)
-{
- QmlTypeNameCache *typeNameCache = context?QmlContextPrivate::get(context)->imports:0;
-
- QStringList path = name.split(QLatin1Char('.'));
- QObject *object = obj;
-
- for (int jj = 0; jj < path.count() - 1; ++jj) {
- const QString &pathName = path.at(jj);
-
- if (QmlTypeNameCache::Data *data = typeNameCache?typeNameCache->data(pathName):0) {
- if (data->type) {
- QmlAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
- if (!func)
- return QmlMetaProperty();
- object = qmlAttachedPropertiesObjectById(data->type->index(), object);
- if (!object)
- return QmlMetaProperty();
- continue;
- } else {
- Q_ASSERT(data->typeNamespace);
- ++jj;
- data = data->typeNamespace->data(path.at(jj));
- if (!data || !data->type)
- return QmlMetaProperty();
- QmlAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
- if (!func)
- return QmlMetaProperty();
- object = qmlAttachedPropertiesObjectById(data->type->index(), object);
- if (!object)
- return QmlMetaProperty();
- continue;
- }
- }
-
- QmlMetaProperty prop(object, pathName, context);
-
- if (jj == path.count() - 2 && prop.propertyType() < (int)QVariant::UserType &&
- qmlValueTypes()->valueTypes[prop.propertyType()]) {
- // We're now at a value type property. We can use a global valuetypes array as we
- // never actually use the objects, just look up their properties.
- QObject *typeObject =
- qmlValueTypes()->valueTypes[prop.propertyType()];
- int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
- if (idx == -1)
- return QmlMetaProperty();
- QMetaProperty vtProp = typeObject->metaObject()->property(idx);
-
- QmlMetaProperty p = prop;
- p.d->valueType.valueTypeCoreIdx = idx;
- p.d->valueType.valueTypePropType = vtProp.userType();
- return p;
- }
-
- QObject *objVal = QmlMetaType::toQObject(prop.read());
- if (!objVal)
- return QmlMetaProperty();
- object = objVal;
- }
-
- const QString &propName = path.last();
- QmlMetaProperty prop(object, propName, context);
- if (!prop.isValid())
- return QmlMetaProperty();
- else
- return prop;
-}
-
-/*!
- Returns true if lhs and rhs refer to the same metaobject data
-*/
-bool QmlMetaPropertyPrivate::equal(const QMetaObject *lhs, const QMetaObject *rhs)
-{
- return lhs == rhs || (1 && lhs && rhs && lhs->d.stringdata == rhs->d.stringdata);
-}
-
-/*!
- Returns true if from inherits to.
-*/
-bool QmlMetaPropertyPrivate::canConvert(const QMetaObject *from, const QMetaObject *to)
-{
- if (from && to == &QObject::staticMetaObject)
- return true;
-
- while (from) {
- if (equal(from, to))
- return true;
- from = from->superClass();
- }
-
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h
deleted file mode 100644
index 82266c8..0000000
--- a/src/declarative/qml/qmlmetaproperty.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLMETAPROPERTY_H
-#define QMLMETAPROPERTY_H
-
-#include <QtCore/qmetaobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QObject;
-class QmlAbstractBinding;
-class QmlExpression;
-class QStringList;
-class QVariant;
-struct QMetaObject;
-class QmlContext;
-class QmlEngine;
-
-class QmlMetaPropertyPrivate;
-class Q_DECLARATIVE_EXPORT QmlMetaProperty
-{
-public:
- enum PropertyCategory {
- Unknown,
- InvalidProperty,
- Bindable,
- List,
- Object,
- Normal
- };
- QmlMetaProperty();
- QmlMetaProperty(QObject *);
- QmlMetaProperty(QObject *, const QString &);
- QmlMetaProperty(QObject *, QmlContext *);
- QmlMetaProperty(QObject *, const QString &, QmlContext *);
- QmlMetaProperty(const QmlMetaProperty &);
- QmlMetaProperty &operator=(const QmlMetaProperty &);
- ~QmlMetaProperty();
-
- QString name() const;
-
- QVariant read() const;
- bool write(const QVariant &) const;
- enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02 };
- Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
- bool write(const QVariant &, QmlMetaProperty::WriteFlags) const;
- bool reset() const;
-
- bool hasChangedNotifier() const;
- bool needsChangedNotifier() const;
- bool connectNotifier(QObject *dest, const char *slot) const;
- bool connectNotifier(QObject *dest, int method) const;
-
- QMetaMethod method() const;
-
- enum Type { Invalid = 0x00,
- Property = 0x01,
- SignalProperty = 0x02,
- Default = 0x08,
- Attached = 0x10,
- ValueTypeProperty = 0x20 };
-
- Type type() const;
- bool isProperty() const;
- bool isDefault() const;
- bool isWritable() const;
- bool isDesignable() const;
- bool isResettable() const;
- bool isValid() const;
- QObject *object() const;
-
- PropertyCategory propertyCategory() const;
-
- int propertyType() const;
- const char *propertyTypeName() const;
-
- bool operator==(const QmlMetaProperty &) const;
-
- QMetaProperty property() const;
-
- QmlAbstractBinding *binding() const;
- QmlAbstractBinding *setBinding(QmlAbstractBinding *,
- QmlMetaProperty::WriteFlags flags = QmlMetaProperty::DontRemoveBinding) const;
-
- QmlExpression *signalExpression() const;
- QmlExpression *setSignalExpression(QmlExpression *) const;
-
- static QmlMetaProperty createProperty(QObject *, const QString &, QmlContext *context=0);
-
- int coreIndex() const;
- int valueTypeCoreIndex() const;
-private:
- friend class QmlEnginePrivate;
- friend class QmlMetaPropertyPrivate;
- QmlMetaPropertyPrivate *d;
-};
-typedef QList<QmlMetaProperty> QmlMetaProperties;
- Q_DECLARE_OPERATORS_FOR_FLAGS(QmlMetaProperty::WriteFlags)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLMETAPROPERTY_H
diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h
deleted file mode 100644
index 9236bd3..0000000
--- a/src/declarative/qml/qmlmetaproperty_p.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLMETAPROPERTY_P_H
-#define QMLMETAPROPERTY_P_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 "qmlmetaproperty.h"
-
-#include "qmlpropertycache_p.h"
-#include "qmlguard_p.h"
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlContext;
-class QmlEnginePrivate;
-class QmlMetaPropertyPrivate
-{
-public:
- QmlMetaPropertyPrivate()
- : q(0), context(0), object(0), isDefaultProperty(false), isNameCached(false),
- attachedFunc(-1) {}
-
- QmlMetaPropertyPrivate(const QmlMetaPropertyPrivate &other)
- : q(0), context(other.context), object(other.object),
- isDefaultProperty(other.isDefaultProperty), isNameCached(other.isNameCached),
- core(other.core), nameCache(other.nameCache),
- valueType(other.valueType), attachedFunc(other.attachedFunc) {}
-
- QmlMetaProperty *q;
- QmlContext *context;
- QmlGuard<QObject> object;
-
- bool isDefaultProperty:1;
- bool isNameCached:1;
- QmlPropertyCache::Data core;
- QString nameCache;
-
- // Describes the "virtual" value-type sub-property.
- QmlPropertyCache::ValueTypeData valueType;
-
- // The attached property accessor
- int attachedFunc;
-
- void initProperty(QObject *obj, const QString &name);
- void initDefault(QObject *obj);
-
- QObject *attachedObject() const;
- QMetaMethod findSignal(QObject *, const QString &);
-
- int propertyType() const;
- QmlMetaProperty::PropertyCategory propertyCategory() const;
-
- QVariant readValueProperty();
- bool writeValueProperty(const QVariant &, QmlMetaProperty::WriteFlags);
-
- static const QMetaObject *rawMetaObjectForType(QmlEnginePrivate *, int);
- static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags);
- static bool write(QObject *, const QmlPropertyCache::Data &, const QVariant &, QmlContext *,
- QmlMetaProperty::WriteFlags flags = 0);
- static QmlAbstractBinding *setBinding(QObject *, const QmlPropertyCache::Data &, QmlAbstractBinding *,
- QmlMetaProperty::WriteFlags flags = QmlMetaProperty::DontRemoveBinding);
-
- static QByteArray saveValueType(const QMetaObject *, int,
- const QMetaObject *, int);
- static QByteArray saveProperty(const QMetaObject *, int);
- static QmlMetaProperty restore(const QByteArray &, QObject *, QmlContext * = 0);
-
- static bool equal(const QMetaObject *, const QMetaObject *);
- static bool canConvert(const QMetaObject *from, const QMetaObject *to);
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLMETAPROPERTY_P_H
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
deleted file mode 100644
index 6db70d4..0000000
--- a/src/declarative/qml/qmlmetatype.cpp
+++ /dev/null
@@ -1,1153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlmetatype.h"
-
-#include "qmlproxymetaobject_p.h"
-#include "qmlcustomparser_p.h"
-#include "qmlguard_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qmetaobject.h>
-#include <QtCore/qbitarray.h>
-#include <QtCore/qreadwritelock.h>
-#include <qmetatype.h>
-#include <qobjectdefs.h>
-#include <qdatetime.h>
-#include <qbytearray.h>
-#include <qreadwritelock.h>
-#include <qstring.h>
-#include <qstringlist.h>
-#include <qvector.h>
-#include <qlocale.h>
-#include <QtCore/qcryptographichash.h>
-#include <QtScript/qscriptvalue.h>
-
-#include <ctype.h>
-
-#ifdef QT_BOOTSTRAPPED
-# ifndef QT_NO_GEOM_VARIANT
-# define QT_NO_GEOM_VARIANT
-# endif
-#else
-# include <qbitarray.h>
-# include <qurl.h>
-# include <qvariant.h>
-#endif
-
-#ifndef QT_NO_GEOM_VARIANT
-# include <qsize.h>
-# include <qpoint.h>
-# include <qrect.h>
-# include <qline.h>
-# include <qvector3d.h>
-#endif
-#define NS(x) QT_PREPEND_NAMESPACE(x)
-
-QT_BEGIN_NAMESPACE
-
-struct QmlMetaTypeData
-{
- ~QmlMetaTypeData();
- QList<QmlType *> types;
- typedef QHash<int, QmlType *> Ids;
- Ids idToType;
- typedef QHash<QByteArray, QmlType *> Names;
- Names nameToType;
- typedef QHash<const QMetaObject *, QmlType *> MetaObjects;
- MetaObjects metaObjectToType;
- typedef QHash<int, QmlMetaType::StringConverter> StringConverters;
- StringConverters stringConverters;
-
- QBitArray objects;
- QBitArray interfaces;
- QBitArray lists;
-};
-Q_GLOBAL_STATIC(QmlMetaTypeData, metaTypeData)
-Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock)
-
-QmlMetaTypeData::~QmlMetaTypeData()
-{
- for (int i = 0; i < types.count(); ++i)
- delete types.at(i);
-}
-
-class QmlTypePrivate
-{
-public:
- QmlTypePrivate();
-
- void init() const;
-
- bool m_isInterface : 1;
- const char *m_iid;
- QByteArray m_name;
- int m_version_maj;
- int m_version_min;
- int m_typeId; int m_listId;
- QObject *(*m_newFunc)();
- const QMetaObject *m_baseMetaObject;
- QmlAttachedPropertiesFunc m_attachedPropertiesFunc;
- const QMetaObject *m_attachedPropertiesType;
- int m_parserStatusCast;
- int m_propertyValueSourceCast;
- int m_propertyValueInterceptorCast;
- QmlPrivate::CreateFunc m_extFunc;
- const QMetaObject *m_extMetaObject;
- int m_index;
- QmlCustomParser *m_customParser;
- mutable volatile bool m_isSetup:1;
- mutable QList<QmlProxyMetaObject::ProxyData> m_metaObjects;
-};
-
-QmlTypePrivate::QmlTypePrivate()
-: m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0),
- m_newFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_attachedPropertiesType(0),
- m_parserStatusCast(-1), m_propertyValueSourceCast(-1), m_propertyValueInterceptorCast(-1),
- m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0), m_isSetup(false)
-{
-}
-
-
-QmlType::QmlType(int type, int listType, const char *iid, int index)
-: d(new QmlTypePrivate)
-{
- d->m_isInterface = true;
- d->m_iid = iid;
- d->m_typeId = type;
- d->m_listId = listType;
- d->m_newFunc = 0;
- d->m_index = index;
- d->m_isSetup = true;
- d->m_version_maj = 0;
- d->m_version_min = 0;
-}
-
-QmlType::QmlType(int type, int listType,
- QObject *(*newFunc)(), const char *qmlName,
- int version_maj, int version_min,
- const QMetaObject *metaObject,
- QmlAttachedPropertiesFunc attachedPropertiesFunc,
- const QMetaObject *attachedType,
- int parserStatusCast, int propertyValueSourceCast, int propertyValueInterceptorCast,
- QmlPrivate::CreateFunc extFunc,
- const QMetaObject *extMetaObject, int index,
- QmlCustomParser *customParser)
-: d(new QmlTypePrivate)
-{
- d->m_name = qmlName;
- d->m_version_maj = version_maj;
- d->m_version_min = version_min;
- d->m_typeId = type;
- d->m_listId = listType;
- d->m_newFunc = newFunc;
- d->m_baseMetaObject = metaObject;
- d->m_attachedPropertiesFunc = attachedPropertiesFunc;
- d->m_attachedPropertiesType = attachedType;
- d->m_parserStatusCast = parserStatusCast;
- d->m_propertyValueSourceCast = propertyValueSourceCast;
- d->m_propertyValueInterceptorCast = propertyValueInterceptorCast;
- d->m_extFunc = extFunc;
- d->m_index = index;
- d->m_customParser = customParser;
-
- if (extMetaObject)
- d->m_extMetaObject = extMetaObject;
-}
-
-QmlType::~QmlType()
-{
- delete d->m_customParser;
- delete d;
-}
-
-int QmlType::majorVersion() const
-{
- return d->m_version_maj;
-}
-
-int QmlType::minorVersion() const
-{
- return d->m_version_min;
-}
-
-bool QmlType::availableInVersion(int vmajor, int vminor) const
-{
- return vmajor > d->m_version_maj || (vmajor == d->m_version_maj && vminor >= d->m_version_min);
-}
-
-void QmlTypePrivate::init() const
-{
- if (m_isSetup) return;
-
- QWriteLocker lock(metaTypeDataLock());
- if (m_isSetup)
- return;
-
- // Setup extended meta object
- // XXX - very inefficient
- const QMetaObject *mo = m_baseMetaObject;
- if (m_extFunc) {
- QMetaObject *mmo = new QMetaObject;
- *mmo = *m_extMetaObject;
- mmo->d.superdata = mo;
- QmlProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0, 0 };
- m_metaObjects << data;
- }
-
- mo = mo->d.superdata;
- while(mo) {
- QmlType *t = metaTypeData()->metaObjectToType.value(mo);
- if (t) {
- if (t->d->m_extFunc) {
- QMetaObject *mmo = new QMetaObject;
- *mmo = *t->d->m_extMetaObject;
- mmo->d.superdata = m_baseMetaObject;
- if (!m_metaObjects.isEmpty())
- m_metaObjects.last().metaObject->d.superdata = mmo;
- QmlProxyMetaObject::ProxyData data = { mmo, t->d->m_extFunc, 0, 0 };
- m_metaObjects << data;
- }
- }
- mo = mo->d.superdata;
- }
-
- for (int ii = 0; ii < m_metaObjects.count(); ++ii) {
- m_metaObjects[ii].propertyOffset =
- m_metaObjects.at(ii).metaObject->propertyOffset();
- m_metaObjects[ii].methodOffset =
- m_metaObjects.at(ii).metaObject->methodOffset();
- }
-
- m_isSetup = true;
- lock.unlock();
-}
-
-QByteArray QmlType::typeName() const
-{
- if (d->m_baseMetaObject)
- return d->m_baseMetaObject->className();
- else
- return QByteArray();
-}
-
-QByteArray QmlType::qmlTypeName() const
-{
- return d->m_name;
-}
-
-QObject *QmlType::create() const
-{
- d->init();
-
- QObject *rv = d->m_newFunc();
- if (rv && !d->m_metaObjects.isEmpty())
- (void *)new QmlProxyMetaObject(rv, &d->m_metaObjects);
-
- return rv;
-}
-
-QmlCustomParser *QmlType::customParser() const
-{
- return d->m_customParser;
-}
-
-bool QmlType::isInterface() const
-{
- return d->m_isInterface;
-}
-
-int QmlType::typeId() const
-{
- return d->m_typeId;
-}
-
-int QmlType::qListTypeId() const
-{
- return d->m_listId;
-}
-
-const QMetaObject *QmlType::metaObject() const
-{
- d->init();
-
- if (d->m_metaObjects.isEmpty())
- return d->m_baseMetaObject;
- else
- return d->m_metaObjects.first().metaObject;
-
-}
-
-const QMetaObject *QmlType::baseMetaObject() const
-{
- return d->m_baseMetaObject;
-}
-
-QmlAttachedPropertiesFunc QmlType::attachedPropertiesFunction() const
-{
- return d->m_attachedPropertiesFunc;
-}
-
-const QMetaObject *QmlType::attachedPropertiesType() const
-{
- return d->m_attachedPropertiesType;
-}
-
-int QmlType::parserStatusCast() const
-{
- return d->m_parserStatusCast;
-}
-
-int QmlType::propertyValueSourceCast() const
-{
- return d->m_propertyValueSourceCast;
-}
-
-int QmlType::propertyValueInterceptorCast() const
-{
- return d->m_propertyValueInterceptorCast;
-}
-
-const char *QmlType::interfaceIId() const
-{
- return d->m_iid;
-}
-
-int QmlType::index() const
-{
- return d->m_index;
-}
-
-int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id,
- const char *iid)
-{
- QWriteLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
-
- int index = data->types.count();
-
- QmlType *type = new QmlType(id.typeId, id.listId, iid, index);
-
- data->types.append(type);
- data->idToType.insert(type->typeId(), type);
- data->idToType.insert(type->qListTypeId(), type);
- // XXX No insertMulti, so no multi-version interfaces?
- if (!type->qmlTypeName().isEmpty())
- data->nameToType.insert(type->qmlTypeName(), type);
-
- if (data->interfaces.size() <= id.typeId)
- data->interfaces.resize(id.typeId + 16);
- if (data->lists.size() <= id.listId)
- data->lists.resize(id.listId + 16);
- data->interfaces.setBit(id.typeId, true);
- data->lists.setBit(id.listId, true);
-
- return index;
-}
-
-int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QObject *(*func)(),
- const char *uri, int version_maj, int version_min, const char *cname,
- const QMetaObject *mo, QmlAttachedPropertiesFunc attach, const QMetaObject *attachMo,
- int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *parser)
-{
- Q_UNUSED(object);
-
- if (cname) {
- for (int ii = 0; cname[ii]; ++ii) {
- if (!isalnum(cname[ii])) {
- qWarning("QmlMetaType: Invalid QML name %s", cname);
- return -1;
- }
- }
- }
-
- QWriteLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- int index = data->types.count();
-
- QByteArray name = uri;
- if (uri)
- name += '/';
- name += cname;
-
- QmlType *type = new QmlType(id.typeId, id.listId,
- func, name, version_maj, version_min, mo, attach, attachMo, pStatus,
- valueSource, valueInterceptor, extFunc, extmo, index, parser);
-
- data->types.append(type);
- data->idToType.insert(type->typeId(), type);
- data->idToType.insert(type->qListTypeId(), type);
-
- if (!type->qmlTypeName().isEmpty())
- data->nameToType.insertMulti(type->qmlTypeName(), type);
-
- data->metaObjectToType.insert(type->baseMetaObject(), type);
-
- if (data->objects.size() <= id.typeId)
- data->objects.resize(id.typeId + 16);
- if (data->lists.size() <= id.listId)
- data->lists.resize(id.listId + 16);
- data->objects.setBit(id.typeId, true);
- data->lists.setBit(id.listId, true);
-
- return index;
-}
-
-QObject *QmlMetaType::toQObject(const QVariant &v, bool *ok)
-{
- if (!isQObject(v.userType())) {
- if (ok) *ok = false;
- return 0;
- }
-
- if (ok) *ok = true;
-
- return *(QObject **)v.constData();
-}
-
-bool QmlMetaType::isQObject(int userType)
-{
- if (userType == QMetaType::QObjectStar)
- return true;
-
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- return userType >= 0 && userType < data->objects.size() && data->objects.testBit(userType);
-}
-
-/*
- Returns the item type for a list of type \a id.
- */
-int QmlMetaType::listType(int id)
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- QmlType *type = data->idToType.value(id);
- if (type && type->qListTypeId() == id)
- return type->typeId();
- else
- return 0;
-}
-
-int QmlMetaType::attachedPropertiesFuncId(const QMetaObject *mo)
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
-
- QmlType *type = data->metaObjectToType.value(mo);
- if (type && type->attachedPropertiesFunction())
- return type->index();
- else
- return -1;
-}
-
-QmlAttachedPropertiesFunc QmlMetaType::attachedPropertiesFuncById(int id)
-{
- if (id < 0)
- return 0;
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- return data->types.at(id)->attachedPropertiesFunction();
-}
-
-QMetaProperty QmlMetaType::defaultProperty(const QMetaObject *metaObject)
-{
- int idx = metaObject->indexOfClassInfo("DefaultProperty");
- if (-1 == idx)
- return QMetaProperty();
-
- QMetaClassInfo info = metaObject->classInfo(idx);
- if (!info.value())
- return QMetaProperty();
-
- idx = metaObject->indexOfProperty(info.value());
- if (-1 == idx)
- return QMetaProperty();
-
- return metaObject->property(idx);
-}
-
-QMetaProperty QmlMetaType::defaultProperty(QObject *obj)
-{
- if (!obj)
- return QMetaProperty();
-
- const QMetaObject *metaObject = obj->metaObject();
- return defaultProperty(metaObject);
-}
-
-QMetaMethod QmlMetaType::defaultMethod(const QMetaObject *metaObject)
-{
- int idx = metaObject->indexOfClassInfo("DefaultMethod");
- if (-1 == idx)
- return QMetaMethod();
-
- QMetaClassInfo info = metaObject->classInfo(idx);
- if (!info.value())
- return QMetaMethod();
-
- idx = metaObject->indexOfMethod(info.value());
- if (-1 == idx)
- return QMetaMethod();
-
- return metaObject->method(idx);
-}
-
-QMetaMethod QmlMetaType::defaultMethod(QObject *obj)
-{
- if (!obj)
- return QMetaMethod();
-
- const QMetaObject *metaObject = obj->metaObject();
- return defaultMethod(metaObject);
-}
-
-QmlMetaType::TypeCategory QmlMetaType::typeCategory(int userType)
-{
- if (userType < 0)
- return Unknown;
- if (userType == QMetaType::QObjectStar)
- return Object;
-
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- if (userType < data->objects.size() && data->objects.testBit(userType))
- return Object;
- else if (userType < data->lists.size() && data->lists.testBit(userType))
- return List;
- else
- return Unknown;
-}
-
-bool QmlMetaType::isInterface(int userType)
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- return userType >= 0 && userType < data->interfaces.size() && data->interfaces.testBit(userType);
-}
-
-const char *QmlMetaType::interfaceIId(int userType)
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- QmlType *type = data->idToType.value(userType);
- lock.unlock();
- if (type && type->isInterface() && type->typeId() == userType)
- return type->interfaceIId();
- else
- return 0;
-}
-
-bool QmlMetaType::isList(int userType)
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- return userType >= 0 && userType < data->lists.size() && data->lists.testBit(userType);
-}
-
-/*!
- A custom string convertor allows you to specify a function pointer that
- returns a variant of \a type. For example, if you have written your own icon
- class that you want to support as an object property assignable in QML:
-
- \code
- int type = qRegisterMetaType<SuperIcon>("SuperIcon");
- QML::addCustomStringConvertor(type, &SuperIcon::pixmapFromString);
- \endcode
-
- The function pointer must be of the form:
- \code
- QVariant (*StringConverter)(const QString &);
- \endcode
- */
-void QmlMetaType::registerCustomStringConverter(int type, StringConverter converter)
-{
- QWriteLocker lock(metaTypeDataLock());
-
- QmlMetaTypeData *data = metaTypeData();
- if (data->stringConverters.contains(type))
- return;
- data->stringConverters.insert(type, converter);
-}
-
-/*!
- Return the custom string converter for \a type, previously installed through
- registerCustomStringConverter()
- */
-QmlMetaType::StringConverter QmlMetaType::customStringConverter(int type)
-{
- QReadLocker lock(metaTypeDataLock());
-
- QmlMetaTypeData *data = metaTypeData();
- return data->stringConverters.value(type);
-}
-
-/*!
- Returns the type (if any) of URI-qualified named \a name in version specified
- by \a version_major and \a version_minor.
-*/
-QmlType *QmlMetaType::qmlType(const QByteArray &name, int version_major, int version_minor)
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
-
- QList<QmlType*> types = data->nameToType.values(name);
- foreach (QmlType *t, types) {
- // XXX version_major<0 just a kludge for QmlMetaPropertyPrivate::initProperty
- if (version_major<0 || t->availableInVersion(version_major,version_minor))
- return t;
- }
- return 0;
-}
-
-/*!
- Returns the type (if any) that corresponds to the \a metaObject. Returns null if no
- type is registered.
-*/
-QmlType *QmlMetaType::qmlType(const QMetaObject *metaObject)
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
-
- return data->metaObjectToType.value(metaObject);
-}
-
-/*!
- Returns the type (if any) that corresponds to the QVariant::Type \a userType.
- Returns null if no type is registered.
-*/
-QmlType *QmlMetaType::qmlType(int userType)
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
-
- QmlType *type = data->idToType.value(userType);
- if (type && type->typeId() == userType)
- return type;
- else
- return 0;
-}
-
-/*!
- Returns the list of registered QML type names.
-*/
-QList<QByteArray> QmlMetaType::qmlTypeNames()
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
-
- return data->nameToType.keys();
-}
-
-/*!
- Returns the list of registered QML types.
-*/
-QList<QmlType*> QmlMetaType::qmlTypes()
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
-
- return data->nameToType.values();
-}
-
-QT_END_NAMESPACE
-
-#include <QtGui/qfont.h>
-#include <QtGui/qpixmap.h>
-#include <QtGui/qbrush.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qpalette.h>
-#include <QtGui/qicon.h>
-#include <QtGui/qimage.h>
-#include <QtGui/qpolygon.h>
-#include <QtGui/qregion.h>
-#include <QtGui/qbitmap.h>
-#include <QtGui/qcursor.h>
-#include <QtGui/qsizepolicy.h>
-#include <QtGui/qkeysequence.h>
-#include <QtGui/qpen.h>
-
-//#include <QtGui/qtextlength.h>
-#include <QtGui/qtextformat.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qtransform.h>
-#include <QtGui/qmatrix4x4.h>
-#include <QtGui/qvector2d.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-#include <QtGui/qquaternion.h>
-
-Q_DECLARE_METATYPE(QScriptValue);
-
-QT_BEGIN_NAMESPACE
-/*!
- Copies \a copy into \a data, assuming they both are of type \a type. If
- \a copy is zero, a default type is copied. Returns true if the copy was
- successful and false if not.
-
- \note This should move into QMetaType once complete
-
-*/
-bool QmlMetaType::copy(int type, void *data, const void *copy)
-{
- if (copy) {
- switch(type) {
- case QMetaType::VoidStar:
- case QMetaType::QObjectStar:
- case QMetaType::QWidgetStar:
- *static_cast<void **>(data) = *static_cast<void* const *>(copy);
- return true;
- case QMetaType::Long:
- *static_cast<long *>(data) = *static_cast<const long*>(copy);
- return true;
- case QMetaType::Int:
- *static_cast<int *>(data) = *static_cast<const int*>(copy);
- return true;
- case QMetaType::Short:
- *static_cast<short *>(data) = *static_cast<const short*>(copy);
- return true;
- case QMetaType::Char:
- *static_cast<char *>(data) = *static_cast<const char*>(copy);
- return true;
- case QMetaType::ULong:
- *static_cast<ulong *>(data) = *static_cast<const ulong*>(copy);
- return true;
- case QMetaType::UInt:
- *static_cast<uint *>(data) = *static_cast<const uint*>(copy);
- return true;
- case QMetaType::LongLong:
- *static_cast<qlonglong *>(data) = *static_cast<const qlonglong*>(copy);
- return true;
- case QMetaType::ULongLong:
- *static_cast<qulonglong *>(data) = *static_cast<const qulonglong*>(copy);
- return true;
- case QMetaType::UShort:
- *static_cast<ushort *>(data) = *static_cast<const ushort*>(copy);
- return true;
- case QMetaType::UChar:
- *static_cast<uchar *>(data) = *static_cast<const uchar*>(copy);
- return true;
- case QMetaType::Bool:
- *static_cast<bool *>(data) = *static_cast<const bool*>(copy);
- return true;
- case QMetaType::Float:
- *static_cast<float *>(data) = *static_cast<const float*>(copy);
- return true;
- case QMetaType::Double:
- *static_cast<double *>(data) = *static_cast<const double*>(copy);
- return true;
- case QMetaType::QChar:
- *static_cast<NS(QChar) *>(data) = *static_cast<const NS(QChar)*>(copy);
- return true;
- case QMetaType::QVariantMap:
- *static_cast<NS(QVariantMap) *>(data) = *static_cast<const NS(QVariantMap)*>(copy);
- return true;
- case QMetaType::QVariantHash:
- *static_cast<NS(QVariantHash) *>(data) = *static_cast<const NS(QVariantHash)*>(copy);
- return true;
- case QMetaType::QVariantList:
- *static_cast<NS(QVariantList) *>(data) = *static_cast<const NS(QVariantList)*>(copy);
- return true;
- case QMetaType::QByteArray:
- *static_cast<NS(QByteArray) *>(data) = *static_cast<const NS(QByteArray)*>(copy);
- return true;
- case QMetaType::QString:
- *static_cast<NS(QString) *>(data) = *static_cast<const NS(QString)*>(copy);
- return true;
- case QMetaType::QStringList:
- *static_cast<NS(QStringList) *>(data) = *static_cast<const NS(QStringList)*>(copy);
- return true;
- case QMetaType::QBitArray:
- *static_cast<NS(QBitArray) *>(data) = *static_cast<const NS(QBitArray)*>(copy);
- return true;
- case QMetaType::QDate:
- *static_cast<NS(QDate) *>(data) = *static_cast<const NS(QDate)*>(copy);
- return true;
- case QMetaType::QTime:
- *static_cast<NS(QTime) *>(data) = *static_cast<const NS(QTime)*>(copy);
- return true;
- case QMetaType::QDateTime:
- *static_cast<NS(QDateTime) *>(data) = *static_cast<const NS(QDateTime)*>(copy);
- return true;
- case QMetaType::QUrl:
- *static_cast<NS(QUrl) *>(data) = *static_cast<const NS(QUrl)*>(copy);
- return true;
- case QMetaType::QLocale:
- *static_cast<NS(QLocale) *>(data) = *static_cast<const NS(QLocale)*>(copy);
- return true;
- case QMetaType::QRect:
- *static_cast<NS(QRect) *>(data) = *static_cast<const NS(QRect)*>(copy);
- return true;
- case QMetaType::QRectF:
- *static_cast<NS(QRectF) *>(data) = *static_cast<const NS(QRectF)*>(copy);
- return true;
- case QMetaType::QSize:
- *static_cast<NS(QSize) *>(data) = *static_cast<const NS(QSize)*>(copy);
- return true;
- case QMetaType::QSizeF:
- *static_cast<NS(QSizeF) *>(data) = *static_cast<const NS(QSizeF)*>(copy);
- return true;
- case QMetaType::QLine:
- *static_cast<NS(QLine) *>(data) = *static_cast<const NS(QLine)*>(copy);
- return true;
- case QMetaType::QLineF:
- *static_cast<NS(QLineF) *>(data) = *static_cast<const NS(QLineF)*>(copy);
- return true;
- case QMetaType::QPoint:
- *static_cast<NS(QPoint) *>(data) = *static_cast<const NS(QPoint)*>(copy);
- return true;
- case QMetaType::QPointF:
- *static_cast<NS(QPointF) *>(data) = *static_cast<const NS(QPointF)*>(copy);
- return true;
- case QMetaType::QVector3D:
- *static_cast<NS(QVector3D) *>(data) = *static_cast<const NS(QVector3D)*>(copy);
- return true;
-#ifndef QT_NO_REGEXP
- case QMetaType::QRegExp:
- *static_cast<NS(QRegExp) *>(data) = *static_cast<const NS(QRegExp)*>(copy);
- return true;
-#endif
- case QMetaType::Void:
- return true;
-
-
-#ifdef QT3_SUPPORT
- case QMetaType::QColorGroup:
- *static_cast<NS(QColorGroup) *>(data) = *static_cast<const NS(QColorGroup)*>(copy);
- return true;
-#endif
-
- case QMetaType::QFont:
- *static_cast<NS(QFont) *>(data) = *static_cast<const NS(QFont)*>(copy);
- return true;
- case QMetaType::QPixmap:
- *static_cast<NS(QPixmap) *>(data) = *static_cast<const NS(QPixmap)*>(copy);
- return true;
- case QMetaType::QBrush:
- *static_cast<NS(QBrush) *>(data) = *static_cast<const NS(QBrush)*>(copy);
- return true;
- case QMetaType::QColor:
- *static_cast<NS(QColor) *>(data) = *static_cast<const NS(QColor)*>(copy);
- return true;
- case QMetaType::QPalette:
- *static_cast<NS(QPalette) *>(data) = *static_cast<const NS(QPalette)*>(copy);
- return true;
- case QMetaType::QIcon:
- *static_cast<NS(QIcon) *>(data) = *static_cast<const NS(QIcon)*>(copy);
- return true;
- case QMetaType::QImage:
- *static_cast<NS(QImage) *>(data) = *static_cast<const NS(QImage)*>(copy);
- return true;
- case QMetaType::QPolygon:
- *static_cast<NS(QPolygon) *>(data) = *static_cast<const NS(QPolygon)*>(copy);
- return true;
- case QMetaType::QRegion:
- *static_cast<NS(QRegion) *>(data) = *static_cast<const NS(QRegion)*>(copy);
- return true;
- case QMetaType::QBitmap:
- *static_cast<NS(QBitmap) *>(data) = *static_cast<const NS(QBitmap)*>(copy);
- return true;
-#ifndef QT_NO_CURSOR
- case QMetaType::QCursor:
- *static_cast<NS(QCursor) *>(data) = *static_cast<const NS(QCursor)*>(copy);
- return true;
-#endif
- case QMetaType::QSizePolicy:
- *static_cast<NS(QSizePolicy) *>(data) = *static_cast<const NS(QSizePolicy)*>(copy);
- return true;
- case QMetaType::QKeySequence:
- *static_cast<NS(QKeySequence) *>(data) = *static_cast<const NS(QKeySequence)*>(copy);
- return true;
- case QMetaType::QPen:
- *static_cast<NS(QPen) *>(data) = *static_cast<const NS(QPen)*>(copy);
- return true;
- case QMetaType::QTextLength:
- *static_cast<NS(QTextLength) *>(data) = *static_cast<const NS(QTextLength)*>(copy);
- return true;
- case QMetaType::QTextFormat:
- *static_cast<NS(QTextFormat) *>(data) = *static_cast<const NS(QTextFormat)*>(copy);
- return true;
- case QMetaType::QMatrix:
- *static_cast<NS(QMatrix) *>(data) = *static_cast<const NS(QMatrix)*>(copy);
- return true;
- case QMetaType::QTransform:
- *static_cast<NS(QTransform) *>(data) = *static_cast<const NS(QTransform)*>(copy);
- return true;
- case QMetaType::QMatrix4x4:
- *static_cast<NS(QMatrix4x4) *>(data) = *static_cast<const NS(QMatrix4x4)*>(copy);
- return true;
- case QMetaType::QVector2D:
- *static_cast<NS(QVector2D) *>(data) = *static_cast<const NS(QVector2D)*>(copy);
- return true;
- case QMetaType::QVector4D:
- *static_cast<NS(QVector4D) *>(data) = *static_cast<const NS(QVector4D)*>(copy);
- return true;
- case QMetaType::QQuaternion:
- *static_cast<NS(QQuaternion) *>(data) = *static_cast<const NS(QQuaternion)*>(copy);
- return true;
-
- default:
- if (type == qMetaTypeId<QVariant>()) {
- *static_cast<NS(QVariant) *>(data) = *static_cast<const NS(QVariant)*>(copy);
- return true;
- } else if (type == qMetaTypeId<QScriptValue>()) {
- *static_cast<NS(QScriptValue) *>(data) = *static_cast<const NS(QScriptValue)*>(copy);
- return true;
- } else if (typeCategory(type) != Unknown) {
- *static_cast<void **>(data) = *static_cast<void* const *>(copy);
- return true;
- }
- break;
- }
- } else {
- switch(type) {
- case QMetaType::VoidStar:
- case QMetaType::QObjectStar:
- case QMetaType::QWidgetStar:
- *static_cast<void **>(data) = 0;
- return true;
- case QMetaType::Long:
- *static_cast<long *>(data) = long(0);
- return true;
- case QMetaType::Int:
- *static_cast<int *>(data) = int(0);
- return true;
- case QMetaType::Short:
- *static_cast<short *>(data) = short(0);
- return true;
- case QMetaType::Char:
- *static_cast<char *>(data) = char(0);
- return true;
- case QMetaType::ULong:
- *static_cast<ulong *>(data) = ulong(0);
- return true;
- case QMetaType::UInt:
- *static_cast<uint *>(data) = uint(0);
- return true;
- case QMetaType::LongLong:
- *static_cast<qlonglong *>(data) = qlonglong(0);
- return true;
- case QMetaType::ULongLong:
- *static_cast<qulonglong *>(data) = qulonglong(0);
- return true;
- case QMetaType::UShort:
- *static_cast<ushort *>(data) = ushort(0);
- return true;
- case QMetaType::UChar:
- *static_cast<uchar *>(data) = uchar(0);
- return true;
- case QMetaType::Bool:
- *static_cast<bool *>(data) = bool(false);
- return true;
- case QMetaType::Float:
- *static_cast<float *>(data) = float(0);
- return true;
- case QMetaType::Double:
- *static_cast<double *>(data) = double();
- return true;
- case QMetaType::QChar:
- *static_cast<NS(QChar) *>(data) = NS(QChar)();
- return true;
- case QMetaType::QVariantMap:
- *static_cast<NS(QVariantMap) *>(data) = NS(QVariantMap)();
- return true;
- case QMetaType::QVariantHash:
- *static_cast<NS(QVariantHash) *>(data) = NS(QVariantHash)();
- return true;
- case QMetaType::QVariantList:
- *static_cast<NS(QVariantList) *>(data) = NS(QVariantList)();
- return true;
- case QMetaType::QByteArray:
- *static_cast<NS(QByteArray) *>(data) = NS(QByteArray)();
- return true;
- case QMetaType::QString:
- *static_cast<NS(QString) *>(data) = NS(QString)();
- return true;
- case QMetaType::QStringList:
- *static_cast<NS(QStringList) *>(data) = NS(QStringList)();
- return true;
- case QMetaType::QBitArray:
- *static_cast<NS(QBitArray) *>(data) = NS(QBitArray)();
- return true;
- case QMetaType::QDate:
- *static_cast<NS(QDate) *>(data) = NS(QDate)();
- return true;
- case QMetaType::QTime:
- *static_cast<NS(QTime) *>(data) = NS(QTime)();
- return true;
- case QMetaType::QDateTime:
- *static_cast<NS(QDateTime) *>(data) = NS(QDateTime)();
- return true;
- case QMetaType::QUrl:
- *static_cast<NS(QUrl) *>(data) = NS(QUrl)();
- return true;
- case QMetaType::QLocale:
- *static_cast<NS(QLocale) *>(data) = NS(QLocale)();
- return true;
- case QMetaType::QRect:
- *static_cast<NS(QRect) *>(data) = NS(QRect)();
- return true;
- case QMetaType::QRectF:
- *static_cast<NS(QRectF) *>(data) = NS(QRectF)();
- return true;
- case QMetaType::QSize:
- *static_cast<NS(QSize) *>(data) = NS(QSize)();
- return true;
- case QMetaType::QSizeF:
- *static_cast<NS(QSizeF) *>(data) = NS(QSizeF)();
- return true;
- case QMetaType::QLine:
- *static_cast<NS(QLine) *>(data) = NS(QLine)();
- return true;
- case QMetaType::QLineF:
- *static_cast<NS(QLineF) *>(data) = NS(QLineF)();
- return true;
- case QMetaType::QPoint:
- *static_cast<NS(QPoint) *>(data) = NS(QPoint)();
- return true;
- case QMetaType::QPointF:
- *static_cast<NS(QPointF) *>(data) = NS(QPointF)();
- return true;
- case QMetaType::QVector3D:
- *static_cast<NS(QVector3D) *>(data) = NS(QVector3D)();
- return true;
-#ifndef QT_NO_REGEXP
- case QMetaType::QRegExp:
- *static_cast<NS(QRegExp) *>(data) = NS(QRegExp)();
- return true;
-#endif
- case QMetaType::Void:
- return true;
-
-#ifdef QT3_SUPPORT
- case QMetaType::QColorGroup:
- *static_cast<NS(QColorGroup) *>(data) = NS(QColorGroup)();
- return true;
-#endif
-
- case QMetaType::QFont:
- *static_cast<NS(QFont) *>(data) = NS(QFont)();
- return true;
- case QMetaType::QPixmap:
- *static_cast<NS(QPixmap) *>(data) = NS(QPixmap)();
- return true;
- case QMetaType::QBrush:
- *static_cast<NS(QBrush) *>(data) = NS(QBrush)();
- return true;
- case QMetaType::QColor:
- *static_cast<NS(QColor) *>(data) = NS(QColor)();
- return true;
- case QMetaType::QPalette:
- *static_cast<NS(QPalette) *>(data) = NS(QPalette)();
- return true;
- case QMetaType::QIcon:
- *static_cast<NS(QIcon) *>(data) = NS(QIcon)();
- return true;
- case QMetaType::QImage:
- *static_cast<NS(QImage) *>(data) = NS(QImage)();
- return true;
- case QMetaType::QPolygon:
- *static_cast<NS(QPolygon) *>(data) = NS(QPolygon)();
- return true;
- case QMetaType::QRegion:
- *static_cast<NS(QRegion) *>(data) = NS(QRegion)();
- return true;
- case QMetaType::QBitmap:
- *static_cast<NS(QBitmap) *>(data) = NS(QBitmap)();
- return true;
-#ifndef QT_NO_CURSOR
- case QMetaType::QCursor:
- *static_cast<NS(QCursor) *>(data) = NS(QCursor)();
- return true;
-#endif
- case QMetaType::QSizePolicy:
- *static_cast<NS(QSizePolicy) *>(data) = NS(QSizePolicy)();
- return true;
- case QMetaType::QKeySequence:
- *static_cast<NS(QKeySequence) *>(data) = NS(QKeySequence)();
- return true;
- case QMetaType::QPen:
- *static_cast<NS(QPen) *>(data) = NS(QPen)();
- return true;
- case QMetaType::QTextLength:
- *static_cast<NS(QTextLength) *>(data) = NS(QTextLength)();
- return true;
- case QMetaType::QTextFormat:
- *static_cast<NS(QTextFormat) *>(data) = NS(QTextFormat)();
- return true;
- case QMetaType::QMatrix:
- *static_cast<NS(QMatrix) *>(data) = NS(QMatrix)();
- return true;
- case QMetaType::QTransform:
- *static_cast<NS(QTransform) *>(data) = NS(QTransform)();
- return true;
- case QMetaType::QMatrix4x4:
- *static_cast<NS(QMatrix4x4) *>(data) = NS(QMatrix4x4)();
- return true;
- case QMetaType::QVector2D:
- *static_cast<NS(QVector2D) *>(data) = NS(QVector2D)();
- return true;
- case QMetaType::QVector4D:
- *static_cast<NS(QVector4D) *>(data) = NS(QVector4D)();
- return true;
- case QMetaType::QQuaternion:
- *static_cast<NS(QQuaternion) *>(data) = NS(QQuaternion)();
- return true;
- default:
- if (type == qMetaTypeId<QVariant>()) {
- *static_cast<NS(QVariant) *>(data) = NS(QVariant)();
- return true;
- } else if (type == qMetaTypeId<QScriptValue>()) {
- *static_cast<NS(QScriptValue) *>(data) = NS(QScriptValue)();
- return true;
- } else if (typeCategory(type) != Unknown) {
- *static_cast<void **>(data) = 0;
- return true;
- }
- break;
- }
- }
-
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h
deleted file mode 100644
index 98d04c1..0000000
--- a/src/declarative/qml/qmlmetatype.h
+++ /dev/null
@@ -1,281 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLMETATYPE_H
-#define QMLMETATYPE_H
-
-#include "qmlprivate.h"
-#include "qmlparserstatus.h"
-#include "qmlpropertyvaluesource.h"
-#include "qmlpropertyvalueinterceptor.h"
-#include "qmllist.h"
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qbitarray.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlType;
-class QmlCustomParser;
-class Q_DECLARATIVE_EXPORT QmlMetaType
-{
-public:
- static int registerType(const QmlPrivate::MetaTypeIds &, QObject *(*)(), const char *, int vmaj, int vmin, const char *qmlName, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *);
- static int registerInterface(const QmlPrivate::MetaTypeIds &, const char *);
-
- static bool copy(int type, void *data, const void *copy = 0);
-
- static QList<QByteArray> qmlTypeNames();
- static QList<QmlType*> qmlTypes();
-
- static QmlType *qmlType(const QByteArray &, int, int);
- static QmlType *qmlType(const QMetaObject *);
- static QmlType *qmlType(int);
-
- static QMetaProperty defaultProperty(const QMetaObject *);
- static QMetaProperty defaultProperty(QObject *);
- static QMetaMethod defaultMethod(const QMetaObject *);
- static QMetaMethod defaultMethod(QObject *);
-
- static bool isQObject(int);
- static QObject *toQObject(const QVariant &, bool *ok = 0);
-
- static int listType(int);
- static int attachedPropertiesFuncId(const QMetaObject *);
- static QmlAttachedPropertiesFunc attachedPropertiesFuncById(int);
-
- enum TypeCategory { Unknown, Object, List };
- static TypeCategory typeCategory(int);
-
- static bool isInterface(int);
- static const char *interfaceIId(int);
- static bool isList(int);
-
- typedef QVariant (*StringConverter)(const QString &);
- static void registerCustomStringConverter(int, StringConverter);
- static StringConverter customStringConverter(int);
-};
-
-class QmlTypePrivate;
-class Q_DECLARATIVE_EXPORT QmlType
-{
-public:
- QByteArray typeName() const;
- QByteArray qmlTypeName() const;
-
- int majorVersion() const;
- int minorVersion() const;
- bool availableInVersion(int vmajor, int vminor) const;
-
- QObject *create() const;
-
- QmlCustomParser *customParser() const;
-
- bool isInterface() const;
- int typeId() const;
- int qListTypeId() const;
-
- const QMetaObject *metaObject() const;
- const QMetaObject *baseMetaObject() const;
-
- QmlAttachedPropertiesFunc attachedPropertiesFunction() const;
- const QMetaObject *attachedPropertiesType() const;
-
- int parserStatusCast() const;
- QVariant fromObject(QObject *) const;
- const char *interfaceIId() const;
- int propertyValueSourceCast() const;
- int propertyValueInterceptorCast() const;
-
- int index() const;
-private:
- friend class QmlMetaType;
- friend class QmlTypePrivate;
- friend struct QmlMetaTypeData;
- QmlType(int, int, const char *, int);
- QmlType(int, int, QObject *(*)(), const char *, int, int, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int, int, int, QmlPrivate::CreateFunc, const QMetaObject *, int, QmlCustomParser *);
- ~QmlType();
-
- QmlTypePrivate *d;
-};
-
-template<typename T>
-int qmlRegisterType(const char *typeName)
-{
- QByteArray name(typeName);
- QmlPrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
- };
-
- return QmlMetaType::registerType(ids, 0, 0, 0, 0, 0,
- &T::staticMetaObject,
- QmlPrivate::attachedPropertiesFunc<T>(),
- QmlPrivate::attachedPropertiesMetaObject<T>(),
- QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
- QmlPrivate::StaticCastSelector<T,QObject>::cast(),
- QmlPrivate::StaticCastSelector<T,QmlPropertyValueSource>::cast(),
- QmlPrivate::StaticCastSelector<T,QmlPropertyValueInterceptor>::cast(),
- 0, 0, 0);
-}
-
-template<typename T>
-int qmlRegisterType(const char *uri, int version_maj, int version_min, const char *qmlName, const char *typeName)
-{
- QByteArray name(typeName);
- QmlPrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
- };
-
- return QmlMetaType::registerType(ids, QmlPrivate::create<T>,
- uri, version_maj, version_min, qmlName,
- &T::staticMetaObject,
- QmlPrivate::attachedPropertiesFunc<T>(),
- QmlPrivate::attachedPropertiesMetaObject<T>(),
- QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
- QmlPrivate::StaticCastSelector<T,QObject>::cast(),
- QmlPrivate::StaticCastSelector<T,QmlPropertyValueSource>::cast(),
- QmlPrivate::StaticCastSelector<T,QmlPropertyValueInterceptor>::cast(),
- 0, 0, 0);
-}
-
-template<typename T, typename E>
-int qmlRegisterExtendedType(const char *typeName)
-{
- QByteArray name(typeName);
- QmlPrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
- };
-
- QmlAttachedPropertiesFunc attached =
- QmlPrivate::attachedPropertiesFunc<E>();
- const QMetaObject * attachedMo =
- QmlPrivate::attachedPropertiesMetaObject<E>();
- if (!attached) {
- attached = QmlPrivate::attachedPropertiesFunc<T>();
- attachedMo = QmlPrivate::attachedPropertiesMetaObject<T>();
- }
-
- return QmlMetaType::registerType(ids, 0, 0, 0, 0, 0,
- &T::staticMetaObject, attached, attachedMo,
- QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
- QmlPrivate::StaticCastSelector<T,QObject>::cast(),
- QmlPrivate::StaticCastSelector<T,QmlPropertyValueSource>::cast(),
- QmlPrivate::StaticCastSelector<T,QmlPropertyValueInterceptor>::cast(),
- &QmlPrivate::CreateParent<E>::create, &E::staticMetaObject, 0);
-}
-
-template<typename T, typename E>
-int qmlRegisterExtendedType(const char *uri, int version_maj, int version_min, const char *qmlName, const char *typeName)
-{
- QByteArray name(typeName);
- QmlPrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
- };
-
- QmlAttachedPropertiesFunc attached =
- QmlPrivate::attachedPropertiesFunc<E>();
- const QMetaObject * attachedMo =
- QmlPrivate::attachedPropertiesMetaObject<E>();
- if (!attached) {
- attached = QmlPrivate::attachedPropertiesFunc<T>();
- attachedMo = QmlPrivate::attachedPropertiesMetaObject<T>();
- }
-
- return QmlMetaType::registerType(ids, QmlPrivate::create<T>,
- uri, version_maj, version_min, qmlName,
- &T::staticMetaObject,
- attached, attachedMo,
- QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
- QmlPrivate::StaticCastSelector<T,QObject>::cast(),
- QmlPrivate::StaticCastSelector<T,QmlPropertyValueSource>::cast(),
- QmlPrivate::StaticCastSelector<T,QmlPropertyValueInterceptor>::cast(),
- &QmlPrivate::CreateParent<E>::create,
- &E::staticMetaObject, 0);
-}
-
-template<typename T>
-int qmlRegisterInterface(const char *typeName)
-{
- QByteArray name(typeName);
- QmlPrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
- };
-
- return QmlMetaType::registerInterface(ids, qobject_interface_iid<T *>());
-}
-
-template<typename T>
-int qmlRegisterCustomType(const char *uri, int version_maj, int version_min, const char *qmlName, const char *typeName, QmlCustomParser *parser)
-{
- QByteArray name(typeName);
- QmlPrivate::MetaTypeIds ids = {
- qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
- };
-
- return QmlMetaType::registerType(ids, QmlPrivate::create<T>,
- uri, version_maj, version_min, qmlName,
- &T::staticMetaObject,
- QmlPrivate::attachedPropertiesFunc<T>(),
- QmlPrivate::attachedPropertiesMetaObject<T>(),
- QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
- QmlPrivate::StaticCastSelector<T,QObject>::cast(),
- QmlPrivate::StaticCastSelector<T,QmlPropertyValueSource>::cast(),
- QmlPrivate::StaticCastSelector<T,QmlPropertyValueInterceptor>::cast(),
- 0, 0, parser);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLMETATYPE_H
-
diff --git a/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp b/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp
deleted file mode 100644
index 455d09e..0000000
--- a/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlnetworkaccessmanagerfactory.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlNetworkAccessManagerFactory
- \since 4.7
- \brief The QmlNetworkAccessManagerFactory class provides a factory for QNetworkAccessManager
-
- QNetworkAccessManager is used for all network access by QML.
- By implementing a factory it is possible to create custom
- QNetworkAccessManager with specialized caching, proxy and
- cookie support.
-
- To implement a factory, subclass QmlNetworkAccessManagerFactory and implement
- the create() method.
-
- If the created QNetworkAccessManager becomes invalid, due to a
- change in proxy settings, for example, call the invalidate() method.
- This will cause all QNetworkAccessManagers to be recreated.
-
- Note: the create() method may be called by multiple threads, so ensure the
- implementation of this method is reentrant.
-*/
-
-/*!
- The destructor is empty.
- */
-QmlNetworkAccessManagerFactory::~QmlNetworkAccessManagerFactory()
-{
-}
-
-/*!
- \fn QNetworkAccessManager *QmlNetworkAccessManagerFactory::create(QObject *parent)
-
- Implement this method to create a QNetworkAccessManager with \a parent.
- This allows proxies, caching and cookie support to be setup appropriately.
-
- Note: this method may be called by multiple threads, so ensure the
- implementation of this method is reentrant.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlnetworkaccessmanagerfactory.h b/src/declarative/qml/qmlnetworkaccessmanagerfactory.h
deleted file mode 100644
index 1660929..0000000
--- a/src/declarative/qml/qmlnetworkaccessmanagerfactory.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLNETWORKACCESSMANAGERFACTORY_H
-#define QMLNETWORKACCESSMANAGERFACTORY_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QNetworkAccessManager;
-class Q_DECLARATIVE_EXPORT QmlNetworkAccessManagerFactory
-{
-public:
- virtual ~QmlNetworkAccessManagerFactory();
- virtual QNetworkAccessManager *create(QObject *parent) = 0;
-
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLNETWORKACCESSMANAGERFACTORY_H
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp
deleted file mode 100644
index 155a7d6..0000000
--- a/src/declarative/qml/qmlobjectscriptclass.cpp
+++ /dev/null
@@ -1,673 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlobjectscriptclass_p.h"
-
-#include "qmlengine_p.h"
-#include "qmlcontext_p.h"
-#include "qmldeclarativedata_p.h"
-#include "qmltypenamescriptclass_p.h"
-#include "qmllistscriptclass_p.h"
-#include "qmlbinding_p.h"
-#include "qmlguard_p.h"
-#include "qmlvmemetaobject_p.h"
-
-#include <QtCore/qtimer.h>
-#include <QtCore/qvarlengtharray.h>
-
-Q_DECLARE_METATYPE(QScriptValue);
-
-QT_BEGIN_NAMESPACE
-
-struct ObjectData : public QScriptDeclarativeClass::Object {
- ObjectData(QObject *o, int t) : object(o), type(t) {}
- QmlGuard<QObject> object;
- int type;
-};
-
-/*
- The QmlObjectScriptClass handles property access for QObjects
- via QtScript. It is also used to provide a more useful API in
- QtScript for QML.
- */
-QmlObjectScriptClass::QmlObjectScriptClass(QmlEngine *bindEngine)
-: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)),
-#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
- methods(bindEngine),
-#endif
- lastData(0), engine(bindEngine)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- m_destroy = scriptEngine->newFunction(destroy);
- m_destroyId = createPersistentIdentifier(QLatin1String("destroy"));
- m_toString = scriptEngine->newFunction(tostring);
- m_toStringId = createPersistentIdentifier(QLatin1String("toString"));
-}
-
-QmlObjectScriptClass::~QmlObjectScriptClass()
-{
-}
-
-QScriptValue QmlObjectScriptClass::newQObject(QObject *object, int type)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- if (!object)
- return newObject(scriptEngine, this, new ObjectData(object, type));
-
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(object, true);
-
- if (!ddata->scriptValue.isValid()) {
- ddata->scriptValue = newObject(scriptEngine, this, new ObjectData(object, type));
- return ddata->scriptValue;
- } else if (ddata->scriptValue.engine() == QmlEnginePrivate::getScriptEngine(engine)) {
- return ddata->scriptValue;
- } else {
- return newObject(scriptEngine, this, new ObjectData(object, type));
- }
-}
-
-QObject *QmlObjectScriptClass::toQObject(const QScriptValue &value) const
-{
- return value.toQObject();
-}
-
-int QmlObjectScriptClass::objectType(const QScriptValue &value) const
-{
- if (scriptClass(value) != this)
- return QVariant::Invalid;
-
- Object *o = object(value);
- return ((ObjectData*)(o))->type;
-}
-
-QScriptClass::QueryFlags
-QmlObjectScriptClass::queryProperty(Object *object, const Identifier &name,
- QScriptClass::QueryFlags flags)
-{
- return queryProperty(toQObject(object), name, flags, 0);
-}
-
-QScriptClass::QueryFlags
-QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name,
- QScriptClass::QueryFlags flags, QmlContext *evalContext,
- QueryHints hints)
-{
- Q_UNUSED(flags);
- lastData = 0;
- lastTNData = 0;
-
- if (name == m_destroyId.identifier ||
- name == m_toStringId.identifier)
- return QScriptClass::HandlesReadAccess;
-
- if (!obj)
- return 0;
-
- QmlEnginePrivate *enginePrivate = QmlEnginePrivate::get(engine);
- lastData = QmlPropertyCache::property(engine, obj, name, local);
-
- if (lastData)
- return QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess;
-
- if (!(hints & SkipAttachedProperties)) {
- if (!evalContext && context()) {
- // Global object, QScriptContext activation object, QmlContext object
- QScriptValue scopeNode = scopeChainValue(context(), -3);
- if (scopeNode.isValid()) {
- Q_ASSERT(scriptClass(scopeNode) == enginePrivate->contextClass);
-
- evalContext = enginePrivate->contextClass->contextFromValue(scopeNode);
- }
- }
-
- if (evalContext) {
- QmlContextPrivate *cp = QmlContextPrivate::get(evalContext);
-
- if (cp->imports) {
- QmlTypeNameCache::Data *data = cp->imports->data(name);
- if (data) {
- lastTNData = data;
- return QScriptClass::HandlesReadAccess;
- }
- }
- }
- }
-
- if (!(hints & ImplicitObject)) {
- local.coreIndex = -1;
- lastData = &local;
- return QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess;
- }
-
- return 0;
-}
-
-QmlObjectScriptClass::ScriptValue
-QmlObjectScriptClass::property(Object *object, const Identifier &name)
-{
- return property(toQObject(object), name);
-}
-
-QmlObjectScriptClass::ScriptValue
-QmlObjectScriptClass::property(QObject *obj, const Identifier &name)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- if (name == m_destroyId.identifier)
- return Value(scriptEngine, m_destroy);
- else if (name == m_toStringId.identifier)
- return Value(scriptEngine, m_toString);
-
- if (lastData && !lastData->isValid())
- return Value();
-
- Q_ASSERT(obj);
-
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine);
-
- if (lastTNData) {
-
- if (lastTNData->type)
- return Value(scriptEngine, enginePriv->typeNameClass->newObject(obj, lastTNData->type));
- else
- return Value(scriptEngine, enginePriv->typeNameClass->newObject(obj, lastTNData->typeNamespace));
-
- } else if (lastData->flags & QmlPropertyCache::Data::IsFunction) {
- if (lastData->flags & QmlPropertyCache::Data::IsVMEFunction) {
- return Value(scriptEngine, ((QmlVMEMetaObject *)(obj->metaObject()))->vmeMethod(lastData->coreIndex));
- } else {
-#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
- // Uncomment to use QtScript method call logic
- // QScriptValue sobj = scriptEngine->newQObject(obj);
- // return Value(scriptEngine, sobj.property(toString(name)));
- return Value(scriptEngine, methods.newMethod(obj, lastData));
-#else
- QScriptValue sobj = scriptEngine->newQObject(obj);
- return Value(scriptEngine, sobj.property(toString(name)));
-#endif
- }
- } else {
- if (enginePriv->captureProperties && !(lastData->flags & QmlPropertyCache::Data::IsConstant)) {
- enginePriv->capturedProperties <<
- QmlEnginePrivate::CapturedProperty(obj, lastData->coreIndex, lastData->notifyIndex);
- }
-
- if ((uint)lastData->propType < QVariant::UserType) {
- QmlValueType *valueType = enginePriv->valueTypes[lastData->propType];
- if (valueType)
- return Value(scriptEngine, enginePriv->valueTypeClass->newObject(obj, lastData->coreIndex, valueType));
- }
-
- if (lastData->flags & QmlPropertyCache::Data::IsQList) {
- return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, lastData->propType));
- } else if (lastData->flags & QmlPropertyCache::Data::IsQObjectDerived) {
- QObject *rv = 0;
- void *args[] = { &rv, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
- return Value(scriptEngine, newQObject(rv, lastData->propType));
- } else if (lastData->flags & QmlPropertyCache::Data::IsQScriptValue) {
- QScriptValue rv = scriptEngine->nullValue();
- void *args[] = { &rv, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
- return Value(scriptEngine, rv);
- } else if (lastData->propType == QMetaType::QReal) {
- qreal rv = 0;
- void *args[] = { &rv, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
- return Value(scriptEngine, rv);
- } else if (lastData->propType == QMetaType::Int) {
- int rv = 0;
- void *args[] = { &rv, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
- return Value(scriptEngine, rv);
- } else if (lastData->propType == QMetaType::Bool) {
- bool rv = false;
- void *args[] = { &rv, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
- return Value(scriptEngine, rv);
- } else if (lastData->propType == QMetaType::QString) {
- QString rv;
- void *args[] = { &rv, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
- return Value(scriptEngine, rv);
- } else if (lastData->propType == QMetaType::UInt) {
- uint rv = 0;
- void *args[] = { &rv, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
- return Value(scriptEngine, rv);
- } else if (lastData->propType == QMetaType::Float) {
- float rv = 0;
- void *args[] = { &rv, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
- return Value(scriptEngine, rv);
- } else if (lastData->propType == QMetaType::Double) {
- double rv = 0;
- void *args[] = { &rv, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args);
- return Value(scriptEngine, rv);
- } else {
- QVariant var = obj->metaObject()->property(lastData->coreIndex).read(obj);
- return Value(scriptEngine, enginePriv->scriptValueFromVariant(var));
- }
-
- }
-}
-
-void QmlObjectScriptClass::setProperty(Object *object,
- const Identifier &name,
- const QScriptValue &value)
-{
- return setProperty(toQObject(object), name, value);
-}
-
-void QmlObjectScriptClass::setProperty(QObject *obj,
- const Identifier &name,
- const QScriptValue &value,
- QmlContext *evalContext)
-{
- Q_UNUSED(name);
-
- Q_ASSERT(obj);
- Q_ASSERT(lastData);
-
- if (!lastData->isValid()) {
- QString error = QLatin1String("Cannot assign to non-existent property \"") +
- toString(name) + QLatin1Char('\"');
- if (context())
- context()->throwError(error);
- return;
- }
-
- if (!(lastData->flags & QmlPropertyCache::Data::IsWritable)) {
- QString error = QLatin1String("Cannot assign to read-only property \"") +
- toString(name) + QLatin1Char('\"');
- if (context())
- context()->throwError(error);
- return;
- }
-
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine);
-
- if (!evalContext && context()) {
- // Global object, QScriptContext activation object, QmlContext object
- QScriptValue scopeNode = scopeChainValue(context(), -3);
- if (scopeNode.isValid()) {
- Q_ASSERT(scriptClass(scopeNode) == enginePriv->contextClass);
-
- evalContext = enginePriv->contextClass->contextFromValue(scopeNode);
- }
- }
-
- QmlAbstractBinding *delBinding = QmlMetaPropertyPrivate::setBinding(obj, *lastData, 0);
- if (delBinding)
- delBinding->destroy();
-
- if (value.isUndefined() && lastData->flags & QmlPropertyCache::Data::IsResettable) {
- void *a[] = { 0 };
- QMetaObject::metacall(obj, QMetaObject::ResetProperty, lastData->coreIndex, a);
- } else {
- // ### Can well known types be optimized?
- QVariant v = QmlScriptClass::toVariant(engine, value);
- QmlMetaPropertyPrivate::write(obj, *lastData, v, evalContext);
- }
-}
-
-bool QmlObjectScriptClass::isQObject() const
-{
- return true;
-}
-
-QObject *QmlObjectScriptClass::toQObject(Object *object, bool *ok)
-{
- if (ok) *ok = true;
-
- ObjectData *data = (ObjectData*)object;
- return data->object.data();
-}
-
-QScriptValue QmlObjectScriptClass::tostring(QScriptContext *context, QScriptEngine *)
-{
- QObject* obj = context->thisObject().toQObject();
-
- QString ret;
- if(obj){
- QString objectName = obj->objectName();
-
- ret += QString::fromUtf8(obj->metaObject()->className());
- ret += QLatin1String("(0x");
- ret += QString::number((intptr_t)obj,16);
-
- if (!objectName.isEmpty()) {
- ret += QLatin1String(", \"");
- ret += objectName;
- ret += QLatin1Char('\"');
- }
-
- ret += QLatin1Char(')');
- }else{
- ret += QLatin1String("null");
- }
- return QScriptValue(ret);
-}
-
-QScriptValue QmlObjectScriptClass::destroy(QScriptContext *context, QScriptEngine *engine)
-{
- QObject* obj = context->thisObject().toQObject();
- if(obj){
- int delay = 0;
- if(context->argumentCount() > 0)
- delay = context->argument(0).toInt32();
- if (delay > 0)
- QTimer::singleShot(delay, obj, SLOT(deleteLater()));
- else
- obj->deleteLater();
- }
- return engine->nullValue();
-}
-
-QStringList QmlObjectScriptClass::propertyNames(Object *object)
-{
- QObject *obj = toQObject(object);
- if (!obj)
- return QStringList();
-
- QmlEnginePrivate *enginePrivate = QmlEnginePrivate::get(engine);
-
- QmlPropertyCache *cache = 0;
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(obj);
- if (ddata)
- cache = ddata->propertyCache;
- if (!cache) {
- cache = enginePrivate->cache(obj);
- if (cache && ddata) { cache->addref(); ddata->propertyCache = cache; }
- }
-
- if (!cache)
- return QStringList();
-
- return cache->propertyNames();
-}
-
-#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
-
-struct MethodData : public QScriptDeclarativeClass::Object {
- MethodData(QObject *o, const QmlPropertyCache::Data &d) : object(o), data(d) {}
-
- QmlGuard<QObject> object;
- QmlPropertyCache::Data data;
-};
-
-QmlObjectMethodScriptClass::QmlObjectMethodScriptClass(QmlEngine *bindEngine)
-: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(bindEngine)),
- engine(bindEngine)
-{
- setSupportsCall(true);
-}
-
-QmlObjectMethodScriptClass::~QmlObjectMethodScriptClass()
-{
-}
-
-QScriptValue QmlObjectMethodScriptClass::newMethod(QObject *object, const QmlPropertyCache::Data *method)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- return newObject(scriptEngine, this, new MethodData(object, *method));
-}
-
-namespace {
-struct MetaCallArgument {
- inline MetaCallArgument();
- inline ~MetaCallArgument();
- inline void *dataPtr();
-
- inline void initAsType(int type, QmlEngine *);
- void fromScriptValue(int type, QmlEngine *, const QScriptValue &);
- inline QScriptDeclarativeClass::Value toValue(QmlEngine *);
-
-private:
- MetaCallArgument(const MetaCallArgument &);
-
- inline void cleanup();
-
- char *data[16];
- int type;
-};
-}
-
-MetaCallArgument::MetaCallArgument()
-: type(QVariant::Invalid)
-{
-}
-
-MetaCallArgument::~MetaCallArgument()
-{
- cleanup();
-}
-
-void MetaCallArgument::cleanup()
-{
- if (type == QMetaType::QString) {
- ((QString *)data)->~QString();
- } else if (type == -1 || type == qMetaTypeId<QVariant>()) {
- ((QVariant *)data)->~QVariant();
- } else if (type == qMetaTypeId<QScriptValue>()) {
- ((QScriptValue *)data)->~QScriptValue();
- }
-}
-
-void *MetaCallArgument::dataPtr()
-{
- if (type == -1)
- return ((QVariant *)data)->data();
- else
- return (void *)data;
-}
-
-void MetaCallArgument::initAsType(int callType, QmlEngine *e)
-{
- if (type != 0) { cleanup(); type = 0; }
- if (callType == 0) return;
-
- QScriptEngine *engine = QmlEnginePrivate::getScriptEngine(e);
-
- if (callType == qMetaTypeId<QScriptValue>()) {
- new (data) QScriptValue(engine->undefinedValue());
- type = callType;
- } else if (callType == QMetaType::Int ||
- callType == QMetaType::UInt ||
- callType == QMetaType::Bool ||
- callType == QMetaType::Double ||
- callType == QMetaType::Float) {
- type = callType;
- } else if (callType == QMetaType::QObjectStar) {
- *((QObject **)data) = 0;
- type = callType;
- } else if (callType == QMetaType::QString) {
- new (data) QString();
- type = callType;
- } else if (callType == qMetaTypeId<QVariant>()) {
- type = qMetaTypeId<QVariant>();
- new (data) QVariant();
- } else {
- type = -1;
- new (data) QVariant(callType, (void *)0);
- }
-}
-
-void MetaCallArgument::fromScriptValue(int callType, QmlEngine *engine, const QScriptValue &value)
-{
- if (type != 0) { cleanup(); type = 0; }
-
- if (callType == qMetaTypeId<QScriptValue>()) {
- new (data) QScriptValue(value);
- type = qMetaTypeId<QScriptValue>();
- } else if (callType == QMetaType::Int) {
- *((int *)data) = int(value.toInt32());
- type = callType;
- } else if (callType == QMetaType::UInt) {
- *((uint *)data) = uint(value.toUInt32());
- type = callType;
- } else if (callType == QMetaType::Bool) {
- *((bool *)data) = value.toBool();
- type = callType;
- } else if (callType == QMetaType::Double) {
- *((double *)data) = double(value.toNumber());
- type = callType;
- } else if (callType == QMetaType::Float) {
- *((float *)data) = float(value.toNumber());
- type = callType;
- } else if (callType == QMetaType::QString) {
- if (value.isNull() || value.isUndefined())
- new (data) QString();
- else
- new (data) QString(value.toString());
- type = callType;
- } else if (callType == QMetaType::QObjectStar) {
- *((QObject **)data) = value.toQObject();
- type = callType;
- } else if (callType == qMetaTypeId<QVariant>()) {
- new (data) QVariant(QmlScriptClass::toVariant(engine, value));
- type = callType;
- } else {
- new (data) QVariant();
- type = -1;
-
- QVariant v = QmlScriptClass::toVariant(engine, value);
- if (v.userType() == callType) {
- *((QVariant *)data) = v;
- } else if (v.canConvert((QVariant::Type)callType)) {
- *((QVariant *)data) = v;
- ((QVariant *)data)->convert((QVariant::Type)callType);
- } else {
- *((QVariant *)data) = QVariant(callType, (void *)0);
- }
- }
-}
-
-QScriptDeclarativeClass::Value MetaCallArgument::toValue(QmlEngine *e)
-{
- QScriptEngine *engine = QmlEnginePrivate::getScriptEngine(e);
-
- if (type == qMetaTypeId<QScriptValue>()) {
- return QScriptDeclarativeClass::Value(engine, *((QScriptValue *)data));
- } else if (type == QMetaType::Int) {
- return QScriptDeclarativeClass::Value(engine, *((int *)data));
- } else if (type == QMetaType::UInt) {
- return QScriptDeclarativeClass::Value(engine, *((uint *)data));
- } else if (type == QMetaType::Bool) {
- return QScriptDeclarativeClass::Value(engine, *((bool *)data));
- } else if (type == QMetaType::Double) {
- return QScriptDeclarativeClass::Value(engine, *((double *)data));
- } else if (type == QMetaType::Float) {
- return QScriptDeclarativeClass::Value(engine, *((float *)data));
- } else if (type == QMetaType::QString) {
- return QScriptDeclarativeClass::Value(engine, *((QString *)data));
- } else if (type == QMetaType::QObjectStar) {
- return QScriptDeclarativeClass::Value(engine, QmlEnginePrivate::get(e)->objectClass->newQObject(*((QObject **)data)));
- } else if (type == -1 || type == qMetaTypeId<QVariant>()) {
- return QScriptDeclarativeClass::Value(engine, QmlEnginePrivate::get(e)->scriptValueFromVariant(*((QVariant *)data)));
- } else {
- return QScriptDeclarativeClass::Value();
- }
-}
-
-QmlObjectMethodScriptClass::Value QmlObjectMethodScriptClass::call(Object *o, QScriptContext *ctxt)
-{
- MethodData *method = static_cast<MethodData *>(o);
-
- if (method->data.flags & QmlPropertyCache::Data::HasArguments) {
-
- QMetaMethod m = method->object->metaObject()->method(method->data.coreIndex);
- QList<QByteArray> argTypeNames = m.parameterTypes();
- QVarLengthArray<int, 9> argTypes(argTypeNames.count());
-
- // ### Cache
- for (int ii = 0; ii < argTypeNames.count(); ++ii) {
- argTypes[ii] = QMetaType::type(argTypeNames.at(ii));
- if (argTypes[ii] == QVariant::Invalid)
- return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii)))));
- }
-
- if (argTypes.count() > ctxt->argumentCount())
- return Value(ctxt, ctxt->throwError(QLatin1String("Insufficient arguments")));
-
- QVarLengthArray<MetaCallArgument, 9> args(argTypes.count() + 1);
- args[0].initAsType(method->data.propType, engine);
-
- for (int ii = 0; ii < argTypes.count(); ++ii)
- args[ii + 1].fromScriptValue(argTypes[ii], engine, ctxt->argument(ii));
-
- QVarLengthArray<void *, 9> argData(args.count());
- for (int ii = 0; ii < args.count(); ++ii)
- argData[ii] = args[ii].dataPtr();
-
- QMetaObject::metacall(method->object, QMetaObject::InvokeMetaMethod, method->data.coreIndex, argData.data());
-
- return args[0].toValue(engine);
-
- } else if (method->data.propType != 0) {
-
- MetaCallArgument arg;
- arg.initAsType(method->data.propType, engine);
-
- void *args[] = { arg.dataPtr() };
-
- QMetaObject::metacall(method->object, QMetaObject::InvokeMetaMethod, method->data.coreIndex, args);
-
- return arg.toValue(engine);
-
- } else {
-
- void *args[] = { 0 };
- QMetaObject::metacall(method->object, QMetaObject::InvokeMetaMethod, method->data.coreIndex, args);
- return Value();
-
- }
- return Value();
-}
-
-#endif
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qmlobjectscriptclass_p.h b/src/declarative/qml/qmlobjectscriptclass_p.h
deleted file mode 100644
index 729f34f..0000000
--- a/src/declarative/qml/qmlobjectscriptclass_p.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLOBJECTSCRIPTCLASS_P_H
-#define QMLOBJECTSCRIPTCLASS_P_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 "qmlpropertycache_p.h"
-#include "qmltypenamecache_p.h"
-
-#include <private/qmlscriptclass_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngine;
-class QScriptContext;
-class QScriptEngine;
-class QmlContext;
-
-#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
-class Q_AUTOTEST_EXPORT QmlObjectMethodScriptClass : public QScriptDeclarativeClass
-{
-public:
- QmlObjectMethodScriptClass(QmlEngine *);
- ~QmlObjectMethodScriptClass();
-
- QScriptValue newMethod(QObject *, const QmlPropertyCache::Data *);
-protected:
- virtual Value call(Object *, QScriptContext *);
-
-private:
- QmlEngine *engine;
-};
-#endif
-
-class Q_AUTOTEST_EXPORT QmlObjectScriptClass : public QmlScriptClass
-{
-public:
- QmlObjectScriptClass(QmlEngine *);
- ~QmlObjectScriptClass();
-
- QScriptValue newQObject(QObject *, int type = QMetaType::QObjectStar);
- QObject *toQObject(const QScriptValue &) const;
- int objectType(const QScriptValue &) const;
-
- enum QueryHint {
- ImplicitObject = 0x01,
- SkipAttachedProperties = 0x02
- };
- Q_DECLARE_FLAGS(QueryHints, QueryHint)
-
- QScriptClass::QueryFlags queryProperty(QObject *, const Identifier &,
- QScriptClass::QueryFlags flags,
- QmlContext *evalContext,
- QueryHints hints = 0);
-
- ScriptValue property(QObject *, const Identifier &);
-
- void setProperty(QObject *, const Identifier &name, const QScriptValue &,
- QmlContext *evalContext = 0);
- virtual QStringList propertyNames(Object *);
-
-protected:
- virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
- QScriptClass::QueryFlags flags);
-
- virtual ScriptValue property(Object *, const Identifier &);
- virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
- virtual bool isQObject() const;
- virtual QObject *toQObject(Object *, bool *ok = 0);
-
-private:
-#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
- QmlObjectMethodScriptClass methods;
-#endif
-
- QmlTypeNameCache::Data *lastTNData;
- QmlPropertyCache::Data *lastData;
- QmlPropertyCache::Data local;
-
- PersistentIdentifier m_destroyId;
- PersistentIdentifier m_toStringId;
- QScriptValue m_destroy;
- QScriptValue m_toString;
-
- static QScriptValue tostring(QScriptContext *context, QScriptEngine *engine);
- static QScriptValue destroy(QScriptContext *context, QScriptEngine *engine);
-
- QmlEngine *engine;
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QmlObjectScriptClass::QueryHints);
-
-QT_END_NAMESPACE
-
-#endif // QMLOBJECTSCRIPTCLASS_P_H
-
diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp
deleted file mode 100644
index f2690e2..0000000
--- a/src/declarative/qml/qmlparser.cpp
+++ /dev/null
@@ -1,387 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlparser_p.h"
-
-#include "qmlpropertyvaluesource.h"
-#include "qmlvme_p.h"
-#include "qml.h"
-#include "qmlcomponent_p.h"
-#include "qmlcomponent.h"
-#include "qmetaobjectbuilder_p.h"
-#include "qmlvmemetaobject_p.h"
-#include "qmlcompiler_p.h"
-#include "parser/qmljsast_p.h"
-#include "parser/qmljsengine_p.h"
-
-#include <qfxperf_p_p.h>
-
-#include <QStack>
-#include <QColor>
-#include <QPointF>
-#include <QSizeF>
-#include <QRectF>
-#include <QtDebug>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QmlJS;
-using namespace QmlParser;
-
-QmlParser::Object::Object()
-: type(-1), majorVersion(-1), minorVersion(-1), idIndex(-1), metatype(0), defaultProperty(0), parserStatusCast(-1)
-{
-}
-
-QmlParser::Object::~Object()
-{
- if (defaultProperty) defaultProperty->release();
- foreach(Property *prop, properties)
- prop->release();
- foreach(Property *prop, valueProperties)
- prop->release();
- foreach(Property *prop, signalProperties)
- prop->release();
- foreach(Property *prop, attachedProperties)
- prop->release();
- foreach(Property *prop, groupedProperties)
- prop->release();
- foreach(Property *prop, valueTypeProperties)
- prop->release();
- typedef QPair<Property *, int> PropPair;
- foreach(const PropPair &prop, scriptStringProperties)
- prop.first->release();
- foreach(const DynamicProperty &prop, dynamicProperties)
- if (prop.defaultValue) prop.defaultValue->release();
- foreach(Object *obj, scriptBlockObjects)
- obj->release();
-}
-
-void Object::setBindingBit(int b)
-{
- while (bindingBitmask.size() < 4 * (1 + b / 32))
- bindingBitmask.append(char(0));
-
- quint32 *bits = (quint32 *)bindingBitmask.data();
- bits[b / 32] |= (1 << (b % 32));
-}
-
-const QMetaObject *Object::metaObject() const
-{
- if (!metadata.isEmpty() && metatype)
- return &extObject;
- else
- return metatype;
-}
-
-QmlParser::Property *Object::getDefaultProperty()
-{
- if (!defaultProperty) {
- defaultProperty = new Property;
- defaultProperty->parent = this;
- }
- return defaultProperty;
-}
-
-void QmlParser::Object::addValueProperty(Property *p)
-{
- p->addref();
- valueProperties << p;
-}
-
-void QmlParser::Object::addSignalProperty(Property *p)
-{
- p->addref();
- signalProperties << p;
-}
-
-void QmlParser::Object::addAttachedProperty(Property *p)
-{
- p->addref();
- attachedProperties << p;
-}
-
-void QmlParser::Object::addGroupedProperty(Property *p)
-{
- p->addref();
- groupedProperties << p;
-}
-
-void QmlParser::Object::addValueTypeProperty(Property *p)
-{
- p->addref();
- valueTypeProperties << p;
-}
-
-void QmlParser::Object::addScriptStringProperty(Property *p, int stack)
-{
- p->addref();
- scriptStringProperties << qMakePair(p, stack);
-}
-
-
-Property *QmlParser::Object::getProperty(const QByteArray &name, bool create)
-{
- if (!properties.contains(name)) {
- if (create) {
- Property *property = new Property(name);
- property->parent = this;
- properties.insert(name, property);
- } else {
- return 0;
- }
- }
- return properties[name];
-}
-
-QmlParser::Object::DynamicProperty::DynamicProperty()
-: isDefaultProperty(false), type(Variant), defaultValue(0)
-{
-}
-
-QmlParser::Object::DynamicProperty::DynamicProperty(const DynamicProperty &o)
-: isDefaultProperty(o.isDefaultProperty),
- type(o.type),
- customType(o.customType),
- name(o.name),
- defaultValue(o.defaultValue),
- location(o.location)
-{
-}
-
-QmlParser::Object::DynamicSignal::DynamicSignal()
-{
-}
-
-QmlParser::Object::DynamicSignal::DynamicSignal(const DynamicSignal &o)
-: name(o.name), parameterTypes(o.parameterTypes),
- parameterNames(o.parameterNames)
-{
-}
-
-QmlParser::Object::DynamicSlot::DynamicSlot()
-{
-}
-
-QmlParser::Object::DynamicSlot::DynamicSlot(const DynamicSlot &o)
-: name(o.name), body(o.body), parameterNames(o.parameterNames)
-{
-}
-
-QmlParser::Property::Property()
-: parent(0), type(0), index(-1), value(0), isDefault(true), isDeferred(false)
-{
-}
-
-QmlParser::Property::Property(const QByteArray &n)
-: parent(0), type(0), index(-1), value(0), name(n), isDefault(false),
- isDeferred(false)
-{
-}
-
-QmlParser::Property::~Property()
-{
- foreach(Value *value, values)
- value->release();
- if (value) value->release();
-}
-
-Object *QmlParser::Property::getValue()
-{
- if (!value) value = new Object;
- return value;
-}
-
-void QmlParser::Property::addValue(Value *v)
-{
- values << v;
-}
-
-bool QmlParser::Property::isEmpty() const
-{
- return !value && values.isEmpty();
-}
-
-QmlParser::Value::Value()
-: type(Unknown), object(0)
-{
-}
-
-QmlParser::Value::~Value()
-{
- if (object) object->release();
-}
-
-QmlParser::Variant::Variant()
-: t(Invalid) {}
-
-QmlParser::Variant::Variant(const Variant &o)
-: t(o.t), d(o.d), s(o.s)
-{
-}
-
-QmlParser::Variant::Variant(bool v)
-: t(Boolean), b(v)
-{
-}
-
-QmlParser::Variant::Variant(double v, const QString &asWritten)
-: t(Number), d(v), s(asWritten)
-{
-}
-
-QmlParser::Variant::Variant(const QString &v)
-: t(String), s(v)
-{
-}
-
-QmlParser::Variant::Variant(const QString &v, QmlJS::AST::Node *n)
-: t(Script), n(n), s(v)
-{
-}
-
-QmlParser::Variant &QmlParser::Variant::operator=(const Variant &o)
-{
- t = o.t;
- d = o.d;
- s = o.s;
- return *this;
-}
-
-QmlParser::Variant::Type QmlParser::Variant::type() const
-{
- return t;
-}
-
-bool QmlParser::Variant::asBoolean() const
-{
- return b;
-}
-
-QString QmlParser::Variant::asString() const
-{
- return s;
-}
-
-double QmlParser::Variant::asNumber() const
-{
- return d;
-}
-
-QString QmlParser::Variant::asScript() const
-{
- switch(type()) {
- default:
- case Invalid:
- return QString();
- case Boolean:
- return b?QLatin1String("true"):QLatin1String("false");
- case Number:
- if (s.isEmpty())
- return QString::number(d);
- else
- return s;
- case String:
- case Script:
- return s;
- }
-}
-
-QmlJS::AST::Node *QmlParser::Variant::asAST() const
-{
- if (type() == Script)
- return n;
- else
- return 0;
-}
-
-bool QmlParser::Variant::isStringList() const
-{
- if (isString())
- return true;
-
- if (type() != Script || !n)
- return false;
-
- AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
- if (!array)
- return false;
-
- AST::ElementList *elements = array->elements;
-
- while (elements) {
-
- if (!AST::cast<AST::StringLiteral *>(elements->expression))
- return false;
-
- elements = elements->next;
- }
-
- return true;
-}
-
-QStringList QmlParser::Variant::asStringList() const
-{
- QStringList rv;
- if (isString()) {
- rv << asString();
- return rv;
- }
-
- AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
- if (!array)
- return rv;
-
- AST::ElementList *elements = array->elements;
- while (elements) {
-
- AST::StringLiteral *string = AST::cast<AST::StringLiteral *>(elements->expression);
- if (!string)
- return QStringList();
- rv.append(string->value->asString());
-
- elements = elements->next;
- }
-
- return rv;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h
deleted file mode 100644
index 222229b..0000000
--- a/src/declarative/qml/qmlparser_p.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLPARSER_P_H
-#define QMLPARSER_P_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 "qml.h"
-#include "qmlrefcount_p.h"
-
-#include <QtCore/QByteArray>
-#include <QtCore/QList>
-#include <QtCore/qstring.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-namespace QmlJS { namespace AST { class Node; } }
-
-/*
- XXX
-
- These types are created (and owned) by the QmlXmlParser and consumed by the
- QmlCompiler. During the compilation phase the compiler will update some of
- the fields for both its own use and for the use of the upcoming QmlDom API.
-
- The types are part of the generic sounding "QmlParser" namespace for legacy
- reasons (there used to be more in this namespace) and will be cleaned up and
- migrated into a more appropriate location shortly.
-*/
-namespace QmlParser
-{
- struct Location
- {
- Location() : line(-1), column(-1) {}
- int line;
- int column;
- };
-
- struct LocationRange
- {
- LocationRange() : offset(0), length(0) {}
- quint32 offset;
- quint32 length;
- };
-
- struct LocationSpan
- {
- Location start;
- Location end;
- LocationRange range;
- };
-
- class Property;
- class Object : public QmlRefCount
- {
- public:
- Object();
- virtual ~Object();
-
- // Type of the object. The integer is an index into the
- // QmlCompiledData::types array, or -1 if the object is a property
- // group.
- int type;
- // The url of this object if it is an external type. Used by the DOM
- QUrl url;
-
- // version information if type is defined in library or C++
- int majorVersion;
- int minorVersion;
-
- // The fully-qualified name of this type
- QByteArray typeName;
- // The class name
- QByteArray className;
- // The id assigned to the object (if any). Set by the QmlCompiler
- QString id;
- // The id index assigned to the object (if any). Set by the QmlCompiler
- int idIndex;
- // Custom parsed data
- QByteArray custom;
- // Bit mask of the properties assigned bindings
- QByteArray bindingBitmask;
- void setBindingBit(int);
- // Returns the metaobject for this type, or 0 if not available.
- // Internally selectd between the metatype and extObject variables
- const QMetaObject *metaObject() const;
-
- // The compile time metaobject for this type
- const QMetaObject *metatype;
- // The synthesized metaobject, if QML added signals or properties to
- // this type. Otherwise null
- QAbstractDynamicMetaObject extObject;
- QByteArray metadata; // Generated by compiler
- QByteArray synthdata; // Generated by compiler
-
- Property *getDefaultProperty();
- Property *getProperty(const QByteArray &name, bool create=true);
-
- Property *defaultProperty;
- QHash<QByteArray, Property *> properties;
-
- QList<Object *> scriptBlockObjects;
-
- // Output of the compilation phase (these properties continue to exist
- // in either the defaultProperty or properties members too)
- void addValueProperty(Property *);
- void addSignalProperty(Property *);
- void addAttachedProperty(Property *);
- void addGroupedProperty(Property *);
- void addValueTypeProperty(Property *);
- void addScriptStringProperty(Property *, int = 0);
- QList<Property *> valueProperties;
- QList<Property *> signalProperties;
- QList<Property *> attachedProperties;
- QList<Property *> groupedProperties;
- QList<Property *> valueTypeProperties;
- QList<QPair<Property *, int> > scriptStringProperties;
-
- // Script blocks that were nested under this object
- struct ScriptBlock {
- QStringList codes;
- QStringList files;
- QList<int> lineNumbers;
- };
- QList<ScriptBlock> scripts;
-
- // The bytes to cast instances by to get to the QmlParserStatus
- // interface. -1 indicates the type doesn't support this interface.
- // Set by the QmlCompiler.
- int parserStatusCast;
-
- LocationSpan location;
-
- struct DynamicProperty {
- DynamicProperty();
- DynamicProperty(const DynamicProperty &);
-
- enum Type { Variant, Int, Bool, Real, String, Url, Color, Date, Alias, Custom, CustomList };
-
- bool isDefaultProperty;
- Type type;
- QByteArray customType;
- QByteArray name;
- QmlParser::Property *defaultValue;
- LocationSpan location;
- };
- struct DynamicSignal {
- DynamicSignal();
- DynamicSignal(const DynamicSignal &);
-
- QByteArray name;
- QList<QByteArray> parameterTypes;
- QList<QByteArray> parameterNames;
- };
- struct DynamicSlot {
- DynamicSlot();
- DynamicSlot(const DynamicSlot &);
-
- QByteArray name;
- QString body;
- QList<QByteArray> parameterNames;
- };
-
- // The list of dynamic properties
- QList<DynamicProperty> dynamicProperties;
- // The list of dynamic signals
- QList<DynamicSignal> dynamicSignals;
- // The list of dynamic slots
- QList<DynamicSlot> dynamicSlots;
- };
-
- class Variant
- {
- public:
- enum Type {
- Invalid,
- Boolean,
- Number,
- String,
- Script
- };
-
- Variant();
- Variant(const Variant &);
- Variant(bool);
- Variant(double, const QString &asWritten=QString());
- Variant(const QString &);
- Variant(const QString &, QmlJS::AST::Node *);
- Variant &operator=(const Variant &);
-
- Type type() const;
-
- bool isBoolean() const { return type() == Boolean; }
- bool isNumber() const { return type() == Number; }
- bool isString() const { return type() == String; }
- bool isScript() const { return type() == Script; }
- bool isStringList() const;
-
- bool asBoolean() const;
- QString asString() const;
- double asNumber() const;
- QString asScript() const;
- QmlJS::AST::Node *asAST() const;
- QStringList asStringList() const;
-
- private:
- Type t;
- union {
- bool b;
- double d;
- QmlJS::AST::Node *n;
- };
- QString s;
- };
-
- class Value : public QmlRefCount
- {
- public:
- Value();
- virtual ~Value();
-
- enum Type {
- // The type of this value assignment is not yet known
- Unknown,
- // This is used as a literal property assignment
- Literal,
- // This is used as a property binding assignment
- PropertyBinding,
- // This is used as a QmlPropertyValueSource assignment
- ValueSource,
- // This is used as a QmlPropertyValueInterceptor assignment
- ValueInterceptor,
- // This is used as a property QObject assignment
- CreatedObject,
- // This is used as a signal object assignment
- SignalObject,
- // This is used as a signal expression assignment
- SignalExpression,
- // This is used as an id assignment only
- Id
- };
- Type type;
-
- // ### Temporary
- QString primitive() const { return value.asScript(); }
-
- // Primitive value
- Variant value;
- // Object value
- Object *object;
-
- LocationSpan location;
- };
-
- class Property : public QmlRefCount
- {
- public:
- Property();
- Property(const QByteArray &n);
- virtual ~Property();
-
- // The Object to which this property is attached
- Object *parent;
-
- Object *getValue();
- void addValue(Value *v);
-
- // The QVariant::Type of the property, or 0 (QVariant::Invalid) if
- // unknown.
- int type;
- // The metaobject index of this property, or -1 if unknown.
- int index;
-
- // Returns true if this is an empty property - both value and values
- // are unset.
- bool isEmpty() const;
- // The list of values assigned to this property. Content in values
- // and value are mutually exclusive
- QList<Value *> values;
- // The accessed property. This is used to represent dot properties.
- // Content in value and values are mutually exclusive.
- Object *value;
- // The property name
- QByteArray name;
- // True if this property was accessed as the default property.
- bool isDefault;
- // True if the setting of this property will be deferred. Set by the
- // QmlCompiler
- bool isDeferred;
-
- LocationSpan location;
- LocationRange listValueRange;
- QList<int> listCommaPositions;
- };
-}
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QmlParser::Variant)
-
-QT_END_HEADER
-
-#endif // QMLPARSER_P_H
diff --git a/src/declarative/qml/qmlparserstatus.cpp b/src/declarative/qml/qmlparserstatus.cpp
deleted file mode 100644
index 315bc75..0000000
--- a/src/declarative/qml/qmlparserstatus.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlparserstatus.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlParserStatus
- \since 4.7
- \brief The QmlParserStatus class provides updates on the parser state.
-*/
-
-/*! \internal */
-QmlParserStatus::QmlParserStatus()
-: d(0)
-{
-}
-
-/*! \internal */
-QmlParserStatus::~QmlParserStatus()
-{
- if(d)
- (*d) = 0;
-}
-
-/*!
- Invoked after class creation, but before any properties have been set.
-*/
-void QmlParserStatus::classBegin()
-{
-}
-
-/*!
- Invoked after the root component that caused this instantiation has
- completed construction. At this point all static values and binding values
- have been assigned to the class.
-*/
-void QmlParserStatus::componentComplete()
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlparserstatus.h b/src/declarative/qml/qmlparserstatus.h
deleted file mode 100644
index e4cfe8b..0000000
--- a/src/declarative/qml/qmlparserstatus.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLPARSERSTATUS_H
-#define QMLPARSERSTATUS_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QmlParserStatus
-{
-public:
- QmlParserStatus();
- virtual ~QmlParserStatus();
-
- virtual void classBegin();
- virtual void componentComplete();
-
-private:
- friend class QmlVME;
- friend class QmlComponent;
- friend class QmlComponentPrivate;
- friend class QmlEnginePrivate;
- QmlParserStatus **d;
-};
-Q_DECLARE_INTERFACE(QmlParserStatus, "com.trolltech.qml.QmlParserStatus")
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLPARSERSTATUS_H
diff --git a/src/declarative/qml/qmlprivate.cpp b/src/declarative/qml/qmlprivate.cpp
deleted file mode 100644
index f85e280..0000000
--- a/src/declarative/qml/qmlprivate.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlprivate.h"
-
-QT_BEGIN_NAMESPACE
-
-QmlPrivate::InstanceType::InstanceType(int) {}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h
deleted file mode 100644